aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Göffringmann2005-02-20 19:06:09 +0000
committerRobert Göffringmann2005-02-20 19:06:09 +0000
commit78533d416f63ffc236dfad3a3f838c0daca95da3 (patch)
tree640e031db76179e71f35043c4e4575a84d12a31a
parentb455a94e0fb2cb522a75cb1e2a98422f860de9b1 (diff)
downloadscummvm-rg350-78533d416f63ffc236dfad3a3f838c0daca95da3.tar.gz
scummvm-rg350-78533d416f63ffc236dfad3a3f838c0daca95da3.tar.bz2
scummvm-rg350-78533d416f63ffc236dfad3a3f838c0daca95da3.zip
Changed mutex usage.
It now unlocks the mutex while it's loading mp3/ogg/wave data in order to have the sound thread play normally. The ps2's cd/dvd drive is too slow to transfer the entire file within a few millisecs, so it made the sound skip. svn-id: r16831
-rw-r--r--sword1/music.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/sword1/music.cpp b/sword1/music.cpp
index 34ef5b48c9..d882291747 100644
--- a/sword1/music.cpp
+++ b/sword1/music.cpp
@@ -285,9 +285,9 @@ void Music::giveVolume(uint8 *volL, uint8 *volR) {
}
void Music::startMusic(int32 tuneId, int32 loopFlag) {
- Common::StackLock lock(_mutex);
if (strlen(_tuneList[tuneId]) > 0) {
int newStream = 0;
+ _mutex.lock();
if (_handles[0].streaming() && _handles[1].streaming()) {
int streamToStop;
// Both streams playing - one must be forced to stop.
@@ -318,15 +318,25 @@ void Music::startMusic(int32 tuneId, int32 loopFlag) {
_handles[1].fadeDown();
newStream = 0;
}
+ delete _converter[newStream];
+ _converter[newStream] = NULL;
+ _mutex.unlock();
+
+ /* The handle will load the music file now. It can take a while, so unlock
+ the mutex before, to have the soundthread playing normally.
+ As the corresponding _converter is NULL, the handle will be ignored by the playing thread */
if (_handles[newStream].play(_tuneList[tuneId], loopFlag != 0)) {
- delete _converter[newStream];
+ _mutex.lock();
_converter[newStream] = makeRateConverter(_handles[newStream].getRate(), _mixer->getOutputRate(), _handles[newStream].isStereo(), false);
+ _mutex.unlock();
}
} else {
+ _mutex.lock();
if (_handles[0].streaming())
_handles[0].fadeDown();
if (_handles[1].streaming())
_handles[1].fadeDown();
+ _mutex.unlock();
}
}