Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

spdif.c

00001 /*****************************************************************************
00002  * spdif.c : dummy mixer for S/PDIF output (1 input only)
00003  *****************************************************************************
00004  * Copyright (C) 2002 the VideoLAN team
00005  * $Id: spdif.c 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Christophe Massiot <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  * 
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 /*****************************************************************************
00025  * Preamble
00026  *****************************************************************************/
00027 #include <stdlib.h>                                      /* malloc(), free() */
00028 #include <string.h>
00029 
00030 #include <vlc/vlc.h>
00031 #include "audio_output.h"
00032 #include "aout_internal.h"
00033 
00034 /*****************************************************************************
00035  * Local prototypes
00036  *****************************************************************************/
00037 static int  Create    ( vlc_object_t * );
00038 
00039 static void DoWork    ( aout_instance_t *, aout_buffer_t * );
00040 
00041 /*****************************************************************************
00042  * Module descriptor
00043  *****************************************************************************/
00044 vlc_module_begin();
00045     set_category( CAT_AUDIO );
00046     set_subcategory( SUBCAT_AUDIO_MISC );
00047     set_description( _("Dummy S/PDIF audio mixer") );
00048     set_capability( "audio mixer", 1 );
00049     set_callbacks( Create, NULL );
00050 vlc_module_end();
00051 
00052 /*****************************************************************************
00053  * Create: allocate spdif mixer
00054  *****************************************************************************/
00055 static int Create( vlc_object_t *p_this )
00056 {
00057     aout_instance_t * p_aout = (aout_instance_t *)p_this;
00058 
00059     if ( !AOUT_FMT_NON_LINEAR(&p_aout->mixer.mixer) )
00060     {
00061         return -1;
00062     }
00063 
00064     p_aout->mixer.pf_do_work = DoWork;
00065     /* This is a bit kludgy - do not ask for a new buffer, since the one
00066      * provided by the first input will be good enough. */
00067     p_aout->mixer.output_alloc.i_alloc_type = AOUT_ALLOC_NONE;
00068 
00069     return 0;
00070 }
00071 
00072 /*****************************************************************************
00073  * DoWork: mix a new output buffer - this does nothing, indeed
00074  *****************************************************************************/
00075 static void DoWork( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
00076 {
00077     int i = 0;
00078     aout_input_t * p_input = p_aout->pp_inputs[i];
00079     while ( p_input->b_error )
00080     {
00081         p_input = p_aout->pp_inputs[++i];
00082     }
00083     aout_FifoPop( p_aout, &p_input->fifo );
00084 
00085     /* Empty other FIFOs to avoid a memory leak. */
00086     for ( i++; i < p_aout->i_nb_inputs; i++ )
00087     {
00088         aout_fifo_t * p_fifo;
00089         aout_buffer_t * p_deleted;
00090 
00091         p_input = p_aout->pp_inputs[i];
00092         if ( p_input->b_error ) continue;
00093         p_fifo = &p_input->fifo;
00094         p_deleted = p_fifo->p_first;  
00095         while ( p_deleted != NULL )
00096         {
00097             aout_buffer_t * p_next = p_deleted->p_next;
00098             aout_BufferFree( p_deleted );
00099             p_deleted = p_next;
00100         }
00101         p_fifo->p_first = NULL;
00102         p_fifo->pp_last = &p_fifo->p_first;
00103     }
00104 }
00105 

Generated on Tue Dec 20 10:14:27 2005 for vlc-0.8.4a by  doxygen 1.4.2