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() */
46 #include "mtime.h" /* mtime_t, mdate(), msleep() */
50 #include "intf_msg.h" /* intf_DbgMsg(), intf_ErrMsg() */
52 #include "audio_output.h"
55 /*****************************************************************************
57 *****************************************************************************/
59 static int aout_SpawnThread( aout_thread_t * p_aout );
61 /* Creating as much aout_Thread functions as configurations is one solution,
62 * examining the different cases in the Thread loop of an unique function is
63 * another. I chose the first solution. */
64 void aout_Thread_S8_Mono ( aout_thread_t * p_aout );
65 void aout_Thread_U8_Mono ( aout_thread_t * p_aout );
66 void aout_Thread_S16_Mono ( aout_thread_t * p_aout );
67 void aout_Thread_U16_Mono ( aout_thread_t * p_aout );
68 void aout_Thread_S8_Stereo ( aout_thread_t * p_aout );
69 void aout_Thread_U8_Stereo ( aout_thread_t * p_aout );
70 void aout_Thread_S16_Stereo ( aout_thread_t * p_aout );
71 void aout_Thread_U16_Stereo ( aout_thread_t * p_aout );
73 static __inline__ void InitializeIncrement( aout_increment_t * p_increment, long l_numerator, long l_denominator );
74 static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, mtime_t aout_date );
76 /*****************************************************************************
77 * aout_CreateThread: initialize audio thread
78 *****************************************************************************/
79 aout_thread_t *aout_CreateThread( int *pi_status )
81 aout_thread_t * p_aout; /* thread descriptor */
84 int i_status; /* thread status */
87 /* Allocate descriptor */
88 p_aout = (aout_thread_t *) malloc( sizeof(aout_thread_t) );
94 /* Request an interface plugin */
95 psz_method = main_GetPszVariable( AOUT_METHOD_VAR, AOUT_DEFAULT_METHOD );
96 p_aout->p_aout_plugin = RequestPlugin( "aout", psz_method );
98 if( !p_aout->p_aout_plugin )
100 intf_ErrMsg( "error: could not open audio plugin aout_%s.so\n", psz_method );
106 p_aout->p_sys_open = GetPluginFunction( p_aout->p_aout_plugin, "aout_SysOpen" );
107 p_aout->p_sys_reset = GetPluginFunction( p_aout->p_aout_plugin, "aout_SysReset" );
108 p_aout->p_sys_setformat = GetPluginFunction( p_aout->p_aout_plugin, "aout_SysSetFormat" );
109 p_aout->p_sys_setchannels = GetPluginFunction( p_aout->p_aout_plugin, "aout_SysSetChannels" );
110 p_aout->p_sys_setrate = GetPluginFunction( p_aout->p_aout_plugin, "aout_SysSetRate" );
111 p_aout->p_sys_getbufinfo = GetPluginFunction( p_aout->p_aout_plugin, "aout_SysGetBufInfo" );
112 p_aout->p_sys_playsamples = GetPluginFunction( p_aout->p_aout_plugin, "aout_SysPlaySamples" );
113 p_aout->p_sys_close = GetPluginFunction( p_aout->p_aout_plugin, "aout_SysClose" );
116 * Initialize audio device
118 if ( p_aout->p_sys_open( p_aout ) )
120 TrashPlugin( p_aout->p_aout_plugin );
125 p_aout->b_stereo = ( p_aout->i_channels == 2 ) ? 1 : 0; /* FIXME: only works
126 for i_channels == 1 or 2 ??*/
128 if ( p_aout->p_sys_reset( p_aout ) )
130 p_aout->p_sys_close( p_aout );
131 TrashPlugin( p_aout->p_aout_plugin );
135 if ( p_aout->p_sys_setformat( p_aout ) )
137 p_aout->p_sys_close( p_aout );
138 TrashPlugin( p_aout->p_aout_plugin );
142 if ( p_aout->p_sys_setchannels( p_aout ) )
144 p_aout->p_sys_close( p_aout );
145 TrashPlugin( p_aout->p_aout_plugin );
149 if ( p_aout->p_sys_setrate( p_aout ) )
151 p_aout->p_sys_close( p_aout );
152 TrashPlugin( p_aout->p_aout_plugin );
157 /* FIXME: maybe it would be cleaner to change SpawnThread prototype
158 * see vout to handle status correctly ?? however, it is not critical since
159 * this thread is only called in main and all calls are blocking */
160 if( aout_SpawnThread( p_aout ) )
162 p_aout->p_sys_close( p_aout );
163 TrashPlugin( p_aout->p_aout_plugin );
171 /*****************************************************************************
173 *****************************************************************************/
174 static int aout_SpawnThread( aout_thread_t * p_aout )
178 void * aout_thread = NULL;
180 intf_DbgMsg("aout debug: spawning audio output thread (%p)\n", p_aout);
182 /* We want the audio output thread to live */
185 /* Initialize the fifos lock */
186 vlc_mutex_init( &p_aout->fifos_lock );
187 /* Initialize audio fifos : set all fifos as empty and initialize locks */
188 for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
190 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO;
191 vlc_mutex_init( &p_aout->fifo[i_fifo].data_lock );
192 vlc_cond_init( &p_aout->fifo[i_fifo].data_wait );
195 /* Compute the size (in audio units) of the audio output buffer. Although
196 * AOUT_BUFFER_DURATION is given in microseconds, the output rate is given
197 * in Hz, that's why we need to divide by 10^6 microseconds (1 second) */
198 p_aout->l_units = (long)( ((s64)p_aout->l_rate * AOUT_BUFFER_DURATION) / 1000000 );
199 p_aout->l_msleep = (long)( ((s64)p_aout->l_units * 1000000) / (s64)p_aout->l_rate );
201 /* Make aout_thread point to the right thread function, and compute the
202 * byte size of the audio output buffer */
203 switch ( p_aout->i_channels )
205 /* Audio output is mono */
207 switch ( p_aout->i_format )
210 l_bytes = 1 * sizeof(u8) * p_aout->l_units;
211 aout_thread = (void *)aout_Thread_U8_Mono;
215 l_bytes = 1 * sizeof(s8) * p_aout->l_units;
216 aout_thread = (void *)aout_Thread_S8_Mono;
219 case AOUT_FMT_U16_LE:
220 case AOUT_FMT_U16_BE:
221 l_bytes = 1 * sizeof(u16) * p_aout->l_units;
222 aout_thread = (void *)aout_Thread_U16_Mono;
225 case AOUT_FMT_S16_LE:
226 case AOUT_FMT_S16_BE:
227 l_bytes = 1 * sizeof(s16) * p_aout->l_units;
228 aout_thread = (void *)aout_Thread_S16_Mono;
232 intf_ErrMsg( "aout error: unknown audio output format (%i)\n",
238 /* Audio output is stereo */
240 switch ( p_aout->i_format )
243 l_bytes = 2 * sizeof(u8) * p_aout->l_units;
244 aout_thread = (void *)aout_Thread_U8_Stereo;
248 l_bytes = 2 * sizeof(s8) * p_aout->l_units;
249 aout_thread = (void *)aout_Thread_S8_Stereo;
252 case AOUT_FMT_U16_LE:
253 case AOUT_FMT_U16_BE:
254 l_bytes = 2 * sizeof(u16) * p_aout->l_units;
255 aout_thread = (void *)aout_Thread_U16_Stereo;
258 case AOUT_FMT_S16_LE:
259 case AOUT_FMT_S16_BE:
260 l_bytes = 2 * sizeof(s16) * p_aout->l_units;
261 aout_thread = (void *)aout_Thread_S16_Stereo;
265 intf_ErrMsg("aout error: unknown audio output format (%i)\n",
272 intf_ErrMsg("aout error: unknown number of audio channels (%i)\n",
273 p_aout->i_channels );
277 /* Allocate the memory needed by the audio output buffers, and set to zero
278 * the s32 buffer's memory */
279 if ( (p_aout->buffer = malloc(l_bytes)) == NULL )
281 intf_ErrMsg("aout error: not enough memory to create the output buffer\n");
284 if ( (p_aout->s32_buffer = (s32 *)calloc(p_aout->l_units, sizeof(s32) << ( p_aout->b_stereo))) == NULL )
286 intf_ErrMsg("aout error: not enough memory to create the s32 output buffer\n");
287 free( p_aout->buffer );
291 /* Before launching the thread, we try to predict the date of the first
292 * audio unit in the first output buffer */
293 p_aout->date = mdate() - 1000000;
295 /* Launch the thread */
296 if ( vlc_thread_create( &p_aout->thread_id, "audio output", (vlc_thread_func_t)aout_thread, p_aout ) )
298 intf_ErrMsg("aout error: can't spawn audio output thread (%p)\n", p_aout);
299 free( p_aout->buffer );
300 free( p_aout->s32_buffer );
304 intf_DbgMsg("aout debug: audio output thread (%p) spawned\n", p_aout);
308 /*****************************************************************************
310 *****************************************************************************/
311 void aout_DestroyThread( aout_thread_t * p_aout, int *pi_status )
313 /* FIXME: pi_status is not handled correctly: check vout how to do!?? */
315 intf_DbgMsg("aout debug: requesting termination of audio output thread (%p)\n", p_aout);
317 /* Ask thread to kill itself and wait until it's done */
319 vlc_thread_join( p_aout->thread_id ); /* only if pi_status is NULL */
321 /* Free the allocated memory */
322 free( p_aout->buffer );
323 free( p_aout->s32_buffer );
325 /* Free the structure */
326 p_aout->p_sys_close( p_aout );
327 intf_DbgMsg("aout debug: audio device (%s) closed\n", p_aout->psz_device);
330 TrashPlugin( p_aout->p_aout_plugin );
336 /*****************************************************************************
338 *****************************************************************************/
339 aout_fifo_t * aout_CreateFifo( aout_thread_t * p_aout, aout_fifo_t * p_fifo )
343 /* Take the fifos lock */
344 vlc_mutex_lock( &p_aout->fifos_lock );
346 /* Looking for a free fifo structure */
347 for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
349 if ( p_aout->fifo[i_fifo].i_type == AOUT_EMPTY_FIFO)
354 if ( i_fifo == AOUT_MAX_FIFOS )
356 intf_ErrMsg("aout error: no empty fifo available\n");
357 vlc_mutex_unlock( &p_aout->fifos_lock );
361 /* Initialize the new fifo structure */
362 switch ( p_aout->fifo[i_fifo].i_type = p_fifo->i_type )
364 case AOUT_INTF_MONO_FIFO:
365 case AOUT_INTF_STEREO_FIFO:
366 p_aout->fifo[i_fifo].b_die = 0;
368 p_aout->fifo[i_fifo].i_channels = p_fifo->i_channels;
369 p_aout->fifo[i_fifo].b_stereo = p_fifo->b_stereo;
370 p_aout->fifo[i_fifo].l_rate = p_fifo->l_rate;
372 p_aout->fifo[i_fifo].buffer = p_fifo->buffer;
374 p_aout->fifo[i_fifo].l_unit = 0;
375 InitializeIncrement( &p_aout->fifo[i_fifo].unit_increment, p_fifo->l_rate, p_aout->l_rate );
376 p_aout->fifo[i_fifo].l_units = p_fifo->l_units;
379 case AOUT_ADEC_MONO_FIFO:
380 case AOUT_ADEC_STEREO_FIFO:
381 p_aout->fifo[i_fifo].b_die = 0;
383 p_aout->fifo[i_fifo].i_channels = p_fifo->i_channels;
384 p_aout->fifo[i_fifo].b_stereo = p_fifo->b_stereo;
385 p_aout->fifo[i_fifo].l_rate = p_fifo->l_rate;
387 p_aout->fifo[i_fifo].l_frame_size = p_fifo->l_frame_size;
388 /* Allocate the memory needed to store the audio frames. As the
389 * fifo is a rotative fifo, we must be able to find out whether the
390 * fifo is full or empty, that's why we must in fact allocate memory
391 * for (AOUT_FIFO_SIZE+1) audio frames. */
392 if ( (p_aout->fifo[i_fifo].buffer = malloc( sizeof(s16)*(AOUT_FIFO_SIZE+1)*p_fifo->l_frame_size )) == NULL )
394 intf_ErrMsg("aout error: not enough memory to create the frames buffer\n");
395 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO;
396 vlc_mutex_unlock( &p_aout->fifos_lock );
400 /* Allocate the memory needed to store the dates of the frames */
401 if ( (p_aout->fifo[i_fifo].date = (mtime_t *)malloc( sizeof(mtime_t)*(AOUT_FIFO_SIZE+1) )) == NULL )
403 intf_ErrMsg("aout error: not enough memory to create the dates buffer\n");
404 free( p_aout->fifo[i_fifo].buffer );
405 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO;
406 vlc_mutex_unlock( &p_aout->fifos_lock );
410 /* Set the fifo's buffer as empty (the first frame that is to be
411 * played is also the first frame that is not to be played) */
412 p_aout->fifo[i_fifo].l_start_frame = 0;
413 /* p_aout->fifo[i_fifo].l_next_frame = 0; */
414 p_aout->fifo[i_fifo].l_end_frame = 0;
416 /* Waiting for the audio decoder to compute enough frames to work
417 * out the fifo's current rate (as soon as the decoder has decoded
418 * enough frames, the members of the fifo structure that are not
419 * initialized now will be calculated) */
420 p_aout->fifo[i_fifo].b_start_frame = 0;
421 p_aout->fifo[i_fifo].b_next_frame = 0;
425 intf_ErrMsg("aout error: unknown fifo type (%i)\n", p_aout->fifo[i_fifo].i_type);
426 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO;
427 vlc_mutex_unlock( &p_aout->fifos_lock );
431 /* Release the fifos lock */
432 vlc_mutex_unlock( &p_aout->fifos_lock );
434 /* Return the pointer to the fifo structure */
435 intf_DbgMsg("aout debug: audio output fifo (%p) allocated\n", &p_aout->fifo[i_fifo]);
436 return( &p_aout->fifo[i_fifo] );
439 /*****************************************************************************
441 *****************************************************************************/
442 void aout_DestroyFifo( aout_fifo_t * p_fifo )
444 intf_DbgMsg("aout debug: requesting destruction of audio output fifo (%p)\n", p_fifo);
448 /* Here are the local macros */
450 #define UPDATE_INCREMENT( increment, integer ) \
451 if ( ((increment).l_remainder += (increment).l_euclidean_remainder) >= 0 )\
453 (integer) += (increment).l_euclidean_integer + 1; \
454 (increment).l_remainder -= (increment).l_euclidean_denominator; \
458 (integer) += (increment).l_euclidean_integer; \
461 /* Following functions are local */
463 /*****************************************************************************
464 * InitializeIncrement
465 *****************************************************************************/
466 static __inline__ void InitializeIncrement( aout_increment_t * p_increment, long l_numerator, long l_denominator )
468 p_increment->l_remainder = -l_denominator;
470 p_increment->l_euclidean_integer = 0;
471 while ( l_numerator >= l_denominator )
473 p_increment->l_euclidean_integer++;
474 l_numerator -= l_denominator;
477 p_increment->l_euclidean_remainder = l_numerator;
479 p_increment->l_euclidean_denominator = l_denominator;
482 /*****************************************************************************
484 *****************************************************************************/
485 static __inline__ int NextFrame( aout_thread_t * p_aout, aout_fifo_t * p_fifo, mtime_t aout_date )
487 long l_units, l_rate;
489 /* We take the lock */
490 vlc_mutex_lock( &p_fifo->data_lock );
492 /* Are we looking for a dated start frame ? */
493 if ( !p_fifo->b_start_frame )
495 while ( p_fifo->l_start_frame != p_fifo->l_end_frame )
497 if ( p_fifo->date[p_fifo->l_start_frame] != LAST_MDATE )
499 p_fifo->b_start_frame = 1;
500 p_fifo->l_next_frame = (p_fifo->l_start_frame + 1) & AOUT_FIFO_SIZE;
501 p_fifo->l_unit = p_fifo->l_start_frame * (p_fifo->l_frame_size >> (p_fifo->b_stereo));
504 p_fifo->l_start_frame = (p_fifo->l_start_frame + 1) & AOUT_FIFO_SIZE;
507 if ( p_fifo->l_start_frame == p_fifo->l_end_frame )
509 vlc_mutex_unlock( &p_fifo->data_lock );
514 /* We are looking for the next dated frame */
515 /* FIXME : is the output fifo full ?? */
516 while ( !p_fifo->b_next_frame )
518 while ( p_fifo->l_next_frame != p_fifo->l_end_frame )
520 if ( p_fifo->date[p_fifo->l_next_frame] != LAST_MDATE )
522 p_fifo->b_next_frame = 1;
525 p_fifo->l_next_frame = (p_fifo->l_next_frame + 1) & AOUT_FIFO_SIZE;
528 while ( p_fifo->l_next_frame == p_fifo->l_end_frame )
530 vlc_cond_wait( &p_fifo->data_wait, &p_fifo->data_lock );
533 vlc_mutex_unlock( &p_fifo->data_lock );
539 l_units = ((p_fifo->l_next_frame - p_fifo->l_start_frame) & AOUT_FIFO_SIZE) * (p_fifo->l_frame_size >> (p_fifo->b_stereo));
541 l_rate = p_fifo->l_rate + ((aout_date - p_fifo->date[p_fifo->l_start_frame]) / 256);
542 // fprintf( stderr, "aout debug: %lli (%li);\n", aout_date - p_fifo->date[p_fifo->l_start_frame], l_rate );
544 InitializeIncrement( &p_fifo->unit_increment, l_rate, p_aout->l_rate );
546 p_fifo->l_units = (((l_units - (p_fifo->l_unit -
547 (p_fifo->l_start_frame * (p_fifo->l_frame_size >> (p_fifo->b_stereo)))))
548 * p_aout->l_rate) / l_rate) + 1;
550 /* We release the lock before leaving */
551 vlc_mutex_unlock( &p_fifo->data_lock );
555 void aout_Thread_S8_Mono( aout_thread_t * p_aout )
559 void aout_Thread_S8_Stereo( aout_thread_t * p_aout )
563 void aout_Thread_U8_Mono( aout_thread_t * p_aout )
567 void aout_Thread_U8_Stereo( aout_thread_t * p_aout )
570 long l_buffer, l_buffer_limit;
571 long l_units, l_bytes;
573 intf_DbgMsg("adec debug: ********aout_Thread_U8_Stereo********\n");
574 intf_DbgMsg("adec debug: running audio output thread (%p) (pid == %i)\n", p_aout, getpid());
576 /* As the s32_buffer was created with calloc(), we don't have to set this
577 * memory to zero and we can immediately jump into the thread's loop */
578 while ( !p_aout->b_die )
580 vlc_mutex_lock( &p_aout->fifos_lock );
581 for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
583 switch ( p_aout->fifo[i_fifo].i_type )
585 case AOUT_EMPTY_FIFO:
588 case AOUT_INTF_MONO_FIFO:
589 if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units )
592 while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->b_stereo == 1 */
594 p_aout->s32_buffer[l_buffer++] +=
595 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
596 p_aout->s32_buffer[l_buffer++] +=
597 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
598 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
600 p_aout->fifo[i_fifo].l_units -= p_aout->l_units;
605 while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->b_stereo == 1 */
607 p_aout->s32_buffer[l_buffer++] +=
608 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
609 p_aout->s32_buffer[l_buffer++] +=
610 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
611 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
613 free( p_aout->fifo[i_fifo].buffer ); /* !! */
614 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
615 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); /* !! */
619 case AOUT_INTF_STEREO_FIFO:
620 if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units )
623 while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->b_stereo == 1 */
625 p_aout->s32_buffer[l_buffer++] +=
626 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
627 p_aout->s32_buffer[l_buffer++] +=
628 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
629 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
631 p_aout->fifo[i_fifo].l_units -= p_aout->l_units;
636 while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->b_stereo == 1 */
638 p_aout->s32_buffer[l_buffer++] +=
639 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
640 p_aout->s32_buffer[l_buffer++] +=
641 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
642 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
644 free( p_aout->fifo[i_fifo].buffer ); /* !! */
645 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
646 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); /* !! */
650 case AOUT_ADEC_MONO_FIFO:
651 if ( p_aout->fifo[i_fifo].b_die )
653 free( p_aout->fifo[i_fifo].buffer );
654 free( p_aout->fifo[i_fifo].date );
655 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
656 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
660 l_units = p_aout->l_units;
662 while ( l_units > 0 )
664 if ( !p_aout->fifo[i_fifo].b_next_frame )
666 if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) )
672 if ( p_aout->fifo[i_fifo].l_units > l_units )
674 l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */
675 while ( l_buffer < l_buffer_limit )
677 p_aout->s32_buffer[l_buffer++] +=
678 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
679 p_aout->s32_buffer[l_buffer++] +=
680 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
682 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
683 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */
684 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) )
686 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */
687 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0));
690 p_aout->fifo[i_fifo].l_units -= l_units;
695 l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1);
696 /* p_aout->b_stereo == 1 */
697 while ( l_buffer < l_buffer_limit )
699 p_aout->s32_buffer[l_buffer++] +=
700 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
701 p_aout->s32_buffer[l_buffer++] +=
702 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
704 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
705 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */
706 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) )
708 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */
709 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0));
712 l_units -= p_aout->fifo[i_fifo].l_units;
714 vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock );
715 p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame;
716 vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait );
717 vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
719 /* p_aout->fifo[i_fifo].b_start_frame = 1; */
720 p_aout->fifo[i_fifo].l_next_frame += 1;
721 p_aout->fifo[i_fifo].l_next_frame &= AOUT_FIFO_SIZE;
722 p_aout->fifo[i_fifo].b_next_frame = 0;
727 case AOUT_ADEC_STEREO_FIFO:
728 if ( p_aout->fifo[i_fifo].b_die )
730 free( p_aout->fifo[i_fifo].buffer );
731 free( p_aout->fifo[i_fifo].date );
732 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
733 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
737 l_units = p_aout->l_units;
739 while ( l_units > 0 )
741 if ( !p_aout->fifo[i_fifo].b_next_frame )
743 if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) )
749 if ( p_aout->fifo[i_fifo].l_units > l_units )
751 l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */
752 while ( l_buffer < l_buffer_limit )
754 p_aout->s32_buffer[l_buffer++] +=
755 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
756 p_aout->s32_buffer[l_buffer++] +=
757 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
759 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
760 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */
761 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) )
763 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */
764 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1));
767 p_aout->fifo[i_fifo].l_units -= l_units;
772 l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1);
773 /* p_aout->b_stereo == 1 */
774 while ( l_buffer < l_buffer_limit )
776 p_aout->s32_buffer[l_buffer++] +=
777 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
778 p_aout->s32_buffer[l_buffer++] +=
779 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
781 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
782 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */
783 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) )
785 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */
786 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1));
789 l_units -= p_aout->fifo[i_fifo].l_units;
791 vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock );
792 p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame;
793 vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait );
794 vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
796 /* p_aout->fifo[i_fifo].b_start_frame = 1; */
797 p_aout->fifo[i_fifo].l_next_frame += 1;
798 p_aout->fifo[i_fifo].l_next_frame &= AOUT_FIFO_SIZE;
799 p_aout->fifo[i_fifo].b_next_frame = 0;
805 intf_DbgMsg("aout debug: unknown fifo type (%i)\n", p_aout->fifo[i_fifo].i_type);
809 vlc_mutex_unlock( &p_aout->fifos_lock );
811 l_buffer_limit = p_aout->l_units << 1 ; /* p_aout->b_stereo == 1 */
813 for ( l_buffer = 0; l_buffer < l_buffer_limit; l_buffer++ )
815 ((u8 *)p_aout->buffer)[l_buffer] = (u8)( (p_aout->s32_buffer[l_buffer] / 256) + 128 );
816 p_aout->s32_buffer[l_buffer] = 0;
818 l_bytes = p_aout->p_sys_getbufinfo( p_aout, l_buffer_limit );
819 p_aout->date = mdate() + ((((mtime_t)(l_bytes / 2 )) * 1000000) / ((mtime_t)p_aout->l_rate)); /* sizeof(u8) << (p_aout->b_stereo) == 2 */
820 p_aout->p_sys_playsamples( p_aout, (byte_t *)p_aout->buffer, l_buffer_limit * sizeof(u8) );
821 if ( l_bytes > (l_buffer_limit * sizeof(u8)) )
823 msleep( p_aout->l_msleep );
827 vlc_mutex_lock( &p_aout->fifos_lock );
828 for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
830 switch ( p_aout->fifo[i_fifo].i_type )
832 case AOUT_EMPTY_FIFO:
835 case AOUT_INTF_MONO_FIFO:
836 case AOUT_INTF_STEREO_FIFO:
837 free( p_aout->fifo[i_fifo].buffer ); /* !! */
838 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
839 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
842 case AOUT_ADEC_MONO_FIFO:
843 case AOUT_ADEC_STEREO_FIFO:
844 free( p_aout->fifo[i_fifo].buffer );
845 free( p_aout->fifo[i_fifo].date );
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]);
854 vlc_mutex_unlock( &p_aout->fifos_lock );
858 void aout_Thread_S16_Mono( aout_thread_t * p_aout )
862 void aout_Thread_S16_Stereo( aout_thread_t * p_aout )
865 long l_buffer, l_buffer_limit;
866 long l_units, l_bytes;
868 intf_DbgMsg("adec debug: ********aout_Thread_S16_Stereo********\n");
869 intf_DbgMsg("adec debug: running audio output thread (%p) (pid == %i)\n", p_aout, getpid());
871 /* As the s32_buffer was created with calloc(), we don't have to set this
872 * memory to zero and we can immediately jump into the thread's loop */
873 while ( !p_aout->b_die )
875 vlc_mutex_lock( &p_aout->fifos_lock );
876 for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
878 switch ( p_aout->fifo[i_fifo].i_type )
880 case AOUT_EMPTY_FIFO:
883 case AOUT_INTF_MONO_FIFO:
884 if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units )
887 while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->b_stereo == 1 */
889 p_aout->s32_buffer[l_buffer++] +=
890 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
891 p_aout->s32_buffer[l_buffer++] +=
892 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
893 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
895 p_aout->fifo[i_fifo].l_units -= p_aout->l_units;
900 while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->b_stereo == 1 */
902 p_aout->s32_buffer[l_buffer++] +=
903 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
904 p_aout->s32_buffer[l_buffer++] +=
905 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
906 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
908 free( p_aout->fifo[i_fifo].buffer ); /* !! */
909 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
910 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); /* !! */
914 case AOUT_INTF_STEREO_FIFO:
915 if ( p_aout->fifo[i_fifo].l_units > p_aout->l_units )
918 while ( l_buffer < (p_aout->l_units << 1) ) /* p_aout->b_stereo == 1 */
920 p_aout->s32_buffer[l_buffer++] +=
921 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
922 p_aout->s32_buffer[l_buffer++] +=
923 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
924 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
926 p_aout->fifo[i_fifo].l_units -= p_aout->l_units;
931 while ( l_buffer < (p_aout->fifo[i_fifo].l_units << 1) ) /* p_aout->b_stereo == 1 */
933 p_aout->s32_buffer[l_buffer++] +=
934 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
935 p_aout->s32_buffer[l_buffer++] +=
936 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
937 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
939 free( p_aout->fifo[i_fifo].buffer ); /* !! */
940 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
941 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]); /* !! */
945 case AOUT_ADEC_MONO_FIFO:
946 if ( p_aout->fifo[i_fifo].b_die )
948 free( p_aout->fifo[i_fifo].buffer );
949 free( p_aout->fifo[i_fifo].date );
950 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
951 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
955 l_units = p_aout->l_units;
957 while ( l_units > 0 )
959 if ( !p_aout->fifo[i_fifo].b_next_frame )
961 if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) )
967 if ( p_aout->fifo[i_fifo].l_units > l_units )
969 l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */
970 while ( l_buffer < l_buffer_limit )
972 p_aout->s32_buffer[l_buffer++] +=
973 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
974 p_aout->s32_buffer[l_buffer++] +=
975 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
977 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
978 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */
979 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) )
981 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */
982 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0));
985 p_aout->fifo[i_fifo].l_units -= l_units;
990 l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1);
991 /* p_aout->b_stereo == 1 */
992 while ( l_buffer < l_buffer_limit )
994 p_aout->s32_buffer[l_buffer++] +=
995 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
996 p_aout->s32_buffer[l_buffer++] +=
997 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[p_aout->fifo[i_fifo].l_unit] );
999 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
1000 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 0 */
1001 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0)) )
1003 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 0 */
1004 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 0));
1007 l_units -= p_aout->fifo[i_fifo].l_units;
1009 vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock );
1010 p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame;
1011 vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait );
1012 vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
1014 /* p_aout->fifo[i_fifo].b_start_frame = 1; */
1015 p_aout->fifo[i_fifo].l_next_frame += 1;
1016 p_aout->fifo[i_fifo].l_next_frame &= AOUT_FIFO_SIZE;
1017 p_aout->fifo[i_fifo].b_next_frame = 0;
1022 case AOUT_ADEC_STEREO_FIFO:
1023 if ( p_aout->fifo[i_fifo].b_die )
1025 free( p_aout->fifo[i_fifo].buffer );
1026 free( p_aout->fifo[i_fifo].date );
1027 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
1028 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
1032 l_units = p_aout->l_units;
1034 while ( l_units > 0 )
1036 if ( !p_aout->fifo[i_fifo].b_next_frame )
1038 if ( NextFrame(p_aout, &p_aout->fifo[i_fifo], p_aout->date + ((((mtime_t)(l_buffer >> 1)) * 1000000) / ((mtime_t)p_aout->l_rate))) )
1044 if ( p_aout->fifo[i_fifo].l_units > l_units )
1046 l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */
1047 while ( l_buffer < l_buffer_limit )
1049 p_aout->s32_buffer[l_buffer++] +=
1050 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
1051 p_aout->s32_buffer[l_buffer++] +=
1052 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
1054 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
1055 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */
1056 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) )
1058 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */
1059 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1));
1062 p_aout->fifo[i_fifo].l_units -= l_units;
1067 l_buffer_limit = l_buffer + (p_aout->fifo[i_fifo].l_units << 1);
1068 /* p_aout->b_stereo == 1 */
1069 while ( l_buffer < l_buffer_limit )
1071 p_aout->s32_buffer[l_buffer++] +=
1072 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit] );
1073 p_aout->s32_buffer[l_buffer++] +=
1074 (s32)( ((s16 *)p_aout->fifo[i_fifo].buffer)[2*p_aout->fifo[i_fifo].l_unit+1] );
1076 UPDATE_INCREMENT( p_aout->fifo[i_fifo].unit_increment, p_aout->fifo[i_fifo].l_unit )
1077 if ( p_aout->fifo[i_fifo].l_unit >= /* p_aout->fifo[i_fifo].b_stereo == 1 */
1078 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1)) )
1080 p_aout->fifo[i_fifo].l_unit -= /* p_aout->fifo[i_fifo].b_stereo == 1 */
1081 ((AOUT_FIFO_SIZE + 1) * (p_aout->fifo[i_fifo].l_frame_size >> 1));
1084 l_units -= p_aout->fifo[i_fifo].l_units;
1086 vlc_mutex_lock( &p_aout->fifo[i_fifo].data_lock );
1087 p_aout->fifo[i_fifo].l_start_frame = p_aout->fifo[i_fifo].l_next_frame;
1088 vlc_cond_signal( &p_aout->fifo[i_fifo].data_wait );
1089 vlc_mutex_unlock( &p_aout->fifo[i_fifo].data_lock );
1091 /* p_aout->fifo[i_fifo].b_start_frame = 1; */
1092 p_aout->fifo[i_fifo].l_next_frame += 1;
1093 p_aout->fifo[i_fifo].l_next_frame &= AOUT_FIFO_SIZE;
1094 p_aout->fifo[i_fifo].b_next_frame = 0;
1100 intf_DbgMsg("aout debug: unknown fifo type (%i)\n", p_aout->fifo[i_fifo].i_type);
1104 vlc_mutex_unlock( &p_aout->fifos_lock );
1106 l_buffer_limit = p_aout->l_units << 1; /* p_aout->b_stereo == 1 */
1108 for ( l_buffer = 0; l_buffer < l_buffer_limit; l_buffer++ )
1110 ((s16 *)p_aout->buffer)[l_buffer] = (s16)( p_aout->s32_buffer[l_buffer] / AOUT_MAX_FIFOS );
1111 p_aout->s32_buffer[l_buffer] = 0;
1114 l_bytes = p_aout->p_sys_getbufinfo( p_aout, l_buffer_limit );
1115 p_aout->date = -1000000 + mdate() + ((((mtime_t)(l_bytes / 4)) * 1000000) / ((mtime_t)p_aout->l_rate)); /* sizeof(s16) << (p_aout->b_stereo) == 4 */
1116 p_aout->p_sys_playsamples( p_aout, (byte_t *)p_aout->buffer, l_buffer_limit * sizeof(s16) );
1117 if ( l_bytes > (l_buffer_limit * sizeof(s16)) )
1119 msleep( p_aout->l_msleep );
1123 vlc_mutex_lock( &p_aout->fifos_lock );
1124 for ( i_fifo = 0; i_fifo < AOUT_MAX_FIFOS; i_fifo++ )
1126 switch ( p_aout->fifo[i_fifo].i_type )
1128 case AOUT_EMPTY_FIFO:
1131 case AOUT_INTF_MONO_FIFO:
1132 case AOUT_INTF_STEREO_FIFO:
1133 free( p_aout->fifo[i_fifo].buffer ); /* !! */
1134 p_aout->fifo[i_fifo].i_type = AOUT_EMPTY_FIFO; /* !! */
1135 intf_DbgMsg("aout debug: audio output fifo (%p) destroyed\n", &p_aout->fifo[i_fifo]);
1138 case AOUT_ADEC_MONO_FIFO:
1139 case AOUT_ADEC_STEREO_FIFO:
1140 free( p_aout->fifo[i_fifo].buffer );
1141 free( p_aout->fifo[i_fifo].date );
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]);
1150 vlc_mutex_unlock( &p_aout->fifos_lock );
1153 void aout_Thread_U16_Mono( aout_thread_t * p_aout )
1157 void aout_Thread_U16_Stereo( aout_thread_t * p_aout )