mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-26 04:35:16 +00:00
AGOS: Sanitize the mutex locking in MidiPlayer::startTrack
This commit is contained in:
parent
7b02dac3c5
commit
2bc842dcee
@ -62,9 +62,8 @@ MidiPlayer::MidiPlayer() {
|
||||
}
|
||||
|
||||
MidiPlayer::~MidiPlayer() {
|
||||
_mutex.lock();
|
||||
Common::StackLock lock(_mutex);
|
||||
close();
|
||||
_mutex.unlock();
|
||||
}
|
||||
|
||||
int MidiPlayer::open() {
|
||||
@ -211,6 +210,8 @@ void MidiPlayer::onTimer(void *data) {
|
||||
}
|
||||
|
||||
void MidiPlayer::startTrack(int track) {
|
||||
Common::StackLock lock(_mutex);
|
||||
|
||||
if (track == _currentTrack)
|
||||
return;
|
||||
|
||||
@ -218,8 +219,6 @@ void MidiPlayer::startTrack(int track) {
|
||||
if (track >= _music.num_songs)
|
||||
return;
|
||||
|
||||
_mutex.lock();
|
||||
|
||||
if (_music.parser) {
|
||||
_current = &_music;
|
||||
delete _music.parser;
|
||||
@ -240,9 +239,7 @@ void MidiPlayer::startTrack(int track) {
|
||||
_currentTrack = (byte)track;
|
||||
_music.parser = parser; // That plugs the power cord into the wall
|
||||
} else if (_music.parser) {
|
||||
_mutex.lock();
|
||||
if (!_music.parser->setTrack(track)) {
|
||||
_mutex.unlock();
|
||||
return;
|
||||
}
|
||||
_currentTrack = (byte)track;
|
||||
@ -250,8 +247,6 @@ void MidiPlayer::startTrack(int track) {
|
||||
_music.parser->jumpToTick(0);
|
||||
_current = 0;
|
||||
}
|
||||
|
||||
_mutex.unlock();
|
||||
}
|
||||
|
||||
void MidiPlayer::stop() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user