Commit 897c162e authored by David Fuhrmann's avatar David Fuhrmann

auhal: do an early check for the stream format set

This prevents waiting for the timeout in some situations, especially
if the format was already set to the new value before.
parent 3aa6b1be
...@@ -1726,8 +1726,6 @@ static int AudioStreamSupportsDigital(audio_output_t *p_aout, AudioStreamID i_st ...@@ -1726,8 +1726,6 @@ static int AudioStreamSupportsDigital(audio_output_t *p_aout, AudioStreamID i_st
static int AudioStreamChangeFormat(audio_output_t *p_aout, AudioStreamID i_stream_id, AudioStreamBasicDescription change_format) static int AudioStreamChangeFormat(audio_output_t *p_aout, AudioStreamID i_stream_id, AudioStreamBasicDescription change_format)
{ {
OSStatus err = noErr; OSStatus err = noErr;
UInt32 i_param_size = 0;
int retValue = true; int retValue = true;
AudioObjectPropertyAddress physicalFormatAddress = { kAudioStreamPropertyPhysicalFormat, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster }; AudioObjectPropertyAddress physicalFormatAddress = { kAudioStreamPropertyPhysicalFormat, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
...@@ -1762,14 +1760,10 @@ static int AudioStreamChangeFormat(audio_output_t *p_aout, AudioStreamID i_strea ...@@ -1762,14 +1760,10 @@ static int AudioStreamChangeFormat(audio_output_t *p_aout, AudioStreamID i_strea
* it is also not atomic in its behaviour. * it is also not atomic in its behaviour.
* Therefore we check 5 times before we really give up. * Therefore we check 5 times before we really give up.
* FIXME: failing isn't actually implemented yet. */ * FIXME: failing isn't actually implemented yet. */
for (int i = 0; i < 5; i++) {
AudioStreamBasicDescription actual_format; AudioStreamBasicDescription actual_format;
mtime_t timeout = mdate() + 500000; UInt32 i_param_size = sizeof(AudioStreamBasicDescription);
for (int i = 0; i < 5; i++) {
if (vlc_cond_timedwait(&w.cond, &w.lock, timeout)) /* Callback is not always invoked. So first check if format is already set. */
msg_Dbg(p_aout, "reached timeout");
i_param_size = sizeof(AudioStreamBasicDescription);
err = AudioObjectGetPropertyData(i_stream_id, &physicalFormatAddress, 0, NULL, &i_param_size, &actual_format); err = AudioObjectGetPropertyData(i_stream_id, &physicalFormatAddress, 0, NULL, &i_param_size, &actual_format);
msg_Dbg(p_aout, STREAM_FORMAT_MSG("actual format in use: ", actual_format)); msg_Dbg(p_aout, STREAM_FORMAT_MSG("actual format in use: ", actual_format));
...@@ -1779,7 +1773,11 @@ static int AudioStreamChangeFormat(audio_output_t *p_aout, AudioStreamID i_strea ...@@ -1779,7 +1773,11 @@ static int AudioStreamChangeFormat(audio_output_t *p_aout, AudioStreamID i_strea
/* The right format is now active */ /* The right format is now active */
break; break;
} }
/* We need to check again */ /* We need to check again */
mtime_t timeout = mdate() + 500000;
if (vlc_cond_timedwait(&w.cond, &w.lock, timeout))
msg_Dbg(p_aout, "reached timeout");
} }
out: out:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment