Skip to content

Commit

Permalink
SOUND: Fix locking in QueuingAudioStreamImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
clone2727 authored and DrMcCoy committed Aug 18, 2018
1 parent b644f1f commit a0131cb
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/sound/audiostream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class QueuingAudioStreamImpl : public QueuingAudioStream {
* A mutex to avoid access problems (causing e.g. corruption of
* the linked list) in thread aware environments.
*/
Common::Mutex _mutex;
mutable Common::Mutex _mutex;

/**
* The queue of audio streams.
Expand All @@ -196,17 +196,24 @@ class QueuingAudioStreamImpl : public QueuingAudioStream {
virtual int getChannels() const { return _channels; }
virtual int getRate() const { return _rate; }
virtual bool endOfData() const {
//Common::StackLock lock(_mutex);
Common::StackLock lock(_mutex);
return _queue.empty();
}
virtual bool endOfStream() const { return _finished && _queue.empty(); }
virtual bool endOfStream() const {
Common::StackLock lock(_mutex);
return _finished && _queue.empty();
}

// Implement the QueuingAudioStream API
virtual void queueAudioStream(AudioStream *stream, bool disposeAfterUse);
virtual void finish() { _finished = true; }

virtual void finish() {
Common::StackLock lock(_mutex);
_finished = true;
}

size_t numQueuedStreams() const {
//Common::StackLock lock(_mutex);
Common::StackLock lock(_mutex);
return _queue.size();
}
};
Expand Down

0 comments on commit a0131cb

Please sign in to comment.