Audio: Fix BGM not starting after ME has ended
A previous commit prevented the MeWatch from starting a BGM stream that was in stopped state. However, when a new BGM is loaded while the ME is still playing, the BGM stream will be stopped even though we want it to start after the ME finishes. Also add some comments trying to explain members of 'AudioStream' a bit better.
This commit is contained in:
parent
bf712f3738
commit
946d778b96
|
@ -1132,12 +1132,34 @@ struct AudioStream
|
||||||
/* Volume set by external threads,
|
/* Volume set by external threads,
|
||||||
* such as for fade-in/out.
|
* such as for fade-in/out.
|
||||||
* Multiplied with intVolume for final
|
* Multiplied with intVolume for final
|
||||||
* playback volume */
|
* playback volume.
|
||||||
|
* fadeVolume: used by fade-out thread.
|
||||||
|
* extVolume: used by MeWatch. */
|
||||||
float fadeVolume;
|
float fadeVolume;
|
||||||
float extVolume;
|
float extVolume;
|
||||||
|
|
||||||
|
/* Note that 'extPaused' and 'noResumeStop' are
|
||||||
|
* effectively only used with the AudioStream
|
||||||
|
* instance representing the BGM */
|
||||||
|
|
||||||
|
/* Flag indicating that the MeWatch paused this
|
||||||
|
* (BGM) stream because a ME started playing.
|
||||||
|
* While this flag is set, calls to 'play()'
|
||||||
|
* might open another file, but will not start
|
||||||
|
* the playback stream (the MeWatch will start
|
||||||
|
* it as soon as the ME finished playing). */
|
||||||
bool extPaused;
|
bool extPaused;
|
||||||
|
|
||||||
|
/* Flag indicating that this stream shouldn't be
|
||||||
|
* started by the MeWatch when it is in stopped
|
||||||
|
* state (eg. because the BGM stream was explicitly
|
||||||
|
* stopped by the user script while the ME was playing.
|
||||||
|
* When a new BGM is started (via 'play()') while an ME
|
||||||
|
* is playing, the file will be loaded without starting
|
||||||
|
* the stream, but we want the MeWatch to start it as
|
||||||
|
* soon as the ME ends, so we unset this flag. */
|
||||||
|
bool noResumeStop;
|
||||||
|
|
||||||
ALStream stream;
|
ALStream stream;
|
||||||
SDL_mutex *streamMut;
|
SDL_mutex *streamMut;
|
||||||
|
|
||||||
|
@ -1169,6 +1191,7 @@ struct AudioStream
|
||||||
fadeVolume(1.0),
|
fadeVolume(1.0),
|
||||||
extVolume(1.0),
|
extVolume(1.0),
|
||||||
extPaused(false),
|
extPaused(false),
|
||||||
|
noResumeStop(false),
|
||||||
stream(loopMode)
|
stream(loopMode)
|
||||||
{
|
{
|
||||||
current.volume = 1.0;
|
current.volume = 1.0;
|
||||||
|
@ -1261,6 +1284,8 @@ struct AudioStream
|
||||||
|
|
||||||
if (!extPaused)
|
if (!extPaused)
|
||||||
stream.play(offset);
|
stream.play(offset);
|
||||||
|
else
|
||||||
|
noResumeStop = false;
|
||||||
|
|
||||||
unlockStream();
|
unlockStream();
|
||||||
}
|
}
|
||||||
|
@ -1271,6 +1296,8 @@ struct AudioStream
|
||||||
|
|
||||||
lockStream();
|
lockStream();
|
||||||
|
|
||||||
|
noResumeStop = true;
|
||||||
|
|
||||||
stream.stop();
|
stream.stop();
|
||||||
|
|
||||||
unlockStream();
|
unlockStream();
|
||||||
|
@ -1554,6 +1581,10 @@ struct AudioPrivate
|
||||||
{
|
{
|
||||||
/* BGM is stopped. -> MeNotPlaying */
|
/* BGM is stopped. -> MeNotPlaying */
|
||||||
bgm.setExtVolume1(1.0);
|
bgm.setExtVolume1(1.0);
|
||||||
|
|
||||||
|
if (!bgm.noResumeStop)
|
||||||
|
bgm.stream.play();
|
||||||
|
|
||||||
meWatch.state = MeNotPlaying;
|
meWatch.state = MeNotPlaying;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue