]> git.sesse.net Git - vlc/blobdiff - modules/audio_output/portaudio.c
SpuRegionPlace now works in rendered unit.
[vlc] / modules / audio_output / portaudio.c
index a78885d1fa9a677f20fba65f22f11fbf9c739d87..74afad6048485257111dafe8cd9c3bb7733267e9 100644 (file)
@@ -30,7 +30,8 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_aout.h>
 
 
@@ -76,21 +77,16 @@ struct aout_sys_t
     uint32_t i_channels;
 };
 
-static const uint32_t pi_channels_in[] =
-    { AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT,
-      AOUT_CHAN_MIDDLELEFT, AOUT_CHAN_MIDDLERIGHT,
-      AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT,
-      AOUT_CHAN_CENTER, AOUT_CHAN_LFE, 0 };
 static const uint32_t pi_channels_out[] =
     { AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT,
       AOUT_CHAN_CENTER, AOUT_CHAN_LFE,
-      AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT,
+      AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT, AOUT_CHAN_REARCENTER,
       AOUT_CHAN_MIDDLELEFT, AOUT_CHAN_MIDDLERIGHT, 0 };
 
 #ifdef PORTAUDIO_IS_SERIOUSLY_BROKEN
 static bool b_init = 0;
 static pa_thread_t *pa_thread;
-static void PORTAUDIOThread( pa_thread_t * );
+static void* PORTAUDIOThread( vlc_object_t * );
 #endif
 
 /*****************************************************************************
@@ -111,7 +107,7 @@ static int PAOpenStream( aout_instance_t * );
 
 vlc_module_begin();
     set_shortname( "PortAudio" );
-    set_description( _("PORTAUDIO audio output") );
+    set_description( N_("PORTAUDIO audio output") );
     set_category( CAT_AUDIO );
     set_subcategory( SUBCAT_AUDIO_AOUT );
     add_integer( "portaudio-device", 0, NULL,
@@ -147,8 +143,8 @@ static int paCallback( const void *inputBuffer, void *outputBuffer,
                                  p_sys->i_channels, p_sys->pi_chan_table,
                                  p_sys->i_bits_per_sample );
         }
-        p_aout->p_libvlc->pf_memcpy( outputBuffer, p_buffer->p_buffer,
-                                  framesPerBuffer * p_sys->i_sample_size );
+        vlc_memcpy( outputBuffer, p_buffer->p_buffer,
+                    framesPerBuffer * p_sys->i_sample_size );
         /* aout_BufferFree may be dangereous here, but then so is
          * aout_OutputNextBuffer (calls aout_BufferFree internally).
          * one solution would be to link the no longer useful buffers
@@ -160,8 +156,7 @@ static int paCallback( const void *inputBuffer, void *outputBuffer,
     else
         /* Audio output buffer shortage -> stop the fill process and wait */
     {
-        p_aout->p_libvlc->pf_memset( outputBuffer, 0,
-                                  framesPerBuffer * p_sys->i_sample_size );
+        vlc_memset( outputBuffer, 0, framesPerBuffer * p_sys->i_sample_size );
     }
     return 0;
 }
@@ -181,10 +176,7 @@ static int Open( vlc_object_t * p_this )
     /* Allocate p_sys structure */
     p_sys = (aout_sys_t *)malloc( sizeof(aout_sys_t) );
     if( p_sys == NULL )
-    {
-        msg_Err( p_aout, "out of memory" );
         return VLC_ENOMEM;
-    }
     p_sys->p_aout = p_aout;
     p_sys->p_stream = 0;
     p_aout->output.p_sys = p_sys;
@@ -218,11 +210,11 @@ static int Open( vlc_object_t * p_this )
         pa_thread = vlc_object_create( p_aout, sizeof(pa_thread_t) );
         pa_thread->p_aout = p_aout;
         pa_thread->b_error = false;
-        vlc_mutex_init( p_aout, &pa_thread->lock_wait );
-        vlc_cond_init( p_aout, &pa_thread->wait );
+        vlc_mutex_init( &pa_thread->lock_wait );
+        vlc_cond_init( &pa_thread->wait );
         pa_thread->b_wait = false;
-        vlc_mutex_init( p_aout, &pa_thread->lock_signal );
-        vlc_cond_init( p_aout, &pa_thread->signal );
+        vlc_mutex_init( &pa_thread->lock_signal );
+        vlc_cond_init( &pa_thread->signal );
         pa_thread->b_signal = false;
 
         /* Create PORTAUDIOThread */
@@ -518,7 +510,7 @@ static int PAOpenStream( aout_instance_t *p_aout )
     p_aout->output.p_sys->i_channels = i_channels;
 
     p_aout->output.p_sys->b_chan_reorder =
-        aout_CheckChannelReorder( pi_channels_in, pi_channels_out,
+        aout_CheckChannelReorder( NULL, pi_channels_out,
                                   i_channel_mask, i_channels,
                                   p_aout->output.p_sys->pi_chan_table );
 
@@ -575,13 +567,15 @@ static void Play( aout_instance_t * p_aout )
  * PORTAUDIOThread: all interactions with libportaudio.a are handled
  * in this single thread.  Otherwise libportaudio.a is _not_ happy :-(
  *****************************************************************************/
-static void PORTAUDIOThread( pa_thread_t *pa_thread )
+static void* PORTAUDIOThread( vlc_object_t *p_this )
 {
+    pa_thread_t *pa_thread = (pa_thread_t*)p_this;
     aout_instance_t *p_aout;
     aout_sys_t *p_sys;
     int i_err;
+    int canc = vlc_savecancel ();
 
-    while( !pa_thread->b_die )
+    while( vlc_object_alive (pa_thread) )
     {
         /* Wait for start of stream */
         vlc_mutex_lock( &pa_thread->lock_signal );
@@ -652,5 +646,7 @@ static void PORTAUDIOThread( pa_thread_t *pa_thread )
         vlc_cond_signal( &pa_thread->wait );
         vlc_mutex_unlock( &pa_thread->lock_wait );
     }
+    vlc_restorecancel (canc);
+    return NULL;
 }
 #endif