mirror of
https://github.com/jorio/Pomme.git
synced 2024-11-23 06:32:14 +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()
|
||||
{
|
||||
Unlink();
|
||||
Unlink(); // Unlink chan from list of managed chans
|
||||
|
||||
macChannel->channelImpl = nullptr;
|
||||
|
||||
@ -39,6 +39,11 @@ ChannelImpl::~ChannelImpl()
|
||||
{
|
||||
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()
|
||||
|
@ -255,16 +255,29 @@ void Source::Init(int theSampleRate, int theLength)
|
||||
Stop();
|
||||
}
|
||||
|
||||
Source::~Source()
|
||||
void Source::RemoveFromMixer()
|
||||
{
|
||||
gMixer.Lock();
|
||||
if (active)
|
||||
{
|
||||
gMixer.sources.remove(this);
|
||||
active = false;
|
||||
}
|
||||
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()
|
||||
{
|
||||
RewindImplementation();
|
||||
|
@ -77,6 +77,8 @@ namespace cmixer
|
||||
public:
|
||||
virtual ~Source();
|
||||
|
||||
void RemoveFromMixer();
|
||||
|
||||
void Clear();
|
||||
|
||||
void Rewind();
|
||||
|
Loading…
Reference in New Issue
Block a user