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 *****************************************************************************/
41 #include <unistd.h> /* getpid() */
43 #include <stdio.h> /* "intf_msg.h" */
44 #include <stdlib.h> /* calloc(), malloc(), free() */
49 #include "mtime.h" /* mtime_t, mdate(), msleep() */
52 #include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
54 #include "audio_output.h"
57 /*****************************************************************************
59 *****************************************************************************/
61 static int aout_SpawnThread( aout_thread_t * p_aout );
63 /* Creating as much aout_Thread functions as configurations is one solution,
64 * examining the different cases in the Thread loop of an unique function is
65 * another. I chose the first solution. */
66 void aout_Thread_S8_Mono ( aout_thread_t * p_aout );
67 void aout_Thread_U8_Mono ( aout_thread_t * p_aout );
68 void aout_Thread_S16_Mono ( aout_thread_t * p_aout );
69 void aout_Thread_U16_Mono ( aout_thread_t * p_aout );
70 void aout_Thread_S8_Stereo ( aout_thread_t * p_aout );
71 void aout_Thread_U8_Stereo ( aout_thread_t * p_aout );
72 void aout_Thread_S16_Stereo ( aout_thread_t * p_aout );
73 void aout_Thread_U16_Stereo ( aout_thread_t * p_aout );
75 static __inline__ void InitializeIncrement( aout_increment_t * p_increment, long l_numerator, long l_denominator );
76 static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, mtime_t aout_date );
78 /*****************************************************************************
79 * aout_CreateThread: initialize audio thread
80 *****************************************************************************/
81 aout_thread_t *aout_CreateThread( int *pi_status )
83 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 /* Request an interface plugin */
97 psz_method = main_GetPszVariable( AOUT_METHOD_VAR, AOUT_DEFAULT_METHOD );
99 if( RequestPlugin( &p_aout->aout_plugin, "aout", psz_method ) )
101 intf_ErrMsg( "error: could not open audio plugin aout_%s.so\n", psz_method );
107 p_aout->p_sys_open = GetPluginFunction( p_aout->aout_plugin, "aout_SysOpen" );
108 p_aout->p_sys_reset = GetPluginFunction( p_aout->aout_plugin, "aout_SysReset" );
109 p_aout->p_sys_setformat = GetPluginFunction( p_aout->aout_plugin, "aout_SysSetFormat" );
110 p_aout->p_sys_setchannels = GetPluginFunction( p_aout->aout_plugin, "aout_SysSetChannels" );
111 p_aout->p_sys_setrate = GetPluginFunction( p_aout->aout_plugin, "aout_SysSetRate" );
112 p_aout->p_sys_getbufinfo = GetPluginFunction( p_aout->aout_plugin, "aout_SysGetBufInfo" );
113 p_aout->p_sys_playsamples = GetPluginFunction( p_aout->aout_plugin, "aout_SysPlaySamples" );
114 p_aout->p_sys_close = GetPluginFunction( p_aout->aout_plugin, "aout_SysClose" );
117 * Initialize audio device
119 if ( p_aout->p_sys_open( p_aout ) )
121 TrashPlugin( p_aout->aout_plugin );
126 p_aout->b_stereo = ( p_aout->i_channels == 2 ) ? 1 : 0; /* FIXME: only works
127 for i_channels == 1 or 2 ??*/
129 if ( p_aout->p_sys_reset( p_aout ) )
131 p_aout->p_sys_close( p_aout );
132 TrashPlugin( p_aout->aout_plugin );
136 if ( p_aout->p_sys_setformat( p_aout ) )
138 p_aout->p_sys_close( p_aout );
139 TrashPlugin( p_aout->aout_plugin );
143 if ( p_aout->p_sys_setchannels( p_aout ) )
145 p_aout->p_sys_close( p_aout );
146 TrashPlugin( p_aout->aout_plugin );
150 if ( p_aout->p_sys_setrate( p_aout ) )
152 p_aout->p_sys_close( p_aout );
153 TrashPlugin( p_aout->aout_plugin );
158 /* FIXME: maybe it would be cleaner to change SpawnThread prototype
159 * see vout to handle status correctly ?? however, it is not critical since
160 * this thread is only called in main and all calls are blocking */
161 if( aout_SpawnThread( p_aout ) )
163 p_aout->p_sys_close( p_aout );
164 TrashPlugin( p_aout->aout_plugin );
172 /*****************************************************************************
174 *****************************************************************************/
175 static int aout_SpawnThread( aout_thread_t * p_aout )
179 void * aout_thread = NULL;
181 intf_DbgMsg("aout debug: spawning audio output thread (%p)\n", p_aout);
183 /* We want the audio output thread to live */
185 p_aout->b_active = 1;
187 /* Initialize the fifos lock */
188 vlc_mutex_init( &p_aout->fifos_lock );
189 /* Initialize audio fifos : set all fifos as empty and initialize locks */
190 for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
192 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO;
193 vlc_mutex_init( &p_aout->fifo[i_fifo].data_lock );
194 vlc_cond_init( &p_aout->fifo[i_fifo].data_wait );
197 /* Compute the size (in audio units) of the audio output buffer. Although
198 * AOUT_BUFFER_DURATION is given in microseconds, the output rate is given
199 * in Hz, that's why we need to divide by 10^6 microseconds (1 second) */
200 p_aout->l_units = (long)( ((s64)p_aout->l_rate * AOUT_BUFFER_DURATION) / 1000000 );
201 p_aout->l_msleep = (long)( ((s64)p_aout->l_units * 1000000) / (s64)p_aout->l_rate );
203 /* Make aout_thread point to the right thread function, and compute the
204 * byte size of the audio output buffer */
205 switch ( p_aout->i_channels )
207 /* Audio output is mono */
209 switch ( p_aout->i_format )
212 l_bytes = 1 * sizeof(u8) * p_aout->l_units;
213 aout_thread = (void *)aout_Thread_U8_Mono;
217 l_bytes = 1 * sizeof(s8) * p_aout->l_units;
218 aout_thread = (void *)aout_Thread_S8_Mono;
221 case AOUT_FMT_U16_LE:
222 case AOUT_FMT_U16_BE:
223 l_bytes = 1 * sizeof(u16) * p_aout->l_units;
224 aout_thread = (void *)aout_Thread_U16_Mono;
227 case AOUT_FMT_S16_LE:
228 case AOUT_FMT_S16_BE:
229 l_bytes = 1 * sizeof(s16) * p_aout->l_units;
230 aout_thread = (void *)aout_Thread_S16_Mono;
234 intf_ErrMsg( "aout error: unknown audio output format (%i)\n",
240 /* Audio output is stereo */
242 switch ( p_aout->i_format )
245 l_bytes = 2 * sizeof(u8) * p_aout->l_units;
246 aout_thread = (void *)aout_Thread_U8_Stereo;
250 l_bytes = 2 * sizeof(s8) * p_aout->l_units;
251 aout_thread = (void *)aout_Thread_S8_Stereo;
254 case AOUT_FMT_U16_LE:
255 case AOUT_FMT_U16_BE:
256 l_bytes = 2 * sizeof(u16) * p_aout->l_units;
257 aout_thread = (void *)aout_Thread_U16_Stereo;
260 case AOUT_FMT_S16_LE:
261 case AOUT_FMT_S16_BE:
262 l_bytes = 2 * sizeof(s16) * p_aout->l_units;
263 aout_thread = (void *)aout_Thread_S16_Stereo;
267 intf_ErrMsg("aout error: unknown audio output format (%i)\n",
274 intf_ErrMsg("aout error: unknown number of audio channels (%i)\n",
275 p_aout->i_channels );
279 /* Allocate the memory needed by the audio output buffers, and set to zero
280 * the s32 buffer's memory */
281 if ( (p_aout->buffer = malloc(l_bytes)) == NULL )
283 intf_ErrMsg("aout error: not enough memory to create the output buffer\n");
286 if ( (p_aout->s32_buffer = (s32 *)calloc(p_aout->l_units, sizeof(s32) << ( p_aout->b_stereo))) == NULL )
288 intf_ErrMsg("aout error: not enough memory to create the s32 output buffer\n");
289 free( p_aout->buffer );
293 /* Before launching the thread, we try to predict the date of the first
294 * audio unit in the first output buffer */
295 p_aout->date = mdate() - 1000000;
297 /* Launch the thread */
298 if ( vlc_thread_create( &p_aout->thread_id, "audio output", (vlc_thread_func_t)aout_thread, p_aout ) )
300 intf_ErrMsg("aout error: can't spawn audio output thread (%p)\n", p_aout);
301 free( p_aout->buffer );
302 free( p_aout->s32_buffer );
306 intf_DbgMsg("aout debug: audio output thread (%p) spawned\n", p_aout);
310 /*****************************************************************************
312 *****************************************************************************/
313 void aout_DestroyThread( aout_thread_t * p_aout, int *pi_status )
315 /* FIXME: pi_status is not handled correctly: check vout how to do!?? */
317 intf_DbgMsg("aout debug: requesting termination of audio output thread (%p)\n", p_aout);
319 /* Ask thread to kill itself and wait until it's done */
321 vlc_thread_join( p_aout->thread_id ); /* only if pi_status is NULL */
323 /* Free the allocated memory */
324 free( p_aout->buffer );
325 free( p_aout->s32_buffer );
327 /* Free the structure */
328 p_aout->p_sys_close( p_aout );
329 intf_DbgMsg("aout debug: audio device (%s) closed\n", p_aout->psz_device);
332 TrashPlugin( p_aout->aout_plugin );
338 /*****************************************************************************
340 *****************************************************************************/
341 aout_fifo_t * aout_CreateFifo( aout_thread_t * p_aout, aout_fifo_t * p_fifo )
345 /* Take the fifos lock */
346 vlc_mutex_lock( &p_aout->fifos_lock );
348 /* Looking for a free fifo structure */
349 for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
351 if ( p_aout->fifo[i_fifo].i_type == AOUT_EMPTY_FIFO)
356 if ( i_fifo == AOUT_MAX_FIFOS )
358 intf_ErrMsg("aout error: no empty fifo available\n");
359 vlc_mutex_unlock( &p_aout->fifos_lock );
363 /* Initialize the new fifo structure */
364 switch ( p_aout->fifo[i_fifo].i_type = p_fifo->i_type )
366 case AOUT_INTF_MONO_FIFO:
367 case AOUT_INTF_STEREO_FIFO:
368 p_aout->fifo[i_fifo].b_die = 0;
370 p_aout->fifo[i_fifo].i_channels = p_fifo->i_channels;
371 p_aout->fifo[i_fifo].b_stereo = p_fifo->b_stereo;
372 p_aout->fifo[i_fifo].l_rate = p_fifo->l_rate;
374 p_aout->fifo[i_fifo].buffer = p_fifo->buffer;
376 p_aout->fifo[i_fifo].l_unit = 0;
377 InitializeIncrement( &p_aout->fifo[i_fifo].unit_increment, p_fifo->l_rate, p_aout->l_rate );
378 p_aout->fifo[i_fifo].l_units = p_fifo->l_units;
381 case AOUT_ADEC_MONO_FIFO:
382 case AOUT_ADEC_STEREO_FIFO:
383 p_aout->fifo[i_fifo].b_die = 0;
385 p_aout->fifo[i_fifo].i_channels = p_fifo->i_channels;
386 p_aout->fifo[i_fifo].b_stereo = p_fifo->b_stereo;
387 p_aout->fifo[i_fifo].l_rate = p_fifo->l_rate;
389 p_aout->fifo[i_fifo].l_frame_size = p_fifo->l_frame_size;
390 /* Allocate the memory needed to store the audio frames. As the
391 * fifo is a rotative fifo, we must be able to find out whether the
392 * fifo is full or empty, that's why we must in fact allocate memory
393 * for (AOUT_FIFO_SIZE+1) audio frames. */
394 if ( (p_aout->fifo[i_fifo].buffer = malloc( sizeof(s16)*(AOUT_FIFO_SIZE+1)*p_fifo->l_frame_size )) == NULL )
396 intf_ErrMsg("aout error: not enough memory to create the frames buffer\n");
397 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO;
398 vlc_mutex_unlock( &p_aout->fifos_lock );
402 /* Allocate the memory needed to store the dates of the frames */
403 if ( (p_aout->fifo[i_fifo].date = (mtime_t *)malloc( sizeof(mtime_t)*(AOUT_FIFO_SIZE+1) )) == NULL )
405 intf_ErrMsg("aout error: not enough memory to create the dates buffer\n");
406 free( p_aout->fifo[i_fifo].buffer );
407 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO;
408 vlc_mutex_unlock( &p_aout->fifos_lock );
412 /* Set the fifo's buffer as empty (the first frame that is to be
413 * played is also the first frame that is not to be played) */
414 p_aout->fifo[i_fifo].l_start_frame = 0;
415 /* p_aout->fifo[i_fifo].l_next_frame = 0; */
416 p_aout->fifo[i_fifo].l_end_frame = 0;
418 /* Waiting for the audio decoder to compute enough frames to work
419 * out the fifo's current rate (as soon as the decoder has decoded
420 * enough frames, the members of the fifo structure that are not
421 * initialized now will be calculated) */
422 p_aout->fifo[i_fifo].b_start_frame = 0;
423 p_aout->fifo[i_fifo].b_next_frame = 0;
427 intf_ErrMsg("aout error: unknown fifo type (%i)\n", p_aout->fifo[i_fifo].i_type);
428 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO;
429 vlc_mutex_unlock( &p_aout->fifos_lock );
433 /* Release the fifos lock */
434 vlc_mutex_unlock( &p_aout->fifos_lock );
436 /* Return the pointer to the fifo structure */
437 intf_DbgMsg("aout debug: audio output fifo (%p) allocated\n", &p_aout->fifo[i_fifo]);
438 return( &p_aout->fifo[i_fifo] );
441 /*****************************************************************************
443 *****************************************************************************/
444 void aout_DestroyFifo( aout_fifo_t * p_fifo )
446 intf_DbgMsg("aout debug: requesting destruction of audio output fifo (%p)\n", p_fifo);
450 /* Here are the local macros */
452 #define UPDATE_INCREMENT( increment, integer ) \
453 if ( ((increment).l_remainder += (increment).l_euclidean_remainder) >= 0 )\
455 (integer) += (increment).l_euclidean_integer + 1; \
456 (increment).l_remainder -= (increment).l_euclidean_denominator; \
460 (integer) += (increment).l_euclidean_integer; \
463 /* Following functions are local */
465 /*****************************************************************************
466 * InitializeIncrement
467 *****************************************************************************/
468 static __inline__ void InitializeIncrement( aout_increment_t * p_increment, long l_numerator, long l_denominator )
470 p_increment->l_remainder = -l_denominator;
472 p_increment->l_euclidean_integer = 0;
473 while ( l_numerator >= l_denominator )
475 p_increment->l_euclidean_integer++;
476 l_numerator -= l_denominator;
479 p_increment->l_euclidean_remainder = l_numerator;
481 p_increment->l_euclidean_denominator = l_denominator;
484 /*****************************************************************************
486 *****************************************************************************/
487 static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, mtime_t aout_date )
489 long l_units, l_rate;
491 /* We take the lock */
492 vlc_mutex_lock( &p_fifo->data_lock );
494 /* Are we looking for a dated start frame ? */
495 if ( !p_fifo->b_start_frame )
497 while ( p_fifo->l_start_frame != p_fifo->l_end_frame )
499 if ( p_fifo->date[p_fifo->l_start_frame] != LAST_MDATE )
501 p_fifo->b_start_frame = 1;
502 p_fifo->l_next_frame = (p_fifo->l_start_frame + 1) & AOUT_FIFO_SIZE;
503 p_fifo->l_unit = p_fifo->l_start_frame * (p_fifo->l_frame_size >> (p_fifo->b_stereo));
506 p_fifo->l_start_frame = (p_fifo->l_start_frame + 1) & AOUT_FIFO_SIZE;
509 if ( p_fifo->l_start_frame == p_fifo->l_end_frame )
511 vlc_mutex_unlock( &p_fifo->data_lock );
516 /* We are looking for the next dated frame */
517 /* FIXME : is the output fifo full ?? */
518 while ( !p_fifo->b_next_frame )
520 while ( p_fifo->l_next_frame != p_fifo->l_end_frame )
522 if ( p_fifo->date[p_fifo->l_next_frame] != LAST_MDATE )
524 p_fifo->b_next_frame = 1;
527 p_fifo->l_next_frame = (p_fifo->l_next_frame + 1) & AOUT_FIFO_SIZE;
530 while ( p_fifo->l_next_frame == p_fifo->l_end_frame )
532 vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
535 vlc_mutex_unlock( &p_fifo->data_lock );
541 l_units = ((p_fifo->l_next_frame - p_fifo->l_start_frame) & AOUT_FIFO_SIZE) * (p_fifo->l_frame_size >> (p_fifo->b_stereo));
543 l_rate = p_fifo->l_rate + ((aout_date - p_fifo->date[p_fifo->l_start_frame]) / 256);
544 // fprintf( stderr, "aout debug: %lli (%li);\n", aout_date - p_fifo->date[p_fifo->l_start_frame], l_rate );
546 InitializeIncrement( &p_fifo->unit_increment, l_rate, p_aout->l_rate );
548 p_fifo->l_units = (((l_units - (p_fifo->l_unit -
549 (p_fifo->l_start_frame * (p_fifo->l_frame_size >> (p_fifo->b_stereo)))))
550 * p_aout->l_rate) / l_rate) + 1;
552 /* We release the lock before leaving */
553 vlc_mutex_unlock( &p_fifo->data_lock );
557 void aout_Thread_S8_Mono( aout_thread_t * p_aout )
561 void aout_Thread_S8_Stereo( aout_thread_t * p_aout )
565 void aout_Thread_U8_Mono( aout_thread_t * p_aout )
569 void aout_Thread_U8_Stereo( aout_thread_t * p_aout )
572 long l_buffer, l_buffer_limit;
573 long l_units, l_bytes;
575 intf_DbgMsg("adec debug: ********aout_Thread_U8_Stereo********\n");
576 intf_DbgMsg("adec debug: running audio output thread (%p) (pid == %i)\n", p_aout, getpid());
578 /* As the s32_buffer was created with calloc(), we don't have to set this
579 * memory to zero and we can immediately jump into the thread's loop */
580 while ( !p_aout->b_die )
582 vlc_mutex_lock( &p_aout->fifos_lock );
583 for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
585 switch ( p_aout->fifo[i_fifo].i_type )
587 case AOUT_EMPTY_FIFO:
590 case AOUT_INTF_MONO_FIFO:
591 if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units )
594 while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->b_stereo == 1 */
596 p_aout->s32_buffer[l_buffer++] +=
597 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
598 p_aout->s32_buffer[l_buffer++] +=
599 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
600 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
602 p_aout->fifo[i_fifo].l_units -= p_aout->l_units;
607 while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->b_stereo == 1 */
609 p_aout->s32_buffer[l_buffer++] +=
610 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
611 p_aout->s32_buffer[l_buffer++] +=
612 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
613 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
615 free( p_aout->fifo[i_fifo].buffer ); /* !! */
616 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
617 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); /* !! */
621 case AOUT_INTF_STEREO_FIFO:
622 if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units )
625 while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->b_stereo == 1 */
627 p_aout->s32_buffer[l_buffer++] +=
628 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
629 p_aout->s32_buffer[l_buffer++] +=
630 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
631 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
633 p_aout->fifo[i_fifo].l_units -= p_aout->l_units;
638 while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->b_stereo == 1 */
640 p_aout->s32_buffer[l_buffer++] +=
641 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
642 p_aout->s32_buffer[l_buffer++] +=
643 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
644 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
646 free( p_aout->fifo[i_fifo].buffer ); /* !! */
647 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
648 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); /* !! */
652 case AOUT_ADEC_MONO_FIFO:
653 if ( p_aout->fifo[i_fifo].b_die )
655 free( p_aout->fifo[i_fifo].buffer );
656 free( p_aout->fifo[i_fifo].date );
657 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
658 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
662 l_units = p_aout->l_units;
664 while ( l_units > 0 )
666 if ( !p_aout->fifo[i_fifo].b_next_frame )
668 if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) )
674 if ( p_aout->fifo[i_fifo].l_units > l_units )
676 l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */
677 while ( l_buffer < l_buffer_limit )
679 p_aout->s32_buffer[l_buffer++] +=
680 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
681 p_aout->s32_buffer[l_buffer++] +=
682 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
684 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
685 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */
686 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) )
688 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */
689 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0));
692 p_aout->fifo[i_fifo].l_units -= l_units;
697 l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1);
698 /* p_aout->b_stereo == 1 */
699 while ( l_buffer < l_buffer_limit )
701 p_aout->s32_buffer[l_buffer++] +=
702 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
703 p_aout->s32_buffer[l_buffer++] +=
704 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
706 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
707 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */
708 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) )
710 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */
711 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0));
714 l_units -= p_aout->fifo[i_fifo].l_units;
716 vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock );
717 p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame;
718 vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait );
719 vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
721 /* p_aout->fifo[i_fifo].b_start_frame = 1; */
722 p_aout->fifo[i_fifo].l_next_frame += 1;
723 p_aout->fifo[i_fifo].l_next_frame &= AOUT_FIFO_SIZE;
724 p_aout->fifo[i_fifo].b_next_frame = 0;
729 case AOUT_ADEC_STEREO_FIFO:
730 if ( p_aout->fifo[i_fifo].b_die )
732 free( p_aout->fifo[i_fifo].buffer );
733 free( p_aout->fifo[i_fifo].date );
734 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
735 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
739 l_units = p_aout->l_units;
741 while ( l_units > 0 )
743 if ( !p_aout->fifo[i_fifo].b_next_frame )
745 if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) )
751 if ( p_aout->fifo[i_fifo].l_units > l_units )
753 l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */
754 while ( l_buffer < l_buffer_limit )
756 p_aout->s32_buffer[l_buffer++] +=
757 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
758 p_aout->s32_buffer[l_buffer++] +=
759 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
761 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
762 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */
763 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) )
765 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */
766 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1));
769 p_aout->fifo[i_fifo].l_units -= l_units;
774 l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1);
775 /* p_aout->b_stereo == 1 */
776 while ( l_buffer < l_buffer_limit )
778 p_aout->s32_buffer[l_buffer++] +=
779 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
780 p_aout->s32_buffer[l_buffer++] +=
781 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
783 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
784 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */
785 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) )
787 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */
788 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1));
791 l_units -= p_aout->fifo[i_fifo].l_units;
793 vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock );
794 p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame;
795 vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait );
796 vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
798 /* p_aout->fifo[i_fifo].b_start_frame = 1; */
799 p_aout->fifo[i_fifo].l_next_frame += 1;
800 p_aout->fifo[i_fifo].l_next_frame &= AOUT_FIFO_SIZE;
801 p_aout->fifo[i_fifo].b_next_frame = 0;
807 intf_DbgMsg("aout debug: unknown fifo type (%i)\n", p_aout->fifo[i_fifo].i_type);
811 vlc_mutex_unlock( &p_aout->fifos_lock );
813 l_buffer_limit = p_aout->l_units << 1 ; /* p_aout->b_stereo == 1 */
815 for ( l_buffer = 0; l_buffer < l_buffer_limit; l_buffer++ )
817 ((u8 *)p_aout->buffer)[l_buffer] = (u8)( (p_aout->s32_buffer[l_buffer] / 256) + 128 );
818 p_aout->s32_buffer[l_buffer] = 0;
820 l_bytes = p_aout->p_sys_getbufinfo( p_aout, l_buffer_limit );
821 p_aout->date = mdate() + ((((mtime_t)(l_bytes / 2 )) * 1000000) / ((mtime_t)p_aout->l_rate)); /* sizeof(u8) << (p_aout->b_stereo) == 2 */
822 p_aout->p_sys_playsamples( p_aout, (byte_t *)p_aout->buffer, l_buffer_limit * sizeof(u8) );
823 if ( l_bytes > (l_buffer_limit * sizeof(u8)) )
825 msleep( p_aout->l_msleep );
829 vlc_mutex_lock( &p_aout->fifos_lock );
830 for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
832 switch ( p_aout->fifo[i_fifo].i_type )
834 case AOUT_EMPTY_FIFO:
837 case AOUT_INTF_MONO_FIFO:
838 case AOUT_INTF_STEREO_FIFO:
839 free( p_aout->fifo[i_fifo].buffer ); /* !! */
840 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
841 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
844 case AOUT_ADEC_MONO_FIFO:
845 case AOUT_ADEC_STEREO_FIFO:
846 free( p_aout->fifo[i_fifo].buffer );
847 free( p_aout->fifo[i_fifo].date );
848 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
849 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
856 vlc_mutex_unlock( &p_aout->fifos_lock );
860 void aout_Thread_S16_Mono( aout_thread_t * p_aout )
864 void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
867 long l_buffer, l_buffer_limit;
868 long l_units, l_bytes;
870 intf_DbgMsg("adec debug: ********aout_Thread_S16_Stereo********\n");
871 intf_DbgMsg("adec debug: running audio output thread (%p) (pid == %i)\n", p_aout, getpid());
873 /* As the s32_buffer was created with calloc(), we don't have to set this
874 * memory to zero and we can immediately jump into the thread's loop */
875 while ( !p_aout->b_die )
877 vlc_mutex_lock( &p_aout->fifos_lock );
878 for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
880 switch ( p_aout->fifo[i_fifo].i_type )
882 case AOUT_EMPTY_FIFO:
885 case AOUT_INTF_MONO_FIFO:
886 if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units )
889 while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->b_stereo == 1 */
891 p_aout->s32_buffer[l_buffer++] +=
892 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
893 p_aout->s32_buffer[l_buffer++] +=
894 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
895 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
897 p_aout->fifo[i_fifo].l_units -= p_aout->l_units;
902 while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->b_stereo == 1 */
904 p_aout->s32_buffer[l_buffer++] +=
905 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
906 p_aout->s32_buffer[l_buffer++] +=
907 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
908 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
910 free( p_aout->fifo[i_fifo].buffer ); /* !! */
911 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
912 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); /* !! */
916 case AOUT_INTF_STEREO_FIFO:
917 if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units )
920 while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->b_stereo == 1 */
922 p_aout->s32_buffer[l_buffer++] +=
923 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
924 p_aout->s32_buffer[l_buffer++] +=
925 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
926 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
928 p_aout->fifo[i_fifo].l_units -= p_aout->l_units;
933 while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->b_stereo == 1 */
935 p_aout->s32_buffer[l_buffer++] +=
936 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
937 p_aout->s32_buffer[l_buffer++] +=
938 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
939 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
941 free( p_aout->fifo[i_fifo].buffer ); /* !! */
942 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
943 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); /* !! */
947 case AOUT_ADEC_MONO_FIFO:
948 if ( p_aout->fifo[i_fifo].b_die )
950 free( p_aout->fifo[i_fifo].buffer );
951 free( p_aout->fifo[i_fifo].date );
952 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
953 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
957 l_units = p_aout->l_units;
959 while ( l_units > 0 )
961 if ( !p_aout->fifo[i_fifo].b_next_frame )
963 if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) )
969 if ( p_aout->fifo[i_fifo].l_units > l_units )
971 l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */
972 while ( l_buffer < l_buffer_limit )
974 p_aout->s32_buffer[l_buffer++] +=
975 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
976 p_aout->s32_buffer[l_buffer++] +=
977 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
979 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
980 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */
981 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) )
983 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */
984 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0));
987 p_aout->fifo[i_fifo].l_units -= l_units;
992 l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1);
993 /* p_aout->b_stereo == 1 */
994 while ( l_buffer < l_buffer_limit )
996 p_aout->s32_buffer[l_buffer++] +=
997 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
998 p_aout->s32_buffer[l_buffer++] +=
999 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
1001 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
1002 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */
1003 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) )
1005 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */
1006 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0));
1009 l_units -= p_aout->fifo[i_fifo].l_units;
1011 vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock );
1012 p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame;
1013 vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait );
1014 vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
1016 /* p_aout->fifo[i_fifo].b_start_frame = 1; */
1017 p_aout->fifo[i_fifo].l_next_frame += 1;
1018 p_aout->fifo[i_fifo].l_next_frame &= AOUT_FIFO_SIZE;
1019 p_aout->fifo[i_fifo].b_next_frame = 0;
1024 case AOUT_ADEC_STEREO_FIFO:
1025 if ( p_aout->fifo[i_fifo].b_die )
1027 free( p_aout->fifo[i_fifo].buffer );
1028 free( p_aout->fifo[i_fifo].date );
1029 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
1030 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
1034 l_units = p_aout->l_units;
1036 while ( l_units > 0 )
1038 if ( !p_aout->fifo[i_fifo].b_next_frame )
1040 if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) )
1046 if ( p_aout->fifo[i_fifo].l_units > l_units )
1048 l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */
1049 while ( l_buffer < l_buffer_limit )
1051 p_aout->s32_buffer[l_buffer++] +=
1052 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
1053 p_aout->s32_buffer[l_buffer++] +=
1054 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
1056 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
1057 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */
1058 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) )
1060 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */
1061 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1));
1064 p_aout->fifo[i_fifo].l_units -= l_units;
1069 l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1);
1070 /* p_aout->b_stereo == 1 */
1071 while ( l_buffer < l_buffer_limit )
1073 p_aout->s32_buffer[l_buffer++] +=
1074 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
1075 p_aout->s32_buffer[l_buffer++] +=
1076 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
1078 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
1079 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */
1080 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) )
1082 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */
1083 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1));
1086 l_units -= p_aout->fifo[i_fifo].l_units;
1088 vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock );
1089 p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame;
1090 vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait );
1091 vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
1093 /* p_aout->fifo[i_fifo].b_start_frame = 1; */
1094 p_aout->fifo[i_fifo].l_next_frame += 1;
1095 p_aout->fifo[i_fifo].l_next_frame &= AOUT_FIFO_SIZE;
1096 p_aout->fifo[i_fifo].b_next_frame = 0;
1102 intf_DbgMsg("aout debug: unknown fifo type (%i)\n", p_aout->fifo[i_fifo].i_type);
1106 vlc_mutex_unlock( &p_aout->fifos_lock );
1108 l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */
1110 for ( l_buffer = 0; l_buffer < l_buffer_limit; l_buffer++ )
1112 ((s16 *)p_aout->buffer)[l_buffer] = (s16)( p_aout->s32_buffer[l_buffer] / AOUT_MAX_FIFOS );
1113 p_aout->s32_buffer[l_buffer] = 0;
1116 l_bytes = p_aout->p_sys_getbufinfo( p_aout, l_buffer_limit );
1117 p_aout->date = mdate() + ((((mtime_t)(l_bytes / 4)) * 1000000) / ((mtime_t)p_aout->l_rate)); /* sizeof(s16) << (p_aout->b_stereo) == 4 */
1118 p_aout->p_sys_playsamples( p_aout, (byte_t *)p_aout->buffer, l_buffer_limit * sizeof(s16) );
1119 if ( l_bytes > (l_buffer_limit * sizeof(s16)) )
1121 msleep( p_aout->l_msleep );
1125 vlc_mutex_lock( &p_aout->fifos_lock );
1126 for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
1128 switch ( p_aout->fifo[i_fifo].i_type )
1130 case AOUT_EMPTY_FIFO:
1133 case AOUT_INTF_MONO_FIFO:
1134 case AOUT_INTF_STEREO_FIFO:
1135 free( p_aout->fifo[i_fifo].buffer ); /* !! */
1136 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
1137 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
1140 case AOUT_ADEC_MONO_FIFO:
1141 case AOUT_ADEC_STEREO_FIFO:
1142 free( p_aout->fifo[i_fifo].buffer );
1143 free( p_aout->fifo[i_fifo].date );
1144 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
1145 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
1152 vlc_mutex_unlock( &p_aout->fifos_lock );
1155 void aout_Thread_U16_Mono( aout_thread_t * p_aout )
1159 void aout_Thread_U16_Stereo( aout_thread_t * p_aout )