]> git.sesse.net Git - vlc/blobdiff - plugins/qnx/aout_qnx.c
* Fixed a problem in the MacOS X aout which caused the previously
[vlc] / plugins / qnx / aout_qnx.c
index 1210e677bdc88d04e894f0f6c68795690301dd87..8a892ee829ab681b31135e4cc9eeb7259c541acf 100644 (file)
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#define MODULE_NAME qnx 
-#include "modules_inner.h"
-
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-
-#include "defs.h"
-
 #include <errno.h>                                                 /* ENOMEM */
 #include <string.h>                                            /* strerror() */
 #include <stdio.h>                                           /* "intf_msg.h" */
 
 #include <sys/asoundlib.h>
 
-#include "common.h"                                     /* boolean_t, byte_t */
-#include "intf_msg.h"                        /* intf_DbgMsg(), intf_ErrMsg() */
-#include "threads.h"
-#include "mtime.h"
-#include "tests.h"
+#include <videolan/vlc.h>
 
 #include "audio_output.h"                                   /* aout_thread_t */
 
-#include "modules.h"
-#include "modules_export.h"
-
 typedef struct aout_sys_s
 {
     snd_pcm_t  * p_pcm_handle;
@@ -58,10 +45,9 @@ typedef struct aout_sys_s
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static int     aout_Probe       ( probedata_t *p_data );
 static int     aout_Open        ( aout_thread_t *p_aout );
 static int     aout_SetFormat   ( aout_thread_t *p_aout );
-static long    aout_GetBufInfo  ( aout_thread_t *p_aout, long l_buffer_info );
+static int     aout_GetBufInfo  ( aout_thread_t *p_aout, int i_buffer_info );
 static void    aout_Play        ( aout_thread_t *p_aout,
                                   byte_t *buffer, int i_size );
 static void    aout_Close       ( aout_thread_t *p_aout );
@@ -72,7 +58,6 @@ static void    aout_Close       ( aout_thread_t *p_aout );
  *****************************************************************************/
 void _M( aout_getfunctions )( function_list_t * p_function_list )
 {
-    p_function_list->pf_probe = aout_Probe;
     p_function_list->functions.aout.pf_open = aout_Open;
     p_function_list->functions.aout.pf_setformat = aout_SetFormat;
     p_function_list->functions.aout.pf_getbufinfo = aout_GetBufInfo;
@@ -80,44 +65,6 @@ void _M( aout_getfunctions )( function_list_t * p_function_list )
     p_function_list->functions.aout.pf_close = aout_Close;
 }
 
-/*****************************************************************************
- * aout_Probe: probes the audio device and return a score
- *****************************************************************************
- * This function tries to open the dps and returns a score to the plugin
- * manager so that it can make its choice.
- *****************************************************************************/
-static int aout_Probe( probedata_t *p_data )
-{
-    int i_ret;
-    aout_sys_t adev;
-
-    /* open audio device */
-    if( ( i_ret = snd_pcm_open_preferred( &adev.p_pcm_handle,
-                                          &adev.i_card, &adev.i_device,
-                                          SND_PCM_OPEN_PLAYBACK ) ) < 0 )
-    {
-        intf_WarnMsg( 2, "aout error: unable to open audio device (%s)",
-                      snd_strerror( i_ret ) );
-        return( 0 );
-    }
-
-    /* close audio device */
-    if( ( i_ret = snd_pcm_close( adev.p_pcm_handle ) ) < 0 )
-    {
-        intf_WarnMsg( 2, "aout error: unable to close audio device (%s)",
-                      snd_strerror( i_ret ) );
-        return( 0 );
-    }
-
-    if( TestMethod( AOUT_METHOD_VAR, "qnx" ) )
-    {
-        return( 999 );
-    }
-
-    /* return score */
-    return( 50 );
-}    
-
 /*****************************************************************************
  * aout_Open : creates a handle and opens an alsa device
  *****************************************************************************
@@ -136,13 +83,6 @@ static int aout_Open( aout_thread_t *p_aout )
         return( 1 );
     }
 
-    /* initialize  */
-    p_aout->i_format   = AOUT_FORMAT_DEFAULT;
-    p_aout->i_channels = main_GetIntVariable( AOUT_STEREO_VAR,
-                                              AOUT_STEREO_DEFAULT ) + 1;
-    p_aout->l_rate     = main_GetIntVariable( AOUT_RATE_VAR,
-                                              AOUT_RATE_DEFAULT );
-
     /* open audio device */
     if( ( i_ret = snd_pcm_open_preferred( &p_aout->p_sys->p_pcm_handle,
                                           &p_aout->p_sys->i_card,
@@ -151,6 +91,7 @@ static int aout_Open( aout_thread_t *p_aout )
     {
         intf_ErrMsg( "aout error: unable to open audio device (%s)",
                       snd_strerror( i_ret ) );
+        free( p_aout->p_sys );
         return( 1 );
     }
 
@@ -161,6 +102,7 @@ static int aout_Open( aout_thread_t *p_aout )
         intf_ErrMsg( "aout error: unable to disable mmap (%s)",
                      snd_strerror( i_ret ) );
         aout_Close( p_aout );
+        free( p_aout->p_sys );
         return( 1 );
     }
 
@@ -202,7 +144,7 @@ static int aout_SetFormat( aout_thread_t *p_aout )
     pp.buf.block.frags_min   = 1;
     
     pp.format.interleave     = 1;
-    pp.format.rate           = p_aout->l_rate;
+    pp.format.rate           = p_aout->i_rate;
     pp.format.voices         = p_aout->i_channels;
 
     switch( p_aout->i_format )
@@ -219,7 +161,7 @@ static int aout_SetFormat( aout_thread_t *p_aout )
     }
 
     pp.buf.block.frag_size =
-        (((s64)p_aout->l_rate * AOUT_BUFFER_DURATION) / 1000000) *
+        (((s64)p_aout->i_rate * AOUT_BUFFER_DURATION) / 1000000) *
         p_aout->i_channels * i_bytes_per_sample;
 
     /* set parameters */
@@ -240,8 +182,6 @@ static int aout_SetFormat( aout_thread_t *p_aout )
         return( 1 );
     }
 
-    p_aout->i_latency = 0;
-
     return( 0 );
 }
 
@@ -253,7 +193,7 @@ static int aout_SetFormat( aout_thread_t *p_aout )
  * of data to play, it switches to the "underrun" status. It has to
  * be flushed and re-prepared
  *****************************************************************************/
-static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
+static int aout_GetBufInfo( aout_thread_t *p_aout, int i_buffer_limit )
 {
     int i_ret;
     snd_pcm_channel_status_t status;