X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Faudio_output%2Faudio_output.c;h=de60d0348bba8bd9054f7eee3920383b2aa97534;hb=0a4aeaa67cae0699195b135dcc65ce5b0ee5fdc4;hp=b616989bbd3fa6cdada1906a128d3cb465045b6c;hpb=1b79957cebd97494e3ae83cae81be93fd9d3a063;p=vlc diff --git a/src/audio_output/audio_output.c b/src/audio_output/audio_output.c index b616989bbd..de60d0348b 100644 --- a/src/audio_output/audio_output.c +++ b/src/audio_output/audio_output.c @@ -1,9 +1,10 @@ /***************************************************************************** * audio_output.c : audio output thread ***************************************************************************** - * Copyright (C) 1999, 2000 VideoLAN + * Copyright (C) 1999, 2000, 2001 VideoLAN + * $Id: audio_output.c,v 1.57 2001/04/28 03:36:25 sam Exp $ * - * Authors: + * Authors: Michel Kaempf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -38,6 +39,9 @@ #include "defs.h" #include /* getpid() */ +#ifdef WIN32 /* getpid() for win32 is located in process.h */ +#include +#endif #include /* "intf_msg.h" */ #include /* calloc(), malloc(), free() */ @@ -46,43 +50,28 @@ #include "common.h" #include "threads.h" #include "mtime.h" /* mtime_t, mdate(), msleep() */ -#include "plugins.h" +#include "modules.h" #include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */ #include "audio_output.h" +#include "aout_common.h" + #include "main.h" /***************************************************************************** * Local prototypes *****************************************************************************/ - static int aout_SpawnThread( aout_thread_t * p_aout ); -/* Creating as much aout_Thread functions as configurations is one solution, - * examining the different cases in the Thread loop of an unique function is - * another. I chose the first solution. */ -void aout_Thread_S8_Mono ( aout_thread_t * p_aout ); -void aout_Thread_U8_Mono ( aout_thread_t * p_aout ); -void aout_Thread_S16_Mono ( aout_thread_t * p_aout ); -void aout_Thread_U16_Mono ( aout_thread_t * p_aout ); -void aout_Thread_S8_Stereo ( aout_thread_t * p_aout ); -void aout_Thread_U8_Stereo ( aout_thread_t * p_aout ); -void aout_Thread_S16_Stereo ( aout_thread_t * p_aout ); -void aout_Thread_U16_Stereo ( aout_thread_t * p_aout ); - -static __inline__ void InitializeIncrement( aout_increment_t * p_increment, long l_numerator, long l_denominator ); -static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, mtime_t aout_date ); - /***************************************************************************** * aout_CreateThread: initialize audio thread *****************************************************************************/ aout_thread_t *aout_CreateThread( int *pi_status ) { aout_thread_t * p_aout; /* thread descriptor */ - char * psz_method; #if 0 - int i_status; /* thread status */ + int i_status; /* thread status */ #endif /* Allocate descriptor */ @@ -92,78 +81,65 @@ aout_thread_t *aout_CreateThread( int *pi_status ) return( NULL ); } - /* Request an interface plugin */ - psz_method = main_GetPszVariable( AOUT_METHOD_VAR, AOUT_DEFAULT_METHOD ); - - if( RequestPlugin( &p_aout->aout_plugin, "aout", psz_method ) ) + /* Choose the best module */ + p_aout->p_module = module_Need( p_main->p_bank, + MODULE_CAPABILITY_AOUT, NULL ); + + if( p_aout->p_module == NULL ) { - intf_ErrMsg( "error: could not open audio plugin aout_%s.so\n", psz_method ); + intf_ErrMsg( "aout error: no suitable aout module" ); free( p_aout ); return( NULL ); } - /* Get plugins */ - p_aout->p_sys_open = GetPluginFunction( p_aout->aout_plugin, "aout_SysOpen" ); - p_aout->p_sys_reset = GetPluginFunction( p_aout->aout_plugin, "aout_SysReset" ); - p_aout->p_sys_setformat = GetPluginFunction( p_aout->aout_plugin, "aout_SysSetFormat" ); - p_aout->p_sys_setchannels = GetPluginFunction( p_aout->aout_plugin, "aout_SysSetChannels" ); - p_aout->p_sys_setrate = GetPluginFunction( p_aout->aout_plugin, "aout_SysSetRate" ); - p_aout->p_sys_getbufinfo = GetPluginFunction( p_aout->aout_plugin, "aout_SysGetBufInfo" ); - p_aout->p_sys_playsamples = GetPluginFunction( p_aout->aout_plugin, "aout_SysPlaySamples" ); - p_aout->p_sys_close = GetPluginFunction( p_aout->aout_plugin, "aout_SysClose" ); +#define aout_functions p_aout->p_module->p_functions->aout.functions.aout + p_aout->pf_open = aout_functions.pf_open; + p_aout->pf_setformat = aout_functions.pf_setformat; + p_aout->pf_getbufinfo = aout_functions.pf_getbufinfo; + p_aout->pf_play = aout_functions.pf_play; + p_aout->pf_close = aout_functions.pf_close; +#undef aout_functions /* * Initialize audio device */ - if ( p_aout->p_sys_open( p_aout ) ) + if ( p_aout->pf_open( p_aout ) ) { - TrashPlugin( p_aout->aout_plugin ); + module_Unneed( p_main->p_bank, p_aout->p_module ); free( p_aout ); return( NULL ); } - p_aout->b_stereo = ( p_aout->i_channels == 2 ) ? 1 : 0; /* FIXME: only works - for i_channels == 1 or 2 ??*/ - - if ( p_aout->p_sys_reset( p_aout ) ) - { - p_aout->p_sys_close( p_aout ); - TrashPlugin( p_aout->aout_plugin ); - free( p_aout ); - return( NULL ); - } - if ( p_aout->p_sys_setformat( p_aout ) ) + if( p_aout->l_rate == 0 ) { - p_aout->p_sys_close( p_aout ); - TrashPlugin( p_aout->aout_plugin ); + intf_ErrMsg( "aout error: null sample rate" ); + p_aout->pf_close( p_aout ); + module_Unneed( p_main->p_bank, p_aout->p_module ); free( p_aout ); return( NULL ); } - if ( p_aout->p_sys_setchannels( p_aout ) ) - { - p_aout->p_sys_close( p_aout ); - TrashPlugin( p_aout->aout_plugin ); - free( p_aout ); - return( NULL ); - } - if ( p_aout->p_sys_setrate( p_aout ) ) + + /* FIXME: only works for i_channels == 1 or 2 ?? */ + p_aout->b_stereo = ( p_aout->i_channels == 2 ) ? 1 : 0; + + if ( p_aout->pf_setformat( p_aout ) ) { - p_aout->p_sys_close( p_aout ); - TrashPlugin( p_aout->aout_plugin ); + p_aout->pf_close( p_aout ); + module_Unneed( p_main->p_bank, p_aout->p_module ); free( p_aout ); return( NULL ); } - /* Initialize the vomue level */ - p_aout->vol = VOL; + /* Initialize the volume level */ + p_aout->vol = VOLUME_DEFAULT; /* FIXME: maybe it would be cleaner to change SpawnThread prototype * see vout to handle status correctly ?? however, it is not critical since * this thread is only called in main and all calls are blocking */ if( aout_SpawnThread( p_aout ) ) { - p_aout->p_sys_close( p_aout ); - TrashPlugin( p_aout->aout_plugin ); + p_aout->pf_close( p_aout ); + module_Unneed( p_main->p_bank, p_aout->p_module ); free( p_aout ); return( NULL ); } @@ -180,8 +156,6 @@ static int aout_SpawnThread( aout_thread_t * p_aout ) long l_bytes; void * aout_thread = NULL; - intf_DbgMsg("aout debug: spawning audio output thread (%p)\n", p_aout); - /* We want the audio output thread to live */ p_aout->b_die = 0; p_aout->b_active = 1; @@ -206,106 +180,118 @@ static int aout_SpawnThread( aout_thread_t * p_aout ) * byte size of the audio output buffer */ switch ( p_aout->i_channels ) { - /* Audio output is mono */ - case 1: - switch ( p_aout->i_format ) - { - case AOUT_FMT_U8: - l_bytes = 1 * sizeof(u8) * p_aout->l_units; - aout_thread = (void *)aout_Thread_U8_Mono; - break; - - case AOUT_FMT_S8: - l_bytes = 1 * sizeof(s8) * p_aout->l_units; - aout_thread = (void *)aout_Thread_S8_Mono; - break; + /* Audio output is mono */ + case 1: + switch ( p_aout->i_format ) + { + case AOUT_FMT_U8: + intf_WarnMsg( 2, "aout info: unsigned 8 bits mono thread" ); + l_bytes = 1 * sizeof(u8) * p_aout->l_units; + aout_thread = (void *)aout_U8MonoThread; + break; - case AOUT_FMT_U16_LE: - case AOUT_FMT_U16_BE: - l_bytes = 1 * sizeof(u16) * p_aout->l_units; - aout_thread = (void *)aout_Thread_U16_Mono; - break; + case AOUT_FMT_S8: + intf_WarnMsg( 2, "aout info: signed 8 bits mono thread" ); + l_bytes = 1 * sizeof(s8) * p_aout->l_units; + aout_thread = (void *)aout_S8MonoThread; + break; - case AOUT_FMT_S16_LE: - case AOUT_FMT_S16_BE: - l_bytes = 1 * sizeof(s16) * p_aout->l_units; - aout_thread = (void *)aout_Thread_S16_Mono; - break; + case AOUT_FMT_U16_LE: + case AOUT_FMT_U16_BE: + intf_WarnMsg( 2, "aout info: unsigned 16 bits mono thread" ); + l_bytes = 1 * sizeof(u16) * p_aout->l_units; + aout_thread = (void *)aout_U16MonoThread; + break; - default: - intf_ErrMsg( "aout error: unknown audio output format (%i)\n", - p_aout->i_format ); - return( -1 ); - } + case AOUT_FMT_S16_LE: + case AOUT_FMT_S16_BE: + intf_WarnMsg( 2, "aout info: signed 16 bits mono thread" ); + l_bytes = 1 * sizeof(s16) * p_aout->l_units; + aout_thread = (void *)aout_S16MonoThread; break; - /* Audio output is stereo */ - case 2: - switch ( p_aout->i_format ) - { - case AOUT_FMT_U8: - l_bytes = 2 * sizeof(u8) * p_aout->l_units; - aout_thread = (void *)aout_Thread_U8_Stereo; - break; + default: + intf_ErrMsg( "aout error: unknown audio output format (%i)", + p_aout->i_format ); + return( -1 ); + } + break; - case AOUT_FMT_S8: - l_bytes = 2 * sizeof(s8) * p_aout->l_units; - aout_thread = (void *)aout_Thread_S8_Stereo; - break; + /* Audio output is stereo */ + case 2: + switch ( p_aout->i_format ) + { + case AOUT_FMT_U8: + intf_WarnMsg( 2, "aout info: unsigned 8 bits stereo thread" ); + l_bytes = 2 * sizeof(u8) * p_aout->l_units; + aout_thread = (void *)aout_U8StereoThread; + break; - case AOUT_FMT_U16_LE: - case AOUT_FMT_U16_BE: - l_bytes = 2 * sizeof(u16) * p_aout->l_units; - aout_thread = (void *)aout_Thread_U16_Stereo; - break; + case AOUT_FMT_S8: + intf_WarnMsg( 2, "aout info: signed 8 bits stereo thread" ); + l_bytes = 2 * sizeof(s8) * p_aout->l_units; + aout_thread = (void *)aout_S8StereoThread; + break; - case AOUT_FMT_S16_LE: - case AOUT_FMT_S16_BE: - l_bytes = 2 * sizeof(s16) * p_aout->l_units; - aout_thread = (void *)aout_Thread_S16_Stereo; - break; + case AOUT_FMT_U16_LE: + case AOUT_FMT_U16_BE: + intf_WarnMsg( 2, "aout info: unsigned 16 bits stereo thread" ); + l_bytes = 2 * sizeof(u16) * p_aout->l_units; + aout_thread = (void *)aout_U16StereoThread; + break; - default: - intf_ErrMsg("aout error: unknown audio output format (%i)\n", - p_aout->i_format); - return( -1 ); - } + case AOUT_FMT_S16_LE: + case AOUT_FMT_S16_BE: + intf_WarnMsg( 2, "aout info: signed 16 bits stereo thread" ); + l_bytes = 2 * sizeof(s16) * p_aout->l_units; + aout_thread = (void *)aout_S16StereoThread; break; default: - intf_ErrMsg("aout error: unknown number of audio channels (%i)\n", - p_aout->i_channels ); + intf_ErrMsg( "aout error: unknown audio output format %i", + p_aout->i_format ); return( -1 ); + } + break; + + default: + intf_ErrMsg( "aout error: unknown number of audio channels (%i)", + p_aout->i_channels ); + return( -1 ); } /* Allocate the memory needed by the audio output buffers, and set to zero * the s32 buffer's memory */ - if ( (p_aout->buffer = malloc(l_bytes)) == NULL ) + p_aout->buffer = malloc( l_bytes ); + if ( p_aout->buffer == NULL ) { - intf_ErrMsg("aout error: not enough memory to create the output buffer\n"); + intf_ErrMsg( "aout error: cannot create output buffer" ); return( -1 ); } - if ( (p_aout->s32_buffer = (s32 *)calloc(p_aout->l_units, sizeof(s32) << ( p_aout->b_stereo))) == NULL ) + + p_aout->s32_buffer = (s32 *)calloc( p_aout->l_units, + sizeof(s32) << ( p_aout->b_stereo ) ); + if ( p_aout->s32_buffer == NULL ) { - intf_ErrMsg("aout error: not enough memory to create the s32 output buffer\n"); + intf_ErrMsg( "aout error: cannot create the s32 output buffer" ); free( p_aout->buffer ); return( -1 ); } - /* Before launching the thread, we try to predict the date of the first - * audio unit in the first output buffer */ - p_aout->date = mdate() - 1000000; + /* Rough estimate of the playing date */ + p_aout->date = mdate(); /* Launch the thread */ - if ( vlc_thread_create( &p_aout->thread_id, "audio output", (vlc_thread_func_t)aout_thread, p_aout ) ) + if ( vlc_thread_create( &p_aout->thread_id, "audio output", + (vlc_thread_func_t)aout_thread, p_aout ) ) { - intf_ErrMsg("aout error: can't spawn audio output thread (%p)\n", p_aout); + intf_ErrMsg( "aout error: cannot spawn audio output thread" ); free( p_aout->buffer ); free( p_aout->s32_buffer ); return( -1 ); } - intf_DbgMsg("aout debug: audio output thread (%p) spawned\n", p_aout); + intf_WarnMsg( 2, "aout info: audio output thread %i spawned", getpid() ); return( 0 ); } @@ -314,9 +300,10 @@ static int aout_SpawnThread( aout_thread_t * p_aout ) *****************************************************************************/ void aout_DestroyThread( aout_thread_t * p_aout, int *pi_status ) { - /* FIXME: pi_status is not handled correctly: check vout how to do!?? */ - intf_DbgMsg("aout debug: requesting termination of audio output thread (%p)\n", p_aout); + int i_fifo; + + /* FIXME: pi_status is not handled correctly: check vout how to do!?? */ /* Ask thread to kill itself and wait until it's done */ p_aout->b_die = 1; @@ -326,1199 +313,21 @@ void aout_DestroyThread( aout_thread_t * p_aout, int *pi_status ) free( p_aout->buffer ); free( p_aout->s32_buffer ); - /* Free the structure */ - p_aout->p_sys_close( p_aout ); - intf_DbgMsg("aout debug: audio device (%s) closed\n", p_aout->psz_device); - - /* Close plugin */ - TrashPlugin( p_aout->aout_plugin ); - - /* Free structure */ - free( p_aout ); -} - -/***************************************************************************** - * aout_CreateFifo - *****************************************************************************/ -aout_fifo_t * aout_CreateFifo( aout_thread_t * p_aout, aout_fifo_t * p_fifo ) -{ - int i_fifo; - - /* Take the fifos lock */ - vlc_mutex_lock( &p_aout->fifos_lock ); - - /* Looking for a free fifo structure */ - for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ ) - { - if ( p_aout->fifo[i_fifo].i_type == AOUT_EMPTY_FIFO) - { - break; - } - } - if ( i_fifo == AOUT_MAX_FIFOS ) - { - intf_ErrMsg("aout error: no empty fifo available\n"); - vlc_mutex_unlock( &p_aout->fifos_lock ); - return( NULL ); - } - - /* Initialize the new fifo structure */ - switch ( p_aout->fifo[i_fifo].i_type = p_fifo->i_type ) - { - case AOUT_INTF_MONO_FIFO: - case AOUT_INTF_STEREO_FIFO: - p_aout->fifo[i_fifo].b_die = 0; - - p_aout->fifo[i_fifo].i_channels = p_fifo->i_channels; - p_aout->fifo[i_fifo].b_stereo = p_fifo->b_stereo; - p_aout->fifo[i_fifo].l_rate = p_fifo->l_rate; - - p_aout->fifo[i_fifo].buffer = p_fifo->buffer; - - p_aout->fifo[i_fifo].l_unit = 0; - InitializeIncrement( &p_aout->fifo[i_fifo].unit_increment, p_fifo->l_rate, p_aout->l_rate ); - p_aout->fifo[i_fifo].l_units = p_fifo->l_units; - break; - - case AOUT_ADEC_MONO_FIFO: - case AOUT_ADEC_STEREO_FIFO: - p_aout->fifo[i_fifo].b_die = 0; - - p_aout->fifo[i_fifo].i_channels = p_fifo->i_channels; - p_aout->fifo[i_fifo].b_stereo = p_fifo->b_stereo; - p_aout->fifo[i_fifo].l_rate = p_fifo->l_rate; - - p_aout->fifo[i_fifo].l_frame_size = p_fifo->l_frame_size; - /* Allocate the memory needed to store the audio frames. As the - * fifo is a rotative fifo, we must be able to find out whether the - * fifo is full or empty, that's why we must in fact allocate memory - * for (AOUT_FIFO_SIZE+1) audio frames. */ - if ( (p_aout->fifo[i_fifo].buffer = malloc( sizeof(s16)*(AOUT_FIFO_SIZE+1)*p_fifo->l_frame_size )) == NULL ) - { - intf_ErrMsg("aout error: not enough memory to create the frames buffer\n"); - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; - vlc_mutex_unlock( &p_aout->fifos_lock ); - return( NULL ); - } - - /* Allocate the memory needed to store the dates of the frames */ - if ( (p_aout->fifo[i_fifo].date = (mtime_t *)malloc( sizeof(mtime_t)*(AOUT_FIFO_SIZE+1) )) == NULL ) - { - intf_ErrMsg("aout error: not enough memory to create the dates buffer\n"); - free( p_aout->fifo[i_fifo].buffer ); - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; - vlc_mutex_unlock( &p_aout->fifos_lock ); - return( NULL ); - } - - /* Set the fifo's buffer as empty (the first frame that is to be - * played is also the first frame that is not to be played) */ - p_aout->fifo[i_fifo].l_start_frame = 0; - /* p_aout->fifo[i_fifo].l_next_frame = 0; */ - p_aout->fifo[i_fifo].l_end_frame = 0; - - /* Waiting for the audio decoder to compute enough frames to work - * out the fifo's current rate (as soon as the decoder has decoded - * enough frames, the members of the fifo structure that are not - * initialized now will be calculated) */ - p_aout->fifo[i_fifo].b_start_frame = 0; - p_aout->fifo[i_fifo].b_next_frame = 0; - break; - - default: - intf_ErrMsg("aout error: unknown fifo type (%i)\n", p_aout->fifo[i_fifo].i_type); - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; - vlc_mutex_unlock( &p_aout->fifos_lock ); - return( NULL ); - } - - /* Release the fifos lock */ - vlc_mutex_unlock( &p_aout->fifos_lock ); - - /* Return the pointer to the fifo structure */ - intf_DbgMsg("aout debug: audio output fifo (%p) allocated\n", &p_aout->fifo[i_fifo]); - return( &p_aout->fifo[i_fifo] ); -} - -/***************************************************************************** - * aout_DestroyFifo - *****************************************************************************/ -void aout_DestroyFifo( aout_fifo_t * p_fifo ) -{ - intf_DbgMsg("aout debug: requesting destruction of audio output fifo (%p)\n", p_fifo); - p_fifo->b_die = 1; -} - -/* Here are the local macros */ - -#define UPDATE_INCREMENT( increment, integer ) \ - if ( ((increment).l_remainder += (increment).l_euclidean_remainder) >= 0 )\ - { \ - (integer) += (increment).l_euclidean_integer + 1; \ - (increment).l_remainder -= (increment).l_euclidean_denominator; \ - } \ - else \ - { \ - (integer) += (increment).l_euclidean_integer; \ - } - -/* Following functions are local */ - -/***************************************************************************** - * InitializeIncrement - *****************************************************************************/ -static __inline__ void InitializeIncrement( aout_increment_t * p_increment, long l_numerator, long l_denominator ) -{ - p_increment->l_remainder = -l_denominator; - - p_increment->l_euclidean_integer = 0; - while ( l_numerator >= l_denominator ) - { - p_increment->l_euclidean_integer++; - l_numerator -= l_denominator; - } - - p_increment->l_euclidean_remainder = l_numerator; - - p_increment->l_euclidean_denominator = l_denominator; -} - -/***************************************************************************** - * NextFrame - *****************************************************************************/ -static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, mtime_t aout_date ) -{ - long l_units, l_rate; - - /* We take the lock */ - vlc_mutex_lock( &p_fifo->data_lock ); - - /* Are we looking for a dated start frame ? */ - if ( !p_fifo->b_start_frame ) - { - while ( p_fifo->l_start_frame != p_fifo->l_end_frame ) - { - if ( p_fifo->date[p_fifo->l_start_frame] != LAST_MDATE ) - { - p_fifo->b_start_frame = 1; - p_fifo->l_next_frame = (p_fifo->l_start_frame + 1) & AOUT_FIFO_SIZE; - p_fifo->l_unit = p_fifo->l_start_frame * (p_fifo->l_frame_size >> (p_fifo->b_stereo)); - break; - } - p_fifo->l_start_frame = (p_fifo->l_start_frame + 1) & AOUT_FIFO_SIZE; - } - - if ( p_fifo->l_start_frame == p_fifo->l_end_frame ) - { - vlc_mutex_unlock( &p_fifo->data_lock ); - return( -1 ); - } - } - - /* We are looking for the next dated frame */ - /* FIXME : is the output fifo full ?? */ - while ( !p_fifo->b_next_frame ) - { - while ( p_fifo->l_next_frame != p_fifo->l_end_frame ) - { - if ( p_fifo->date[p_fifo->l_next_frame] != LAST_MDATE ) - { - p_fifo->b_next_frame = 1; - break; - } - p_fifo->l_next_frame = (p_fifo->l_next_frame + 1) & AOUT_FIFO_SIZE; - } - - while ( p_fifo->l_next_frame == p_fifo->l_end_frame ) - { - vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock ); - if ( p_fifo->b_die ) - { - vlc_mutex_unlock( &p_fifo->data_lock ); - return( -1 ); - } - } - } - - l_units = ((p_fifo->l_next_frame - p_fifo->l_start_frame) & AOUT_FIFO_SIZE) * (p_fifo->l_frame_size >> (p_fifo->b_stereo)); - - l_rate = p_fifo->l_rate + ((aout_date - p_fifo->date[p_fifo->l_start_frame]) / 256); -// intf_DbgMsg( "aout debug: %lli (%li);\n", aout_date - p_fifo->date[p_fifo->l_start_frame], l_rate ); - - InitializeIncrement( &p_fifo->unit_increment, l_rate, p_aout->l_rate ); - - p_fifo->l_units = (((l_units - (p_fifo->l_unit - - (p_fifo->l_start_frame * (p_fifo->l_frame_size >> (p_fifo->b_stereo))))) - * p_aout->l_rate) / l_rate) + 1; - - /* We release the lock before leaving */ - vlc_mutex_unlock( &p_fifo->data_lock ); - return( 0 ); -} - -void aout_Thread_S8_Mono( aout_thread_t * p_aout ) -{ -} - -void aout_Thread_S8_Stereo( aout_thread_t * p_aout ) -{ -} - -void aout_Thread_U8_Mono( aout_thread_t * p_aout ) -{ - int i_fifo; - long l_buffer, l_buffer_limit; - long l_units, l_bytes; - - intf_DbgMsg("adec debug: ********aout_Thread_U8_Mono********\n"); - intf_DbgMsg("adec debug: running audio output thread (%p) (pid == %i)\n", p_aout, getpid()); - - /* As the s32_buffer was created with calloc(), we don't have to set this - * memory to zero and we can immediately jump into the thread's loop */ - while ( !p_aout->b_die ) - { - vlc_mutex_lock( &p_aout->fifos_lock ); - for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ ) - { - switch ( p_aout->fifo[i_fifo].i_type ) - { - case AOUT_EMPTY_FIFO: - break; - - case AOUT_INTF_MONO_FIFO: - if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units ) - { - l_buffer = 0; - while ( l_buffer < (p_aout->l_units /*<< 1*/) ) /* p_aout->b_stereo == 1 */ - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - } - p_aout->fifo[i_fifo].l_units -= p_aout->l_units; - } - else - { - l_buffer = 0; - while ( l_buffer < (p_aout->fifo[i_fifo].l_units /*<< 1*/) ) /* p_aout->b_stereo == 1 */ - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - } - free( p_aout->fifo[i_fifo].buffer ); /* !! */ - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */ - intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); /* !! */ - } - break; - - case AOUT_INTF_STEREO_FIFO: - if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units ) - { - l_buffer = 0; - while ( l_buffer < (p_aout->l_units /*<< 1*/) ) /* p_aout->b_stereo == 1 */ - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] ); - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - } - p_aout->fifo[i_fifo].l_units -= p_aout->l_units; - } - else - { - l_buffer = 0; - while ( l_buffer < (p_aout->fifo[i_fifo].l_units /*<< 1*/) ) /* p_aout->b_stereo == 1 */ - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] ); - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - } - free( p_aout->fifo[i_fifo].buffer ); /* !! */ - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */ - intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); /* !! */ - } - break; - - case AOUT_ADEC_MONO_FIFO: - if ( p_aout->fifo[i_fifo].b_die ) - { - free( p_aout->fifo[i_fifo].buffer ); - free( p_aout->fifo[i_fifo].date ); - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */ - intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); - continue; - } - - l_units = p_aout->l_units; - l_buffer = 0; - while ( l_units > 0 ) - { - if ( !p_aout->fifo[i_fifo].b_next_frame ) - { - if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) ) - { - break; - } - } - - if ( p_aout->fifo[i_fifo].l_units > l_units ) - { - l_buffer_limit = p_aout->l_units /*<< 1*/; /* p_aout->b_stereo == 1 */ - while ( l_buffer < l_buffer_limit ) - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) ) - { - p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)); - } - } - p_aout->fifo[i_fifo].l_units -= l_units; - break; - } - else - { - l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1); - /* p_aout->b_stereo == 1 */ - while ( l_buffer < l_buffer_limit ) - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) ) - { - p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)); - } - } - l_units -= p_aout->fifo[i_fifo].l_units; - - vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock ); - p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame; - vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait ); - vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock ); - - /* p_aout->fifo[i_fifo].b_start_frame = 1; */ - p_aout->fifo[i_fifo].l_next_frame += 1; - p_aout->fifo[i_fifo].l_next_frame &= AOUT_FIFO_SIZE; - p_aout->fifo[i_fifo].b_next_frame = 0; - } - } - break; - - case AOUT_ADEC_STEREO_FIFO: - if ( p_aout->fifo[i_fifo].b_die ) - { - free( p_aout->fifo[i_fifo].buffer ); - free( p_aout->fifo[i_fifo].date ); - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */ - intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); - continue; - } - - l_units = p_aout->l_units; - l_buffer = 0; - while ( l_units > 0 ) - { - if ( !p_aout->fifo[i_fifo].b_next_frame ) - { - if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) ) - { - break; - } - } -#define SOUND 1 -#define DEBUG 0 -#define COEFF 2 - if ( p_aout->fifo[i_fifo].l_units > l_units ) - { - l_buffer_limit = p_aout->l_units /*<< 1*/; /* p_aout->b_stereo == 1 */ -//intf_DbgMsg( "l_buffer_limit:%d\n",l_buffer_limit ); - while ( l_buffer < l_buffer_limit ) - { -#if SOUND - - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[COEFF*p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[COEFF*p_aout->fifo[i_fifo].l_unit+1] ); - -/* -//intf_DbgMsg( "1deb " ); -l_buffer++; -p_aout->s32_buffer[l_buffer] += (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[COEFF*p_aout->fifo[i_fifo].l_unit] ) / 2; -p_aout->s32_buffer[l_buffer] += (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[COEFF*p_aout->fifo[i_fifo].l_unit+1] ) / 2; -l_buffer++; -//intf_DbgMsg( "1fin" ); -*/ -#endif - -#if DEBUG -//intf_DbgMsg( "p_aout->s32_buffer[l_buffer] 11 : %x (%d)",p_aout->s32_buffer[l_buffer-1],p_aout->s32_buffer[l_buffer-1] ); -intf_DbgMsg( "p_aout->fifo %ld\n",COEFF*p_aout->fifo[i_fifo].l_unit ); -intf_DbgMsg( "%d - p_aout->s32b %ld\n", l_buffer, (s32) ( ((s16 *)p_aout->fifo[i_fifo].buffer)[COEFF*p_aout->fifo[i_fifo].l_unit] ) ); -//intf_DbgMsg( "p_aout->s32_buffer[l_buffer] 12 : %x (%d)\n",p_aout->s32_buffer[l_buffer-1],p_aout->s32_buffer[l_buffer-1] ); -#endif - - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 2/*1*/)) ) - { - p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 2/*1*/)); - } - } - p_aout->fifo[i_fifo].l_units -= l_units; - break; - } - else - { -//#if 0 - l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units /*<< 1*/); -//intf_DbgMsg( "l_buffer_limit:%d\n",l_buffer_limit ); - /* p_aout->b_stereo == 1 */ - while ( l_buffer < l_buffer_limit ) - { -#if SOUND - - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[COEFF*p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[COEFF*p_aout->fifo[i_fifo].l_unit+1] ); - -/* -//intf_DbgMsg( "2deb " ); -l_buffer++; -//intf_DbgMsg( "793 "); -// !!!!!! Seg Fault !!!!!!! -//intf_DbgMsg( "\n p->aout_buffer : %d\t%d\n",p_aout->s32_buffer[l_buffer],COEFF*p_aout->fifo[i_fifo].l_unit ); -if( COEFF*p_aout->fifo[i_fifo].l_unit < 60000 ) -{ - p_aout->s32_buffer[l_buffer] += (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[COEFF*p_aout->fifo[i_fifo].l_unit] ) / 2; -// intf_DbgMsg( "795 "); - p_aout->s32_buffer[l_buffer] += (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[COEFF*p_aout->fifo[i_fifo].l_unit+1] ) / 2; -//intf_DbgMsg( "797 "); - l_buffer++; -} -//intf_DbgMsg( "2fin " ); -*/ -#endif - -#if DEBUG -//intf_DbgMsg( "p_aout->s32_buffer[l_buffer] 21 : %x (%d)",p_aout->s32_buffer[l_buffer-1],p_aout->s32_buffer[l_buffer-1] ); -intf_DbgMsg( "p_aout->fifo %ld\n",COEFF*p_aout->fifo[i_fifo].l_unit ); -intf_DbgMsg( "%d - p_aout->s32b %ld\n", l_buffer, (s32) ( ((s16 *)p_aout->fifo[i_fifo].buffer)[COEFF*p_aout->fifo[i_fifo].l_unit] ) ); -//intf_DbgMsg( "p_aout->s32_buffer[l_buffer] 22 : %x (%d)\n",p_aout->s32_buffer[l_buffer-1],p_aout->s32_buffer[l_buffer-1] ); -#endif - - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) -//intf_DbgMsg( "807 "); - if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 2/*1*/)) ) - { -//intf_DbgMsg( "811 "); - p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 2/*1*/)); - } - } -//intf_DbgMsg( "816 "); - l_units -= p_aout->fifo[i_fifo].l_units; -//intf_DbgMsg( "818 "); - vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock ); -//intf_DbgMsg( "820 "); - p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame; -//intf_DbgMsg( "822 "); - vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait ); -//intf_DbgMsg( "824 "); - vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock ); -//intf_DbgMsg( "826 "); - /* p_aout->fifo[i_fifo].b_start_frame = 1; */ - p_aout->fifo[i_fifo].l_next_frame += 1; -//intf_DbgMsg( "829 "); - p_aout->fifo[i_fifo].l_next_frame &= AOUT_FIFO_SIZE; -//intf_DbgMsg( "831 "); - p_aout->fifo[i_fifo].b_next_frame = 0; -//#endif -//intf_DbgMsg( "837 "); - } -//intf_DbgMsg( "838 "); -/* !!!!!!!!!!!!! Seg Fault !!!!!!!!!!!!!!!!! */ - } -//intf_DbgMsg( "839 "); - break; - - default: -//intf_DbgMsg( "841 "); - intf_DbgMsg("aout debug: unknown fifo type (%i)\n", p_aout->fifo[i_fifo].i_type); -//intf_DbgMsg( "842 "); - break; - } - } -//intf_DbgMsg( "843 "); - vlc_mutex_unlock( &p_aout->fifos_lock ); -//intf_DbgMsg( "845 "); - l_buffer_limit = p_aout->l_units /*<< 1*/ ; /* p_aout->b_stereo == 1 */ -//intf_DbgMsg( "\nici commence l'envoi sur sb\n" ); - for ( l_buffer = 0; l_buffer < l_buffer_limit; l_buffer++ ) - { -//intf_DbgMsg( "3deb "); -//intf_DbgMsg( "p_aout->s_32_buffer[l_buffer] : %x (%d)\n",p_aout->s32_buffer[l_buffer],p_aout->s32_buffer[l_buffer] ); - ((u8 *)p_aout->buffer)[l_buffer] = (u8)( (p_aout->s32_buffer[/*2 **/ l_buffer] / 256) + 128 ); -//intf_DbgMsg( "p_aout->buffer[l_buffer] : %x (%d)\n", ((u8 *)p_aout->buffer)[l_buffer], ((u8 *)p_aout->buffer)[l_buffer] ); - p_aout->s32_buffer[/*2 **/ l_buffer] = 0; -// p_aout->s32_buffer[2 * l_buffer + 1] = 0; -//intf_DbgMsg( "3fin "); - } - l_bytes = p_aout->p_sys_getbufinfo( p_aout, l_buffer_limit ); - p_aout->date = mdate() + ((((mtime_t)(l_bytes / 2 )) * 1000000) / ((mtime_t)p_aout->l_rate)); /* sizeof(u8) << (p_aout->b_stereo) == 2 */ - p_aout->p_sys_playsamples( p_aout, (byte_t *)p_aout->buffer, l_buffer_limit * sizeof(u8) ); - if ( l_bytes > (l_buffer_limit * sizeof(u8)) ) - { - msleep( p_aout->l_msleep ); - } - } - - vlc_mutex_lock( &p_aout->fifos_lock ); + /* Destroy the condition and mutex locks */ for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ ) { - switch ( p_aout->fifo[i_fifo].i_type ) - { - case AOUT_EMPTY_FIFO: - break; - - case AOUT_INTF_MONO_FIFO: - case AOUT_INTF_STEREO_FIFO: - free( p_aout->fifo[i_fifo].buffer ); /* !! */ - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */ - intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); - break; - - case AOUT_ADEC_MONO_FIFO: - case AOUT_ADEC_STEREO_FIFO: - free( p_aout->fifo[i_fifo].buffer ); - free( p_aout->fifo[i_fifo].date ); - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */ - intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); - break; - - default: - break; - } + vlc_mutex_destroy( &p_aout->fifo[i_fifo].data_lock ); + vlc_cond_destroy( &p_aout->fifo[i_fifo].data_wait ); } - vlc_mutex_unlock( &p_aout->fifos_lock ); - -} - -void aout_Thread_U8_Stereo( aout_thread_t * p_aout ) -{ - int i_fifo; - long l_buffer, l_buffer_limit; - long l_units, l_bytes; - - intf_DbgMsg("adec debug: ********aout_Thread_U8_Stereo********\n"); - intf_DbgMsg("adec debug: running audio output thread (%p) (pid == %i)\n", p_aout, getpid()); - - /* As the s32_buffer was created with calloc(), we don't have to set this - * memory to zero and we can immediately jump into the thread's loop */ - while ( !p_aout->b_die ) - { - vlc_mutex_lock( &p_aout->fifos_lock ); - for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ ) - { - switch ( p_aout->fifo[i_fifo].i_type ) - { - case AOUT_EMPTY_FIFO: - break; - - case AOUT_INTF_MONO_FIFO: - if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units ) - { - l_buffer = 0; - while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->b_stereo == 1 */ - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - } - p_aout->fifo[i_fifo].l_units -= p_aout->l_units; - } - else - { - l_buffer = 0; - while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->b_stereo == 1 */ - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - } - free( p_aout->fifo[i_fifo].buffer ); /* !! */ - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */ - intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); /* !! */ - } - break; - - case AOUT_INTF_STEREO_FIFO: - if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units ) - { - l_buffer = 0; - while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->b_stereo == 1 */ - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] ); - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - } - p_aout->fifo[i_fifo].l_units -= p_aout->l_units; - } - else - { - l_buffer = 0; - while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->b_stereo == 1 */ - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] ); - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - } - free( p_aout->fifo[i_fifo].buffer ); /* !! */ - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */ - intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); /* !! */ - } - break; - - case AOUT_ADEC_MONO_FIFO: - if ( p_aout->fifo[i_fifo].b_die ) - { - free( p_aout->fifo[i_fifo].buffer ); - free( p_aout->fifo[i_fifo].date ); - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */ - intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); - continue; - } - - l_units = p_aout->l_units; - l_buffer = 0; - while ( l_units > 0 ) - { - if ( !p_aout->fifo[i_fifo].b_next_frame ) - { - if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) ) - { - break; - } - } - - if ( p_aout->fifo[i_fifo].l_units > l_units ) - { - l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */ - while ( l_buffer < l_buffer_limit ) - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) ) - { - p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)); - } - } - p_aout->fifo[i_fifo].l_units -= l_units; - break; - } - else - { - l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1); - /* p_aout->b_stereo == 1 */ - while ( l_buffer < l_buffer_limit ) - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) ) - { - p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)); - } - } - l_units -= p_aout->fifo[i_fifo].l_units; - - vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock ); - p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame; - vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait ); - vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock ); - - /* p_aout->fifo[i_fifo].b_start_frame = 1; */ - p_aout->fifo[i_fifo].l_next_frame += 1; - p_aout->fifo[i_fifo].l_next_frame &= AOUT_FIFO_SIZE; - p_aout->fifo[i_fifo].b_next_frame = 0; - } - } - break; - - case AOUT_ADEC_STEREO_FIFO: - if ( p_aout->fifo[i_fifo].b_die ) - { - free( p_aout->fifo[i_fifo].buffer ); - free( p_aout->fifo[i_fifo].date ); - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */ - intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); - continue; - } - - l_units = p_aout->l_units; - l_buffer = 0; - while ( l_units > 0 ) - { - if ( !p_aout->fifo[i_fifo].b_next_frame ) - { - if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) ) - { - break; - } - } - - if ( p_aout->fifo[i_fifo].l_units > l_units ) - { - l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */ - while ( l_buffer < l_buffer_limit ) - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] ); - - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) ) - { - p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)); - } - } - p_aout->fifo[i_fifo].l_units -= l_units; - break; - } - else - { - l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1); - /* p_aout->b_stereo == 1 */ - while ( l_buffer < l_buffer_limit ) - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] ); - - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) ) - { - p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)); - } - } - l_units -= p_aout->fifo[i_fifo].l_units; - - vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock ); - p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame; - vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait ); - vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock ); - - /* p_aout->fifo[i_fifo].b_start_frame = 1; */ - p_aout->fifo[i_fifo].l_next_frame += 1; - p_aout->fifo[i_fifo].l_next_frame &= AOUT_FIFO_SIZE; - p_aout->fifo[i_fifo].b_next_frame = 0; - } - } - break; - - default: - intf_DbgMsg("aout debug: unknown fifo type (%i)\n", p_aout->fifo[i_fifo].i_type); - break; - } - } - vlc_mutex_unlock( &p_aout->fifos_lock ); - - l_buffer_limit = p_aout->l_units << 1 ; /* p_aout->b_stereo == 1 */ - - for ( l_buffer = 0; l_buffer < l_buffer_limit; l_buffer++ ) - { - ((u8 *)p_aout->buffer)[l_buffer] = (u8)( ( (p_aout->s32_buffer[l_buffer] / 256) + 128 ) * \ - ((float) p_aout->vol / 100 ) ); - p_aout->s32_buffer[l_buffer] = 0; - } - l_bytes = p_aout->p_sys_getbufinfo( p_aout, l_buffer_limit ); - p_aout->date = mdate() + ((((mtime_t)(l_bytes / 2 )) * 1000000) / ((mtime_t)p_aout->l_rate)); /* sizeof(u8) << (p_aout->b_stereo) == 2 */ - p_aout->p_sys_playsamples( p_aout, (byte_t *)p_aout->buffer, l_buffer_limit * sizeof(u8) ); - if ( l_bytes > (l_buffer_limit * sizeof(u8)) ) - { - msleep( p_aout->l_msleep ); - } - } - - vlc_mutex_lock( &p_aout->fifos_lock ); - for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ ) - { - switch ( p_aout->fifo[i_fifo].i_type ) - { - case AOUT_EMPTY_FIFO: - break; - - case AOUT_INTF_MONO_FIFO: - case AOUT_INTF_STEREO_FIFO: - free( p_aout->fifo[i_fifo].buffer ); /* !! */ - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */ - intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); - break; - - case AOUT_ADEC_MONO_FIFO: - case AOUT_ADEC_STEREO_FIFO: - free( p_aout->fifo[i_fifo].buffer ); - free( p_aout->fifo[i_fifo].date ); - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */ - intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); - break; - - default: - break; - } - } - vlc_mutex_unlock( &p_aout->fifos_lock ); - -} - -void aout_Thread_S16_Mono( aout_thread_t * p_aout ) -{ -} - -void aout_Thread_S16_Stereo( aout_thread_t * p_aout ) -{ - int i_fifo; - long l_buffer, l_buffer_limit; - long l_units, l_bytes; - - intf_DbgMsg("adec debug: ********aout_Thread_S16_Stereo********\n"); - intf_DbgMsg("adec debug: running audio output thread (%p) (pid == %i)\n", p_aout, getpid()); - - /* As the s32_buffer was created with calloc(), we don't have to set this - * memory to zero and we can immediately jump into the thread's loop */ - while ( !p_aout->b_die ) - { - vlc_mutex_lock( &p_aout->fifos_lock ); - for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ ) - { - switch ( p_aout->fifo[i_fifo].i_type ) - { - case AOUT_EMPTY_FIFO: - break; - - case AOUT_INTF_MONO_FIFO: - if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units ) - { - l_buffer = 0; - while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->b_stereo == 1 */ - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - } - p_aout->fifo[i_fifo].l_units -= p_aout->l_units; - } - else - { - l_buffer = 0; - while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->b_stereo == 1 */ - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - } - free( p_aout->fifo[i_fifo].buffer ); /* !! */ - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */ - intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); /* !! */ - } - break; - - case AOUT_INTF_STEREO_FIFO: - if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units ) - { - l_buffer = 0; - while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->b_stereo == 1 */ - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] ); - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - } - p_aout->fifo[i_fifo].l_units -= p_aout->l_units; - } - else - { - l_buffer = 0; - while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->b_stereo == 1 */ - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] ); - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - } - free( p_aout->fifo[i_fifo].buffer ); /* !! */ - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */ - intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); /* !! */ - } - break; - - case AOUT_ADEC_MONO_FIFO: - if ( p_aout->fifo[i_fifo].b_die ) - { - free( p_aout->fifo[i_fifo].buffer ); - free( p_aout->fifo[i_fifo].date ); - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */ - intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); - continue; - } - - l_units = p_aout->l_units; - l_buffer = 0; - while ( l_units > 0 ) - { - if ( !p_aout->fifo[i_fifo].b_next_frame ) - { - if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) ) - { - break; - } - } - - if ( p_aout->fifo[i_fifo].l_units > l_units ) - { - l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */ - while ( l_buffer < l_buffer_limit ) - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) ) - { - p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)); - } - } - p_aout->fifo[i_fifo].l_units -= l_units; - break; - } - else - { - l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1); - /* p_aout->b_stereo == 1 */ - while ( l_buffer < l_buffer_limit ) - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] ); - - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) ) - { - p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)); - } - } - l_units -= p_aout->fifo[i_fifo].l_units; - - vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock ); - p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame; - vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait ); - vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock ); - - /* p_aout->fifo[i_fifo].b_start_frame = 1; */ - p_aout->fifo[i_fifo].l_next_frame += 1; - p_aout->fifo[i_fifo].l_next_frame &= AOUT_FIFO_SIZE; - p_aout->fifo[i_fifo].b_next_frame = 0; - } - } - break; - - case AOUT_ADEC_STEREO_FIFO: - if ( p_aout->fifo[i_fifo].b_die ) - { - free( p_aout->fifo[i_fifo].buffer ); - free( p_aout->fifo[i_fifo].date ); - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */ - intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); - continue; - } - - l_units = p_aout->l_units; - l_buffer = 0; - while ( l_units > 0 ) - { - if ( !p_aout->fifo[i_fifo].b_next_frame ) - { - if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) ) - { - break; - } - } - - if ( p_aout->fifo[i_fifo].l_units > l_units ) - { - l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */ - while ( l_buffer < l_buffer_limit ) - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] ); - - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) ) - { - p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)); - } - } - p_aout->fifo[i_fifo].l_units -= l_units; - break; - } - else - { - l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1); - /* p_aout->b_stereo == 1 */ - while ( l_buffer < l_buffer_limit ) - { - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] ); - p_aout->s32_buffer[l_buffer++] += - (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] ); - - UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit ) - if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) ) - { - p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */ - ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)); - } - } - l_units -= p_aout->fifo[i_fifo].l_units; - - vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock ); - p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame; - vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait ); - vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock ); - - /* p_aout->fifo[i_fifo].b_start_frame = 1; */ - p_aout->fifo[i_fifo].l_next_frame += 1; - p_aout->fifo[i_fifo].l_next_frame &= AOUT_FIFO_SIZE; - p_aout->fifo[i_fifo].b_next_frame = 0; - } - } - break; - - default: - intf_DbgMsg("aout debug: unknown fifo type (%i)\n", p_aout->fifo[i_fifo].i_type); - break; - } - } - vlc_mutex_unlock( &p_aout->fifos_lock ); - - l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */ - - for ( l_buffer = 0; l_buffer < l_buffer_limit; l_buffer++ ) - { - ((s16 *)p_aout->buffer)[l_buffer] = (s16)( ( p_aout->s32_buffer[l_buffer] / AOUT_MAX_FIFOS ) * \ - ((float) p_aout->vol / 100 ) ) ; - p_aout->s32_buffer[l_buffer] = 0; - } - - l_bytes = p_aout->p_sys_getbufinfo( p_aout, l_buffer_limit ); - p_aout->date = mdate() + ((((mtime_t)(l_bytes / 4)) * 1000000) / ((mtime_t)p_aout->l_rate)); /* sizeof(s16) << (p_aout->b_stereo) == 4 */ - p_aout->p_sys_playsamples( p_aout, (byte_t *)p_aout->buffer, l_buffer_limit * sizeof(s16) ); - if ( l_bytes > (l_buffer_limit * sizeof(s16)) ) - { - msleep( p_aout->l_msleep ); - } - } - - vlc_mutex_lock( &p_aout->fifos_lock ); - for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ ) - { - switch ( p_aout->fifo[i_fifo].i_type ) - { - case AOUT_EMPTY_FIFO: - break; - - case AOUT_INTF_MONO_FIFO: - case AOUT_INTF_STEREO_FIFO: - free( p_aout->fifo[i_fifo].buffer ); /* !! */ - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */ - intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); - break; + vlc_mutex_destroy( &p_aout->fifos_lock ); + + /* Free the plugin */ + p_aout->pf_close( p_aout ); - case AOUT_ADEC_MONO_FIFO: - case AOUT_ADEC_STEREO_FIFO: - free( p_aout->fifo[i_fifo].buffer ); - free( p_aout->fifo[i_fifo].date ); - p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */ - intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); - break; + /* Release the aout module */ + module_Unneed( p_main->p_bank, p_aout->p_module ); - default: - break; - } - } - vlc_mutex_unlock( &p_aout->fifos_lock ); -} - -void aout_Thread_U16_Mono( aout_thread_t * p_aout ) -{ + /* Free structure */ + free( p_aout ); } -void aout_Thread_U16_Stereo( aout_thread_t * p_aout ) -{ -}