output/Internal: add attribute request.audio_format
Make in_audio_format accessible only from within the OutputThread, and add a new one for inter-thread communication.
This commit is contained in:
parent
176dc11748
commit
e5c9f6c1fe
@ -166,6 +166,8 @@ struct AudioOutput {
|
||||
/**
|
||||
* The audio_format in which audio data is received from the
|
||||
* player thread (which in turn receives it from the decoder).
|
||||
*
|
||||
* Only accessible from within the OutputThread.
|
||||
*/
|
||||
AudioFormat in_audio_format;
|
||||
|
||||
@ -246,6 +248,16 @@ struct AudioOutput {
|
||||
*/
|
||||
Command command = Command::NONE;
|
||||
|
||||
/**
|
||||
* Additional data for #command. Protected by #mutex.
|
||||
*/
|
||||
struct Request {
|
||||
/**
|
||||
* The #AudioFormat requested by #Command::OPEN.
|
||||
*/
|
||||
AudioFormat audio_format;
|
||||
} request;
|
||||
|
||||
/**
|
||||
* This mutex protects #open, #fail_timer, #pipe.
|
||||
*/
|
||||
|
@ -112,7 +112,7 @@ AudioOutput::Open(const AudioFormat audio_format, const MusicPipe &mp)
|
||||
|
||||
fail_timer.Reset();
|
||||
|
||||
if (open && audio_format == in_audio_format) {
|
||||
if (open && audio_format == request.audio_format) {
|
||||
assert(&pipe.GetPipe() == &mp || (always_on && pause));
|
||||
|
||||
if (pause) {
|
||||
@ -131,7 +131,7 @@ AudioOutput::Open(const AudioFormat audio_format, const MusicPipe &mp)
|
||||
return true;
|
||||
}
|
||||
|
||||
in_audio_format = audio_format;
|
||||
request.audio_format = audio_format;
|
||||
|
||||
pipe.Init(mp);
|
||||
|
||||
|
@ -134,7 +134,7 @@ inline void
|
||||
AudioOutput::Open()
|
||||
{
|
||||
assert(!open);
|
||||
assert(in_audio_format.IsValid());
|
||||
assert(request.audio_format.IsValid());
|
||||
|
||||
fail_timer.Reset();
|
||||
|
||||
@ -144,6 +144,8 @@ AudioOutput::Open()
|
||||
/* still no luck */
|
||||
return;
|
||||
|
||||
in_audio_format = request.audio_format;
|
||||
|
||||
bool success;
|
||||
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user