Commit fb397dc0 authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* Backport of the Mac OS X audio fixes to 0.8.4a (fixes #456)

parent b759e185
......@@ -577,8 +577,6 @@ VLC-release.app: vlc
cp "$(srcdir)/$$i" $(top_builddir)/tmp; \
done
mkdir -p $(top_builddir)/tmp/modules/audio_output
cp $(srcdir)/modules/audio_output/coreaudio.c \
$(top_builddir)/tmp/modules/audio_output/coreaudio.c
mkdir -p $(top_builddir)/tmp/modules/gui/macosx
for i in \
about.h \
......@@ -691,8 +689,6 @@ VLC.app: vlc
cp "$(srcdir)/$$i" $(top_builddir)/tmp; \
done
mkdir -p $(top_builddir)/tmp/modules/audio_output
cp $(srcdir)/modules/audio_output/coreaudio.c \
$(top_builddir)/tmp/modules/audio_output/coreaudio.c
mkdir -p $(top_builddir)/tmp/modules/gui/macosx
for i in \
about.h \
......
......@@ -3627,14 +3627,14 @@ fi
dnl
dnl CoreAudio plugin
dnl
AC_ARG_ENABLE(coreaudio,
[ --enable-coreaudio CoreAudio module (default enabled on MacOS X)])
if test "${enable_coreaudio}" != "no" &&
(test "${SYS}" = "darwin" || test "${enable_coreaudio}" = "yes")
AC_ARG_ENABLE(macosx-audio,
[ --enable-macosx-audio Mac OS X audio module (default enabled on MacOS X)])
if test "${enable_macosx-audio}" != "no" &&
(test "${SYS}" = "darwin" || test "${enable_macosx-audio}" = "yes")
then
AC_CHECK_HEADERS(CoreAudio/CoreAudio.h,
[ VLC_ADD_BUILTINS([coreaudio auhal])
VLC_ADD_LDFLAGS([coreaudio auhal],[-framework CoreAudio -framework AudioUnit -framework AudioToolbox])
[ VLC_ADD_BUILTINS([auhal])
VLC_ADD_LDFLAGS([auhal],[-framework CoreAudio -framework AudioUnit -framework AudioToolbox])
], [ AC_MSG_ERROR([cannot find CoreAudio headers]) ])
fi
......
......@@ -41,14 +41,17 @@
# define AOUT_FMT_S16_NE VLC_FOURCC('s','1','6','b')
# define AOUT_FMT_U16_NE VLC_FOURCC('u','1','6','b')
# define AOUT_FMT_S24_NE VLC_FOURCC('s','2','4','b')
# define AOUT_FMT_SPDIF_NE VLC_FOURCC('s','p','d','b')
#else
# define AOUT_FMT_S16_NE VLC_FOURCC('s','1','6','l')
# define AOUT_FMT_U16_NE VLC_FOURCC('u','1','6','l')
# define AOUT_FMT_S24_NE VLC_FOURCC('s','2','4','l')
# define AOUT_FMT_SPDIF_NE VLC_FOURCC('s','p','d','i')
#endif
#define AOUT_FMT_NON_LINEAR( p_format ) \
( ((p_format)->i_format == VLC_FOURCC('s','p','d','i')) \
|| ((p_format)->i_format == VLC_FOURCC('s','p','d','b')) \
|| ((p_format)->i_format == VLC_FOURCC('a','5','2',' ')) \
|| ((p_format)->i_format == VLC_FOURCC('d','t','s',' ')) )
......
......@@ -62,8 +62,9 @@ static int Create( vlc_object_t *p_this )
{
aout_filter_t * p_filter = (aout_filter_t *)p_this;
if ( p_filter->input.i_format != VLC_FOURCC('a','5','2',' ')
|| p_filter->output.i_format != VLC_FOURCC('s','p','d','i') )
if ( p_filter->input.i_format != VLC_FOURCC('a','5','2',' ') ||
( p_filter->output.i_format != VLC_FOURCC('s','p','d','b') &&
p_filter->output.i_format != VLC_FOURCC('s','p','d','i') ) )
{
return -1;
}
......@@ -80,43 +81,49 @@ static int Create( vlc_object_t *p_this )
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 )
{
/* It is not entirely clear which endianness the AC3 stream should have.
* I have been told endianness does not matter, AC3 can be both endian.
* But then, I could not get it to work on Mac OS X and a JVC RX-6000R
* decoder without using little endian. So right now, I convert to little
* endian.
/* AC3 is natively big endian. Most SPDIF devices have the native
* endianness of the computersystem.
* On MAc OS X however, little endian devices are also common.
*/
static const uint8_t p_sync[6] = { 0x72, 0xF8, 0x1F, 0x4E, 0x01, 0x00 };
static const uint8_t p_sync_le[6] = { 0x72, 0xF8, 0x1F, 0x4E, 0x01, 0x00 };
static const uint8_t p_sync_be[6] = { 0xF8, 0x72, 0x4E, 0x1F, 0x00, 0x01 };
#ifndef HAVE_SWAB
byte_t * p_tmp;
uint16_t i;
#endif
uint16_t i_length = p_in_buf->i_nb_bytes;
uint8_t * pi_length;
uint16_t i_frame_size = p_in_buf->i_nb_bytes / 2;
byte_t * p_in = p_in_buf->p_buffer;
byte_t * p_out = p_out_buf->p_buffer;
/* Copy the S/PDIF headers. */
memcpy( p_out, p_sync, 6 );
pi_length = (p_out + 6);
*pi_length = (i_length * 8) & 0xff;
*(pi_length + 1) = (i_length * 8) >> 8;
#ifdef HAVE_SWAB
swab( p_in, p_out + 8, i_length );
#else
p_tmp = p_out + 8;
for ( i = i_length / 2 ; i-- ; )
if( p_filter->output.i_format == VLC_FOURCC('s','p','d','b') )
{
p_tmp[0] = p_in[1];
p_tmp[1] = p_in[0];
p_tmp += 2; p_in += 2;
p_filter->p_vlc->pf_memcpy( p_out, p_sync_be, 6 );
p_out[4] = p_in[5] & 0x7; /* bsmod */
p_out[6] = (i_frame_size >> 4) & 0xff;
p_out[7] = (i_frame_size << 4) & 0xff;
p_filter->p_vlc->pf_memcpy( &p_out[8], p_in, i_frame_size * 2 );
}
else
{
p_filter->p_vlc->pf_memcpy( p_out, p_sync_le, 6 );
p_out[5] = p_in[5] & 0x7; /* bsmod */
p_out[6] = (i_frame_size << 4) & 0xff;
p_out[7] = (i_frame_size >> 4) & 0xff;
#ifdef HAVE_SWAB
swab( p_in, &p_out[8], i_frame_size * 2 );
#else
p_tmp = &p_out[8];
for( i = i_frame_size; i-- ; )
{
p_tmp[0] = p_in[1];
p_tmp[1] = p_in[0];
p_tmp += 2; p_in += 2;
}
#endif
p_filter->p_vlc->pf_memset( p_out + 8 + i_length, 0,
AOUT_SPDIF_SIZE - i_length - 8 );
}
p_filter->p_vlc->pf_memset( p_out + 8 + i_frame_size * 2, 0,
AOUT_SPDIF_SIZE - i_frame_size * 2 - 8 );
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
p_out_buf->i_nb_bytes = AOUT_SPDIF_SIZE;
......
......@@ -79,8 +79,9 @@ static int Create( vlc_object_t *p_this )
{
aout_filter_t * p_filter = (aout_filter_t *)p_this;
if ( p_filter->input.i_format != VLC_FOURCC('d','t','s',' ')
|| p_filter->output.i_format != VLC_FOURCC('s','p','d','i') )
if( p_filter->input.i_format != VLC_FOURCC('d','t','s',' ') ||
( p_filter->output.i_format != VLC_FOURCC('s','p','d','i') &&
p_filter->output.i_format != VLC_FOURCC('s','p','d','b') ) )
{
return -1;
}
......@@ -117,9 +118,11 @@ static void Close( vlc_object_t * p_this )
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 )
{
uint32_t i_ac5_spdif_type = 0;
uint16_t i_fz = p_in_buf->i_nb_samples * 4;
uint16_t i_frame, i_length = p_in_buf->i_nb_bytes;
static const uint8_t p_sync[6] = { 0x72, 0xF8, 0x1F, 0x4E, 0x00, 0x00 };
static const uint8_t p_sync_le[6] = { 0x72, 0xF8, 0x1F, 0x4E, 0x00, 0x00 };
static const uint8_t p_sync_be[6] = { 0xF8, 0x72, 0x4E, 0x1F, 0x00, 0x00 };
if( p_in_buf->i_nb_bytes != p_filter->p_sys->i_frame_size )
{
......@@ -156,23 +159,35 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
byte_t * p_out = p_out_buf->p_buffer + (i_frame * i_fz);
byte_t * p_in = p_filter->p_sys->p_buf + (i_frame * i_length);
/* Copy the S/PDIF headers. */
memcpy( p_out, p_sync, 6 );
switch( p_in_buf->i_nb_samples )
{
case 512: *(p_out + 4) = 0x0B; break;
case 1024: *(p_out + 4) = 0x0C; break;
case 2048: *(p_out + 4) = 0x0D; break;
case 512: i_ac5_spdif_type = 0x0B; break;
case 1024: i_ac5_spdif_type = 0x0C; break;
case 2048: i_ac5_spdif_type = 0x0D; break;
}
*(p_out + 6) = (i_length * 8) & 0xff;
*(p_out + 7) = (i_length * 8) >> 8;
/* Copy the S/PDIF headers. */
if( p_filter->output.i_format == VLC_FOURCC('s','p','d','b') )
{
p_filter->p_vlc->pf_memcpy( p_out, p_sync_be, 6 );
p_out[5] = i_ac5_spdif_type;
p_out[6] = (( i_length ) >> 5 ) & 0xFF;
p_out[7] = ( i_length << 3 ) & 0xFF;
}
else
{
p_filter->p_vlc->pf_memcpy( p_out, p_sync_le, 6 );
p_out[4] = i_ac5_spdif_type;
p_out[6] = ( i_length << 3 ) & 0xFF;
p_out[7] = (( i_length ) >> 5 ) & 0xFF;
}
if( p_in[0] == 0x1f || p_in[0] == 0x7f )
if( ( (p_in[0] == 0x1F || p_in[0] == 0x7F) && p_filter->output.i_format == VLC_FOURCC('s','p','d','i') ) ||
( (p_in[0] == 0xFF || p_in[0] == 0xFE) && p_filter->output.i_format == VLC_FOURCC('s','p','d','b') ) )
{
/* We are dealing with a big endian bitstream.
* Convert to little endian */
/* We are dealing with a big endian bitstream and a little endian output
* or a little endian bitstream and a big endian output.
* Byteswap the stream */
#ifdef HAVE_SWAB
swab( p_in, p_out + 8, i_length );
#else
......@@ -190,8 +205,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter,
}
else
{
/* Little endian */
memcpy( p_out + 8, p_in, i_length );
p_filter->p_vlc->pf_memcpy( p_out + 8, p_in, i_length );
}
if( i_fz > i_length + 8 )
......
......@@ -2,4 +2,3 @@ SOURCES_trivial_resampler = trivial.c
SOURCES_ugly_resampler = ugly.c
SOURCES_linear_resampler = linear.c
SOURCES_bandlimited_resampler = bandlimited.c bandlimited.h
SOURCES_coreaudio_resampler = coreaudio.c
This diff is collapsed.
SOURCES_alsa = alsa.c
SOURCES_arts = arts.c
SOURCES_coreaudio = coreaudio.c
SOURCES_aout_directx = directx.c
SOURCES_esd = esd.c
SOURCES_aout_file = file.c
......
This diff is collapsed.
This diff is collapsed.
......@@ -142,6 +142,7 @@ void aout_FormatPrepare( audio_sample_format_t * p_format )
break;
case VLC_FOURCC('s','p','d','i'):
case VLC_FOURCC('s','p','d','b'): /* Big endian spdif output */
case VLC_FOURCC('a','5','2',' '):
case VLC_FOURCC('d','t','s',' '):
case VLC_FOURCC('m','p','g','a'):
......
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