Commit 2733b268 authored by Sam Hocevar's avatar Sam Hocevar

o changement de nom des fonctions sp�cifiques BeOS

 o d�but de l'�clatage de l'audio_output :
   . giclage des variables *dsp* en faveur de *sys*
   . aout_*GetBufInfo renvoie l_bytes pour que video_output.c ne d�pende
    plus de la structure audio_buf_info sp�cifique � <linux/soundcard.h>
   . cr�ation de la m�thode audio 'dummy' qui ne fait rien.
 o nouvelle option --aout acceptant 'dummy' et 'dsp' pour le moment
parent 8e016bb0
......@@ -60,7 +60,7 @@
#define AOUT_FIFO_ISFULL( fifo ) ( ((((fifo).l_end_frame + 1) - (fifo).l_start_frame) & AOUT_FIFO_SIZE) == 0 )
/*****************************************************************************
* aout_dsp_t
* aout_sys_t
*****************************************************************************/
typedef struct
{
......@@ -75,11 +75,11 @@ typedef struct
/* Rate of the audio output sound (in Hz) */
long l_rate;
/* Buffer information structure, used by aout_dspGetBufInfo() to store the
/* Buffer information structure, used by aout_sys_getbufinfo() to store the
* current state of the internal sound card buffer */
audio_buf_info buf_info;
} aout_dsp_t;
} aout_sys_t;
/*****************************************************************************
* aout_increment_t
......@@ -156,18 +156,38 @@ typedef struct
#define AOUT_ADEC_STEREO_FIFO 4
/*****************************************************************************
* aout_thread_t
* aout_thread_t : audio output thread descriptor
*****************************************************************************/
typedef int (aout_sys_open_t) ( aout_sys_t *p_sys );
typedef int (aout_sys_reset_t) ( aout_sys_t *p_sys );
typedef int (aout_sys_setformat_t) ( aout_sys_t *p_sys );
typedef int (aout_sys_setchannels_t) ( aout_sys_t *p_sys );
typedef int (aout_sys_setrate_t) ( aout_sys_t *p_sys );
typedef long (aout_sys_getbufinfo_t) ( aout_sys_t *p_sys );
typedef void (aout_sys_playsamples_t) ( aout_sys_t *p_sys,
byte_t *buffer, int i_size );
typedef void (aout_sys_close_t) ( aout_sys_t *p_sys );
typedef struct aout_thread_s
{
vlc_thread_t thread_id;
boolean_t b_die;
aout_dsp_t dsp;
aout_sys_t sys;
vlc_mutex_t fifos_lock;
aout_fifo_t fifo[ AOUT_MAX_FIFOS ];
/* method-dependant functions */
aout_sys_open_t * p_sys_open;
aout_sys_reset_t * p_sys_reset;
aout_sys_setformat_t * p_sys_setformat;
aout_sys_setchannels_t * p_sys_setchannels;
aout_sys_setrate_t * p_sys_setrate;
aout_sys_getbufinfo_t * p_sys_getbufinfo;
aout_sys_playsamples_t * p_sys_playsamples;
aout_sys_close_t * p_sys_close;
void * buffer;
/* The s32 buffer is used to mix all the audio fifos together before
* converting them and storing them in the audio output buffer */
......@@ -184,6 +204,15 @@ typedef struct aout_thread_s
} aout_thread_t;
/* Output methods */
#define AOUT_DUMMY_METHOD 0x0000 /* dummy video output */
#define AOUT_DSP_METHOD 0x0001 /* linux /dev/dsp */
/* Get the fallback method */
#ifdef AUDIO_DSP
#define AOUT_DEFAULT_METHOD "dsp"
#endif
/*****************************************************************************
* Prototypes
*****************************************************************************/
......
/*****************************************************************************
* audio_dsp.h : header of the dsp functions library
* audio_sys.h : header of the method-dependant functions library
* (c)1999 VideoLAN
*****************************************************************************
* Required headers:
......@@ -10,11 +10,21 @@
/*****************************************************************************
* Prototypes
*****************************************************************************/
int aout_dspOpen ( aout_dsp_t *p_dsp );
int aout_dspReset ( aout_dsp_t *p_dsp );
int aout_dspSetFormat ( aout_dsp_t *p_dsp );
int aout_dspSetChannels( aout_dsp_t *p_dsp );
int aout_dspSetRate ( aout_dsp_t *p_dsp );
void aout_dspGetBufInfo ( aout_dsp_t *p_dsp );
void aout_dspPlaySamples( aout_dsp_t *p_dsp, byte_t *buffer, int i_size );
void aout_dspClose ( aout_dsp_t *p_dsp );
int aout_DummySysOpen ( aout_sys_t *p_sys );
int aout_DummySysReset ( aout_sys_t *p_sys );
int aout_DummySysSetFormat ( aout_sys_t *p_sys );
int aout_DummySysSetChannels ( aout_sys_t *p_sys );
int aout_DummySysSetRate ( aout_sys_t *p_sys );
long aout_DummySysGetBufInfo ( aout_sys_t *p_sys );
void aout_DummySysPlaySamples ( aout_sys_t *p_sys, byte_t *buffer, int i_size );
void aout_DummySysClose ( aout_sys_t *p_sys );
#ifdef AUDIO_DSP
int aout_DspSysOpen ( aout_sys_t *p_sys );
int aout_DspSysReset ( aout_sys_t *p_sys );
int aout_DspSysSetFormat ( aout_sys_t *p_sys );
int aout_DspSysSetChannels ( aout_sys_t *p_sys );
int aout_DspSysSetRate ( aout_sys_t *p_sys );
long aout_DspSysGetBufInfo ( aout_sys_t *p_sys );
void aout_DspSysPlaySamples ( aout_sys_t *p_dsp, byte_t *buffer, int i_size );
void aout_DspSysClose ( aout_sys_t *p_sys );
#endif
......@@ -35,8 +35,8 @@ void intf_GGISysDestroy ( p_intf_thread_t p_intf );
void intf_GGISysManage ( p_intf_thread_t p_intf );
#endif
#ifdef VIDEO_BEOS
int intf_BeSysCreate ( p_intf_thread_t p_intf );
void intf_BeSysDestroy ( p_intf_thread_t p_intf );
void intf_BeSysManage ( p_intf_thread_t p_intf );
int intf_BSysCreate ( p_intf_thread_t p_intf );
void intf_BSysDestroy ( p_intf_thread_t p_intf );
void intf_BSysManage ( p_intf_thread_t p_intf );
#endif
......@@ -53,11 +53,11 @@ int vout_GGISysManage ( p_vout_thread_t p_vout );
void vout_GGISysDisplay ( p_vout_thread_t p_vout );
#endif
#ifdef VIDEO_BEOS
int vout_BeSysCreate ( p_vout_thread_t p_vout, char *psz_display, int i_root_window );
int vout_BeSysInit ( p_vout_thread_t p_vout );
void vout_BeSysEnd ( p_vout_thread_t p_vout );
void vout_BeSysDestroy ( p_vout_thread_t p_vout );
int vout_BeSysManage ( p_vout_thread_t p_vout );
void vout_BeSysDisplay ( p_vout_thread_t p_vout );
int vout_BSysCreate ( p_vout_thread_t p_vout, char *psz_display, int i_root_window );
int vout_BSysInit ( p_vout_thread_t p_vout );
void vout_BSysEnd ( p_vout_thread_t p_vout );
void vout_BSysDestroy ( p_vout_thread_t p_vout );
int vout_BSysManage ( p_vout_thread_t p_vout );
void vout_BSysDisplay ( p_vout_thread_t p_vout );
#endif
/*****************************************************************************
* audio_dsp.c : dsp functions library
* (c)1999 VideoLAN
*****************************************************************************/
/* TODO:
*
* - an aout_dspGetFormats() function
* - dsp inline/static
* - make this library portable (see mpg123)
* - macroify aout_dspPlaySamples &/| aout_dspGetBufInfo ?
*
*/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <fcntl.h> /* open(), O_WRONLY */
#include <sys/ioctl.h> /* ioctl() */
#include <unistd.h> /* write(), close() */
/* SNDCTL_DSP_RESET, SNDCTL_DSP_SETFMT, SNDCTL_DSP_STEREO, SNDCTL_DSP_SPEED, SNDCTL_DSP_GETOSPACE */
#include <sys/soundcard.h>
#include "common.h" /* boolean_t, byte_t */
#include "mtime.h"
#include "vlc_thread.h"
#include "audio_output.h" /* aout_dsp_t */
#include "audio_dsp.h"
#include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
/*****************************************************************************
* aout_dspOpen: opens the audio device (the digital sound processor)
*****************************************************************************
* - This function opens the dsp as an usual non-blocking write-only file, and
* modifies the p_dsp->i_fd with the file's descriptor.
* - p_dsp->psz_device must be set before calling this function !
*****************************************************************************/
int aout_dspOpen( aout_dsp_t *p_dsp )
{
if ( (p_dsp->i_fd = open( p_dsp->psz_device, O_WRONLY )) < 0 )
{
intf_ErrMsg( "aout error: can't open audio device (%s)\n", p_dsp->psz_device );
return( -1 );
}
return( 0 );
}
/*****************************************************************************
* aout_dspReset: resets the dsp
*****************************************************************************/
int aout_dspReset( aout_dsp_t *p_dsp )
{
if ( ioctl( p_dsp->i_fd, SNDCTL_DSP_RESET, NULL ) < 0 )
{
intf_ErrMsg( "aout error: can't reset audio device (%s)\n", p_dsp->psz_device );
return( -1 );
}
return( 0 );
}
/*****************************************************************************
* aout_dspSetFormat: sets the dsp output format
*****************************************************************************
* This functions tries to initialize the dsp output format with the value
* contained in the dsp structure, and if this value could not be set, the
* default value returned by ioctl is set.
*****************************************************************************/
int aout_dspSetFormat( aout_dsp_t *p_dsp )
{
int i_format;
i_format = p_dsp->i_format;
if ( ioctl( p_dsp->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 )
{
intf_ErrMsg( "aout error: can't set audio output format (%i)\n", p_dsp->i_format );
return( -1 );
}
if ( i_format != p_dsp->i_format )
{
intf_DbgMsg( "aout debug: audio output format not supported (%i)\n", p_dsp->i_format );
p_dsp->i_format = i_format;
}
return( 0 );
}
/*****************************************************************************
* aout_dspSetChannels: sets the dsp's stereo or mono mode
*****************************************************************************
* This function acts just like the previous one...
*****************************************************************************/
int aout_dspSetChannels( aout_dsp_t *p_dsp )
{
boolean_t b_stereo;
b_stereo = p_dsp->b_stereo;
if ( ioctl( p_dsp->i_fd, SNDCTL_DSP_STEREO, &b_stereo ) < 0 )
{
intf_ErrMsg( "aout error: can't set number of audio channels (%i)\n", p_dsp->b_stereo );
return( -1 );
}
if ( b_stereo != p_dsp->b_stereo )
{
intf_DbgMsg( "aout debug: number of audio channels not supported (%i)\n", p_dsp->b_stereo );
p_dsp->b_stereo = b_stereo;
}
return( 0 );
}
/*****************************************************************************
* aout_dspSetRate: sets the dsp's audio output rate
*****************************************************************************
* This function tries to initialize the dsp with the rate contained in the
* dsp structure, but if the dsp doesn't support this value, the function uses
* the value returned by ioctl...
*****************************************************************************/
int aout_dspSetRate( aout_dsp_t *p_dsp )
{
long l_rate;
l_rate = p_dsp->l_rate;
if ( ioctl( p_dsp->i_fd, SNDCTL_DSP_SPEED, &l_rate ) < 0 )
{
intf_ErrMsg( "aout error: can't set audio output rate (%li)\n", p_dsp->l_rate );
return( -1 );
}
if ( l_rate != p_dsp->l_rate )
{
intf_DbgMsg( "aout debug: audio output rate not supported (%li)\n", p_dsp->l_rate );
p_dsp->l_rate = l_rate;
}
return( 0 );
}
/*****************************************************************************
* aout_dspGetBufInfo: buffer status query
*****************************************************************************
* This function fills in the audio_buf_info structure :
* - int fragments : number of available fragments (partially usend ones not
* counted)
* - int fragstotal : total number of fragments allocated
* - int fragsize : size of a fragment in bytes
* - int bytes : available space in bytes (includes partially used fragments)
* Note! 'bytes' could be more than fragments*fragsize
*****************************************************************************/
void aout_dspGetBufInfo( aout_dsp_t *p_dsp )
{
ioctl( p_dsp->i_fd, SNDCTL_DSP_GETOSPACE, &p_dsp->buf_info );
}
/*****************************************************************************
* aout_dspPlaySamples: plays a sound samples buffer
*****************************************************************************
* This function writes a buffer of i_length bytes in the dsp
*****************************************************************************/
void aout_dspPlaySamples( aout_dsp_t *p_dsp, byte_t *buffer, int i_size )
{
write( p_dsp->i_fd, buffer, i_size );
}
/*****************************************************************************
* aout_dspClose: closes the dsp audio device
*****************************************************************************/
void aout_dspClose( aout_dsp_t *p_dsp )
{
close( p_dsp->i_fd );
}
This diff is collapsed.
......@@ -130,14 +130,14 @@ intf_thread_t* intf_Create( void )
#ifdef VIDEO_BEOS
else if( !strcmp(psz_method, "beos") )
{
p_intf->p_sys_create = intf_BeSysCreate;
p_intf->p_sys_manage = intf_BeSysManage;
p_intf->p_sys_destroy = intf_BeSysDestroy;
p_intf->p_sys_create = intf_BSysCreate;
p_intf->p_sys_manage = intf_BSysManage;
p_intf->p_sys_destroy = intf_BSysDestroy;
}
#endif
else
{
intf_ErrMsg( "error: video output method not available\n" );
intf_ErrMsg( "error: requested video output method not available\n" );
free( p_intf );
return( NULL );
}
......
......@@ -26,47 +26,6 @@
*****************************************************************************/
#include "vlc.h"
#include <sys/stat.h>
/*??#include <errno.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/soundcard.h>
#include <sys/uio.h>
#include "config.h"
#include "common.h"
#include "mtime.h"
#include "vlc_thread.h"
#include "debug.h"
#include "intf_msg.h"
#include "input.h"
#include "input_ctrl.h"
#include "input_vlan.h"
#include "input_psi.h"
#include "input_netlist.h"
#include "decoder_fifo.h"
#include "audio_output.h"
#include "audio_decoder.h"
#include "video.h"
#include "video_output.h"
#include "video_graphics.h"
#include "video_decoder.h"
#include "xconsole.h"
#include "interface.h"
#include "intf_cmd.h"
#include "control.h"
#include "intf_ctrl.h"
#include "pgm_data.h"
*/
/*
* Local prototypes
......@@ -383,7 +342,7 @@ static int PlayAudio( int i_argc, intf_arg_t *p_argv )
close( i_fd );
/* Now we can work out how many output units we can compute with the fifo */
fifo.l_units = (long)(((s64)fifo.l_units*(s64)p_main->p_aout->dsp.l_rate)/(s64)fifo.l_rate);
fifo.l_units = (long)(((s64)fifo.l_units*(s64)p_main->p_aout->sys.l_rate)/(s64)fifo.l_rate);
/* Create the fifo */
if ( aout_CreateFifo(p_main->p_aout, &fifo) == NULL )
......
......@@ -144,12 +144,12 @@ vout_thread_t * vout_CreateThread ( char *psz_display, int i_root_window,
#endif
#ifdef VIDEO_BEOS
case VOUT_BEOS_METHOD:
p_vout->p_sys_create = vout_BeSysCreate;
p_vout->p_sys_init = vout_BeSysInit;
p_vout->p_sys_end = vout_BeSysEnd;
p_vout->p_sys_destroy = vout_BeSysDestroy;
p_vout->p_sys_manage = vout_BeSysManage;
p_vout->p_sys_display = vout_BeSysDisplay;
p_vout->p_sys_create = vout_BSysCreate;
p_vout->p_sys_init = vout_BSysInit;
p_vout->p_sys_end = vout_BSysEnd;
p_vout->p_sys_destroy = vout_BSysDestroy;
p_vout->p_sys_manage = vout_BSysManage;
p_vout->p_sys_display = vout_BSysDisplay;
break;
#endif
default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment