]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/aout.m
* if we are paused in fullscreen, show cursor.
[vlc] / modules / gui / macosx / aout.m
index 367d2f2b0ff236dc1f4f52fde46cffe0d9595315..9b89e9a8bc795facf472e4c0ae6ac086b6a12b09 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * aout.m: CoreAudio output plugin
  *****************************************************************************
- * Copyright (C) 2002 VideoLAN
- * $Id: aout.m,v 1.19 2003/01/13 14:51:25 massiot Exp $
+ * Copyright (C) 2002-2003 VideoLAN
+ * $Id: aout.m,v 1.22 2003/01/21 00:47:43 jlj Exp $
  *
  * Authors: Colin Delacroix <colin@zoy.org>
  *          Jon Lech Johansen <jon-vl@nanocrew.net>
 
 #define A52_FRAME_NB 1536
 
+#define STREAM_FORMAT_MSG( pre, sfm ) \
+    pre ": [%ld][%4.4s][%ld][%ld][%ld][%ld][%ld][%ld]", \
+    (UInt32)sfm.mSampleRate, (char *)&sfm.mFormatID, \
+    sfm.mFormatFlags, sfm.mBytesPerPacket, \
+    sfm.mFramesPerPacket, sfm.mBytesPerFrame, \
+    sfm.mChannelsPerFrame, sfm.mBitsPerChannel
+
 /*****************************************************************************
  * aout_class_t 
  ****************************************************************************/
@@ -173,10 +180,10 @@ static OSStatus IOCallback      ( AudioDeviceID inDevice,
 int E_(OpenAudio)( vlc_object_t * p_this )
 {
     OSStatus err;
+    vlc_value_t val;
     UInt32 i, i_param_size;
     struct aout_sys_t * p_sys;
     aout_instance_t * p_aout = (aout_instance_t *)p_this;
-    vlc_value_t val;
 
     /* Allocate structure */
     p_sys = (struct aout_sys_t *)malloc( sizeof( struct aout_sys_t ) );
@@ -198,6 +205,8 @@ int E_(OpenAudio)( vlc_object_t * p_this )
 
     if( var_Type( p_aout, "audio-device" ) == 0 )
     {
+        UInt32 i_option = config_GetInt( p_aout, "macosx-adev" );
+
         var_Create( p_aout, "audio-device", VLC_VAR_STRING | 
                                             VLC_VAR_HASCHOICE );
 
@@ -205,15 +214,21 @@ int E_(OpenAudio)( vlc_object_t * p_this )
         {
             val.psz_string = p_sys->p_options[i].sz_option;
             var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );
+
+            if( i == i_option )
+            {
+                var_Set( p_aout, "audio-device", val );
+            }
         }
 
         var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart,
                          NULL );
+
+        val.b_bool = VLC_TRUE;
+        var_Set( p_aout, "intf-change", val );
     }
-    val.b_bool = VLC_TRUE;
-    var_Set( p_aout, "intf-change", val );
 
-    /* Get selected device */
+    /* Get requested device */
     if( GetDevice( p_aout, &p_sys->devid ) )
     {
         msg_Err( p_aout, "GetDevice failed" );
@@ -243,15 +258,8 @@ int E_(OpenAudio)( vlc_object_t * p_this )
     p_aout->output.output.i_rate = 
         (unsigned int)p_sys->stream_format.mSampleRate;
 
-    msg_Dbg( p_aout, "format: [%ld][%4.4s][%ld][%ld][%ld][%ld][%ld][%ld]",
-             (UInt32)p_sys->stream_format.mSampleRate,
-             (char *)&p_sys->stream_format.mFormatID,
-             p_sys->stream_format.mFormatFlags,
-             p_sys->stream_format.mBytesPerPacket,
-             p_sys->stream_format.mFramesPerPacket,
-             p_sys->stream_format.mBytesPerFrame,
-             p_sys->stream_format.mChannelsPerFrame,
-             p_sys->stream_format.mBitsPerChannel );                  
+    msg_Dbg( p_aout, STREAM_FORMAT_MSG( "using format",
+                                        p_sys->stream_format ) );
 
     /* Get the buffer size */
     i_param_size = sizeof( p_sys->i_buffer_size );
@@ -410,13 +418,6 @@ void E_(CloseAudio)( aout_instance_t * p_aout )
                  (char *)&err );
     }
 
-    err = AudioHardwareUnload();
-    if( err != noErr )
-    {
-        msg_Err( p_aout, "AudioHardwareUnload failed: [%4.4s]", 
-                 (char *)&err );
-    }
-
     FreeHardware( p_aout );
 
     free( p_sys );
@@ -813,6 +814,12 @@ static int InitStream( UInt32 i_dev, aout_instance_t *p_aout,
 
         for( i = 0; i < i_streams; i++ )
         {
+            if( j == 0 )
+            {
+                msg_Dbg( p_aout, STREAM_FORMAT_MSG( "supported format",
+                                                    P_STREAMS[i] ) );
+            }
+
             if( ( P_STREAMS[i].mFormatID != aout_classes[j].mFormatID ) ||
                 ( P_STREAMS[i].mChannelsPerFrame < 
                   aout_classes[j].mChannelsPerFrame ) )
@@ -886,9 +893,8 @@ static void FreeStream( UInt32 i_dev, aout_instance_t *p_aout,
 static int GetDevice( aout_instance_t *p_aout, AudioDeviceID *p_devid ) 
 {
     OSStatus err;
-    char *psz_tmp;
     vlc_value_t val;
-    UInt32 i_option;
+    unsigned int i_option;
 
     struct aout_dev_t * p_dev;
     struct aout_option_t * p_option;
@@ -900,16 +906,12 @@ static int GetDevice( aout_instance_t *p_aout, AudioDeviceID *p_devid )
         return( VLC_ENOVAR );
     }
 
-    psz_tmp = strchr( val.psz_string, ':' );
-    if( psz_tmp == NULL )
+    if( !sscanf( val.psz_string, "%d:", &i_option ) ||
+        p_sys->i_options <= i_option )
     {
-        msg_Err( p_aout, "audio-device value missing seperator" );
-        free( (void *)val.psz_string );
-        return( VLC_EGENERIC );
+        i_option = 0;
     }
 
-    *psz_tmp = '\0';
-    i_option = atol( val.psz_string );
     free( (void *)val.psz_string );
 
     p_option = &p_sys->p_options[i_option];
@@ -932,6 +934,8 @@ static int GetDevice( aout_instance_t *p_aout, AudioDeviceID *p_devid )
 
     msg_Dbg( p_aout, "getting device [%ld]", p_option->i_dev );
 
+    config_PutInt( p_aout, "macosx-adev", i_option );
+
     *p_devid = p_dev->devid;
 
     return( VLC_SUCCESS );