]> git.sesse.net Git - vlc/blobdiff - modules/gui/qnx/aout.c
Remove CDDAX module
[vlc] / modules / gui / qnx / aout.c
index a334ee7f4162a8450c9d4655e45da96b70ab4fe9..10e06d9f15aa53b5b8d5d41265fa97aec0d32a1c 100644 (file)
  *****************************************************************************/
 #include <errno.h>                                                 /* ENOMEM */
 
-#include <vlc/vlc.h>
-
-#ifdef HAVE_ALLOCA_H
-#   include <alloca.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
 #endif
 
+#include <vlc_common.h>
+
 #include <vlc_aout.h>
 
 #include <sys/asoundlib.h>
@@ -43,7 +43,7 @@ struct aout_sys_t
     int          i_card;
     int          i_device;
 
-    byte_t *     p_silent_buffer;
+    uint8_t *    p_silent_buffer;
 };
 
 #define DEFAULT_FRAME_SIZE 2048
@@ -51,18 +51,18 @@ struct aout_sys_t
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-int            E_(OpenAudio)    ( vlc_object_t *p_this );
-void           E_(CloseAudio)   ( vlc_object_t *p_this );
+int            OpenAudio    ( vlc_object_t *p_this );
+void           CloseAudio   ( vlc_object_t *p_this );
 static int     GetBufInfo       ( aout_instance_t * );
 static void    Play             ( aout_instance_t * );
-static int     QNXaoutThread    ( aout_instance_t * );
+static void*   QNXaoutThread    ( vlc_object_t * );
 
 /*****************************************************************************
  * Open : creates a handle and opens an alsa device
  *****************************************************************************
  * This function opens an alsa device, through the alsa API
  *****************************************************************************/
-int E_(OpenAudio)( vlc_object_t *p_this )
+int OpenAudio( vlc_object_t *p_this )
 {
     aout_instance_t *p_aout = (aout_instance_t *)p_this;
     int i_ret;
@@ -75,10 +75,7 @@ int E_(OpenAudio)( vlc_object_t *p_this )
     /* allocate structure */
     p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) );
     if( p_aout->output.p_sys == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
         return -1;
-    }
 
     /* open audio device */
     if( ( i_ret = snd_pcm_open_preferred( &p_aout->output.p_sys->p_pcm_handle,
@@ -97,7 +94,7 @@ int E_(OpenAudio)( vlc_object_t *p_this )
                                               PLUGIN_DISABLE_MMAP ) ) < 0 )
     {
         msg_Err( p_aout, "unable to disable mmap (%s)", snd_strerror(i_ret) );
-        E_(CloseAudio)( p_this );
+        CloseAudio( p_this );
         free( p_aout->output.p_sys );
         return -1;
     }
@@ -115,7 +112,7 @@ int E_(OpenAudio)( vlc_object_t *p_this )
     {
         msg_Err( p_aout, "unable to get plugin info (%s)",
                          snd_strerror( i_ret ) );
-        E_(CloseAudio)( p_this );
+        CloseAudio( p_this );
         free( p_aout->output.p_sys );
         return -1;
     }
@@ -140,7 +137,7 @@ int E_(OpenAudio)( vlc_object_t *p_this )
     }
     pp.format.voices         = i_nb_channels;
 
-    p_aout->output.output.i_format = AOUT_FMT_S16_NE;
+    p_aout->output.output.i_format = VLC_CODEC_S16N;
     p_aout->output.i_nb_samples = DEFAULT_FRAME_SIZE;
     pp.format.format = SND_PCM_SFMT_S16;
     i_bytes_per_sample = 2;
@@ -154,7 +151,7 @@ int E_(OpenAudio)( vlc_object_t *p_this )
                                          &pp ) ) < 0 )
     {
         msg_Err( p_aout, "unable to set parameters (%s)", snd_strerror(i_ret) );
-        E_(CloseAudio)( p_this );
+        CloseAudio( p_this );
         free( p_aout->output.p_sys );
         return -1;
     }
