mirror of
https://github.com/jorio/Pomme.git
synced 2024-11-27 05:49:18 +00:00
Remove sources from the mixer before deleting them
This commit is contained in:
parent
53cbdb54c4
commit
dae4b61b5b
@ -31,7 +31,7 @@ ChannelImpl::ChannelImpl(SndChannelPtr _macChannel, bool transferMacChannelOwner
|
|||||||
|
|
||||||
ChannelImpl::~ChannelImpl()
|
ChannelImpl::~ChannelImpl()
|
||||||
{
|
{
|
||||||
Unlink();
|
Unlink(); // Unlink chan from list of managed chans
|
||||||
|
|
||||||
macChannel->channelImpl = nullptr;
|
macChannel->channelImpl = nullptr;
|
||||||
|
|
||||||
@ -39,6 +39,11 @@ ChannelImpl::~ChannelImpl()
|
|||||||
{
|
{
|
||||||
delete macChannel;
|
delete macChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure we've stopped mixing the source before we allow its destructor
|
||||||
|
// to be called. Otherwise, the WavSource's buffer may be freed as it is still
|
||||||
|
// being processed!
|
||||||
|
source.RemoveFromMixer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelImpl::Recycle()
|
void ChannelImpl::Recycle()
|
||||||
|
@ -255,16 +255,29 @@ void Source::Init(int theSampleRate, int theLength)
|
|||||||
Stop();
|
Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
Source::~Source()
|
void Source::RemoveFromMixer()
|
||||||
{
|
{
|
||||||
gMixer.Lock();
|
gMixer.Lock();
|
||||||
if (active)
|
if (active)
|
||||||
{
|
{
|
||||||
gMixer.sources.remove(this);
|
gMixer.sources.remove(this);
|
||||||
|
active = false;
|
||||||
}
|
}
|
||||||
gMixer.Unlock();
|
gMixer.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Source::~Source()
|
||||||
|
{
|
||||||
|
if (active)
|
||||||
|
{
|
||||||
|
// You MUST call RemoveFromMixer before destroying a source. If you get here, your program is incorrect.
|
||||||
|
fprintf(stderr, "Source wasn't removed from mixer prior to destruction!\n");
|
||||||
|
#if _DEBUG
|
||||||
|
std::terminate();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Source::Rewind()
|
void Source::Rewind()
|
||||||
{
|
{
|
||||||
RewindImplementation();
|
RewindImplementation();
|
||||||
|
@ -77,6 +77,8 @@ namespace cmixer
|
|||||||
public:
|
public:
|
||||||
virtual ~Source();
|
virtual ~Source();
|
||||||
|
|
||||||
|
void RemoveFromMixer();
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
void Rewind();
|
void Rewind();
|
||||||
|
Loading…
Reference in New Issue
Block a user