audio: Fix sound resuming after reactivation if stop() was called while inactive

Backport of fix for #559
This commit is contained in:
rdb 2020-12-12 19:50:48 +01:00
parent 130c70a9f5
commit a11e21e4f4
2 changed files with 7 additions and 3 deletions

View File

@ -259,6 +259,7 @@ stop() {
}
}
_start_time = 0.0;
_paused = false;
}
@ -827,12 +828,13 @@ set_active(bool active) {
} else {
// ...deactivate the sound.
if (status() == PLAYING) {
PN_stdfloat time = get_time();
stop();
if (get_loop_count() == 0) {
// ...we're pausing a looping sound.
_paused = true;
_start_time = get_time();
_start_time = time;
}
stop();
}
}
}

View File

@ -217,6 +217,8 @@ stop() {
_stream_queued.resize(0);
}
_paused = false;
_manager->stopping_sound(this);
release_sound_data(false);
}
@ -813,11 +815,11 @@ set_active(bool active) {
} else {
// ...deactivate the sound.
if (status()==PLAYING) {
stop();
if (_loop_count==0) {
// ...we're pausing a looping sound.
_paused=true;
}
stop();
}
}
}