Commit eb93d56d authored by Christophe Massiot's avatar Christophe Massiot

* Changed aout_FormatTo* ; aout_FormatToSize does no longer exist.

  p_buffer now has a i_nb_bytes member. It is possible to indicate for a
  format its byterate (necessary for AC3 and SPDIF).
* S/PDIF output seems to be working at last (tested with the file output).
parent 32184100
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout_internal.h : internal defines for audio output * aout_internal.h : internal defines for audio output
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -35,30 +35,29 @@ typedef struct aout_alloc_t ...@@ -35,30 +35,29 @@ typedef struct aout_alloc_t
#define AOUT_ALLOC_STACK 1 #define AOUT_ALLOC_STACK 1
#define AOUT_ALLOC_HEAP 2 #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 ) \ if ( (p_alloc)->i_alloc_type == AOUT_ALLOC_NONE ) \
{ \ { \
(p_new_buffer) = p_previous_buffer; \ (p_new_buffer) = p_previous_buffer; \
} \ } \
else \ 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 ) \ if ( (p_alloc)->i_alloc_type == AOUT_ALLOC_STACK ) \
{ \ { \
(p_new_buffer) = alloca( (u64)(p_alloc)->i_bytes_per_sec \ (p_new_buffer) = alloca( i_alloc_size + sizeof(aout_buffer_t) );\
* (i_nb_usec) \
/ 1000000 + 1 + sizeof(aout_buffer_t) ); \
} \ } \
else \ else \
{ \ { \
(p_new_buffer) = malloc( (u64)(p_alloc)->i_bytes_per_sec \ (p_new_buffer) = malloc( i_alloc_size + sizeof(aout_buffer_t) );\
* (i_nb_usec) \
/ 1000000 + 1 + sizeof(aout_buffer_t) ); \
} \ } \
if ( p_new_buffer != NULL ) \ if ( p_new_buffer != NULL ) \
{ \ { \
(p_new_buffer)->i_alloc_type = (p_alloc)->i_alloc_type; \ (p_new_buffer)->i_alloc_type = (p_alloc)->i_alloc_type; \
(p_new_buffer)->i_size = (u64)(p_alloc)->i_bytes_per_sec \ (p_new_buffer)->i_size = i_alloc_size; \
* (i_nb_usec) / 1000000 + 1; \
(p_new_buffer)->p_buffer = (byte_t *)(p_new_buffer) \ (p_new_buffer)->p_buffer = (byte_t *)(p_new_buffer) \
+ sizeof(aout_buffer_t); \ + sizeof(aout_buffer_t); \
if ( (p_previous_buffer) != NULL ) \ if ( (p_previous_buffer) != NULL ) \
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* audio_output.h : audio output interface * audio_output.h : audio output interface
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -31,6 +31,8 @@ struct audio_sample_format_t ...@@ -31,6 +31,8 @@ struct audio_sample_format_t
int i_format; int i_format;
int i_rate; int i_rate;
int i_channels; int i_channels;
/* Optional - for A52, SPDIF and DTS types */
int i_bytes_per_sec;
}; };
#define AOUT_FMT_MU_LAW 0x00000001 #define AOUT_FMT_MU_LAW 0x00000001
...@@ -62,7 +64,7 @@ struct audio_sample_format_t ...@@ -62,7 +64,7 @@ struct audio_sample_format_t
# define AOUT_FMT_U16_NE AOUT_FMT_U16_LE # define AOUT_FMT_U16_NE AOUT_FMT_U16_LE
#endif #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_SPDIF) \
|| ((p_format)->i_format == AOUT_FMT_A52) \ || ((p_format)->i_format == AOUT_FMT_A52) \
|| ((p_format)->i_format == AOUT_FMT_DTS) ) || ((p_format)->i_format == AOUT_FMT_DTS) )
...@@ -94,7 +96,6 @@ typedef s32 vlc_fixed_t; ...@@ -94,7 +96,6 @@ typedef s32 vlc_fixed_t;
#define FIXED32_ONE ((vlc_fixed_t) 0x10000000) #define FIXED32_ONE ((vlc_fixed_t) 0x10000000)
/***************************************************************************** /*****************************************************************************
* aout_buffer_t : audio output buffer * aout_buffer_t : audio output buffer
*****************************************************************************/ *****************************************************************************/
...@@ -102,7 +103,9 @@ struct aout_buffer_t ...@@ -102,7 +103,9 @@ struct aout_buffer_t
{ {
byte_t * p_buffer; byte_t * p_buffer;
int i_alloc_type; 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; int i_nb_samples;
mtime_t start_date, end_date; mtime_t start_date, end_date;
...@@ -122,9 +125,7 @@ VLC_EXPORT( void, aout_DeleteInstance, ( aout_instance_t * ) ); ...@@ -122,9 +125,7 @@ VLC_EXPORT( void, aout_DeleteInstance, ( aout_instance_t * ) );
VLC_EXPORT( aout_buffer_t *, aout_BufferNew, ( aout_instance_t *, aout_input_t *, size_t ) ); 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_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( void, aout_BufferPlay, ( aout_instance_t *, aout_input_t *, aout_buffer_t * ) );
VLC_EXPORT( int, aout_FormatTo, ( audio_sample_format_t * p_format, int ) ); VLC_EXPORT( int, aout_FormatToByterate, ( audio_sample_format_t * p_format ) );
#define aout_FormatToByterate(a,b) aout_FormatTo(a,b)
#define aout_FormatToSize(a,b) aout_FormatTo(a,b)
/* From input.c : */ /* From input.c : */
#define aout_InputNew(a,b,c) __aout_InputNew(VLC_OBJECT(a),b,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. */ /* Define if using alloca.c. */
#undef C_ALLOCA #undef C_ALLOCA
......
...@@ -36,7 +36,7 @@ struct module_symbols_t ...@@ -36,7 +36,7 @@ struct module_symbols_t
int (* __vlc_thread_create_inner) ( vlc_object_t *, char *, int, char *, void * ( * ) ( void * ), vlc_bool_t ) ; 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_end_inner) ( vlc_object_t * ) ;
int (* __vlc_threads_init_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_AccessInit_inner) ( input_thread_t * ) ;
int (* input_AddInfo_inner) ( input_info_category_t *, char *, char *, ... ) ; int (* input_AddInfo_inner) ( input_info_category_t *, char *, char *, ... ) ;
int (* input_ChangeArea_inner) ( input_thread_t *, input_area_t * ) ; int (* input_ChangeArea_inner) ( input_thread_t *, input_area_t * ) ;
...@@ -206,7 +206,7 @@ struct module_symbols_t ...@@ -206,7 +206,7 @@ struct module_symbols_t
# define aout_BufferNew p_symbols->aout_BufferNew_inner # define aout_BufferNew p_symbols->aout_BufferNew_inner
# define aout_BufferPlay p_symbols->aout_BufferPlay_inner # define aout_BufferPlay p_symbols->aout_BufferPlay_inner
# define aout_DeleteInstance p_symbols->aout_DeleteInstance_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_InputDelete p_symbols->aout_InputDelete_inner
# define aout_OutputNextBuffer p_symbols->aout_OutputNextBuffer_inner # define aout_OutputNextBuffer p_symbols->aout_OutputNextBuffer_inner
# define config_Duplicate p_symbols->config_Duplicate_inner # define config_Duplicate p_symbols->config_Duplicate_inner
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* a52tospdif.c : encapsulates A/52 frames into S/PDIF packets * a52tospdif.c : encapsulates A/52 frames into S/PDIF packets
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Stphane Borel <stef@via.ecp.fr> * Stphane Borel <stef@via.ecp.fr>
...@@ -120,6 +120,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter, ...@@ -120,6 +120,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
p_filter->p_vlc->pf_memset( p_out + 8 + i_length, 0, p_filter->p_vlc->pf_memset( p_out + 8 + i_length, 0,
AOUT_SPDIF_SIZE - i_length - 8 ); 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;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* float32tos16.c : converter from float32 to signed 16 bits integer * float32tos16.c : converter from float32 to signed 16 bits integer
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -107,5 +107,6 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter, ...@@ -107,5 +107,6 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
} }
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples; 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;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* float32tos8.c : converter from float32 to signed 8 bits integer * float32tos8.c : converter from float32 to signed 8 bits integer
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Xavier Maillard <zedek@fxgsproject.org>
* *
...@@ -96,5 +96,6 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter, ...@@ -96,5 +96,6 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
} }
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples; 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;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* float32tou16.c : converter from float32 to unsigned 16 bits integer * float32tou16.c : converter from float32 to unsigned 16 bits integer
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Xavier Maillard <zedek@fxgsproject.org>
* *
...@@ -59,7 +59,7 @@ static int Create( vlc_object_t *p_this ) ...@@ -59,7 +59,7 @@ static int Create( vlc_object_t *p_this )
aout_filter_t * p_filter = (aout_filter_t *)p_this; aout_filter_t * p_filter = (aout_filter_t *)p_this;
if ( p_filter->input.i_format != AOUT_FMT_FLOAT32 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; return -1;
} }
...@@ -95,5 +95,6 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter, ...@@ -95,5 +95,6 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
} }
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples; 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;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* float32tou8.c : converter from float32 to unsigned 8 bits integer * float32tou8.c : converter from float32 to unsigned 8 bits integer
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Xavier Maillard <zedek@fxgsproject.org>
* *
...@@ -59,7 +59,7 @@ static int Create( vlc_object_t *p_this ) ...@@ -59,7 +59,7 @@ static int Create( vlc_object_t *p_this )
aout_filter_t * p_filter = (aout_filter_t *)p_this; aout_filter_t * p_filter = (aout_filter_t *)p_this;
if ( p_filter->input.i_format != AOUT_FMT_FLOAT32 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; return -1;
} }
...@@ -96,5 +96,6 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter, ...@@ -96,5 +96,6 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
} }
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples; 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;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* spdif.c : dummy mixer for S/PDIF output (1 input only) * spdif.c : dummy mixer for S/PDIF output (1 input only)
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -56,7 +56,7 @@ static int Create( vlc_object_t *p_this ) ...@@ -56,7 +56,7 @@ static int Create( vlc_object_t *p_this )
{ {
aout_instance_t * p_aout = (aout_instance_t *)p_this; 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; return -1;
} }
......
...@@ -210,13 +210,13 @@ static int aRtsThread( aout_instance_t * p_aout ) ...@@ -210,13 +210,13 @@ static int aRtsThread( aout_instance_t * p_aout )
if ( p_buffer != NULL ) if ( p_buffer != NULL )
{ {
p_bytes = p_buffer->p_buffer; p_bytes = p_buffer->p_buffer;
i_size = aout_FormatToSize( &p_aout->output.output, i_size = p_buffer->i_nb_bytes;
p_buffer->i_nb_samples );
} }
else else
{ {
i_size = aout_FormatToSize( &p_aout->output.output, i_size = aout_FormatToByterate( &p_aout->output.output )
p_sys->i_size ); * p_sys->i_size
/ p_aout->output.output.i_rate;
p_bytes = alloca( i_size ); p_bytes = alloca( i_size );
memset( p_bytes, 0, i_size ); memset( p_bytes, 0, i_size );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* esd.c : EsounD module * esd.c : EsounD module
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -150,8 +150,7 @@ static int SetFormat( aout_instance_t *p_aout ) ...@@ -150,8 +150,7 @@ static int SetFormat( aout_instance_t *p_aout )
* p_aout->output.output.i_rate / ESD_DEFAULT_RATE * p_aout->output.output.i_rate / ESD_DEFAULT_RATE
* aout_FormatTo( &p_aout->output.output, 1 ) ) * aout_FormatTo( &p_aout->output.output, 1 ) )
* (mtime_t)1000000 * (mtime_t)1000000
/ (mtime_t)aout_FormatToByterate( &p_aout->output.output, / (mtime_t)aout_FormatToByterate( &p_aout->output.output );
p_aout->output.output.i_rate );
p_sys->b_initialized = VLC_TRUE; p_sys->b_initialized = VLC_TRUE;
...@@ -207,13 +206,13 @@ static int ESDThread( aout_instance_t * p_aout ) ...@@ -207,13 +206,13 @@ static int ESDThread( aout_instance_t * p_aout )
if ( p_buffer != NULL ) if ( p_buffer != NULL )
{ {
p_bytes = p_buffer->p_buffer; p_bytes = p_buffer->p_buffer;
i_size = aout_FormatToSize( &p_aout->output.output, i_size = p_buffer->i_nb_bytes;
p_buffer->i_nb_samples );
} }
else else
{ {
i_size = aout_FormatToSize( &p_aout->output.output, i_size = aout_FormatToByterate( &p_aout->output.output )
ESD_BUF_SIZE * 2 ); * ESD_BUF_SIZE * 2
/ p_aout->output.output.i_rate;
p_bytes = alloca( i_size ); p_bytes = alloca( i_size );
memset( p_bytes, 0, i_size ); memset( p_bytes, 0, i_size );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* file.c : audio output which writes the samples to a file * file.c : audio output which writes the samples to a file
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "aout_internal.h" #include "aout_internal.h"
#define FRAME_SIZE 2048 #define FRAME_SIZE 2048
#define A52_FRAME_NB 1536
/***************************************************************************** /*****************************************************************************
* Local prototypes. * Local prototypes.
...@@ -57,7 +58,7 @@ static char *format_list[] = { "u8", "s8", "u16", "s16", "u16_le", "s16_le", ...@@ -57,7 +58,7 @@ static char *format_list[] = { "u8", "s8", "u16", "s16", "u16_le", "s16_le",
static int format_int[] = { AOUT_FMT_U8, AOUT_FMT_S8, AOUT_FMT_U16_NE, 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_S16_NE, AOUT_FMT_U16_LE, AOUT_FMT_S16_LE,
AOUT_FMT_U16_BE, AOUT_FMT_S16_BE, AOUT_FMT_FIXED32, 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_TEXT N_("Path of the output file")
#define PATH_LONGTEXT N_("By default samples.raw") #define PATH_LONGTEXT N_("By default samples.raw")
...@@ -82,7 +83,8 @@ static int Open( vlc_object_t * p_this ) ...@@ -82,7 +83,8 @@ static int Open( vlc_object_t * p_this )
FILE * p_file; FILE * p_file;
char * psz_name = config_GetPsz( p_this, "path" ); 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 ); free( psz_name );
if ( p_file == NULL ) return -1; if ( p_file == NULL ) return -1;
...@@ -128,7 +130,16 @@ static int SetFormat( aout_instance_t * p_aout ) ...@@ -128,7 +130,16 @@ static int SetFormat( aout_instance_t * p_aout )
} }
p_aout->output.output.i_format = format_int[i]; p_aout->output.output.i_format = format_int[i];
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; p_aout->output.i_nb_samples = FRAME_SIZE;
}
return 0; return 0;
} }
...@@ -137,9 +148,7 @@ static int SetFormat( aout_instance_t * p_aout ) ...@@ -137,9 +148,7 @@ static int SetFormat( aout_instance_t * p_aout )
*****************************************************************************/ *****************************************************************************/
static void Play( aout_instance_t * p_aout, aout_buffer_t * p_buffer ) static void Play( aout_instance_t * p_aout, aout_buffer_t * p_buffer )
{ {
if( fwrite( p_buffer->p_buffer, if( fwrite( p_buffer->p_buffer, p_buffer->i_nb_bytes, 1,
aout_FormatToSize( &p_aout->output.output,
p_buffer->i_nb_samples ), 1,
(FILE *)p_aout->output.p_sys ) != 1 ) (FILE *)p_aout->output.p_sys ) != 1 )
{ {
msg_Err( p_aout, "write error (%s)", strerror(errno) ); msg_Err( p_aout, "write error (%s)", strerror(errno) );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* oss.c : OSS /dev/dsp module for vlc * oss.c : OSS /dev/dsp module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2000-2002 VideoLAN * 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> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -65,7 +65,8 @@ struct aout_sys_t ...@@ -65,7 +65,8 @@ struct aout_sys_t
volatile vlc_bool_t b_initialized; volatile vlc_bool_t b_initialized;
}; };
#define DEFAULT_FRAME_SIZE 2048 #define FRAME_SIZE 2048
#define A52_FRAME_NB 1536
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
...@@ -167,15 +168,16 @@ static int SetFormat( aout_instance_t *p_aout ) ...@@ -167,15 +168,16 @@ static int SetFormat( aout_instance_t *p_aout )
} }
/* Set the output format */ /* 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 = A52_FRAME_NB;
p_aout->output.i_nb_samples = 1; p_aout->output.output.i_bytes_per_sec = p_aout->output.output.i_rate
* AOUT_SPDIF_SIZE / A52_FRAME_NB;
} }
else else
{ {
p_aout->output.output.i_format = i_format = AOUT_FMT_S16_NE; 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 if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0
...@@ -186,7 +188,7 @@ static int SetFormat( aout_instance_t *p_aout ) ...@@ -186,7 +188,7 @@ static int SetFormat( aout_instance_t *p_aout )
return -1; return -1;
} }
if ( !AOUT_FMT_IS_SPDIF( &p_aout->output.output ) ) if ( p_aout->output.output.i_format != AOUT_FMT_SPDIF )
{ {
/* FIXME */ /* FIXME */
if ( p_aout->output.output.i_channels > 2 ) if ( p_aout->output.output.i_channels > 2 )
...@@ -308,8 +310,7 @@ static int OSSThread( aout_instance_t * p_aout ) ...@@ -308,8 +310,7 @@ static int OSSThread( aout_instance_t * p_aout )
* Order is important here, since GetBufInfo is believed to take * Order is important here, since GetBufInfo is believed to take
* more time than mdate(). */ * more time than mdate(). */
next_date = (mtime_t)GetBufInfo( p_aout ) * 1000000 next_date = (mtime_t)GetBufInfo( p_aout ) * 1000000
/ aout_FormatToByterate( &p_aout->output.output, / aout_FormatToByterate( &p_aout->output.output );
p_aout->output.output.i_rate );
next_date += mdate(); next_date += mdate();
} }
...@@ -318,13 +319,13 @@ static int OSSThread( aout_instance_t * p_aout ) ...@@ -318,13 +319,13 @@ static int OSSThread( aout_instance_t * p_aout )
if ( p_buffer != NULL ) if ( p_buffer != NULL )
{ {
p_bytes = p_buffer->p_buffer; p_bytes = p_buffer->p_buffer;
i_size = aout_FormatToSize( &p_aout->output.output, i_size = p_buffer->i_nb_bytes;
p_buffer->i_nb_samples );
} }
else else
{ {
i_size = aout_FormatToSize( &p_aout->output.output, i_size = aout_FormatToByterate( &p_aout->output.output )
DEFAULT_FRAME_SIZE ); * FRAME_SIZE
/ p_aout->output.output.i_rate;
p_bytes = alloca( i_size ); p_bytes = alloca( i_size );
memset( p_bytes, 0, i_size ); memset( p_bytes, 0, i_size );
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* (http://liba52.sf.net/). * (http://liba52.sf.net/).
***************************************************************************** *****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN * 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> * Authors: Gildas Bazin <gbazin@netcourrier.com>
* Christophe Massiot <massiot@via.ecp.fr> * Christophe Massiot <massiot@via.ecp.fr>
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
# include "a52dec/a52.h" # include "a52dec/a52.h"
#endif #endif
#define A52_FRAME_SIZE 1536 #define A52_FRAME_NB 1536
/***************************************************************************** /*****************************************************************************
* a52_thread_t : a52 decoder thread descriptor * a52_thread_t : a52 decoder thread descriptor
...@@ -301,10 +301,10 @@ static int DecodeFrame( a52_thread_t * p_dec, byte_t * p_frame_buffer ) ...@@ -301,10 +301,10 @@ static int DecodeFrame( a52_thread_t * p_dec, byte_t * p_frame_buffer )
} }
p_buffer = aout_BufferNew( p_dec->p_aout, p_dec->p_aout_input, 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; if ( p_buffer == NULL ) return -1;
p_buffer->start_date = p_dec->last_date; 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_dec->output_format.i_rate;
p_buffer->end_date = p_dec->last_date; p_buffer->end_date = p_dec->last_date;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* spdif.c: A52 pass-through to external decoder with enabled soundcard * spdif.c: A52 pass-through to external decoder with enabled soundcard
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2002 VideoLAN * 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: Stphane Borel <stef@via.ecp.fr> * Authors: Stphane Borel <stef@via.ecp.fr>
* Juha Yrjola <jyrjola@cc.hut.fi> * Juha Yrjola <jyrjola@cc.hut.fi>
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
# include <unistd.h> # include <unistd.h>
#endif #endif
#define A52_FRAME_SIZE 1536 #define A52_FRAME_NB 1536
/***************************************************************************** /*****************************************************************************
* spdif_thread_t : A52 pass-through thread descriptor * spdif_thread_t : A52 pass-through thread descriptor
...@@ -137,8 +137,8 @@ static int RunDecoder( decoder_fifo_t *p_fifo ) ...@@ -137,8 +137,8 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
return -1; return -1;
} }
/* liba52 decoder thread's main loop */ /* decoder thread's main loop */
while( !p_dec->p_fifo->b_die && !p_dec->p_fifo->b_error ) while ( !p_dec->p_fifo->b_die && !p_dec->p_fifo->b_error )
{ {
int i_frame_size, i_flags, i_rate, i_bit_rate; int i_frame_size, i_flags, i_rate, i_bit_rate;
mtime_t pts; mtime_t pts;
...@@ -148,7 +148,7 @@ static int RunDecoder( decoder_fifo_t *p_fifo ) ...@@ -148,7 +148,7 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
/* Look for sync word - should be 0x0b77 */ /* Look for sync word - should be 0x0b77 */
RealignBits( &p_dec->bit_stream ); RealignBits( &p_dec->bit_stream );
while( (ShowBits( &p_dec->bit_stream, 16 ) ) != 0x0b77 && while ( (ShowBits( &p_dec->bit_stream, 16 ) ) != 0x0b77 &&
(!p_dec->p_fifo->b_die) && (!p_dec->p_fifo->b_error)) (!p_dec->p_fifo->b_die) && (!p_dec->p_fifo->b_error))
{ {
RemoveBits( &p_dec->bit_stream, 8 ); RemoveBits( &p_dec->bit_stream, 8 );
...@@ -169,7 +169,8 @@ static int RunDecoder( decoder_fifo_t *p_fifo ) ...@@ -169,7 +169,8 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
} }
if( (p_dec->p_aout_input != NULL) && 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. */ /* Parameters changed - this should not happen. */
aout_InputDelete( p_dec->p_aout, p_dec->p_aout_input ); aout_InputDelete( p_dec->p_aout, p_dec->p_aout_input );
...@@ -180,6 +181,7 @@ static int RunDecoder( decoder_fifo_t *p_fifo ) ...@@ -180,6 +181,7 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
if( p_dec->p_aout_input == NULL ) 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;
/* p_dec->output_format.i_channels = i_channels; */ /* p_dec->output_format.i_channels = i_channels; */
p_dec->p_aout_input = aout_InputNew( p_dec->p_fifo, p_dec->p_aout_input = aout_InputNew( p_dec->p_fifo,
&p_dec->p_aout, &p_dec->p_aout,
...@@ -209,10 +211,10 @@ static int RunDecoder( decoder_fifo_t *p_fifo ) ...@@ -209,10 +211,10 @@ static int RunDecoder( decoder_fifo_t *p_fifo )
} }
p_buffer = aout_BufferNew( p_dec->p_aout, p_dec->p_aout_input, 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; if ( p_buffer == NULL ) return -1;
p_buffer->start_date = last_date; 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_dec->output_format.i_rate;
p_buffer->end_date = last_date; p_buffer->end_date = last_date;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* aout_dummy.c : dummy audio output plugin * aout_dummy.c : dummy audio output plugin
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "aout_internal.h" #include "aout_internal.h"
#define FRAME_SIZE 2048 #define FRAME_SIZE 2048
#define A52_FRAME_NB 1536
/***************************************************************************** /*****************************************************************************
* Local prototypes. * Local prototypes.
...@@ -58,7 +59,16 @@ int E_(OpenAudio) ( vlc_object_t * p_this ) ...@@ -58,7 +59,16 @@ int E_(OpenAudio) ( vlc_object_t * p_this )
*****************************************************************************/ *****************************************************************************/
static int SetFormat( aout_instance_t * p_aout ) static int SetFormat( aout_instance_t * p_aout )
{ {
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; p_aout->output.i_nb_samples = FRAME_SIZE;
}
return 0; return 0;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* audio_output.c : audio output instance * audio_output.c : audio output instance
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -88,12 +88,15 @@ aout_buffer_t * aout_BufferNew( aout_instance_t * p_aout, ...@@ -88,12 +88,15 @@ aout_buffer_t * aout_BufferNew( aout_instance_t * p_aout,
size_t i_nb_samples ) size_t i_nb_samples )
{ {
aout_buffer_t * p_buffer; 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. */ /* This necessarily allocates in the heap. */
aout_BufferAlloc( &p_input->input_alloc, (u64)(1000000 * i_nb_samples) aout_BufferAlloc( &p_input->input_alloc, duration, NULL, p_buffer );
/ p_input->input.i_rate,
NULL, p_buffer );
p_buffer->i_nb_samples = i_nb_samples; p_buffer->i_nb_samples = i_nb_samples;
p_buffer->i_nb_bytes = duration
* aout_FormatToByterate( &p_input->input )
/ 1000000;
if ( p_buffer == NULL ) if ( p_buffer == NULL )
{ {
...@@ -161,10 +164,9 @@ void aout_BufferPlay( aout_instance_t * p_aout, aout_input_t * p_input, ...@@ -161,10 +164,9 @@ void aout_BufferPlay( aout_instance_t * p_aout, aout_input_t * p_input,
} }
/***************************************************************************** /*****************************************************************************
* aout_FormatTo : compute the number of bytes/sample for format (used for * aout_FormatToByterate : compute the number of bytes per second
* aout_FormatToByterate and aout_FormatToSize)
*****************************************************************************/ *****************************************************************************/
int aout_FormatTo( audio_sample_format_t * p_format, int i_multiplier ) int aout_FormatToByterate( audio_sample_format_t * p_format )
{ {
int i_result; int i_result;
...@@ -188,17 +190,16 @@ int aout_FormatTo( audio_sample_format_t * p_format, int i_multiplier ) ...@@ -188,17 +190,16 @@ int aout_FormatTo( audio_sample_format_t * p_format, int i_multiplier )
break; break;
case AOUT_FMT_SPDIF: case AOUT_FMT_SPDIF:
case AOUT_FMT_A52: /* Actually smaller and variable, but who cares ? */ case AOUT_FMT_A52:
case AOUT_FMT_DTS: /* Unimplemented and untested */ case AOUT_FMT_DTS:
/* Please note that we don't multiply by multiplier, because i_rate /* For these formats the caller has to indicate the number of bytes
* and i_nb_samples do not have any sense for S/PDIF (yes, it * per second it evaluates. */
* _is_ kludgy). --Meuuh */ return p_format->i_bytes_per_sec;
return AOUT_SPDIF_SIZE;
default: default:
return 0; /* will segfault much sooner... */ 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;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* filters.c : audio output filters management * filters.c : audio output filters management
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -161,10 +161,8 @@ void aout_FiltersHintBuffers( aout_instance_t * p_aout, ...@@ -161,10 +161,8 @@ void aout_FiltersHintBuffers( aout_instance_t * p_aout,
{ {
aout_filter_t * p_filter = pp_filters[i]; aout_filter_t * p_filter = pp_filters[i];
int i_output_size = aout_FormatToByterate( &p_filter->output, int i_output_size = aout_FormatToByterate( &p_filter->output );
p_filter->output.i_rate ); int i_input_size = aout_FormatToByterate( &p_filter->input );
int i_input_size = aout_FormatToByterate( &p_filter->input,
p_filter->input.i_rate );
p_first_alloc->i_bytes_per_sec = __MAX( p_first_alloc->i_bytes_per_sec, p_first_alloc->i_bytes_per_sec = __MAX( p_first_alloc->i_bytes_per_sec,
i_output_size ); i_output_size );
...@@ -209,8 +207,8 @@ void aout_FiltersPlay( aout_instance_t * p_aout, ...@@ -209,8 +207,8 @@ void aout_FiltersPlay( aout_instance_t * p_aout,
msg_Err( p_aout, "out of memory" ); msg_Err( p_aout, "out of memory" );
return; return;
} }
/* Please note that p_output_buffer->i_nb_samples shall be set by /* Please note that p_output_buffer->i_nb_samples & i_nb_bytes
* the filter plug-in. */ * shall be set by the filter plug-in. */
p_filter->pf_do_work( p_aout, p_filter, *pp_input_buffer, p_filter->pf_do_work( p_aout, p_filter, *pp_input_buffer,
p_output_buffer ); p_output_buffer );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input.c : internal management of input streams for the audio output * input.c : internal management of input streams for the audio output
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -64,6 +64,8 @@ static aout_input_t * InputNew( aout_instance_t * p_aout, ...@@ -64,6 +64,8 @@ static aout_input_t * InputNew( aout_instance_t * p_aout,
memcpy( &p_input->input, p_format, memcpy( &p_input->input, p_format,
sizeof(audio_sample_format_t) ); sizeof(audio_sample_format_t) );
p_input->input.i_bytes_per_sec =
aout_FormatToByterate( &p_input->input );
/* Prepare FIFO. */ /* Prepare FIFO. */
aout_FifoInit( p_aout, &p_input->fifo ); aout_FifoInit( p_aout, &p_input->fifo );
...@@ -117,8 +119,7 @@ static aout_input_t * InputNew( aout_instance_t * p_aout, ...@@ -117,8 +119,7 @@ static aout_input_t * InputNew( aout_instance_t * p_aout,
/* i_bytes_per_sec is still == -1 if no filters */ /* 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 = __MAX(
p_input->input_alloc.i_bytes_per_sec, p_input->input_alloc.i_bytes_per_sec,
aout_FormatToByterate( &p_input->input, p_input->input.i_bytes_per_sec );
p_input->input.i_rate ) );
/* Allocate in the heap, it is more convenient for the decoder. */ /* Allocate in the heap, it is more convenient for the decoder. */
p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP; p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mixer.c : audio output mixing operations * mixer.c : audio output mixing operations
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -122,6 +122,9 @@ void aout_MixerRun( aout_instance_t * p_aout ) ...@@ -122,6 +122,9 @@ void aout_MixerRun( aout_instance_t * p_aout )
return; return;
} }
p_output_buffer->i_nb_samples = p_aout->output.i_nb_samples; 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->start_date = first_date;
p_output_buffer->end_date = wanted_date; p_output_buffer->end_date = wanted_date;
p_aout->output.last_date = wanted_date; p_aout->output.last_date = wanted_date;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* output.c : internal management of output streams for the audio output * output.c : internal management of output streams for the audio output
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -61,7 +61,7 @@ int aout_OutputNew( aout_instance_t * p_aout, ...@@ -61,7 +61,7 @@ int aout_OutputNew( aout_instance_t * p_aout,
memcpy( &p_aout->output.output, p_format, sizeof(audio_sample_format_t) ); 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_rate != -1 ) p_aout->output.output.i_rate = i_rate;
if ( i_channels != -1 ) p_aout->output.output.i_channels = i_channels; 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; p_aout->output.output.i_format = AOUT_FMT_SPDIF;
} }
...@@ -88,22 +88,30 @@ int aout_OutputNew( aout_instance_t * p_aout, ...@@ -88,22 +88,30 @@ int aout_OutputNew( aout_instance_t * p_aout,
/* Calculate the resulting mixer output format. */ /* Calculate the resulting mixer output format. */
p_aout->mixer.output.i_channels = p_aout->output.output.i_channels; p_aout->mixer.output.i_channels = p_aout->output.output.i_channels;
p_aout->mixer.output.i_rate = p_aout->output.output.i_rate; p_aout->mixer.output.i_rate = p_aout->output.output.i_rate;
if ( AOUT_FMT_IS_SPDIF(&p_aout->output.output) ) if ( !AOUT_FMT_NON_LINEAR(&p_aout->output.output) )
{
p_aout->mixer.output.i_format = AOUT_FMT_SPDIF;
}
else
{ {
/* Non-S/PDIF mixer only deals with float32 or fixed32. */ /* Non-S/PDIF mixer only deals with float32 or fixed32. */
p_aout->mixer.output.i_format p_aout->mixer.output.i_format
= (p_aout->p_vlc->i_cpu & CPU_CAPABILITY_FPU) ? = (p_aout->p_vlc->i_cpu & CPU_CAPABILITY_FPU) ?
AOUT_FMT_FLOAT32 : AOUT_FMT_FIXED32; 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. */ /* Calculate the resulting mixer input format. */
p_aout->mixer.input.i_channels = -1; /* unchanged */ 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_rate = p_aout->mixer.output.i_rate;
p_aout->mixer.input.i_format = p_aout->mixer.output.i_format; 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. */ /* Create filters. */
if ( aout_FiltersCreatePipeline( p_aout, p_aout->output.pp_filters, if ( aout_FiltersCreatePipeline( p_aout, p_aout->output.pp_filters,
...@@ -119,8 +127,7 @@ int aout_OutputNew( aout_instance_t * p_aout, ...@@ -119,8 +127,7 @@ int aout_OutputNew( aout_instance_t * p_aout,
/* Prepare hints for the buffer allocator. */ /* Prepare hints for the buffer allocator. */
p_aout->mixer.output_alloc.i_alloc_type = AOUT_ALLOC_HEAP; p_aout->mixer.output_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
p_aout->mixer.output_alloc.i_bytes_per_sec p_aout->mixer.output_alloc.i_bytes_per_sec
= aout_FormatToByterate( &p_aout->output.output, = aout_FormatToByterate( &p_aout->output.output );
p_aout->output.output.i_rate );
aout_FiltersHintBuffers( p_aout, p_aout->output.pp_filters, aout_FiltersHintBuffers( p_aout, p_aout->output.pp_filters,
p_aout->output.i_nb_filters, p_aout->output.i_nb_filters,
......
...@@ -184,7 +184,7 @@ static const char * module_error( char *psz_buffer ) ...@@ -184,7 +184,7 @@ static const char * module_error( char *psz_buffer )
(p_symbols)->aout_BufferNew_inner = aout_BufferNew; \ (p_symbols)->aout_BufferNew_inner = aout_BufferNew; \
(p_symbols)->aout_BufferDelete_inner = aout_BufferDelete; \ (p_symbols)->aout_BufferDelete_inner = aout_BufferDelete; \
(p_symbols)->aout_BufferPlay_inner = aout_BufferPlay; \ (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_InputNew_inner = __aout_InputNew; \
(p_symbols)->aout_InputDelete_inner = aout_InputDelete; \ (p_symbols)->aout_InputDelete_inner = aout_InputDelete; \
(p_symbols)->aout_OutputNextBuffer_inner = aout_OutputNextBuffer; \ (p_symbols)->aout_OutputNextBuffer_inner = aout_OutputNextBuffer; \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment