* aout_internal.h : internal defines for audio output
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: aout_internal.h,v 1.3 2002/08/12 22:12:50 massiot Exp $
+ * $Id: aout_internal.h,v 1.4 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
#define AOUT_ALLOC_STACK 1
#define AOUT_ALLOC_HEAP 2
-#define aout_BufferAlloc( p_alloc, i_nb_usec, p_previous_buffer, p_new_buffer ) \
+#define aout_BufferAlloc( p_alloc, i_nb_usec, p_previous_buffer, \
+ p_new_buffer ) \
if ( (p_alloc)->i_alloc_type == AOUT_ALLOC_NONE ) \
{ \
(p_new_buffer) = p_previous_buffer; \
} \
else \
{ \
+ int i_alloc_size; \
+ i_alloc_size = (u64)(p_alloc)->i_bytes_per_sec \
+ * (i_nb_usec) / 1000000 + 1; \
if ( (p_alloc)->i_alloc_type == AOUT_ALLOC_STACK ) \
{ \
- (p_new_buffer) = alloca( (u64)(p_alloc)->i_bytes_per_sec \
- * (i_nb_usec) \
- / 1000000 + 1 + sizeof(aout_buffer_t) ); \
+ (p_new_buffer) = alloca( i_alloc_size + sizeof(aout_buffer_t) );\
} \
else \
{ \
- (p_new_buffer) = malloc( (u64)(p_alloc)->i_bytes_per_sec \
- * (i_nb_usec) \
- / 1000000 + 1 + sizeof(aout_buffer_t) ); \
+ (p_new_buffer) = malloc( i_alloc_size + sizeof(aout_buffer_t) );\
} \
if ( p_new_buffer != NULL ) \
{ \
(p_new_buffer)->i_alloc_type = (p_alloc)->i_alloc_type; \
- (p_new_buffer)->i_size = (u64)(p_alloc)->i_bytes_per_sec \
- * (i_nb_usec) / 1000000 + 1; \
+ (p_new_buffer)->i_size = i_alloc_size; \
(p_new_buffer)->p_buffer = (byte_t *)(p_new_buffer) \
+ sizeof(aout_buffer_t); \
if ( (p_previous_buffer) != NULL ) \
* audio_output.h : audio output interface
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: audio_output.h,v 1.57 2002/08/11 23:26:28 massiot Exp $
+ * $Id: audio_output.h,v 1.58 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
int i_format;
int i_rate;
int i_channels;
+ /* Optional - for A52, SPDIF and DTS types */
+ int i_bytes_per_sec;
};
#define AOUT_FMT_MU_LAW 0x00000001
# define AOUT_FMT_U16_NE AOUT_FMT_U16_LE
#endif
-#define AOUT_FMT_IS_SPDIF( p_format ) \
+#define AOUT_FMT_NON_LINEAR( p_format ) \
( ((p_format)->i_format == AOUT_FMT_SPDIF) \
|| ((p_format)->i_format == AOUT_FMT_A52) \
|| ((p_format)->i_format == AOUT_FMT_DTS) )
#define FIXED32_ONE ((vlc_fixed_t) 0x10000000)
-
/*****************************************************************************
* aout_buffer_t : audio output buffer
*****************************************************************************/
{
byte_t * p_buffer;
int i_alloc_type;
- size_t i_size;
+ /* i_size is the real size of the buffer (normally unused), i_nb_bytes
+ * is the number of significative bytes in it. */
+ size_t i_size, i_nb_bytes;
int i_nb_samples;
mtime_t start_date, end_date;
VLC_EXPORT( aout_buffer_t *, aout_BufferNew, ( aout_instance_t *, aout_input_t *, size_t ) );
VLC_EXPORT( void, aout_BufferDelete, ( aout_instance_t *, aout_input_t *, aout_buffer_t * ) );
VLC_EXPORT( void, aout_BufferPlay, ( aout_instance_t *, aout_input_t *, aout_buffer_t * ) );
-VLC_EXPORT( int, aout_FormatTo, ( audio_sample_format_t * p_format, int ) );
-#define aout_FormatToByterate(a,b) aout_FormatTo(a,b)
-#define aout_FormatToSize(a,b) aout_FormatTo(a,b)
+VLC_EXPORT( int, aout_FormatToByterate, ( audio_sample_format_t * p_format ) );
/* From input.c : */
#define aout_InputNew(a,b,c) __aout_InputNew(VLC_OBJECT(a),b,c)
-/* include/defs.h.in. Generated automatically from configure.in by autoheader 2.13. */
+/* include/defs.h.in. Generated automatically from configure.in by autoheader. */
/* Define if using alloca.c. */
#undef C_ALLOCA
int (* __vlc_thread_create_inner) ( vlc_object_t *, char *, int, char *, void * ( * ) ( void * ), vlc_bool_t ) ;
int (* __vlc_threads_end_inner) ( vlc_object_t * ) ;
int (* __vlc_threads_init_inner) ( vlc_object_t * ) ;
- int (* aout_FormatTo_inner) ( audio_sample_format_t * p_format, int ) ;
+ int (* aout_FormatToByterate_inner) ( audio_sample_format_t * p_format ) ;
int (* input_AccessInit_inner) ( input_thread_t * ) ;
int (* input_AddInfo_inner) ( input_info_category_t *, char *, char *, ... ) ;
int (* input_ChangeArea_inner) ( input_thread_t *, input_area_t * ) ;
# define aout_BufferNew p_symbols->aout_BufferNew_inner
# define aout_BufferPlay p_symbols->aout_BufferPlay_inner
# define aout_DeleteInstance p_symbols->aout_DeleteInstance_inner
-# define aout_FormatTo p_symbols->aout_FormatTo_inner
+# define aout_FormatToByterate p_symbols->aout_FormatToByterate_inner
# define aout_InputDelete p_symbols->aout_InputDelete_inner
# define aout_OutputNextBuffer p_symbols->aout_OutputNextBuffer_inner
# define config_Duplicate p_symbols->config_Duplicate_inner
* a52tospdif.c : encapsulates A/52 frames into S/PDIF packets
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: a52tospdif.c,v 1.6 2002/08/13 16:11:15 sam Exp $
+ * $Id: a52tospdif.c,v 1.7 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Stéphane Borel <stef@via.ecp.fr>
p_filter->p_vlc->pf_memset( p_out + 8 + i_length, 0,
AOUT_SPDIF_SIZE - i_length - 8 );
- p_out_buf->i_nb_samples = 1;
+ p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
+ p_out_buf->i_nb_bytes = AOUT_SPDIF_SIZE;
}
* float32tos16.c : converter from float32 to signed 16 bits integer
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: float32tos16.c,v 1.6 2002/08/13 22:42:23 massiot Exp $
+ * $Id: float32tos16.c,v 1.7 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
}
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
+ p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes / 2;
}
* float32tos8.c : converter from float32 to signed 8 bits integer
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: float32tos8.c,v 1.1 2002/08/13 22:42:23 massiot Exp $
+ * $Id: float32tos8.c,v 1.2 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Xavier Maillard <zedek@fxgsproject.org>
*
}
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
+ p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes / 4;
}
* float32tou16.c : converter from float32 to unsigned 16 bits integer
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: float32tou16.c,v 1.1 2002/08/13 22:42:23 massiot Exp $
+ * $Id: float32tou16.c,v 1.2 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Xavier Maillard <zedek@fxgsproject.org>
*
aout_filter_t * p_filter = (aout_filter_t *)p_this;
if ( p_filter->input.i_format != AOUT_FMT_FLOAT32
- && p_filter->output.i_format != AOUT_FMT_U16_NE )
+ || p_filter->output.i_format != AOUT_FMT_U16_NE )
{
return -1;
}
}
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
+ p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes / 2;
}
* float32tou8.c : converter from float32 to unsigned 8 bits integer
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: float32tou8.c,v 1.1 2002/08/13 22:42:23 massiot Exp $
+ * $Id: float32tou8.c,v 1.2 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Xavier Maillard <zedek@fxgsproject.org>
*
aout_filter_t * p_filter = (aout_filter_t *)p_this;
if ( p_filter->input.i_format != AOUT_FMT_FLOAT32
- && p_filter->output.i_format != AOUT_FMT_U8 )
+ || p_filter->output.i_format != AOUT_FMT_U8 )
{
return -1;
}
}
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
+ p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes / 4;
}
* spdif.c : dummy mixer for S/PDIF output (1 input only)
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: spdif.c,v 1.2 2002/08/12 07:40:23 massiot Exp $
+ * $Id: spdif.c,v 1.3 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
{
aout_instance_t * p_aout = (aout_instance_t *)p_this;
- if ( p_aout->mixer.output.i_format != AOUT_FMT_SPDIF )
+ if ( !AOUT_FMT_NON_LINEAR(&p_aout->mixer.output) )
{
return -1;
}
if ( p_buffer != NULL )
{
p_bytes = p_buffer->p_buffer;
- i_size = aout_FormatToSize( &p_aout->output.output,
- p_buffer->i_nb_samples );
+ i_size = p_buffer->i_nb_bytes;
}
else
{
- i_size = aout_FormatToSize( &p_aout->output.output,
- p_sys->i_size );
+ i_size = aout_FormatToByterate( &p_aout->output.output )
+ * p_sys->i_size
+ / p_aout->output.output.i_rate;
p_bytes = alloca( i_size );
memset( p_bytes, 0, i_size );
}
* esd.c : EsounD module
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
- * $Id: esd.c,v 1.3 2002/08/13 14:53:46 sam Exp $
+ * $Id: esd.c,v 1.4 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* p_aout->output.output.i_rate / ESD_DEFAULT_RATE
* aout_FormatTo( &p_aout->output.output, 1 ) )
* (mtime_t)1000000
- / (mtime_t)aout_FormatToByterate( &p_aout->output.output,
- p_aout->output.output.i_rate );
+ / (mtime_t)aout_FormatToByterate( &p_aout->output.output );
p_sys->b_initialized = VLC_TRUE;
if ( p_buffer != NULL )
{
p_bytes = p_buffer->p_buffer;
- i_size = aout_FormatToSize( &p_aout->output.output,
- p_buffer->i_nb_samples );
+ i_size = p_buffer->i_nb_bytes;
}
else
{
- i_size = aout_FormatToSize( &p_aout->output.output,
- ESD_BUF_SIZE * 2 );
+ i_size = aout_FormatToByterate( &p_aout->output.output )
+ * ESD_BUF_SIZE * 2
+ / p_aout->output.output.i_rate;
p_bytes = alloca( i_size );
memset( p_bytes, 0, i_size );
}
* file.c : audio output which writes the samples to a file
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: file.c,v 1.4 2002/08/12 22:12:51 massiot Exp $
+ * $Id: file.c,v 1.5 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
#include "aout_internal.h"
#define FRAME_SIZE 2048
+#define A52_FRAME_NB 1536
/*****************************************************************************
* Local prototypes.
static int format_int[] = { AOUT_FMT_U8, AOUT_FMT_S8, AOUT_FMT_U16_NE,
AOUT_FMT_S16_NE, AOUT_FMT_U16_LE, AOUT_FMT_S16_LE,
AOUT_FMT_U16_BE, AOUT_FMT_S16_BE, AOUT_FMT_FIXED32,
- AOUT_FMT_FLOAT32, AOUT_FMT_A52 };
+ AOUT_FMT_FLOAT32, AOUT_FMT_SPDIF };
#define PATH_TEXT N_("Path of the output file")
#define PATH_LONGTEXT N_("By default samples.raw")
FILE * p_file;
char * psz_name = config_GetPsz( p_this, "path" );
- (FILE *)p_aout->output.p_sys = p_file = fopen( psz_name, "wb" );
+ p_file = fopen( psz_name, "wb" );
+ p_aout->output.p_sys = (void *)p_file;
free( psz_name );
if ( p_file == NULL ) return -1;
}
p_aout->output.output.i_format = format_int[i];
- p_aout->output.i_nb_samples = FRAME_SIZE;
+ if ( p_aout->output.output.i_format == AOUT_FMT_SPDIF )
+ {
+ p_aout->output.i_nb_samples = A52_FRAME_NB;
+ p_aout->output.output.i_bytes_per_sec = p_aout->output.output.i_rate
+ * AOUT_SPDIF_SIZE / A52_FRAME_NB;
+ }
+ else
+ {
+ p_aout->output.i_nb_samples = FRAME_SIZE;
+ }
return 0;
}
*****************************************************************************/
static void Play( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
{
- if( fwrite( p_buffer->p_buffer,
- aout_FormatToSize( &p_aout->output.output,
- p_buffer->i_nb_samples ), 1,
+ if( fwrite( p_buffer->p_buffer, p_buffer->i_nb_bytes, 1,
(FILE *)p_aout->output.p_sys ) != 1 )
{
msg_Err( p_aout, "write error (%s)", strerror(errno) );
* oss.c : OSS /dev/dsp module for vlc
*****************************************************************************
* Copyright (C) 2000-2002 VideoLAN
- * $Id: oss.c,v 1.8 2002/08/13 11:59:36 sam Exp $
+ * $Id: oss.c,v 1.9 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
volatile vlc_bool_t b_initialized;
};
-#define DEFAULT_FRAME_SIZE 2048
+#define FRAME_SIZE 2048
+#define A52_FRAME_NB 1536
/*****************************************************************************
* Local prototypes
}
/* Set the output format */
- if ( AOUT_FMT_IS_SPDIF( &p_aout->output.output ) )
+ if ( p_aout->output.output.i_format == AOUT_FMT_SPDIF )
{
- p_aout->output.output.i_format = i_format = AOUT_FMT_SPDIF;
- p_aout->output.i_nb_samples = 1;
+ p_aout->output.i_nb_samples = A52_FRAME_NB;
+ p_aout->output.output.i_bytes_per_sec = p_aout->output.output.i_rate
+ * AOUT_SPDIF_SIZE / A52_FRAME_NB;
}
else
{
p_aout->output.output.i_format = i_format = AOUT_FMT_S16_NE;
- p_aout->output.i_nb_samples = DEFAULT_FRAME_SIZE;
+ p_aout->output.i_nb_samples = FRAME_SIZE;
}
if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0
return -1;
}
- if ( !AOUT_FMT_IS_SPDIF( &p_aout->output.output ) )
+ if ( p_aout->output.output.i_format != AOUT_FMT_SPDIF )
{
/* FIXME */
if ( p_aout->output.output.i_channels > 2 )
* Order is important here, since GetBufInfo is believed to take
* more time than mdate(). */
next_date = (mtime_t)GetBufInfo( p_aout ) * 1000000
- / aout_FormatToByterate( &p_aout->output.output,
- p_aout->output.output.i_rate );
+ / aout_FormatToByterate( &p_aout->output.output );
next_date += mdate();
}
if ( p_buffer != NULL )
{
p_bytes = p_buffer->p_buffer;
- i_size = aout_FormatToSize( &p_aout->output.output,
- p_buffer->i_nb_samples );
+ i_size = p_buffer->i_nb_bytes;
}
else
{
- i_size = aout_FormatToSize( &p_aout->output.output,
- DEFAULT_FRAME_SIZE );
+ i_size = aout_FormatToByterate( &p_aout->output.output )
+ * FRAME_SIZE
+ / p_aout->output.output.i_rate;
p_bytes = alloca( i_size );
memset( p_bytes, 0, i_size );
}
* (http://liba52.sf.net/).
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
- * $Id: a52.c,v 1.3 2002/08/13 11:59:36 sam Exp $
+ * $Id: a52.c,v 1.4 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
* Christophe Massiot <massiot@via.ecp.fr>
# include "a52dec/a52.h"
#endif
-#define A52_FRAME_SIZE 1536
+#define A52_FRAME_NB 1536
/*****************************************************************************
* a52_thread_t : a52 decoder thread descriptor
}
p_buffer = aout_BufferNew( p_dec->p_aout, p_dec->p_aout_input,
- A52_FRAME_SIZE );
+ A52_FRAME_NB );
if ( p_buffer == NULL ) return -1;
p_buffer->start_date = p_dec->last_date;
- p_dec->last_date += (mtime_t)(A52_FRAME_SIZE * 1000000)
+ p_dec->last_date += (mtime_t)(A52_FRAME_NB * 1000000)
/ p_dec->output_format.i_rate;
p_buffer->end_date = p_dec->last_date;
* spdif.c: A52 pass-through to external decoder with enabled soundcard
*****************************************************************************
* Copyright (C) 2001-2002 VideoLAN
- * $Id: spdif.c,v 1.4 2002/08/12 22:12:51 massiot Exp $
+ * $Id: spdif.c,v 1.5 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Stéphane Borel <stef@via.ecp.fr>
* Juha Yrjola <jyrjola@cc.hut.fi>
# include <unistd.h>
#endif
-#define A52_FRAME_SIZE 1536
+#define A52_FRAME_NB 1536
/*****************************************************************************
* spdif_thread_t : A52 pass-through thread descriptor
return -1;
}
- /* liba52 decoder thread's main loop */
- while( !p_dec->p_fifo->b_die && !p_dec->p_fifo->b_error )
+ /* decoder thread's main loop */
+ while ( !p_dec->p_fifo->b_die && !p_dec->p_fifo->b_error )
{
int i_frame_size, i_flags, i_rate, i_bit_rate;
mtime_t pts;
/* Look for sync word - should be 0x0b77 */
RealignBits( &p_dec->bit_stream );
- while( (ShowBits( &p_dec->bit_stream, 16 ) ) != 0x0b77 &&
- (!p_dec->p_fifo->b_die) && (!p_dec->p_fifo->b_error))
+ while ( (ShowBits( &p_dec->bit_stream, 16 ) ) != 0x0b77 &&
+ (!p_dec->p_fifo->b_die) && (!p_dec->p_fifo->b_error))
{
RemoveBits( &p_dec->bit_stream, 8 );
}
}
if( (p_dec->p_aout_input != NULL) &&
- ( (p_dec->output_format.i_rate != i_rate) ) )
+ ( (p_dec->output_format.i_rate != i_rate)
+ || (p_dec->output_format.i_bytes_per_sec != i_bit_rate * 1000 / 8) ) )
{
/* Parameters changed - this should not happen. */
aout_InputDelete( p_dec->p_aout, p_dec->p_aout_input );
if( p_dec->p_aout_input == NULL )
{
p_dec->output_format.i_rate = i_rate;
+ p_dec->output_format.i_bytes_per_sec = i_bit_rate * 1000 / 8;
/* p_dec->output_format.i_channels = i_channels; */
p_dec->p_aout_input = aout_InputNew( p_dec->p_fifo,
&p_dec->p_aout,
}
p_buffer = aout_BufferNew( p_dec->p_aout, p_dec->p_aout_input,
- i_frame_size );
+ A52_FRAME_NB );
if ( p_buffer == NULL ) return -1;
p_buffer->start_date = last_date;
- last_date += (mtime_t)(A52_FRAME_SIZE * 1000000)
+ last_date += (mtime_t)(A52_FRAME_NB * 1000000)
/ p_dec->output_format.i_rate;
p_buffer->end_date = last_date;
* aout_dummy.c : dummy audio output plugin
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: aout.c,v 1.3 2002/08/12 22:12:51 massiot Exp $
+ * $Id: aout.c,v 1.4 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
#include "aout_internal.h"
#define FRAME_SIZE 2048
+#define A52_FRAME_NB 1536
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
static int SetFormat( aout_instance_t * p_aout )
{
- p_aout->output.i_nb_samples = FRAME_SIZE;
+ if ( p_aout->output.output.i_format == AOUT_FMT_SPDIF )
+ {
+ p_aout->output.i_nb_samples = A52_FRAME_NB;
+ p_aout->output.output.i_bytes_per_sec = p_aout->output.output.i_rate
+ * AOUT_SPDIF_SIZE / A52_FRAME_NB;
+ }
+ else
+ {
+ p_aout->output.i_nb_samples = FRAME_SIZE;
+ }
return 0;
}
* audio_output.c : audio output instance
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: audio_output.c,v 1.94 2002/08/12 09:34:15 sam Exp $
+ * $Id: audio_output.c,v 1.95 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
size_t i_nb_samples )
{
aout_buffer_t * p_buffer;
+ mtime_t duration = (1000000 * (mtime_t)i_nb_samples)
+ / p_input->input.i_rate;
/* This necessarily allocates in the heap. */
- aout_BufferAlloc( &p_input->input_alloc, (u64)(1000000 * i_nb_samples)
- / p_input->input.i_rate,
- NULL, p_buffer );
+ aout_BufferAlloc( &p_input->input_alloc, duration, NULL, p_buffer );
p_buffer->i_nb_samples = i_nb_samples;
+ p_buffer->i_nb_bytes = duration
+ * aout_FormatToByterate( &p_input->input )
+ / 1000000;
if ( p_buffer == NULL )
{
}
/*****************************************************************************
- * aout_FormatTo : compute the number of bytes/sample for format (used for
- * aout_FormatToByterate and aout_FormatToSize)
+ * aout_FormatToByterate : compute the number of bytes per second
*****************************************************************************/
-int aout_FormatTo( audio_sample_format_t * p_format, int i_multiplier )
+int aout_FormatToByterate( audio_sample_format_t * p_format )
{
int i_result;
break;
case AOUT_FMT_SPDIF:
- case AOUT_FMT_A52: /* Actually smaller and variable, but who cares ? */
- case AOUT_FMT_DTS: /* Unimplemented and untested */
- /* Please note that we don't multiply by multiplier, because i_rate
- * and i_nb_samples do not have any sense for S/PDIF (yes, it
- * _is_ kludgy). --Meuuh */
- return AOUT_SPDIF_SIZE;
+ case AOUT_FMT_A52:
+ case AOUT_FMT_DTS:
+ /* For these formats the caller has to indicate the number of bytes
+ * per second it evaluates. */
+ return p_format->i_bytes_per_sec;
default:
return 0; /* will segfault much sooner... */
}
- return i_result * p_format->i_channels * i_multiplier;
+ return i_result * p_format->i_channels * p_format->i_rate;
}
* filters.c : audio output filters management
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: filters.c,v 1.3 2002/08/12 09:34:15 sam Exp $
+ * $Id: filters.c,v 1.4 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
{
aout_filter_t * p_filter = pp_filters[i];
- int i_output_size = aout_FormatToByterate( &p_filter->output,
- p_filter->output.i_rate );
- int i_input_size = aout_FormatToByterate( &p_filter->input,
- p_filter->input.i_rate );
+ int i_output_size = aout_FormatToByterate( &p_filter->output );
+ int i_input_size = aout_FormatToByterate( &p_filter->input );
p_first_alloc->i_bytes_per_sec = __MAX( p_first_alloc->i_bytes_per_sec,
i_output_size );
msg_Err( p_aout, "out of memory" );
return;
}
- /* Please note that p_output_buffer->i_nb_samples shall be set by
- * the filter plug-in. */
+ /* Please note that p_output_buffer->i_nb_samples & i_nb_bytes
+ * shall be set by the filter plug-in. */
p_filter->pf_do_work( p_aout, p_filter, *pp_input_buffer,
p_output_buffer );
* input.c : internal management of input streams for the audio output
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: input.c,v 1.3 2002/08/12 22:12:51 massiot Exp $
+ * $Id: input.c,v 1.4 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
memcpy( &p_input->input, p_format,
sizeof(audio_sample_format_t) );
+ p_input->input.i_bytes_per_sec =
+ aout_FormatToByterate( &p_input->input );
/* Prepare FIFO. */
aout_FifoInit( p_aout, &p_input->fifo );
/* i_bytes_per_sec is still == -1 if no filters */
p_input->input_alloc.i_bytes_per_sec = __MAX(
p_input->input_alloc.i_bytes_per_sec,
- aout_FormatToByterate( &p_input->input,
- p_input->input.i_rate ) );
+ p_input->input.i_bytes_per_sec );
/* Allocate in the heap, it is more convenient for the decoder. */
p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
* mixer.c : audio output mixing operations
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: mixer.c,v 1.3 2002/08/12 22:12:51 massiot Exp $
+ * $Id: mixer.c,v 1.4 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
return;
}
p_output_buffer->i_nb_samples = p_aout->output.i_nb_samples;
+ p_output_buffer->i_nb_bytes = (wanted_date - first_date)
+ * aout_FormatToByterate( &p_aout->mixer.output )
+ / 1000000;
p_output_buffer->start_date = first_date;
p_output_buffer->end_date = wanted_date;
p_aout->output.last_date = wanted_date;
* output.c : internal management of output streams for the audio output
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: output.c,v 1.4 2002/08/12 22:12:51 massiot Exp $
+ * $Id: output.c,v 1.5 2002/08/14 00:23:59 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
memcpy( &p_aout->output.output, p_format, sizeof(audio_sample_format_t) );
if ( i_rate != -1 ) p_aout->output.output.i_rate = i_rate;
if ( i_channels != -1 ) p_aout->output.output.i_channels = i_channels;
- if ( AOUT_FMT_IS_SPDIF(&p_aout->output.output) )
+ if ( AOUT_FMT_NON_LINEAR(&p_aout->output.output) )
{
p_aout->output.output.i_format = AOUT_FMT_SPDIF;
}
/* Calculate the resulting mixer output format. */
p_aout->mixer.output.i_channels = p_aout->output.output.i_channels;
p_aout->mixer.output.i_rate = p_aout->output.output.i_rate;
- if ( AOUT_FMT_IS_SPDIF(&p_aout->output.output) )
- {
- p_aout->mixer.output.i_format = AOUT_FMT_SPDIF;
- }
- else
+ if ( !AOUT_FMT_NON_LINEAR(&p_aout->output.output) )
{
/* Non-S/PDIF mixer only deals with float32 or fixed32. */
p_aout->mixer.output.i_format
= (p_aout->p_vlc->i_cpu & CPU_CAPABILITY_FPU) ?
AOUT_FMT_FLOAT32 : AOUT_FMT_FIXED32;
+ p_aout->mixer.output.i_bytes_per_sec
+ = aout_FormatToByterate( &p_aout->mixer.output );
}
+ else
+ {
+ p_aout->mixer.output.i_format = p_format->i_format;
+ p_aout->mixer.output.i_bytes_per_sec = p_format->i_bytes_per_sec;
+ }
+
+ msg_Dbg( p_aout, "mixer format=%d rate=%d channels=%d",
+ p_aout->mixer.output.i_format, p_aout->mixer.output.i_rate,
+ p_aout->mixer.output.i_channels );
/* Calculate the resulting mixer input format. */
p_aout->mixer.input.i_channels = -1; /* unchanged */
p_aout->mixer.input.i_rate = p_aout->mixer.output.i_rate;
p_aout->mixer.input.i_format = p_aout->mixer.output.i_format;
+ p_aout->mixer.input.i_bytes_per_sec = p_aout->mixer.output.i_bytes_per_sec;
/* Create filters. */
if ( aout_FiltersCreatePipeline( p_aout, p_aout->output.pp_filters,
/* Prepare hints for the buffer allocator. */
p_aout->mixer.output_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
p_aout->mixer.output_alloc.i_bytes_per_sec
- = aout_FormatToByterate( &p_aout->output.output,
- p_aout->output.output.i_rate );
+ = aout_FormatToByterate( &p_aout->output.output );
aout_FiltersHintBuffers( p_aout, p_aout->output.pp_filters,
p_aout->output.i_nb_filters,
(p_symbols)->aout_BufferNew_inner = aout_BufferNew; \
(p_symbols)->aout_BufferDelete_inner = aout_BufferDelete; \
(p_symbols)->aout_BufferPlay_inner = aout_BufferPlay; \
- (p_symbols)->aout_FormatTo_inner = aout_FormatTo; \
+ (p_symbols)->aout_FormatToByterate_inner = aout_FormatToByterate; \
(p_symbols)->__aout_InputNew_inner = __aout_InputNew; \
(p_symbols)->aout_InputDelete_inner = aout_InputDelete; \
(p_symbols)->aout_OutputNextBuffer_inner = aout_OutputNextBuffer; \