Commit a15bac03 authored by David Fuhrmann's avatar David Fuhrmann Committed by Felix Paul Kühne

auhal: add callback for changes in supported audio streams

This tries to fix wrong behavior when optical cable is unplugged while spdif-output is running.

Currently, you will probably hear pops and you only get sound from internal speakers,
after you changed system volume.
(cherry picked from commit bdf858dae3bd2c81ceb2082b4c3ac36d2712d612)

Conflicts:
	modules/audio_output/auhal.c
Signed-off-by: default avatarFelix Paul Kühne <fkuehne@videolan.org>
parent 748335b8
......@@ -785,6 +785,11 @@ static int OpenSPDIF( audio_output_t * p_aout )
}
free( p_streams );
/* get notified when we don't have spdif-output anymore */
err = AudioObjectAddPropertyListener(p_sys->i_stream_id, &physicalFormatsAddress, HardwareListener, (void *)p_aout);
if (err != noErr)
msg_Warn(p_aout, "could not set audio device property streams callback on device: %4.4s", (char *)&err);
msg_Dbg( p_aout, STREAM_FORMAT_MSG( "original stream format: ", p_sys->sfmt_revert ) );
if( !AudioStreamChangeFormat( p_aout, p_sys->i_stream_id, p_sys->stream_format ) )
......@@ -856,6 +861,13 @@ static void Close( vlc_object_t * p_this )
msg_Err( p_aout, "failed to remove audio device life checker: [%4.4s]", (char *)&err );
}
if (p_sys->b_digital) {
AudioObjectPropertyAddress physicalFormatsAddress = { kAudioStreamPropertyAvailablePhysicalFormats, kAudioObjectPropertyScopeGlobal, 0 };
err = AudioObjectRemovePropertyListener(p_sys->i_stream_id, &physicalFormatsAddress, HardwareListener, NULL);
if (err != noErr)
msg_Err(p_aout, "failed to remove audio device property streams callback: [%4.4s]", (char *)&err);
}
if( p_sys->au_unit )
{
verify_noerr( AudioOutputUnitStop( p_sys->au_unit ) );
......@@ -1440,6 +1452,10 @@ static OSStatus HardwareListener( AudioObjectID inObjectID, UInt32 inNumberAddr
msg_Warn( p_aout, "audio device died, resetting aout" );
var_TriggerCallback( p_aout, "audio-device" );
var_Destroy( p_aout, "audio-device" );
} else if (inAddresses[i].mSelector == kAudioStreamPropertyAvailablePhysicalFormats) {
msg_Warn(p_aout, "available physical formats for audio device changed, resetting aout");
var_TriggerCallback(p_aout, "audio-device");
var_Destroy(p_aout, "audio-device");
}
}
......
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