]> git.sesse.net Git - vlc/blobdiff - modules/audio_output/oss.c
amem: add channel mapping
[vlc] / modules / audio_output / oss.c
index c324d524a52f62fad96204fe381609c51d5dd407..3f02068e4413cae329f20dbd16d3c6303a7456d8 100644 (file)
@@ -103,7 +103,6 @@ vlc_module_begin ()
     set_subcategory( SUBCAT_AUDIO_AOUT )
     add_loadfile( "oss-audio-device", "/dev/dsp",
                   N_("OSS DSP device"), NULL, false )
-        add_deprecated_alias( "dspdev" )   /* deprecated since 0.9.3 */
 
     set_capability( "audio output", 100 )
     add_shortcut( "oss" )
@@ -229,7 +228,7 @@ static void Probe( audio_output_t * p_aout )
     }
 
     /* Test for spdif. */
-    if ( AOUT_FMT_NON_LINEAR( &p_aout->format ) )
+    if ( AOUT_FMT_SPDIF( &p_aout->format ) )
     {
         i_format = AFMT_AC3;
 
@@ -248,9 +247,6 @@ static void Probe( audio_output_t * p_aout )
             msg_Warn( p_aout, "S/PDIF not supported by card" );
         }
     }
-
-    var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart,
-                     NULL );
 }
 
 /*****************************************************************************
@@ -304,17 +300,12 @@ static int Open( vlc_object_t *p_this )
     p_aout->pf_flush = aout_PacketFlush;
 
     if ( var_Type( p_aout, "audio-device" ) == 0 )
-    {
         Probe( p_aout );
-    }
+    var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
 
     if ( var_Get( p_aout, "audio-device", &val ) < 0 )
-    {
         /* Probe() has failed. */
-        close( p_sys->i_fd );
-        free( p_sys );
-        return VLC_EGENERIC;
-    }
+        goto error;
 
     if ( val.i_int == AOUT_VAR_SPDIF )
     {
@@ -351,9 +342,7 @@ static int Open( vlc_object_t *p_this )
         /* This should not happen ! */
         msg_Err( p_aout, "internal: can't find audio-device (%"PRId64")",
                  val.i_int );
-        close( p_sys->i_fd );
-        free( p_sys );
-        return VLC_EGENERIC;
+        goto error;
     }
 
     var_TriggerCallback( p_aout, "intf-change" );
@@ -362,13 +351,11 @@ static int Open( vlc_object_t *p_this )
     if( ioctl( p_sys->i_fd, SNDCTL_DSP_RESET, NULL ) < 0 )
     {
         msg_Err( p_aout, "cannot reset OSS audio device" );
-        close( p_sys->i_fd );
-        free( p_sys );
-        return VLC_EGENERIC;
+        goto error;
     }
 
     /* Set the output format */
-    if ( AOUT_FMT_NON_LINEAR( &p_aout->format ) )
+    if ( AOUT_FMT_SPDIF( &p_aout->format ) )
     {
         int i_format = AFMT_AC3;
 
@@ -376,9 +363,7 @@ static int Open( vlc_object_t *p_this )
              || i_format != AFMT_AC3 )
         {
             msg_Err( p_aout, "cannot reset OSS audio device" );
-            close( p_sys->i_fd );
-            free( p_sys );
-            return VLC_EGENERIC;
+            goto error;
         }
 
         p_aout->format.i_format = VLC_CODEC_SPDIFL;
@@ -388,8 +373,7 @@ static int Open( vlc_object_t *p_this )
         aout_PacketInit( p_aout, &p_sys->packet, A52_FRAME_NB );
         aout_VolumeNoneInit( p_aout );
     }
-
-    if ( !AOUT_FMT_NON_LINEAR( &p_aout->format ) )
+    else
     {
         unsigned int i_format = AFMT_S16_NE;
         unsigned int i_frame_size, i_fragments;
@@ -400,9 +384,7 @@ static int Open( vlc_object_t *p_this )
         if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 )
         {
             msg_Err( p_aout, "cannot set audio output format" );
-            close( p_sys->i_fd );
-            free( p_sys );
-            return VLC_EGENERIC;
+            goto error;
         }
 
         switch ( i_format )
@@ -428,9 +410,7 @@ static int Open( vlc_object_t *p_this )
         default:
             msg_Err( p_aout, "OSS fell back to an unknown format (%d)",
                      i_format );
-            close( p_sys->i_fd );
-            free( p_sys );
-            return VLC_EGENERIC;
+            goto error;
         }
 
         i_nb_channels = aout_FormatNbChannels( &p_aout->format );
@@ -441,9 +421,7 @@ static int Open( vlc_object_t *p_this )
         {
             msg_Err( p_aout, "cannot set number of audio channels (%s)",
                      aout_FormatPrintChannels( &p_aout->format) );
-            close( p_sys->i_fd );
-            free( p_sys );
-            return VLC_EGENERIC;
+            goto error;
         }
 
         /* Set the output rate */
@@ -452,9 +430,7 @@ static int Open( vlc_object_t *p_this )
         {
             msg_Err( p_aout, "cannot set audio output rate (%i)",
                              p_aout->format.i_rate );
-            close( p_sys->i_fd );
-            free( p_sys );
-            return VLC_EGENERIC;
+            goto error;
         }
 
         if( i_rate != p_aout->format.i_rate )
@@ -482,9 +458,7 @@ static int Open( vlc_object_t *p_this )
         if( ioctl( p_sys->i_fd, SNDCTL_DSP_GETOSPACE, &audio_buf ) < 0 )
         {
             msg_Err( p_aout, "cannot get fragment size" );
-            close( p_sys->i_fd );
-            free( p_sys );
-            return VLC_EGENERIC;
+            goto error;
         }
 
         /* Number of fragments actually allocated */
@@ -507,13 +481,16 @@ static int Open( vlc_object_t *p_this )
                    VLC_THREAD_PRIORITY_OUTPUT ) )
     {
         msg_Err( p_aout, "cannot create OSS thread (%m)" );
-        close( p_sys->i_fd );
         aout_PacketDestroy( p_aout );
-        free( p_sys );
-        return VLC_ENOMEM;
+        goto error;
     }
 
     return VLC_SUCCESS;
+
+    var_DelCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
+    close( p_sys->i_fd );
+    free( p_sys );
+    return VLC_EGENERIC;
 }
 
 /*****************************************************************************
@@ -527,6 +504,7 @@ static void Close( vlc_object_t * p_this )
     vlc_cancel( p_sys->thread );
     vlc_join( p_sys->thread, NULL );
     p_aout->b_die = false;
+    var_DelCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
 
     ioctl( p_sys->i_fd, SNDCTL_DSP_RESET, NULL );
     close( p_sys->i_fd );
@@ -641,7 +619,7 @@ static void* OSSThread( void *obj )
             for( ;; )
             {
                 canc = vlc_savecancel ();
-                p_buffer = aout_PacketNext( p_aout );
+                p_buffer = aout_PacketNext( p_aout, next_date );
                 if ( p_buffer )
                     break;
                 vlc_restorecancel (canc);