Commit 34c71967 authored by Christophe Massiot's avatar Christophe Massiot

The liba52 "codec" is now an audio filter. It means we are now able to

autodetect S/PDIF hardware support and the audio output plug-in chooses
the best one. Of course it probably breaks existing output modules, see
oss.c for hints :).

Also include minor tweaks which will entitle us to decode and output 5.1
audio. It may break existing plug-ins, too. See
audio_output.c:aout_FormatNbChannels for hints.
parent 1e666bc2
......@@ -58,7 +58,7 @@ plugins_CFLAGS = @plugins_CFLAGS@
builtins_CFLAGS = @builtins_CFLAGS@
mozilla_CFLAGS = @mozilla_CFLAGS@
a52_CFLAGS = @a52_CFLAGS@
a52tofloat32_CFLAGS = @a52tofloat32_CFLAGS@
arts_CFLAGS = @arts_CFLAGS@
i420_yuy2_mmx_CFLAGS = @i420_yuy2_mmx_CFLAGS@
directx_CFLAGS = @directx_CFLAGS@
......@@ -94,7 +94,7 @@ plugins_LDFLAGS = @plugins_LDFLAGS@
builtins_LDFLAGS = @builtins_LDFLAGS@
mozilla_LDFLAGS = @mozilla_LDFLAGS@
a52_LDFLAGS = @a52_LDFLAGS@
a52tofloat32_LDFLAGS = @a52tofloat32_LDFLAGS@
aa_LDFLAGS = @aa_LDFLAGS@
alsa_LDFLAGS = @alsa_LDFLAGS@
arts_LDFLAGS = @arts_LDFLAGS@
......
......@@ -446,8 +446,8 @@ BUILTINS="${BUILTINS}"
PLUGINS="${PLUGINS} misc/dummy/dummy misc/null"
PLUGINS="${PLUGINS} control/rc/rc misc/logger/logger access/file misc/memcpy/memcpy"
PLUGINS="${PLUGINS} demux/mpeg/es demux/mpeg/audio demux/mpeg/mpeg_system demux/mpeg/ps demux/mpeg/ts demux/a52sys"
PLUGINS="${PLUGINS} codec/mpeg_video/idct/idct codec/mpeg_video/idct/idctclassic codec/mpeg_video/motion/motion codec/mpeg_video/mpeg_video codec/spudec/spudec codec/spdif codec/mpeg_audio/mpeg_audio"
PLUGINS="${PLUGINS} codec/a52old/imdct/imdct codec/a52old/downmix/downmix codec/a52old/a52old"
PLUGINS="${PLUGINS} codec/mpeg_video/idct/idct codec/mpeg_video/idct/idctclassic codec/mpeg_video/motion/motion codec/mpeg_video/mpeg_video codec/spudec/spudec codec/mpeg_audio/mpeg_audio"
PLUGINS="${PLUGINS} codec/a52old/imdct/imdct codec/a52old/downmix/downmix codec/a52old/a52old codec/a52"
#PLUGINS="${PLUGINS} codec/lpcm/lpcm"
PLUGINS="${PLUGINS} video_filter/deinterlace/deinterlace video_filter/invert video_filter/wall video_filter/transform video_filter/distort video_filter/clone video_filter/crop video_filter/motionblur"
PLUGINS="${PLUGINS} audio_filter/converter/float32tos16 audio_filter/converter/float32tos8 audio_filter/converter/float32tou16 audio_filter/converter/float32tou8 audio_filter/converter/a52tospdif audio_filter/converter/fixed32tofloat32 audio_filter/converter/fixed32tos16 audio_filter/converter/s16tofloat32"
......@@ -1185,17 +1185,17 @@ then
if test -f ${real_a52_tree}/include/a52.h
then
AC_MSG_RESULT(yes)
a52_CFLAGS="${a52_CFLAGS} -I${real_a52_tree}"
a52_LDFLAGS="${a52_LDFLAGS} -L${real_a52_tree}/liba52/.libs"
LDFLAGS="${save_LDFLAGS} ${a52_LDFLAGS}"
a52tofloat32_CFLAGS="${a52tofloat32_CFLAGS} -I${real_a52_tree}"
a52tofloat32_LDFLAGS="${a52tofloat32_LDFLAGS} -L${real_a52_tree}/liba52/.libs"
LDFLAGS="${save_LDFLAGS} ${a52tofloat32_LDFLAGS}"
AC_CHECK_LIB(a52, a52_free, [
BUILTINS="${BUILTINS} codec/a52"
a52_LDFLAGS="${a52_LDFLAGS} -la52 -lm"
a52_CFLAGS="${a52_CFLAGS} -DUSE_A52DEC_TREE"
BUILTINS="${BUILTINS} audio_filter/converter/a52tofloat32"
a52tofloat32_LDFLAGS="${a52tofloat32_LDFLAGS} -la52 -lm"
a52tofloat32_CFLAGS="${a52tofloat32_CFLAGS} -DUSE_A52DEC_TREE"
],[
if test -f ${real_a52_tree}/liba52/.libs/liba52.a
then
AC_MSG_ERROR([make sure you have at least a52dec-0.7.3])
AC_MSG_ERROR([make sure you have at least a52dec-0.7.4])
else
AC_MSG_ERROR([the specified tree hasn't been compiled])
fi
......@@ -1220,9 +1220,9 @@ then
LDFLAGS="${save_LDFLAGS} ${test_LDFLAGS}"
AC_CHECK_HEADERS(a52dec/a52.h, [
AC_CHECK_LIB(a52, a52_free, [
BUILTINS="${BUILTINS} codec/a52"
a52_LDFLAGS="${a52_LDFLAGS} ${test_LDFLAGS} -la52 -lm"
a52_CFLAGS="${a52_CFLAGS} ${test_CFLAGS}"
BUILTINS="${BUILTINS} audio_filter/converter/a52tofloat32"
a52tofloat32_LDFLAGS="${a52tofloat32_LDFLAGS} ${test_LDFLAGS} -la52 -lm"
a52tofloat32_CFLAGS="${a52tofloat32_CFLAGS} ${test_CFLAGS}"
],[
if test "x${enable_dvbpsi}" != "x"
then
......@@ -2081,7 +2081,7 @@ AC_SUBST(plugins_CFLAGS)
AC_SUBST(builtins_CFLAGS)
AC_SUBST(mozilla_CFLAGS)
AC_SUBST(a52_CFLAGS)
AC_SUBST(a52tofloat32_CFLAGS)
AC_SUBST(arts_CFLAGS)
AC_SUBST(i420_yuy2_mmx_CFLAGS)
AC_SUBST(dvd_CFLAGS)
......@@ -2115,7 +2115,7 @@ AC_SUBST(plugins_LDFLAGS)
AC_SUBST(builtins_LDFLAGS)
AC_SUBST(mozilla_LDFLAGS)
AC_SUBST(a52_LDFLAGS)
AC_SUBST(a52tofloat32_LDFLAGS)
AC_SUBST(aa_LDFLAGS)
AC_SUBST(alsa_LDFLAGS)
AC_SUBST(arts_LDFLAGS)
......
......@@ -2,7 +2,7 @@
* aout_internal.h : internal defines for audio output
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: aout_internal.h,v 1.14 2002/08/30 23:27:05 massiot Exp $
* $Id: aout_internal.h,v 1.15 2002/09/02 23:17:05 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -226,6 +226,7 @@ void aout_OutputPlay( aout_instance_t * p_aout, aout_buffer_t * p_buffer );
void aout_OutputDelete( aout_instance_t * p_aout );
VLC_EXPORT( aout_buffer_t *, aout_OutputNextBuffer, ( aout_instance_t *, mtime_t, vlc_bool_t ) );
VLC_EXPORT( int, aout_FormatNbChannels, ( audio_sample_format_t * p_format ) );
void aout_FormatPrepare( audio_sample_format_t * p_format );
void aout_FifoInit( aout_instance_t *, aout_fifo_t *, u32 );
mtime_t aout_FifoNextStart( aout_instance_t *, aout_fifo_t * );
......
......@@ -2,7 +2,7 @@
* audio_output.h : audio output interface
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: audio_output.h,v 1.61 2002/08/21 22:41:59 massiot Exp $
* $Id: audio_output.h,v 1.62 2002/09/02 23:17:05 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -107,6 +107,35 @@ typedef s32 vlc_fixed_t;
#define FIXED32_ONE ((vlc_fixed_t) 0x10000000)
/* Dual mono. Two independant mono channels */
#define AOUT_CHAN_CHANNEL 0x0000000B
#define AOUT_CHAN_MONO 0x00000001
#define AOUT_CHAN_STEREO 0x00000002
/* 3 front channels (left, center, right) */
#define AOUT_CHAN_3F 0x00000003
/* 2 front, 1 rear surround channels (L, R, S) */
#define AOUT_CHAN_2F1R 0x00000004
/* 3 front, 1 rear surround channels (L, C, R, S) */
#define AOUT_CHAN_3F1R 0x00000005
/* 2 front, 2 rear surround channels (L, R, LS, RS) */
#define AOUT_CHAN_2F2R 0x00000006
/* 3 front, 2 rear surround channels (L, C, R, LS, RS) */
#define AOUT_CHAN_3F2R 0x00000007
/* First of two mono channels */
#define AOUT_CHAN_CHANNEL1 0x00000008
/* Second of two mono channels */
#define AOUT_CHAN_CHANNEL2 0x00000009
/* Dolby surround compatible stereo */
#define AOUT_CHAN_DOLBY 0x0000000A
#define AOUT_CHAN_MASK 0x0000000F
/* Low frequency effects channel. Normally used to connect a subwoofer.
* Can be combined with any of the above channels. For example :
* AOUT_CHAN_3F2R | AOUT_CHAN_LFE -> 3 front, 2 rear, 1 LFE (5.1) */
#define AOUT_CHAN_LFE 0x00000010
/*****************************************************************************
* aout_buffer_t : audio output buffer
*****************************************************************************/
......
......@@ -37,6 +37,7 @@ struct module_symbols_t
int (* __vlc_thread_create_inner) ( vlc_object_t *, char *, int, char *, void * ( * ) ( void * ), int, vlc_bool_t ) ;
int (* __vlc_threads_end_inner) ( vlc_object_t * ) ;
int (* __vlc_threads_init_inner) ( vlc_object_t * ) ;
int (* aout_FormatNbChannels_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 * ) ;
......@@ -224,6 +225,7 @@ struct module_symbols_t
# define aout_DateSet p_symbols->aout_DateSet_inner
# define aout_DeleteInstance p_symbols->aout_DeleteInstance_inner
# define aout_FifoPop p_symbols->aout_FifoPop_inner
# define aout_FormatNbChannels p_symbols->aout_FormatNbChannels_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
......
......@@ -3,7 +3,7 @@
* This header provides portable declarations for mutexes & conditions
*****************************************************************************
* Copyright (C) 1999, 2002 VideoLAN
* $Id: vlc_threads.h,v 1.12 2002/09/01 21:20:29 massiot Exp $
* $Id: vlc_threads.h,v 1.13 2002/09/02 23:17:05 massiot Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
......@@ -71,7 +71,7 @@
# define VLC_THREAD_PRIORITY_LOW 0
# define VLC_THREAD_PRIORITY_INPUT 37
# define VLC_THREAD_PRIORITY_AUDIO 38
# define VLC_THREAD_PRIORITY_VIDEO 36
# define VLC_THREAD_PRIORITY_VIDEO 31
# define VLC_THREAD_PRIORITY_OUTPUT 38
#elif defined(WIN32)
......
......@@ -3,6 +3,7 @@ float32tos8_SOURCES = float32tos8.c
float32tou16_SOURCES = float32tou16.c
float32tou8_SOURCES = float32tou8.c
a52tospdif_SOURCES = a52tospdif.c
a52tofloat32_SOURCES = a52tofloat32.c
fixed32tos16_SOURCES = fixed32tos16.c
fixed32tofloat32_SOURCES = fixed32tofloat32.c
s16tofloat32_SOURCES = s16tofloat32.c
/*****************************************************************************
* a52tofloat32.c: ATSC A/52 aka AC-3 decoder plugin for VLC.
* This plugin makes use of liba52 to decode A/52 audio
* (http://liba52.sf.net/).
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: a52tofloat32.c,v 1.1 2002/09/02 23:17:05 massiot Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
* Christophe Massiot <massiot@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <vlc/vlc.h>
#include <stdlib.h> /* malloc(), free() */
#include <string.h> /* strdup() */
#ifdef HAVE_STDINT_H
# include <stdint.h> /* int16_t .. */
#elif HAVE_INTTYPES_H
# include <inttypes.h> /* int16_t .. */
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef USE_A52DEC_TREE /* liba52 header file */
# include "include/a52.h"
#else
# include "a52dec/a52.h"
#endif
#include "audio_output.h"
#include "aout_internal.h"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int Create ( vlc_object_t * );
static void Destroy ( vlc_object_t * );
static void DoWork ( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
aout_buffer_t * );
/*****************************************************************************
* Local structures
*****************************************************************************/
struct aout_filter_sys_t
{
a52_state_t * p_liba52; /* liba52 internal structure */
vlc_bool_t b_dynrng; /* see below */
int i_flags; /* liba52 flags, see a52dec/doc/liba52.txt */
int i_nb_channels; /* number of float32 per sample */
};
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define DYNRNG_TEXT N_("A/52 dynamic range compression")
#define DYNRNG_LONGTEXT N_( \
"Dynamic range compression makes the loud sounds softer, and the soft " \
"sounds louder, so you can more easily listen to the stream in a noisy " \
"environment without disturbing anyone. If you disable the dynamic range "\
"compression the playback will be more adapted to a movie theater or a " \
"listening room.")
vlc_module_begin();
add_category_hint( N_("Miscellaneous"), NULL );
add_bool( "a52-dynrng", 1, NULL, DYNRNG_TEXT, DYNRNG_LONGTEXT );
set_description( _("ATSC A/52 aka AC-3 audio decoder module") );
set_capability( "audio filter", 100 );
set_callbacks( Create, Destroy );
vlc_module_end();
/*****************************************************************************
* Create:
*****************************************************************************/
static int Create( vlc_object_t * _p_filter )
{
aout_filter_t * p_filter = (aout_filter_t *)_p_filter;
struct aout_filter_sys_t * p_sys;
if ( p_filter->input.i_format != AOUT_FMT_A52
|| p_filter->output.i_format != AOUT_FMT_FLOAT32 )
{
return -1;
}
if ( p_filter->input.i_rate != p_filter->output.i_rate )
{
return -1;
}
/* Allocate the memory needed to store the module's structure */
p_sys = p_filter->p_sys = malloc( sizeof(struct aout_filter_sys_t) );
if( p_sys == NULL )
{
msg_Err( p_filter, "out of memory" );
return -1;
}
p_sys->b_dynrng = config_GetInt( p_filter, "a52-dynrng" );
/* We'll do our own downmixing, thanks. */
p_sys->i_nb_channels = aout_FormatNbChannels( &p_filter->output );
switch ( p_filter->output.i_channels & AOUT_CHAN_MASK )
{
case AOUT_CHAN_CHANNEL: p_sys->i_flags = A52_CHANNEL; break;
case AOUT_CHAN_CHANNEL1: p_sys->i_flags = A52_CHANNEL1; break;
case AOUT_CHAN_CHANNEL2: p_sys->i_flags = A52_CHANNEL2; break;
case AOUT_CHAN_MONO: p_sys->i_flags = A52_MONO; break;
case AOUT_CHAN_STEREO: p_sys->i_flags = A52_STEREO; break;
case AOUT_CHAN_DOLBY: p_sys->i_flags = A52_DOLBY; break;
case AOUT_CHAN_3F: p_sys->i_flags = A52_3F; break;
case AOUT_CHAN_2F1R: p_sys->i_flags = A52_2F1R; break;
case AOUT_CHAN_3F1R: p_sys->i_flags = A52_3F1R; break;
case AOUT_CHAN_2F2R: p_sys->i_flags = A52_2F2R; break;
case AOUT_CHAN_3F2R: p_sys->i_flags = A52_3F2R; break;
default:
msg_Err( p_filter, "unknow sample format !" );
free( p_sys );
return -1;
}
if ( p_filter->output.i_channels & AOUT_CHAN_LFE )
{
p_sys->i_flags |= A52_LFE;
}
p_sys->i_flags |= A52_ADJUST_LEVEL;
/* Initialize liba52 */
p_sys->p_liba52 = a52_init( 0 );
if( p_sys->p_liba52 == NULL )
{
msg_Err( p_filter, "unable to initialize liba52" );
return -1;
}
p_filter->pf_do_work = DoWork;
p_filter->b_in_place = 0;
return 0;
}
/*****************************************************************************
* Interleave: helper function to interleave channels
*****************************************************************************/
static void Interleave( float * p_out, const float * p_in, int i_channels )
{
int i, j;
for ( j = 0; j < i_channels; j++ )
{
for ( i = 0; i < 256; i++ )
{
p_out[i * i_channels + j] = p_in[j * 256 + i];
}
}
}
/*****************************************************************************
* DoWork: decode an ATSC A/52 frame.
*****************************************************************************/
static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
aout_buffer_t * p_in_buf, aout_buffer_t * p_out_buf )
{
struct aout_filter_sys_t * p_sys = p_filter->p_sys;
sample_t i_sample_level = 1;
int i_flags = p_sys->i_flags;
int i_bytes_per_block = 256 * p_sys->i_nb_channels
* sizeof(float);
int i;
/* Do the actual decoding now. */
a52_frame( p_sys->p_liba52, p_in_buf->p_buffer,
&i_flags, &i_sample_level, 0 );
if ( i_flags != p_sys->i_flags )
{
msg_Err( p_filter,
"liba52 couldn't do the requested downmix 0x%x->0x%x",
p_sys->i_flags, i_flags );
memset( p_out_buf->p_buffer, 0, i_bytes_per_block * 6 );
return;
}
if( !p_sys->b_dynrng )
{
a52_dynrng( p_filter->p_sys->p_liba52, NULL, NULL );
}
for ( i = 0; i < 6; i++ )
{
sample_t * p_samples;
if( a52_block( p_sys->p_liba52 ) )
{
msg_Warn( p_filter, "a52_block failed for block %d", i );
}
p_samples = a52_samples( p_sys->p_liba52 );
/* Interleave the *$% samples. */
Interleave( (float *)(p_out_buf->p_buffer + i * i_bytes_per_block),
p_samples, p_sys->i_nb_channels );
}
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
p_out_buf->i_nb_bytes = i_bytes_per_block * 6;
}
/*****************************************************************************
* Destroy : deallocate data structures
*****************************************************************************/
static void Destroy( vlc_object_t * _p_filter )
{
aout_filter_t * p_filter = (aout_filter_t *)_p_filter;
struct aout_filter_sys_t * p_sys = p_filter->p_sys;
a52_free( p_sys->p_liba52 );
free( p_sys );
}
......@@ -2,7 +2,7 @@
* a52tospdif.c : encapsulates A/52 frames into S/PDIF packets
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: a52tospdif.c,v 1.10 2002/08/26 23:00:22 massiot Exp $
* $Id: a52tospdif.c,v 1.11 2002/09/02 23:17:05 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Stphane Borel <stef@via.ecp.fr>
......@@ -42,7 +42,6 @@
* Local prototypes
*****************************************************************************/
static int Create ( vlc_object_t * );
static void DoWork ( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
aout_buffer_t * );
......@@ -56,9 +55,7 @@ vlc_module_begin();
vlc_module_end();
/*****************************************************************************
* Create: allocate trivial mixer
*****************************************************************************
* This function allocates and initializes a Crop vout method.
* Create:
*****************************************************************************/
static int Create( vlc_object_t *p_this )
{
......
......@@ -2,7 +2,7 @@
* oss.c : OSS /dev/dsp module for vlc
*****************************************************************************
* Copyright (C) 2000-2002 VideoLAN
* $Id: oss.c,v 1.22 2002/08/31 22:10:25 stef Exp $
* $Id: oss.c,v 1.23 2002/09/02 23:17:05 massiot Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -174,8 +174,25 @@ static int Open( vlc_object_t *p_this )
if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0
|| i_format != p_aout->output.output.i_format )
{
msg_Err( p_aout, "cannot set audio output format (%i)", i_format );
return VLC_EGENERIC;
if ( i_format == AOUT_FMT_SPDIF )
{
/* Retry with S16 */
msg_Warn( p_aout, "cannot set audio output format (%i)", i_format );
p_aout->output.output.i_format = i_format = AOUT_FMT_S16_NE;
p_aout->output.i_nb_samples = FRAME_SIZE;
if( ioctl( p_sys->i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0
|| i_format != p_aout->output.output.i_format )
{
msg_Err( p_aout, "cannot set audio output format (%i)",
i_format );
return VLC_EGENERIC;
}
}
else
{
msg_Err( p_aout, "cannot set audio output format (%i)", i_format );
return VLC_EGENERIC;
}
}
if ( p_aout->output.output.i_format != AOUT_FMT_SPDIF )
......
......@@ -2,7 +2,7 @@
* sdl.c : SDL audio output plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2002 VideoLAN
* $Id: sdl.c,v 1.10 2002/08/31 19:58:04 stef Exp $
* $Id: sdl.c,v 1.11 2002/09/02 23:17:05 massiot Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -103,6 +103,11 @@ static int Open ( vlc_object_t *p_this )
return VLC_EGENERIC;
}
if ( p_aout->output.output.i_channels > 2 )
p_aout->output.output.i_channels = 2;
p_aout->output.output.i_format = AOUT_FMT_S16_NE;
p_aout->output.i_nb_samples = FRAME_SIZE;
/* TODO: finish and clean this */
desired.freq = p_aout->output.output.i_rate;
......@@ -118,9 +123,6 @@ static int Open ( vlc_object_t *p_this )
return VLC_EGENERIC;
}
p_aout->output.output.i_format = AOUT_FMT_S16_NE;
p_aout->output.i_nb_samples = FRAME_SIZE;
SDL_PauseAudio( 0 );
return VLC_SUCCESS;
......
a52_SOURCES = a52.c
spdif_SOURCES = spdif.c
This diff is collapsed.
This diff is collapsed.
......@@ -2,7 +2,7 @@
* aout.m: CoreAudio output plugin
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: aout.m,v 1.8 2002/08/30 23:27:06 massiot Exp $
* $Id: aout.m,v 1.9 2002/09/02 23:17:05 massiot Exp $
*
* Authors: Colin Delacroix <colin@zoy.org>
* Jon Lech Johansen <jon-vl@nanocrew.net>
......@@ -118,17 +118,13 @@ int E_(OpenAudio)( vlc_object_t * p_this )
return -1 ;
}
/* We only deal with floats */
if ( p_aout->output.output.i_format != AOUT_FMT_FLOAT32 )
{
msg_Err( p_aout, "cannot set format 0x%x",
p_aout->output.output.i_format );
return -1;
}
/* We only deal with floats. FIXME : this is where we should do S/PDIF. */
p_aout->output.output.i_format = AOUT_FMT_FLOAT32;
/* Set sample rate and channels per frame */
p_aout->output.output.i_rate = p_sys->stream_format.mSampleRate;
p_aout->output.output.i_channels = p_sys->stream_format.mChannelsPerFrame;
/* FIXME : this is where we should ask for downmixing. */
p_aout->output.output.i_channels = 2; //p_sys->stream_format.mChannelsPerFrame;
/* Get the buffer size that the device uses for IO */
i_param_size = sizeof( p_sys->i_buffer_size );
......
......@@ -2,7 +2,7 @@
# Copyright (C) 1995-1997, 2000, 2001 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
#
# This file file be copied and used freely without restrictions. It can
# be used in projects which are not available under the GNU General Public License
# be used in projects which are not available under the GNU Public License
# but which still want to provide support for the GNU gettext functionality.
# Please note that the actual code is *not* freely available.
......
......@@ -2,7 +2,7 @@
* audio_output.c : audio output instance miscellaneous functions
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: audio_output.c,v 1.100 2002/08/30 22:22:24 massiot Exp $
* $Id: audio_output.c,v 1.101 2002/09/02 23:17:06 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -150,9 +150,54 @@ void aout_BufferPlay( aout_instance_t * p_aout, aout_input_t * p_input,
/*
* Formats management (internal)
* Formats management
*/
/*****************************************************************************
* aout_FormatNbChannels : return the number of channels
*****************************************************************************/
int aout_FormatNbChannels( audio_sample_format_t * p_format )
{
int i_nb;
switch ( p_format->i_channels & AOUT_CHAN_MASK )
{
case AOUT_CHAN_CHANNEL1:
case AOUT_CHAN_CHANNEL2:
case AOUT_CHAN_MONO:
i_nb = 1;
break;
case AOUT_CHAN_CHANNEL:
case AOUT_CHAN_STEREO:
case AOUT_CHAN_DOLBY:
i_nb = 2;
break;
case AOUT_CHAN_3F:
case AOUT_CHAN_2F1R:
i_nb = 3;
break;
case AOUT_CHAN_3F1R:
case AOUT_CHAN_2F2R:
i_nb = 4;
break;
case AOUT_CHAN_3F2R:
i_nb = 5;
break;
default:
i_nb = 0;
}
if ( p_format->i_channels & AOUT_CHAN_LFE )
return i_nb + 1;
else
return i_nb;
}
/*****************************************************************************
* aout_FormatPrepare : compute the number of bytes per frame & frame length
*****************************************************************************/
......@@ -190,7 +235,7 @@ void aout_FormatPrepare( audio_sample_format_t * p_format )
i_result = 0; /* will segfault much sooner... */
}
p_format->i_bytes_per_frame = i_result * p_format->i_channels;
p_format->i_bytes_per_frame = i_result * aout_FormatNbChannels( p_format );
p_format->i_frame_length = 1;
}
......
......@@ -2,7 +2,7 @@
* filters.c : audio output filters management
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: filters.c,v 1.8 2002/08/30 22:22:24 massiot Exp $
* $Id: filters.c,v 1.9 2002/09/02 23:17:06 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -75,9 +75,7 @@ static aout_filter_t * FindFilter( aout_instance_t * p_aout,
static int SplitConversion( aout_instance_t * p_aout,
const audio_sample_format_t * p_input_format,
const audio_sample_format_t * p_output_format,
audio_sample_format_t * p_middle_format,
vlc_bool_t b_format_first,
vlc_bool_t b_rate_first )
audio_sample_format_t * p_middle_format )
{
vlc_bool_t b_format =
(p_input_format->i_format != p_output_format->i_format);
......@@ -94,56 +92,23 @@ static int SplitConversion( aout_instance_t * p_aout,
{
if ( !b_format )
{
if ( b_rate_first )
{
p_middle_format->i_channels = p_input_format->i_channels;
}
else
{
p_middle_format->i_rate = p_input_format->i_rate;
}
p_middle_format->i_rate = p_input_format->i_rate;
return 1;
}
if ( !b_rate )
{
if ( b_format_first )
{
p_middle_format->i_channels = p_input_format->i_channels;
}
else
{
p_middle_format->i_format = p_input_format->i_format;
}
p_middle_format->i_channels = p_input_format->i_channels;
return 1;
}
/* !b_channels */
if ( b_format_first )
{
p_middle_format->i_rate = p_input_format->i_rate;
}
else
{
p_middle_format->i_format = p_input_format->i_format;
}
p_middle_format->i_rate = p_input_format->i_rate;
return 1;
}
/* i_nb_conversion == 3 */
if ( !b_format_first )
{
p_middle_format->i_format = p_input_format->i_format;
}
else if ( !b_rate_first )
{
p_middle_format->i_channels = p_input_format->i_channels;
}
else
{
p_middle_format->i_rate = p_input_format->i_rate;
}
p_middle_format->i_channels = p_input_format->i_channels;
return 2;
}
......@@ -160,7 +125,7 @@ int aout_FiltersCreatePipeline( aout_instance_t * p_aout,
const audio_sample_format_t * p_output_format )
{
audio_sample_format_t temp_format;
vlc_bool_t b_format_first, b_rate_first;
int i_nb_conversions;
if ( AOUT_FMTS_IDENTICAL( p_input_format, p_output_format ) )
{
......@@ -184,90 +149,83 @@ int aout_FiltersCreatePipeline( aout_instance_t * p_aout,
}
/* We'll have to split the conversion. We always do the downmixing
* before the resampling, and the upmixing after the resampling (to
* maximize the resampling efficiency). */
b_rate_first = (p_input_format->i_channels < p_output_format->i_channels);
* before the resampling, because the audio decoder can probably do it
* for us. */
i_nb_conversions = SplitConversion( p_aout, p_input_format,
p_output_format, &temp_format );
if ( !i_nb_conversions )
{
/* There was only one conversion to do, and we already failed. */
msg_Err( p_aout, "couldn't find a filter for the conversion" );
return -1;
}
for ( b_format_first = 1; b_format_first >= 0; b_format_first-- )
pp_filters[0] = FindFilter( p_aout, p_input_format, &temp_format );
if ( pp_filters[0] == NULL && i_nb_conversions == 2 )
{
int i_nb_conversions = SplitConversion( p_aout, p_input_format,
p_output_format, &temp_format,
b_format_first, b_rate_first );
if ( !i_nb_conversions )
{
/* There was only one conversion to do, and we already failed. */
msg_Err( p_aout, "couldn't find a filter for the conversion" );
return -1;
}
/* Try with only one conversion. */
SplitConversion( p_aout, p_input_format, &temp_format,
&temp_format );
pp_filters[0] = FindFilter( p_aout, p_input_format,
&temp_format );
}
if ( pp_filters[0] == NULL )
{
msg_Err( p_aout,
"couldn't find a filter for the first part of the conversion" );
return -1;
}
pp_filters[0] = FindFilter( p_aout, p_input_format, &temp_format );
if ( pp_filters[0] == NULL && i_nb_conversions == 2 )
{
/* Try with only one conversion. */
SplitConversion( p_aout, p_input_format, &temp_format,
&temp_format, b_format_first, b_rate_first );
pp_filters[0] = FindFilter( p_aout, p_input_format,
&temp_format );
}
if ( pp_filters[0] == NULL )
/* We have the first stage of the conversion. Find a filter for
* the rest. */
pp_filters[1] = FindFilter( p_aout, &pp_filters[0]->output,
p_output_format );
if ( pp_filters[1] == NULL )
{
/* Try to split the conversion. */
i_nb_conversions = SplitConversion( p_aout,
&pp_filters[0]->output,
p_output_format, &temp_format );
if ( !i_nb_conversions )
{
/* Retry with b_format_first = 0. */
continue;
vlc_object_detach( pp_filters[0] );
vlc_object_destroy( pp_filters[0] );
msg_Err( p_aout,
"couldn't find a filter for the second part of the conversion" );
}
/* We have the first stage of the conversion. Find a filter for
* the rest. */
pp_filters[1] = FindFilter( p_aout, &pp_filters[0]->output,
&temp_format );
pp_filters[2] = FindFilter( p_aout, &temp_format,
p_output_format );
if ( pp_filters[1] == NULL )
if ( pp_filters[1] == NULL || pp_filters[2] == NULL )
{
/* Try to split the conversion. */
i_nb_conversions = SplitConversion( p_aout,
&pp_filters[0]->output,
p_output_format, &temp_format,
b_format_first, b_rate_first );
if ( !i_nb_conversions )
vlc_object_detach( pp_filters[0] );
vlc_object_destroy( pp_filters[0] );
if ( pp_filters[1] != NULL )
{
vlc_object_detach( pp_filters[0] );
vlc_object_destroy( pp_filters[0] );
continue;
vlc_object_detach( pp_filters[1] );
vlc_object_destroy( pp_filters[1] );
}
pp_filters[1] = FindFilter( p_aout, &pp_filters[0]->output,
&temp_format );
pp_filters[2] = FindFilter( p_aout, &temp_format,
p_output_format );
if ( pp_filters[1] == NULL || pp_filters[2] == NULL )
if ( pp_filters[2] != NULL )
{
vlc_object_detach( pp_filters[0] );
vlc_object_destroy( pp_filters[0] );
if ( pp_filters[1] != NULL )
{
vlc_object_detach( pp_filters[1] );
vlc_object_destroy( pp_filters[1] );
}
if ( pp_filters[2] != NULL )
{
vlc_object_detach( pp_filters[2] );
vlc_object_destroy( pp_filters[2] );
}
continue;
vlc_object_detach( pp_filters[2] );
vlc_object_destroy( pp_filters[2] );
}
*pi_nb_filters = 3;
}
else
{
*pi_nb_filters = 2;
msg_Err( p_aout,
"couldn't find filters for the second part of the conversion" );
}
/* We have enough filters. */
msg_Dbg( p_aout, "found %d filters for the whole conversion",
*pi_nb_filters );
return 0;
*pi_nb_filters = 3;
}
else
{
*pi_nb_filters = 2;
}
msg_Err( p_aout, "couldn't find filters for the conversion" );
return -1;
/* We have enough filters. */
msg_Dbg( p_aout, "found %d filters for the whole conversion",
*pi_nb_filters );
return 0;
}
/*****************************************************************************
......
......@@ -180,6 +180,7 @@ static const char * module_error( char *psz_buffer )
*****************************************************************************/
#define STORE_SYMBOLS( p_symbols ) \
(p_symbols)->aout_OutputNextBuffer_inner = aout_OutputNextBuffer; \
(p_symbols)->aout_FormatNbChannels_inner = aout_FormatNbChannels; \
(p_symbols)->aout_FifoPop_inner = aout_FifoPop; \
(p_symbols)->__aout_NewInstance_inner = __aout_NewInstance; \
(p_symbols)->aout_DeleteInstance_inner = aout_DeleteInstance; \
......
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