1 /*****************************************************************************
2 * audio_output.c : audio output thread
3 *****************************************************************************
4 * Copyright (C) 1999, 2000 VideoLAN
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public
19 * License along with this program; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
22 *****************************************************************************/
26 * - Passer un certain nombre de "fonctions" (genre add_samples) en macro ou
28 * - Faire les optimisations dans les fonctions threads :
29 * = Stocker les "petits calculs" dans des variables au lieu de les refaire
31 * = Utiliser des tables pour les gros calculs
32 * - Faire une structure différente pour intf/adec fifo
36 /*****************************************************************************
38 *****************************************************************************/
39 #include <unistd.h> /* getpid() */
41 #include <stdio.h> /* "intf_msg.h" */
42 #include <stdlib.h> /* calloc(), malloc(), free() */
44 #include <dlfcn.h> /* plugins */
48 #include "mtime.h" /* mtime_t, mdate(), msleep() */
51 #include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
53 #include "audio_output.h"
56 /*****************************************************************************
58 *****************************************************************************/
60 static int aout_SpawnThread( aout_thread_t * p_aout );
62 /* Creating as much aout_Thread functions as configurations is one solution,
63 * examining the different cases in the Thread loop of an unique function is
64 * another. I chose the first solution. */
65 void aout_Thread_S8_Mono ( aout_thread_t * p_aout );
66 void aout_Thread_U8_Mono ( aout_thread_t * p_aout );
67 void aout_Thread_S16_Mono ( aout_thread_t * p_aout );
68 void aout_Thread_U16_Mono ( aout_thread_t * p_aout );
69 void aout_Thread_S8_Stereo ( aout_thread_t * p_aout );
70 void aout_Thread_U8_Stereo ( aout_thread_t * p_aout );
71 void aout_Thread_S16_Stereo ( aout_thread_t * p_aout );
72 void aout_Thread_U16_Stereo ( aout_thread_t * p_aout );
74 static __inline__ void InitializeIncrement( aout_increment_t * p_increment, long l_numerator, long l_denominator );
75 static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, mtime_t aout_date );
77 /*****************************************************************************
78 * aout_CreateThread: initialize audio thread
79 *****************************************************************************/
80 aout_thread_t *aout_CreateThread( int *pi_status )
82 aout_thread_t * p_aout; /* thread descriptor */
86 int i_status; /* thread status */
89 /* Allocate descriptor */
90 p_aout = (aout_thread_t *) malloc( sizeof(aout_thread_t) );
96 /* Initialize method-dependent functions */
97 psz_method = main_GetPszVariable( AOUT_METHOD_VAR, AOUT_DEFAULT_METHOD );
99 psz_plugin = malloc( sizeof("./audio_output/aout_.so") + strlen(psz_method) );
100 sprintf( psz_plugin, "./audio_output/aout_%s.so", psz_method );
102 p_aout->p_aout_plugin = dlopen( psz_plugin, RTLD_NOW | RTLD_GLOBAL );
104 if( p_aout->p_aout_plugin == NULL )
106 intf_ErrMsg( "error: could not open audio plugin %s\n", psz_plugin );
114 p_aout->p_sys_open = dlsym(p_aout->p_aout_plugin, "aout_SysOpen");
115 p_aout->p_sys_reset = dlsym(p_aout->p_aout_plugin, "aout_SysReset");
116 p_aout->p_sys_setformat = dlsym(p_aout->p_aout_plugin, "aout_SysSetFormat");
117 p_aout->p_sys_setchannels = dlsym(p_aout->p_aout_plugin, "aout_SysSetChannels");
118 p_aout->p_sys_setrate = dlsym(p_aout->p_aout_plugin, "aout_SysSetRate");
119 p_aout->p_sys_getbufinfo = dlsym(p_aout->p_aout_plugin, "aout_SysGetBufInfo");
120 p_aout->p_sys_playsamples = dlsym(p_aout->p_aout_plugin, "aout_SysPlaySamples");
121 p_aout->p_sys_close = dlsym(p_aout->p_aout_plugin, "aout_SysClose");
124 * Initialize audio device
126 if ( p_aout->p_sys_open( p_aout ) )
128 dlclose( p_aout->p_aout_plugin );
133 p_aout->b_stereo = ( p_aout->i_channels == 2 ) ? 1 : 0; /* FIXME: only works
134 for i_channels == 1 or 2 ??*/
136 if ( p_aout->p_sys_reset( p_aout ) )
138 p_aout->p_sys_close( p_aout );
139 dlclose( p_aout->p_aout_plugin );
143 if ( p_aout->p_sys_setformat( p_aout ) )
145 p_aout->p_sys_close( p_aout );
146 dlclose( p_aout->p_aout_plugin );
150 if ( p_aout->p_sys_setchannels( p_aout ) )
152 p_aout->p_sys_close( p_aout );
153 dlclose( p_aout->p_aout_plugin );
157 if ( p_aout->p_sys_setrate( p_aout ) )
159 p_aout->p_sys_close( p_aout );
160 dlclose( p_aout->p_aout_plugin );
165 /* FIXME: maybe it would be cleaner to change SpawnThread prototype
166 * see vout to handle status correctly ?? however, it is not critical since
167 * this thread is only called in main and all calls are blocking */
168 if( aout_SpawnThread( p_aout ) )
170 p_aout->p_sys_close( p_aout );
171 dlclose( p_aout->p_aout_plugin );
179 /*****************************************************************************
181 *****************************************************************************/
182 static int aout_SpawnThread( aout_thread_t * p_aout )
186 void * aout_thread = NULL;
188 intf_DbgMsg("aout debug: spawning audio output thread (%p)\n", p_aout);
190 /* We want the audio output thread to live */
193 /* Initialize the fifos lock */
194 vlc_mutex_init( &p_aout->fifos_lock );
195 /* Initialize audio fifos : set all fifos as empty and initialize locks */
196 for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
198 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO;
199 vlc_mutex_init( &p_aout->fifo[i_fifo].data_lock );
200 vlc_cond_init( &p_aout->fifo[i_fifo].data_wait );
203 /* Compute the size (in audio units) of the audio output buffer. Although
204 * AOUT_BUFFER_DURATION is given in microseconds, the output rate is given
205 * in Hz, that's why we need to divide by 10^6 microseconds (1 second) */
206 p_aout->l_units = (long)( ((s64)p_aout->l_rate * AOUT_BUFFER_DURATION) / 1000000 );
207 p_aout->l_msleep = (long)( ((s64)p_aout->l_units * 1000000) / (s64)p_aout->l_rate );
209 /* Make aout_thread point to the right thread function, and compute the
210 * byte size of the audio output buffer */
211 switch ( p_aout->i_channels )
213 /* Audio output is mono */
215 switch ( p_aout->i_format )
218 l_bytes = 1 * sizeof(u8) * p_aout->l_units;
219 aout_thread = (void *)aout_Thread_U8_Mono;
223 l_bytes = 1 * sizeof(s8) * p_aout->l_units;
224 aout_thread = (void *)aout_Thread_S8_Mono;
227 case AOUT_FMT_U16_LE:
228 case AOUT_FMT_U16_BE:
229 l_bytes = 1 * sizeof(u16) * p_aout->l_units;
230 aout_thread = (void *)aout_Thread_U16_Mono;
233 case AOUT_FMT_S16_LE:
234 case AOUT_FMT_S16_BE:
235 l_bytes = 1 * sizeof(s16) * p_aout->l_units;
236 aout_thread = (void *)aout_Thread_S16_Mono;
240 intf_ErrMsg( "aout error: unknown audio output format (%i)\n",
246 /* Audio output is stereo */
248 switch ( p_aout->i_format )
251 l_bytes = 2 * sizeof(u8) * p_aout->l_units;
252 aout_thread = (void *)aout_Thread_U8_Stereo;
256 l_bytes = 2 * sizeof(s8) * p_aout->l_units;
257 aout_thread = (void *)aout_Thread_S8_Stereo;
260 case AOUT_FMT_U16_LE:
261 case AOUT_FMT_U16_BE:
262 l_bytes = 2 * sizeof(u16) * p_aout->l_units;
263 aout_thread = (void *)aout_Thread_U16_Stereo;
266 case AOUT_FMT_S16_LE:
267 case AOUT_FMT_S16_BE:
268 l_bytes = 2 * sizeof(s16) * p_aout->l_units;
269 aout_thread = (void *)aout_Thread_S16_Stereo;
273 intf_ErrMsg("aout error: unknown audio output format (%i)\n",
280 intf_ErrMsg("aout error: unknown number of audio channels (%i)\n",
281 p_aout->i_channels );
285 /* Allocate the memory needed by the audio output buffers, and set to zero
286 * the s32 buffer's memory */
287 if ( (p_aout->buffer = malloc(l_bytes)) == NULL )
289 intf_ErrMsg("aout error: not enough memory to create the output buffer\n");
292 if ( (p_aout->s32_buffer = (s32 *)calloc(p_aout->l_units, sizeof(s32) << ( p_aout->b_stereo))) == NULL )
294 intf_ErrMsg("aout error: not enough memory to create the s32 output buffer\n");
295 free( p_aout->buffer );
299 /* Before launching the thread, we try to predict the date of the first
300 * audio unit in the first output buffer */
301 p_aout->date = mdate() - 1000000;
303 /* Launch the thread */
304 if ( vlc_thread_create( &p_aout->thread_id, "audio output", (vlc_thread_func_t)aout_thread, p_aout ) )
306 intf_ErrMsg("aout error: can't spawn audio output thread (%p)\n", p_aout);
307 free( p_aout->buffer );
308 free( p_aout->s32_buffer );
312 intf_DbgMsg("aout debug: audio output thread (%p) spawned\n", p_aout);
316 /*****************************************************************************
318 *****************************************************************************/
319 void aout_DestroyThread( aout_thread_t * p_aout, int *pi_status )
321 /* FIXME: pi_status is not handled correctly: check vout how to do!?? */
323 intf_DbgMsg("aout debug: requesting termination of audio output thread (%p)\n", p_aout);
325 /* Ask thread to kill itself and wait until it's done */
327 vlc_thread_join( p_aout->thread_id ); /* only if pi_status is NULL */
329 /* Free the allocated memory */
330 free( p_aout->buffer );
331 free( p_aout->s32_buffer );
333 /* Free the structure */
334 p_aout->p_sys_close( p_aout );
335 intf_DbgMsg("aout debug: audio device (%s) closed\n", p_aout->psz_device);
338 dlclose( p_aout->p_aout_plugin );
344 /*****************************************************************************
346 *****************************************************************************/
347 aout_fifo_t * aout_CreateFifo( aout_thread_t * p_aout, aout_fifo_t * p_fifo )
351 /* Take the fifos lock */
352 vlc_mutex_lock( &p_aout->fifos_lock );
354 /* Looking for a free fifo structure */
355 for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
357 if ( p_aout->fifo[i_fifo].i_type == AOUT_EMPTY_FIFO)
362 if ( i_fifo == AOUT_MAX_FIFOS )
364 intf_ErrMsg("aout error: no empty fifo available\n");
365 vlc_mutex_unlock( &p_aout->fifos_lock );
369 /* Initialize the new fifo structure */
370 switch ( p_aout->fifo[i_fifo].i_type = p_fifo->i_type )
372 case AOUT_INTF_MONO_FIFO:
373 case AOUT_INTF_STEREO_FIFO:
374 p_aout->fifo[i_fifo].b_die = 0;
376 p_aout->fifo[i_fifo].i_channels = p_fifo->i_channels;
377 p_aout->fifo[i_fifo].b_stereo = p_fifo->b_stereo;
378 p_aout->fifo[i_fifo].l_rate = p_fifo->l_rate;
380 p_aout->fifo[i_fifo].buffer = p_fifo->buffer;
382 p_aout->fifo[i_fifo].l_unit = 0;
383 InitializeIncrement( &p_aout->fifo[i_fifo].unit_increment, p_fifo->l_rate, p_aout->l_rate );
384 p_aout->fifo[i_fifo].l_units = p_fifo->l_units;
387 case AOUT_ADEC_MONO_FIFO:
388 case AOUT_ADEC_STEREO_FIFO:
389 p_aout->fifo[i_fifo].b_die = 0;
391 p_aout->fifo[i_fifo].i_channels = p_fifo->i_channels;
392 p_aout->fifo[i_fifo].b_stereo = p_fifo->b_stereo;
393 p_aout->fifo[i_fifo].l_rate = p_fifo->l_rate;
395 p_aout->fifo[i_fifo].l_frame_size = p_fifo->l_frame_size;
396 /* Allocate the memory needed to store the audio frames. As the
397 * fifo is a rotative fifo, we must be able to find out whether the
398 * fifo is full or empty, that's why we must in fact allocate memory
399 * for (AOUT_FIFO_SIZE+1) audio frames. */
400 if ( (p_aout->fifo[i_fifo].buffer = malloc( sizeof(s16)*(AOUT_FIFO_SIZE+1)*p_fifo->l_frame_size )) == NULL )
402 intf_ErrMsg("aout error: not enough memory to create the frames buffer\n");
403 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO;
404 vlc_mutex_unlock( &p_aout->fifos_lock );
408 /* Allocate the memory needed to store the dates of the frames */
409 if ( (p_aout->fifo[i_fifo].date = (mtime_t *)malloc( sizeof(mtime_t)*(AOUT_FIFO_SIZE+1) )) == NULL )
411 intf_ErrMsg("aout error: not enough memory to create the dates buffer\n");
412 free( p_aout->fifo[i_fifo].buffer );
413 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO;
414 vlc_mutex_unlock( &p_aout->fifos_lock );
418 /* Set the fifo's buffer as empty (the first frame that is to be
419 * played is also the first frame that is not to be played) */
420 p_aout->fifo[i_fifo].l_start_frame = 0;
421 /* p_aout->fifo[i_fifo].l_next_frame = 0; */
422 p_aout->fifo[i_fifo].l_end_frame = 0;
424 /* Waiting for the audio decoder to compute enough frames to work
425 * out the fifo's current rate (as soon as the decoder has decoded
426 * enough frames, the members of the fifo structure that are not
427 * initialized now will be calculated) */
428 p_aout->fifo[i_fifo].b_start_frame = 0;
429 p_aout->fifo[i_fifo].b_next_frame = 0;
433 intf_ErrMsg("aout error: unknown fifo type (%i)\n", p_aout->fifo[i_fifo].i_type);
434 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO;
435 vlc_mutex_unlock( &p_aout->fifos_lock );
439 /* Release the fifos lock */
440 vlc_mutex_unlock( &p_aout->fifos_lock );
442 /* Return the pointer to the fifo structure */
443 intf_DbgMsg("aout debug: audio output fifo (%p) allocated\n", &p_aout->fifo[i_fifo]);
444 return( &p_aout->fifo[i_fifo] );
447 /*****************************************************************************
449 *****************************************************************************/
450 void aout_DestroyFifo( aout_fifo_t * p_fifo )
452 intf_DbgMsg("aout debug: requesting destruction of audio output fifo (%p)\n", p_fifo);
456 /* Here are the local macros */
458 #define UPDATE_INCREMENT( increment, integer ) \
459 if ( ((increment).l_remainder += (increment).l_euclidean_remainder) >= 0 )\
461 (integer) += (increment).l_euclidean_integer + 1; \
462 (increment).l_remainder -= (increment).l_euclidean_denominator; \
466 (integer) += (increment).l_euclidean_integer; \
469 /* Following functions are local */
471 /*****************************************************************************
472 * InitializeIncrement
473 *****************************************************************************/
474 static __inline__ void InitializeIncrement( aout_increment_t * p_increment, long l_numerator, long l_denominator )
476 p_increment->l_remainder = -l_denominator;
478 p_increment->l_euclidean_integer = 0;
479 while ( l_numerator >= l_denominator )
481 p_increment->l_euclidean_integer++;
482 l_numerator -= l_denominator;
485 p_increment->l_euclidean_remainder = l_numerator;
487 p_increment->l_euclidean_denominator = l_denominator;
490 /*****************************************************************************
492 *****************************************************************************/
493 static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, mtime_t aout_date )
495 long l_units, l_rate;
497 /* We take the lock */
498 vlc_mutex_lock( &p_fifo->data_lock );
500 /* Are we looking for a dated start frame ? */
501 if ( !p_fifo->b_start_frame )
503 while ( p_fifo->l_start_frame != p_fifo->l_end_frame )
505 if ( p_fifo->date[p_fifo->l_start_frame] != LAST_MDATE )
507 p_fifo->b_start_frame = 1;
508 p_fifo->l_next_frame = (p_fifo->l_start_frame + 1) & AOUT_FIFO_SIZE;
509 p_fifo->l_unit = p_fifo->l_start_frame * (p_fifo->l_frame_size >> (p_fifo->b_stereo));
512 p_fifo->l_start_frame = (p_fifo->l_start_frame + 1) & AOUT_FIFO_SIZE;
515 if ( p_fifo->l_start_frame == p_fifo->l_end_frame )
517 vlc_mutex_unlock( &p_fifo->data_lock );
522 /* We are looking for the next dated frame */
523 /* FIXME : is the output fifo full ?? */
524 while ( !p_fifo->b_next_frame )
526 while ( p_fifo->l_next_frame != p_fifo->l_end_frame )
528 if ( p_fifo->date[p_fifo->l_next_frame] != LAST_MDATE )
530 p_fifo->b_next_frame = 1;
533 p_fifo->l_next_frame = (p_fifo->l_next_frame + 1) & AOUT_FIFO_SIZE;
536 while ( p_fifo->l_next_frame == p_fifo->l_end_frame )
538 vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
541 vlc_mutex_unlock( &p_fifo->data_lock );
547 l_units = ((p_fifo->l_next_frame - p_fifo->l_start_frame) & AOUT_FIFO_SIZE) * (p_fifo->l_frame_size >> (p_fifo->b_stereo));
549 l_rate = p_fifo->l_rate + ((aout_date - p_fifo->date[p_fifo->l_start_frame]) / 256);
550 // fprintf( stderr, "aout debug: %lli (%li);\n", aout_date - p_fifo->date[p_fifo->l_start_frame], l_rate );
552 InitializeIncrement( &p_fifo->unit_increment, l_rate, p_aout->l_rate );
554 p_fifo->l_units = (((l_units - (p_fifo->l_unit -
555 (p_fifo->l_start_frame * (p_fifo->l_frame_size >> (p_fifo->b_stereo)))))
556 * p_aout->l_rate) / l_rate) + 1;
558 /* We release the lock before leaving */
559 vlc_mutex_unlock( &p_fifo->data_lock );
563 void aout_Thread_S8_Mono( aout_thread_t * p_aout )
567 void aout_Thread_S8_Stereo( aout_thread_t * p_aout )
571 void aout_Thread_U8_Mono( aout_thread_t * p_aout )
575 void aout_Thread_U8_Stereo( aout_thread_t * p_aout )
578 long l_buffer, l_buffer_limit;
579 long l_units, l_bytes;
581 intf_DbgMsg("adec debug: ********aout_Thread_U8_Stereo********\n");
582 intf_DbgMsg("adec debug: running audio output thread (%p) (pid == %i)\n", p_aout, getpid());
584 /* As the s32_buffer was created with calloc(), we don't have to set this
585 * memory to zero and we can immediately jump into the thread's loop */
586 while ( !p_aout->b_die )
588 vlc_mutex_lock( &p_aout->fifos_lock );
589 for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
591 switch ( p_aout->fifo[i_fifo].i_type )
593 case AOUT_EMPTY_FIFO:
596 case AOUT_INTF_MONO_FIFO:
597 if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units )
600 while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->b_stereo == 1 */
602 p_aout->s32_buffer[l_buffer++] +=
603 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
604 p_aout->s32_buffer[l_buffer++] +=
605 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
606 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
608 p_aout->fifo[i_fifo].l_units -= p_aout->l_units;
613 while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->b_stereo == 1 */
615 p_aout->s32_buffer[l_buffer++] +=
616 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
617 p_aout->s32_buffer[l_buffer++] +=
618 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
619 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
621 free( p_aout->fifo[i_fifo].buffer ); /* !! */
622 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
623 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); /* !! */
627 case AOUT_INTF_STEREO_FIFO:
628 if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units )
631 while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->b_stereo == 1 */
633 p_aout->s32_buffer[l_buffer++] +=
634 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
635 p_aout->s32_buffer[l_buffer++] +=
636 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
637 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
639 p_aout->fifo[i_fifo].l_units -= p_aout->l_units;
644 while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->b_stereo == 1 */
646 p_aout->s32_buffer[l_buffer++] +=
647 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
648 p_aout->s32_buffer[l_buffer++] +=
649 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
650 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
652 free( p_aout->fifo[i_fifo].buffer ); /* !! */
653 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
654 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); /* !! */
658 case AOUT_ADEC_MONO_FIFO:
659 if ( p_aout->fifo[i_fifo].b_die )
661 free( p_aout->fifo[i_fifo].buffer );
662 free( p_aout->fifo[i_fifo].date );
663 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
664 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
668 l_units = p_aout->l_units;
670 while ( l_units > 0 )
672 if ( !p_aout->fifo[i_fifo].b_next_frame )
674 if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) )
680 if ( p_aout->fifo[i_fifo].l_units > l_units )
682 l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */
683 while ( l_buffer < l_buffer_limit )
685 p_aout->s32_buffer[l_buffer++] +=
686 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
687 p_aout->s32_buffer[l_buffer++] +=
688 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
690 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
691 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */
692 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) )
694 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */
695 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0));
698 p_aout->fifo[i_fifo].l_units -= l_units;
703 l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1);
704 /* p_aout->b_stereo == 1 */
705 while ( l_buffer < l_buffer_limit )
707 p_aout->s32_buffer[l_buffer++] +=
708 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
709 p_aout->s32_buffer[l_buffer++] +=
710 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
712 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
713 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */
714 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) )
716 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */
717 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0));
720 l_units -= p_aout->fifo[i_fifo].l_units;
722 vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock );
723 p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame;
724 vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait );
725 vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
727 /* p_aout->fifo[i_fifo].b_start_frame = 1; */
728 p_aout->fifo[i_fifo].l_next_frame += 1;
729 p_aout->fifo[i_fifo].l_next_frame &= AOUT_FIFO_SIZE;
730 p_aout->fifo[i_fifo].b_next_frame = 0;
735 case AOUT_ADEC_STEREO_FIFO:
736 if ( p_aout->fifo[i_fifo].b_die )
738 free( p_aout->fifo[i_fifo].buffer );
739 free( p_aout->fifo[i_fifo].date );
740 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
741 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
745 l_units = p_aout->l_units;
747 while ( l_units > 0 )
749 if ( !p_aout->fifo[i_fifo].b_next_frame )
751 if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) )
757 if ( p_aout->fifo[i_fifo].l_units > l_units )
759 l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */
760 while ( l_buffer < l_buffer_limit )
762 p_aout->s32_buffer[l_buffer++] +=
763 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
764 p_aout->s32_buffer[l_buffer++] +=
765 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
767 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
768 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */
769 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) )
771 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */
772 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1));
775 p_aout->fifo[i_fifo].l_units -= l_units;
780 l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1);
781 /* p_aout->b_stereo == 1 */
782 while ( l_buffer < l_buffer_limit )
784 p_aout->s32_buffer[l_buffer++] +=
785 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
786 p_aout->s32_buffer[l_buffer++] +=
787 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
789 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
790 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */
791 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) )
793 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */
794 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1));
797 l_units -= p_aout->fifo[i_fifo].l_units;
799 vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock );
800 p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame;
801 vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait );
802 vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
804 /* p_aout->fifo[i_fifo].b_start_frame = 1; */
805 p_aout->fifo[i_fifo].l_next_frame += 1;
806 p_aout->fifo[i_fifo].l_next_frame &= AOUT_FIFO_SIZE;
807 p_aout->fifo[i_fifo].b_next_frame = 0;
813 intf_DbgMsg("aout debug: unknown fifo type (%i)\n", p_aout->fifo[i_fifo].i_type);
817 vlc_mutex_unlock( &p_aout->fifos_lock );
819 l_buffer_limit = p_aout->l_units << 1 ; /* p_aout->b_stereo == 1 */
821 for ( l_buffer = 0; l_buffer < l_buffer_limit; l_buffer++ )
823 ((u8 *)p_aout->buffer)[l_buffer] = (u8)( (p_aout->s32_buffer[l_buffer] / 256) + 128 );
824 p_aout->s32_buffer[l_buffer] = 0;
826 l_bytes = p_aout->p_sys_getbufinfo( p_aout, l_buffer_limit );
827 p_aout->date = mdate() + ((((mtime_t)(l_bytes / 2 )) * 1000000) / ((mtime_t)p_aout->l_rate)); /* sizeof(u8) << (p_aout->b_stereo) == 2 */
828 p_aout->p_sys_playsamples( p_aout, (byte_t *)p_aout->buffer, l_buffer_limit * sizeof(u8) );
829 if ( l_bytes > (l_buffer_limit * sizeof(u8)) )
831 msleep( p_aout->l_msleep );
835 vlc_mutex_lock( &p_aout->fifos_lock );
836 for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
838 switch ( p_aout->fifo[i_fifo].i_type )
840 case AOUT_EMPTY_FIFO:
843 case AOUT_INTF_MONO_FIFO:
844 case AOUT_INTF_STEREO_FIFO:
845 free( p_aout->fifo[i_fifo].buffer ); /* !! */
846 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
847 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
850 case AOUT_ADEC_MONO_FIFO:
851 case AOUT_ADEC_STEREO_FIFO:
852 free( p_aout->fifo[i_fifo].buffer );
853 free( p_aout->fifo[i_fifo].date );
854 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
855 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
862 vlc_mutex_unlock( &p_aout->fifos_lock );
866 void aout_Thread_S16_Mono( aout_thread_t * p_aout )
870 void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
873 long l_buffer, l_buffer_limit;
874 long l_units, l_bytes;
876 intf_DbgMsg("adec debug: ********aout_Thread_S16_Stereo********\n");
877 intf_DbgMsg("adec debug: running audio output thread (%p) (pid == %i)\n", p_aout, getpid());
879 /* As the s32_buffer was created with calloc(), we don't have to set this
880 * memory to zero and we can immediately jump into the thread's loop */
881 while ( !p_aout->b_die )
883 vlc_mutex_lock( &p_aout->fifos_lock );
884 for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
886 switch ( p_aout->fifo[i_fifo].i_type )
888 case AOUT_EMPTY_FIFO:
891 case AOUT_INTF_MONO_FIFO:
892 if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units )
895 while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->b_stereo == 1 */
897 p_aout->s32_buffer[l_buffer++] +=
898 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
899 p_aout->s32_buffer[l_buffer++] +=
900 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
901 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
903 p_aout->fifo[i_fifo].l_units -= p_aout->l_units;
908 while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->b_stereo == 1 */
910 p_aout->s32_buffer[l_buffer++] +=
911 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
912 p_aout->s32_buffer[l_buffer++] +=
913 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
914 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
916 free( p_aout->fifo[i_fifo].buffer ); /* !! */
917 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
918 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); /* !! */
922 case AOUT_INTF_STEREO_FIFO:
923 if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units )
926 while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->b_stereo == 1 */
928 p_aout->s32_buffer[l_buffer++] +=
929 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
930 p_aout->s32_buffer[l_buffer++] +=
931 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
932 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
934 p_aout->fifo[i_fifo].l_units -= p_aout->l_units;
939 while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->b_stereo == 1 */
941 p_aout->s32_buffer[l_buffer++] +=
942 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
943 p_aout->s32_buffer[l_buffer++] +=
944 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
945 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
947 free( p_aout->fifo[i_fifo].buffer ); /* !! */
948 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
949 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); /* !! */
953 case AOUT_ADEC_MONO_FIFO:
954 if ( p_aout->fifo[i_fifo].b_die )
956 free( p_aout->fifo[i_fifo].buffer );
957 free( p_aout->fifo[i_fifo].date );
958 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
959 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
963 l_units = p_aout->l_units;
965 while ( l_units > 0 )
967 if ( !p_aout->fifo[i_fifo].b_next_frame )
969 if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) )
975 if ( p_aout->fifo[i_fifo].l_units > l_units )
977 l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */
978 while ( l_buffer < l_buffer_limit )
980 p_aout->s32_buffer[l_buffer++] +=
981 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
982 p_aout->s32_buffer[l_buffer++] +=
983 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
985 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
986 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */
987 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) )
989 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */
990 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0));
993 p_aout->fifo[i_fifo].l_units -= l_units;
998 l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1);
999 /* p_aout->b_stereo == 1 */
1000 while ( l_buffer < l_buffer_limit )
1002 p_aout->s32_buffer[l_buffer++] +=
1003 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
1004 p_aout->s32_buffer[l_buffer++] +=
1005 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
1007 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
1008 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */
1009 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) )
1011 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */
1012 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0));
1015 l_units -= p_aout->fifo[i_fifo].l_units;
1017 vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock );
1018 p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame;
1019 vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait );
1020 vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
1022 /* p_aout->fifo[i_fifo].b_start_frame = 1; */
1023 p_aout->fifo[i_fifo].l_next_frame += 1;
1024 p_aout->fifo[i_fifo].l_next_frame &= AOUT_FIFO_SIZE;
1025 p_aout->fifo[i_fifo].b_next_frame = 0;
1030 case AOUT_ADEC_STEREO_FIFO:
1031 if ( p_aout->fifo[i_fifo].b_die )
1033 free( p_aout->fifo[i_fifo].buffer );
1034 free( p_aout->fifo[i_fifo].date );
1035 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
1036 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
1040 l_units = p_aout->l_units;
1042 while ( l_units > 0 )
1044 if ( !p_aout->fifo[i_fifo].b_next_frame )
1046 if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) )
1052 if ( p_aout->fifo[i_fifo].l_units > l_units )
1054 l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */
1055 while ( l_buffer < l_buffer_limit )
1057 p_aout->s32_buffer[l_buffer++] +=
1058 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
1059 p_aout->s32_buffer[l_buffer++] +=
1060 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
1062 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
1063 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */
1064 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) )
1066 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */
1067 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1));
1070 p_aout->fifo[i_fifo].l_units -= l_units;
1075 l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1);
1076 /* p_aout->b_stereo == 1 */
1077 while ( l_buffer < l_buffer_limit )
1079 p_aout->s32_buffer[l_buffer++] +=
1080 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
1081 p_aout->s32_buffer[l_buffer++] +=
1082 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
1084 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
1085 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */
1086 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) )
1088 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */
1089 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1));
1092 l_units -= p_aout->fifo[i_fifo].l_units;
1094 vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock );
1095 p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame;
1096 vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait );
1097 vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
1099 /* p_aout->fifo[i_fifo].b_start_frame = 1; */
1100 p_aout->fifo[i_fifo].l_next_frame += 1;
1101 p_aout->fifo[i_fifo].l_next_frame &= AOUT_FIFO_SIZE;
1102 p_aout->fifo[i_fifo].b_next_frame = 0;
1108 intf_DbgMsg("aout debug: unknown fifo type (%i)\n", p_aout->fifo[i_fifo].i_type);
1112 vlc_mutex_unlock( &p_aout->fifos_lock );
1114 l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */
1116 for ( l_buffer = 0; l_buffer < l_buffer_limit; l_buffer++ )
1118 ((s16 *)p_aout->buffer)[l_buffer] = (s16)( p_aout->s32_buffer[l_buffer] / AOUT_MAX_FIFOS );
1119 p_aout->s32_buffer[l_buffer] = 0;
1122 l_bytes = p_aout->p_sys_getbufinfo( p_aout, l_buffer_limit );
1123 p_aout->date = -1000000 + mdate() + ((((mtime_t)(l_bytes / 4)) * 1000000) / ((mtime_t)p_aout->l_rate)); /* sizeof(s16) << (p_aout->b_stereo) == 4 */
1124 p_aout->p_sys_playsamples( p_aout, (byte_t *)p_aout->buffer, l_buffer_limit * sizeof(s16) );
1125 if ( l_bytes > (l_buffer_limit * sizeof(s16)) )
1127 msleep( p_aout->l_msleep );
1131 vlc_mutex_lock( &p_aout->fifos_lock );
1132 for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
1134 switch ( p_aout->fifo[i_fifo].i_type )
1136 case AOUT_EMPTY_FIFO:
1139 case AOUT_INTF_MONO_FIFO:
1140 case AOUT_INTF_STEREO_FIFO:
1141 free( p_aout->fifo[i_fifo].buffer ); /* !! */
1142 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
1143 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
1146 case AOUT_ADEC_MONO_FIFO:
1147 case AOUT_ADEC_STEREO_FIFO:
1148 free( p_aout->fifo[i_fifo].buffer );
1149 free( p_aout->fifo[i_fifo].date );
1150 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
1151 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
1158 vlc_mutex_unlock( &p_aout->fifos_lock );
1161 void aout_Thread_U16_Mono( aout_thread_t * p_aout )
1165 void aout_Thread_U16_Stereo( aout_thread_t * p_aout )