* aout_beos.cpp: BeOS audio output
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
- * $Id: aout_beos.cpp,v 1.18 2001/12/30 07:09:54 sam Exp $
+ * $Id: aout_beos.cpp,v 1.26 2002/07/31 20:56:50 sam Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
#include <malloc.h>
#include <string.h>
-extern "C"
-{
-#include <videolan/vlc.h>
-
-#include "audio_output.h"
-}
+#include <vlc/vlc.h>
+#include <vlc/aout.h>
/*****************************************************************************
* aout_sys_t: BeOS audio output method descriptor
* This structure is part of the audio output thread descriptor.
* It describes some BeOS specific variables.
*****************************************************************************/
-typedef struct aout_sys_s
+struct aout_sys_t
{
BPushGameSound * p_sound;
gs_audio_format * p_format;
void * p_buffer;
- long i_buffer_size;
- long i_buffer_pos;
-
-} aout_sys_t;
-
-extern "C"
-{
+ int i_buffer_size;
+ int i_buffer_pos;
+};
/*****************************************************************************
* 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 void aout_Play ( aout_thread_t *p_aout,
- byte_t *buffer, int i_size );
-static void aout_Close ( aout_thread_t *p_aout );
-
-/*****************************************************************************
- * Functions exported as capabilities. They are declared as static so that
- * we don't pollute the namespace too much.
- *****************************************************************************/
-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;
- p_function_list->functions.aout.pf_play = aout_Play;
- p_function_list->functions.aout.pf_close = aout_Close;
-}
+static int SetFormat ( aout_thread_t * );
+static int GetBufInfo ( aout_thread_t *, int );
+static void Play ( aout_thread_t *, byte_t *, int );
/*****************************************************************************
- * aout_Probe: probe the audio device and return a score
+ * OpenAudio: opens a BPushGameSound
*****************************************************************************/
-static int aout_Probe( probedata_t *p_data )
-{
- /* We don't test anything since I don't know what to test. However
- * if the module could be loaded it is quite likely to work. */
- return( 100 );
-}
+int E_(OpenAudio) ( vlc_object_t *p_this )
+{
+ aout_thread_t * p_aout = (aout_thread_t *)p_this;
-/*****************************************************************************
- * aout_Open: opens a BPushGameSound
- *****************************************************************************/
-static int aout_Open( aout_thread_t *p_aout )
-{
/* Allocate structure */
p_aout->p_sys = (aout_sys_t*) malloc( sizeof( aout_sys_t ) );
if( p_aout->p_sys == NULL )
{
- intf_ErrMsg("error: %s", strerror(ENOMEM) );
+ msg_Err( p_aout, "out of memory" );
return( 1 );
}
if( p_aout->p_sys->p_format == NULL )
{
free( p_aout->p_sys );
- intf_ErrMsg("error: cannot allocate memory for gs_audio_format" );
+ msg_Err( p_aout, "out of memory" );
return( 1 );
}
/* Initialize some variables */
- p_aout->i_format = AOUT_FORMAT_DEFAULT;
- p_aout->i_channels = 1 + main_GetIntVariable( AOUT_STEREO_VAR,
- AOUT_STEREO_DEFAULT );
- p_aout->l_rate = main_GetIntVariable( AOUT_RATE_VAR, AOUT_RATE_DEFAULT );
-
p_aout->p_sys->p_format->frame_rate = 44100.0;
p_aout->p_sys->p_format->channel_count = p_aout->i_channels;
p_aout->p_sys->p_format->format = gs_audio_format::B_GS_S16;
p_aout->p_sys->p_format->buffer_size = 4*8192;
p_aout->p_sys->i_buffer_pos = 0;
+ p_aout->pf_setformat = SetFormat;
+ p_aout->pf_getbufinfo = GetBufInfo;
+ p_aout->pf_play = Play;
+
/* Allocate BPushGameSound */
p_aout->p_sys->p_sound = new BPushGameSound( 8192,
p_aout->p_sys->p_format,
{
free( p_aout->p_sys->p_format );
free( p_aout->p_sys );
- intf_ErrMsg("error: cannot allocate memory for BPushGameSound" );
+ msg_Err( p_aout, "cannot allocate BPushGameSound" );
return( 1 );
}
{
free( p_aout->p_sys->p_format );
free( p_aout->p_sys );
- intf_ErrMsg("error: cannot allocate memory for BPushGameSound" );
+ msg_Err( p_aout, "cannot initialize BPushGameSound" );
return( 1 );
}
}
/*****************************************************************************
- * aout_SetFormat: sets the dsp output format
+ * SetFormat: sets the dsp output format
*****************************************************************************/
-static int aout_SetFormat( aout_thread_t *p_aout )
+static int SetFormat( aout_thread_t *p_aout )
{
- p_aout->i_latency = 0;
-
return( 0 );
}
/*****************************************************************************
- * aout_GetBufInfo: buffer status query
+ * GetBufInfo: buffer status query
*****************************************************************************/
-static long aout_GetBufInfo( aout_thread_t *p_aout, long l_buffer_limit )
+static int GetBufInfo( aout_thread_t *p_aout, int i_buffer_limit )
{
/* Each value is 4 bytes long (stereo signed 16 bits) */
- long i_hard_pos = 4 * p_aout->p_sys->p_sound->CurrentPosition();
+ int i_hard_pos = 4 * p_aout->p_sys->p_sound->CurrentPosition();
i_hard_pos = p_aout->p_sys->i_buffer_pos - i_hard_pos;
if( i_hard_pos < 0 )
}
/*****************************************************************************
- * aout_Play: plays a sound samples buffer
+ * Play: plays a sound samples buffer
*****************************************************************************
* This function writes a buffer of i_length bytes in the dsp
*****************************************************************************/
-static void aout_Play( aout_thread_t *p_aout, byte_t *buffer, int i_size )
+static void Play( aout_thread_t *p_aout, byte_t *buffer, int i_size )
{
- long i_newbuf_pos;
+ int i_newbuf_pos;
if( (i_newbuf_pos = p_aout->p_sys->i_buffer_pos + i_size)
> p_aout->p_sys->i_buffer_size )
}
/*****************************************************************************
- * aout_Close: closes the dsp audio device
+ * CloseAudio: closes the dsp audio device
*****************************************************************************/
-static void aout_Close( aout_thread_t *p_aout )
-{
+void E_(CloseAudio) ( vlc_object_t *p_this )
+{
+ aout_thread_t * p_aout = (aout_thread_t *)p_this;
+
p_aout->p_sys->p_sound->UnlockCyclic();
p_aout->p_sys->p_sound->StopPlaying( );
delete p_aout->p_sys->p_sound;
free( p_aout->p_sys );
}
-} /* extern "C" */
-