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];
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; 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 );