[vlc-commits] auhal: add callback for changes in supported audio streams

David Fuhrmann git at videolan.org
Wed Sep 19 13:57:35 CEST 2012


vlc/vlc-2.0 | branch: master | David Fuhrmann <david.fuhrmann at googlemail.com> | Wed Sep 19 11:36:43 2012 +0200| [a15bac03820adae2bcc43c92b4f702f86e79af0c] | committer: 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: Felix Paul Kühne <fkuehne at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=a15bac03820adae2bcc43c92b4f702f86e79af0c
---

 modules/audio_output/auhal.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index d8bfc37..2a73ebf 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -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");
         }
     }
 



More information about the vlc-commits mailing list