@@ -165,17 +162,17 @@ int E_(OpenAudio)( vlc_object_t *p_this )
     {
         msg_Err( p_aout, "unable to prepare channel (%s)",
                          snd_strerror( i_ret ) );
-        E_(CloseAudio)( p_this );
+        CloseAudio( p_this );
         free( p_aout->output.p_sys );
         return -1;
     }
 
     /* Create audio thread and wait for its readiness. */
     if( vlc_thread_create( p_aout, "aout", QNXaoutThread,
-                           VLC_THREAD_PRIORITY_OUTPUT, VLC_FALSE ) )
+                           VLC_THREAD_PRIORITY_OUTPUT ) )
     {
-        msg_Err( p_aout, "cannot create QNX audio thread (%s)", strerror(errno) );
-        E_(CloseAudio)( p_this );
+        msg_Err( p_aout, "cannot create QNX audio thread (%m)" );
+        CloseAudio( p_this );
         free( p_aout->output.p_sys );
         return -1;
     }
@@ -235,7 +232,7 @@ static void Play( aout_instance_t *p_aout )
 /*****************************************************************************
  * CloseAudio: close the audio device
  *****************************************************************************/
-void E_(CloseAudio) ( vlc_object_t *p_this )
+void CloseAudio ( vlc_object_t *p_this )
 {
     aout_instance_t *p_aout = (aout_instance_t *)p_this;
     int i_ret;
@@ -257,17 +254,19 @@ void E_(CloseAudio) ( vlc_object_t *p_this )
 /*****************************************************************************
  * QNXaoutThread: asynchronous thread used to DMA the data to the device
  *****************************************************************************/
-static int QNXaoutThread( aout_instance_t * p_aout )
+static void* QNXaoutThread( vlc_object_t *p_this )
 {
+    aout_instance_t * p_aout = (aout_instance_t*)p_this;
     struct aout_sys_t * p_sys = p_aout->output.p_sys;
+    int canc = vlc_savecancel ();
 
-    while ( !p_aout->b_die )
+    while ( vlc_object_alive (p_aout) )
     {
         aout_buffer_t * p_buffer;
         int i_tmp, i_size;
-        byte_t * p_bytes;
+        uint8_t * p_bytes;
 
-        if ( p_aout->output.output.i_format != VLC_FOURCC('s','p','d','i') )
+        if ( p_aout->output.output.i_format != VLC_CODEC_SPDIFL )
         {
             mtime_t next_date = 0;
 
@@ -281,17 +280,17 @@ static int QNXaoutThread( aout_instance_t * p_aout )
                       * p_aout->output.output.i_frame_length;
             next_date += mdate();
 
-            p_buffer = aout_OutputNextBuffer( p_aout, next_date, VLC_FALSE );
+            p_buffer = aout_OutputNextBuffer( p_aout, next_date, false );
         }
         else
         {
-            p_buffer = aout_OutputNextBuffer( p_aout, 0, VLC_TRUE );
+            p_buffer = aout_OutputNextBuffer( p_aout, 0, true );
         }
 
         if ( p_buffer != NULL )
         {
             p_bytes = p_buffer->p_buffer;
-            i_size = p_buffer->i_nb_bytes;
+            i_size = p_buffer->i_buffer;
         }
         else
         {
@@ -307,7 +306,7 @@ static int QNXaoutThread( aout_instance_t * p_aout )
 
         if( i_tmp < 0 )
         {
-            msg_Err( p_aout, "write failed (%s)", strerror(errno) );
+            msg_Err( p_aout, "write failed (%m)" );
         }
 
         if ( p_buffer != NULL )
@@ -316,6 +315,7 @@ static int QNXaoutThread( aout_instance_t * p_aout )
         }
     }
 
-    return 0;
+    vlc_restorecancel (canc);
+    return NULL;
 }