* alsa.c : alsa plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
- * $Id: alsa.c,v 1.15 2002/03/20 03:43:51 sam Exp $
+ * $Id: alsa.c,v 1.18 2002/06/01 12:31:58 sam Exp $
*
* Authors: Henri Fallon <henri@videolan.org> - Original Author
* Jeffrey Baker <jwbaker@acm.org> - Port to ALSA 1.0 API
*****************************************************************************/
#include <errno.h> /* ENOMEM */
#include <string.h> /* strerror() */
-#include <stdio.h> /* "intf_msg.h" */
#include <stdlib.h> /* calloc(), malloc(), free() */
-#include <alsa/asoundlib.h>
-
-#include <videolan/vlc.h>
+#include <vlc/vlc.h>
+#include <vlc/aout.h>
-#include "audio_output.h" /* aout_thread_t */
+#include <alsa/asoundlib.h>
/*****************************************************************************
* Capabilities defined in the other files.
MODULE_CONFIG_STOP
MODULE_INIT_START
- SET_DESCRIPTION( "Alsa audio module" )
+ SET_DESCRIPTION( _("ALSA audio module") )
ADD_CAPABILITY( AOUT, 50 )
- ADD_SHORTCUT( "alsa" )
MODULE_INIT_STOP
MODULE_ACTIVATE_START
/* here we store plugin dependant informations */
-typedef struct aout_sys_s
+struct aout_sys_s
{
snd_pcm_t * p_alsa_handle;
unsigned long buffer_time;
unsigned int bytes_per_sample;
unsigned int samples_per_frame;
unsigned int bytes_per_frame;
-} aout_sys_t;
+};
/*****************************************************************************
* Functions exported as capabilities. They are declared as static so that
p_aout->p_sys = malloc( sizeof( aout_sys_t ) );
if( p_aout->p_sys == NULL )
{
- intf_ErrMsg( "aout error: failed allocating memory for ALSA (%s)",
- strerror(ENOMEM) );
+ msg_Err( p_aout, "out of memory" );
return -1;
}
psz_alsadev, SND_PCM_STREAM_PLAYBACK, 0);
if( i_ret != 0 )
{
- intf_ErrMsg( "aout error: could not open ALSA device (%s)",
- snd_strerror( i_ret ) );
+ msg_Err( p_aout, "cannot open ALSA device (%s)", snd_strerror(i_ret) );
return -1;
}
i_rv = snd_pcm_hw_params_any( p_aout->p_sys->p_alsa_handle, p_hw );
if( i_rv < 0 )
{
- intf_ErrMsg( "aout error: unable to retrieve initial parameters" );
+ msg_Err( p_aout, "unable to retrieve initial parameters" );
return( -1 );
}
SND_PCM_ACCESS_RW_INTERLEAVED );
if( i_rv < 0 )
{
- intf_ErrMsg( "aout error: unable to set interleaved stream format" );
+ msg_Err( p_aout, "unable to set interleaved stream format" );
return( -1 );
}
p_hw, i_format );
if( i_rv < 0 )
{
- intf_ErrMsg( "aout error: unable to set stream sample size and word"
- " order" );
+ msg_Err( p_aout, "unable to set stream sample size and word order" );
return( -1 );
}
p_aout->i_channels );
if( i_rv < 0 )
{
- intf_ErrMsg( "aout error: unable to set number of output channels" );
+ msg_Err( p_aout, "unable to set number of output channels" );
return( -1 );
}
p_aout->i_rate, 0 );
if( i_rv < 0 )
{
- intf_ErrMsg( "aout error: unable to set sample rate" );
+ msg_Err( p_aout, "unable to set sample rate" );
return( -1 );
}
p_aout->p_sys->rate = i_rv;
0 );
if( i_rv < 0 )
{
- intf_ErrMsg( "aout error: unable to set buffer time" );
+ msg_Err( p_aout, "unable to set buffer time" );
return( -1 );
}
p_aout->p_sys->buffer_time = i_rv;
p_hw, p_aout->p_sys->buffer_time / p_aout->p_sys->bytes_per_frame, 0 );
if( i_rv < 0 )
{
- intf_ErrMsg( "aout error: unable to set period time" );
+ msg_Err( p_aout, "unable to set period time" );
return( -1 );
}
p_aout->p_sys->period_time = i_rv;
i_rv = snd_pcm_hw_params(p_aout->p_sys->p_alsa_handle, p_hw);
if (i_rv < 0)
{
- intf_ErrMsg( "aout error: unable to set hardware configuration" );
+ msg_Err( p_aout, "unable to set hardware configuration" );
return( -1 );
}
i_rv = snd_pcm_sw_params( p_aout->p_sys->p_alsa_handle, p_sw );
if( i_rv < 0 )
{
- intf_ErrMsg( "aout error: unable to set software configuration" );
+ msg_Err( p_aout, "unable to set software configuration" );
return( -1 );
}
{
int i_rv;
- intf_ErrMsg( "aout error: resetting output after buffer underrun" );
+ msg_Err( p_aout, "resetting output after buffer underrun" );
// i_rv = snd_pcm_reset( p_aout->p_sys->p_alsa_handle );
i_rv = snd_pcm_prepare( p_aout->p_sys->p_alsa_handle );
if( i_rv < 0 )
{
- intf_ErrMsg( "aout error: unable to recover from buffer underrun (%s)",
- snd_strerror( i_rv ) );
+ msg_Err( p_aout, "unable to recover from buffer underrun (%s)",
+ snd_strerror( i_rv ) );
}
}
if( i_alsa_get_status_returns )
{
- intf_ErrMsg ( "aout error: failed getting alsa buffer info (%s)",
- snd_strerror ( i_alsa_get_status_returns ) );
+ msg_Err( p_aout, "failed getting alsa buffer info (%s)",
+ snd_strerror ( i_alsa_get_status_returns ) );
return ( -1 );
}
break;
default:
- intf_ErrMsg( "aout error: unhandled condition %i",
- snd_pcm_status_get_state( p_status ) );
+ msg_Err( p_aout, "unhandled condition %i",
+ snd_pcm_status_get_state( p_status ) );
break;
}
if( (signed int) rv < 0 )
{
- intf_ErrMsg( "aout error: failed writing to output (%s)",
- snd_strerror( rv ) );
+ msg_Err( p_aout, "failed writing to output (%s)",
+ snd_strerror( rv ) );
return;
}
if( i_close_returns )
{
- intf_ErrMsg( "aout error: failed closing ALSA device (%s)",
- i_close_returns, snd_strerror( i_close_returns ) );
+ msg_Err( p_aout, "failed closing ALSA device (%s)",
+ snd_strerror( i_close_returns ) );
}
free( p_aout->p_sys );