Commit 60b9d5a5 authored by Christophe Massiot's avatar Christophe Massiot

* Correct socklen_t detection.

* Fix for S/PDIF encapsulation on big endian systems.
* S/PDIF output for Mac OS X, courtesy of Heiko Panther <heiko_panthe@mac.com>.
parent d43c4059
......@@ -283,7 +283,21 @@ if ${have_nanosleep}; then
AC_DEFINE(HAVE_NANOSLEEP, 1,
Define if nanosleep is available.)
fi
# HP/UX port
dnl Check for socklen_t
AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t,
[AC_TRY_COMPILE(
[#include <sys/types.h>
#include <sys/socket.h>],
[socklen_t len = 42; return len;],
ac_cv_type_socklen_t=yes,
ac_cv_type_socklen_t=no)])
if test x$ac_cv_type_socklen_t != xno; then
AC_DEFINE(HAVE_SOCKLEN_T, 1,
Define if <sys/socket.h> defines socklen_t.)
fi
dnl HP/UX port
AC_CHECK_LIB(rt,sem_init, [LDFLAGS_vlc="${LDFLAGS_vlc} -lrt"])
AC_CHECK_FUNC(inet_aton,,[
......
......@@ -2,7 +2,7 @@
* audio_output.h : audio output interface
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: audio_output.h,v 1.71 2002/11/14 22:38:46 massiot Exp $
* $Id: audio_output.h,v 1.72 2002/11/28 23:24:14 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -36,13 +36,16 @@ struct audio_sample_format_t
/* Describes from which original channels, before downmixing, the
* buffer is derived. */
u32 i_original_channels;
/* Optional - for A52, SPDIF and DTS types */
/* Optional - for A/52, SPDIF and DTS types : */
/* Bytes used by one compressed frame, depends on bitrate. */
unsigned int i_bytes_per_frame;
/* Number of sampleframes contained in one compressed frame. */
unsigned int i_frame_length;
/* Please note that it may be completely arbitrary - buffers are not
* obliged to contain a integral number of so-called "frames". It's
* just here for the division :
* i_nb_samples * i_bytes_per_frame / i_frame_length */
* buffer_size = i_nb_samples * i_bytes_per_frame / i_frame_length
*/
};
#define AOUT_FMTS_IDENTICAL( p_first, p_second ) ( \
......
......@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vlc_common.h,v 1.41 2002/11/25 03:12:42 ipkiss Exp $
* $Id: vlc_common.h,v 1.42 2002/11/28 23:24:14 massiot Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
......@@ -116,6 +116,10 @@ typedef uint8_t yuv_data_t;
/* Audio volume */
typedef uint16_t audio_volume_t;
#ifndef HAVE_SOCKLEN_T
typedef int socklen_t;
#endif
/*****************************************************************************
* Old types definitions
*****************************************************************************
......
......@@ -4,7 +4,7 @@
* (http://liba52.sf.net/).
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: a52tofloat32.c,v 1.8 2002/11/21 23:06:08 massiot Exp $
* $Id: a52tofloat32.c,v 1.9 2002/11/28 23:24:14 massiot Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
* Christophe Massiot <massiot@via.ecp.fr>
......@@ -222,37 +222,37 @@ static void Interleave( float * p_out, const float * p_in, int i_nb_channels )
* The WG-4 order is appropriate for stereo, quadrophonia, and 5.1 surround.
*
* 6 channel mode
* channel liba52 order WG-4 order
* 0 LFE // L
* 1 L // R
* 2 C // LS
* 3 R // RS
* 4 LS // C
* 5 RS // LFE
* channel liba52 order WG-4 order
* 0 LFE // L
* 1 L // R
* 2 C // LS
* 3 R // RS
* 4 LS // C
* 5 RS // LFE
*
* The liba52 moves channels to the front if there are unused spaces, so
* there is no gap between channels. The translation table says which
* channel of the new stream [use the new channel # as index] is taken
* from which original channel [use the number from the array to address
* the original channel].
* channel of the new stream is taken from which original channel [use
* the new channel as the array index, use the number you get from the
* array to address the original channel].
*/
static const int translation[7][6] =
{{ 0, 0, 0, 0, 0, 0 }, /* 0 channels (rarely used) */
{ 0, 0, 0, 0, 0, 0 }, /* 1 ch */
{ 0, 1, 0, 0, 0, 0 }, /* 2 */
{ 1, 2, 0, 0, 0, 0 }, /* 3 */
{ 1, 3, 2, 0, 0, 0 }, /* 4 */
{ 1, 3, 4, 2, 0, 0 }, /* 5 */
{ 1, 3, 4, 5, 2, 0 }}; /* 6 */
{{ 0, 0, 0, 0, 0, 0 }, /* 0 channels (rarely used) */
{ 0, 0, 0, 0, 0, 0 }, /* 1 ch */
{ 0, 1, 0, 0, 0, 0 }, /* 2 */
{ 1, 2, 0, 0, 0, 0 }, /* 3 */
{ 1, 3, 2, 0, 0, 0 }, /* 4 */
{ 1, 3, 4, 2, 0, 0 }, /* 5 */
{ 1, 3, 4, 5, 2, 0 }}; /* 6 */
int i, j;
for ( j = 0; j < i_nb_channels; j++ )
{
for ( i = 0; i < 256; i++ )
{
p_out[i * i_nb_channels + translation[i_nb_channels][j]]
= p_in[j * 256 + i];
p_out[i * i_nb_channels + j] = p_in[translation[i_nb_channels][j]
* 256 + i];
}
}
}
......
......@@ -2,7 +2,7 @@
* a52tospdif.c : encapsulates A/52 frames into S/PDIF packets
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: a52tospdif.c,v 1.14 2002/11/20 13:37:35 sam Exp $
* $Id: a52tospdif.c,v 1.15 2002/11/28 23:24:14 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Stphane Borel <stef@via.ecp.fr>
......@@ -78,42 +78,39 @@ 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 )
{
#ifdef WORDS_BIGENDIAN
static const u8 p_sync[6] = { 0xF8, 0x72, 0x4E, 0x1F, 0x00, 0x01 };
#else
/* 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.
*/
static const u8 p_sync[6] = { 0x72, 0xF8, 0x1F, 0x4E, 0x01, 0x00 };
# ifndef HAVE_SWAB
#ifndef HAVE_SWAB
u16 i;
# endif
#endif
u16 i_length = p_in_buf->i_nb_bytes;
u16 * pi_length;
u8 * pi_length;
byte_t * p_in = p_in_buf->p_buffer;
byte_t * p_out = p_out_buf->p_buffer;
byte_t * p_tmp;
/* Copy the S/PDIF headers. */
memcpy( p_out, p_sync, 6 );
pi_length = (u16 *)(p_out + 6);
*pi_length = i_length * 8;
/* FIXME : if i_length is odd, the following code sucks. What should
* we do ? --Meuuh */
pi_length = (p_out + 6);
*pi_length = (i_length * 8) & 0xff;
*(pi_length + 1) = (i_length * 8) >> 8;
#ifndef WORDS_BIGENDIAN
# ifdef HAVE_SWAB
#ifdef HAVE_SWAB
swab( p_in, p_out + 8, i_length );
# else
p_out += 8;
#else
p_tmp = p_out + 8;
for ( i = i_length / 2 ; i-- ; )
{
p_out[0] = p_in[1];
p_out[1] = p_in[0];
p_out += 2; p_in += 2;
p_tmp[0] = p_in[1];
p_tmp[1] = p_in[0];
p_tmp += 2; p_in += 2;
}
# endif
#else
p_filter->p_vlc->pf_memcpy( p_out + 8, p_in, i_length );
#endif
p_filter->p_vlc->pf_memset( p_out + 8 + i_length, 0,
......
......@@ -2,7 +2,7 @@
* aout.m: CoreAudio output plugin
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: aout.m,v 1.15 2002/11/18 23:00:41 massiot Exp $
* $Id: aout.m,v 1.16 2002/11/28 23:24:15 massiot Exp $
*
* Authors: Colin Delacroix <colin@zoy.org>
* Jon Lech Johansen <jon-vl@nanocrew.net>
......@@ -107,13 +107,17 @@ int E_(OpenAudio)( vlc_object_t * p_this )
/* Get a description of the data format used by the device */
i_param_size = sizeof(AudioStreamBasicDescription);
err = AudioDeviceGetProperty(p_sys->device, 0, false, kAudioDevicePropertyStreamFormat, &i_param_size, &p_sys->stream_format );
err = AudioDeviceGetProperty(p_sys->device, 0, false, kAudioDevicePropertyStreamFormat,
&i_param_size, &p_sys->stream_format );
if( err != noErr )
{
msg_Err( p_aout, "failed to get stream format: %4.4s", &err );
return -1 ;
}
/* Now we know the sample rate of the device */
p_aout->output.output.i_rate = p_sys->stream_format.mSampleRate;
msg_Dbg( p_aout, "mSampleRate %ld, mFormatID %4.4s, mFormatFlags %ld, mBytesPerPacket %ld, mFramesPerPacket %ld, mBytesPerFrame %ld, mChannelsPerFrame %ld, mBitsPerChannel %ld",
(UInt32)p_sys->stream_format.mSampleRate, &p_sys->stream_format.mFormatID,
p_sys->stream_format.mFormatFlags, p_sys->stream_format.mBytesPerPacket,
......@@ -122,43 +126,14 @@ int E_(OpenAudio)( vlc_object_t * p_this )
msg_Dbg( p_aout, "vlc format %4.4s, mac output format '%4.4s'",
(char *)&p_aout->output.output.i_format, &p_sys->stream_format.mFormatID );
switch(p_sys->stream_format.mFormatID)
{
case 0:
case kAudioFormatLinearPCM:
p_aout->output.output.i_format = VLC_FOURCC('f','l','3','2');
if ( p_sys->stream_format.mChannelsPerFrame < 6 )
p_aout->output.output.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
else
p_aout->output.output.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
| AOUT_CHAN_CENTER | AOUT_CHAN_REARRIGHT
| AOUT_CHAN_REARLEFT | AOUT_CHAN_LFE;
break;
case kAudioFormat60958AC3:
case 'IAC3':
p_aout->output.output.i_format = VLC_FOURCC('s','p','d','i');
//not necessary, use the input's format by default --Meuuh
//p_aout->output.output.i_channels = AOUT_CHAN_DOLBY | AOUT_CHAN_LFE;
p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; //p_sys->stream_format.mBytesPerFrame;
p_aout->output.output.i_frame_length = A52_FRAME_NB; //p_sys->stream_format.mFramesPerPacket;
break;
default:
msg_Err( p_aout, "Unknown hardware format '%4.4s'. Go ask Heiko.", &p_sys->stream_format.mFormatID );
return -1;
}
/* Set sample rate and channels per frame */
p_aout->output.output.i_rate = p_sys->stream_format.mSampleRate;
/* Get the buffer size that the device uses for IO */
// If we do PCM, use the device's given buffer size
// If we do raw AC3, we could use the devices given size too
// If we do AC3 over SPDIF, force the size of one AC3 frame
// (I think we need to do that because of the packetizer)
i_param_size = sizeof( p_sys->i_buffer_size );
#if 1 // i have a feeling we should use the buffer size imposed by the AC3 device (usually about 6144)
err = AudioDeviceGetProperty( p_sys->device, 1, false,
err = AudioDeviceGetProperty( p_sys->device, 0, false,
kAudioDevicePropertyBufferSize,
&i_param_size, &p_sys->i_buffer_size );
if(err) {
......@@ -166,26 +141,130 @@ int E_(OpenAudio)( vlc_object_t * p_this )
return -1;
}
else msg_Dbg( p_aout, "native buffer Size: %d", p_sys->i_buffer_size );
if((p_sys->stream_format.mFormatID==kAudioFormat60958AC3
|| p_sys->stream_format.mFormatID=='IAC3')
&& p_sys->i_buffer_size != AOUT_SPDIF_SIZE)
{
p_sys->i_buffer_size = AOUT_SPDIF_SIZE;
i_param_size = sizeof( p_sys->i_buffer_size );
err = AudioDeviceSetProperty( p_sys->device, 0, 0, false,
kAudioDevicePropertyBufferSize,
i_param_size, &p_sys->i_buffer_size );
if( err != noErr )
{
msg_Err( p_aout, "failed to set device buffer size: %4.4s", &err );
return -1;
}
else msg_Dbg(p_aout, "bufferSize set to %d", p_sys->i_buffer_size);
};
// We now know the buffer size in bytes. Set the values for the vlc converters.
switch(p_sys->stream_format.mFormatID)
{
case 0:
case kAudioFormatLinearPCM:
p_aout->output.output.i_format = VLC_FOURCC('f','l','3','2');
if ( p_sys->stream_format.mChannelsPerFrame < 6 )
p_aout->output.output.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
else
p_aout->output.output.i_physical_channels
= AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
| AOUT_CHAN_CENTER | AOUT_CHAN_REARRIGHT
| AOUT_CHAN_REARLEFT | AOUT_CHAN_LFE;
p_aout->output.i_nb_samples = p_sys->i_buffer_size / p_sys->stream_format.mBytesPerFrame;
break;
case kAudioFormat60958AC3:
case 'IAC3':
p_aout->output.output.i_format = VLC_FOURCC('s','p','d','i');
msg_Dbg(p_aout, "phychan %d, ochan %d, bytes/fr %d, frlen %d",
p_aout->output.output.i_physical_channels,
p_aout->output.output.i_original_channels,
p_aout->output.output.i_bytes_per_frame,
p_aout->output.output.i_frame_length);
p_aout->output.output.i_bytes_per_frame = AOUT_SPDIF_SIZE; //p_sys->stream_format.mBytesPerFrame;
p_aout->output.output.i_frame_length = A52_FRAME_NB; //p_sys->stream_format.mFramesPerPacket;
p_aout->output.i_nb_samples = p_aout->output.output.i_frame_length;
//Probably not needed after all
// Some more settings to make the SPDIF device work... Other SPDIF Devices might need additional
// values here. But don't change these, in order to not break existing devices. Either add values
// which are not being set here, or check if the SetProperty was successful, and try another version
// if not.
// p_sys->stream_format.mBytesPerFrame=4; // usually set to 0 for AC3 by the system
// p_sys->stream_format.mFormatFlags|=kAudioFormatFlagIsBigEndian;
// +kAudioFormatFlagIsPacked
// +kAudioFormatFlagIsNonInterleaved;
// p_sys->stream_format.mBytesPerPacket=6144;
// p_sys->stream_format.mFramesPerPacket=1536;
break;
default:
msg_Err( p_aout, "Unknown hardware format '%4.4s'. Go ask Heiko.", &p_sys->stream_format.mFormatID );
return -1;
}
// Now tell the device how many sample frames to expect in each buffer
i_param_size=sizeof(p_aout->output.i_nb_samples);
#if 0
err = AudioDeviceGetProperty( p_sys->device, 0, false,
kAudioDevicePropertyBufferFrameSize,
&i_param_size, &p_aout->output.i_nb_samples);
if(err) {
msg_Err(p_aout, "failed to get BufferFrameSize - err %4.4s, device %ld", &err, p_sys->device);
return -1;
}
else msg_Dbg( p_aout, "native BufferFrameSize: %d", p_aout->output.i_nb_samples);
#else
p_sys->i_buffer_size = p_aout->output.output.i_bytes_per_frame;
err = AudioDeviceSetProperty( p_sys->device, 0, 1, false,
kAudioDevicePropertyBufferSize,
i_param_size, &p_sys->i_buffer_size );
err = AudioDeviceSetProperty( p_sys->device, 0, 0, false,
kAudioDevicePropertyBufferFrameSize,
i_param_size, &p_aout->output.i_nb_samples);
if( err != noErr )
{
msg_Err( p_aout, "failed to set device buffer size: %4.4s", err );
return( -1 );
msg_Err( p_aout, "failed to set BufferFrameSize: %4.4s", &err );
return -1;
}
else msg_Dbg(p_aout, "bufferSize set to %d", p_sys->i_buffer_size);
else msg_Dbg(p_aout, "bufferFrameSize set to %d", p_aout->output.i_nb_samples);
#endif
p_aout->output.i_nb_samples = p_sys->i_buffer_size / p_sys->stream_format.mBytesPerFrame;
/*
// And set the device format, since we might have changed some of it above
i_param_size = sizeof(AudioStreamBasicDescription);
err = AudioDeviceSetProperty(p_sys->device, 0, 0, false, kAudioDevicePropertyStreamFormat,
i_param_size, &p_sys->stream_format );
if( err != noErr )
{
msg_Err( p_aout, "failed to set stream format: %4.4s", &err );
return -1 ;
}
else
msg_Dbg( p_aout, "set: mSampleRate %ld, mFormatID %4.4s, mFormatFlags %ld, mBytesPerPacket %ld, mFramesPerPacket %ld, mBytesPerFrame %ld, mChannelsPerFrame %ld, mBitsPerChannel %ld",
(UInt32)p_sys->stream_format.mSampleRate, &p_sys->stream_format.mFormatID,
p_sys->stream_format.mFormatFlags, p_sys->stream_format.mBytesPerPacket,
p_sys->stream_format.mFramesPerPacket, p_sys->stream_format.mBytesPerFrame,
p_sys->stream_format.mChannelsPerFrame, p_sys->stream_format.mBitsPerChannel );
*/
/* Add callback */
err = AudioDeviceAddIOProc( p_sys->device,
(AudioDeviceIOProc)IOCallback,
(void *)p_aout );
if( err != noErr )
{
msg_Err( p_aout, "AudioDeviceAddIOProc failed: %4.4s", &err );
return -1;
}
/* Open the output with callback IOCallback */
err = AudioDeviceStart( p_sys->device,
(AudioDeviceIOProc)IOCallback );
......@@ -216,7 +295,14 @@ void E_(CloseAudio)( aout_instance_t * p_aout )
(AudioDeviceIOProc)IOCallback );
if( err != noErr )
{
msg_Err( p_aout, "AudioDeviceStop failed: %d", err );
msg_Err( p_aout, "AudioDeviceStop failed: %4.4s", &err );
}
err = AudioDeviceRemoveIOProc( p_sys->device,
(AudioDeviceIOProc)IOCallback );
if( err != noErr )
{
msg_Err( p_aout, "AudioDeviceRemoveIOProc failed: %4.4s", &err );
}
free( p_sys );
......@@ -229,6 +315,7 @@ static void Play( aout_instance_t * p_aout )
{
}
#include <syslog.h>
/*****************************************************************************
* IOCallback : callback for audio output
*****************************************************************************/
......@@ -245,13 +332,12 @@ static OSStatus IOCallback( AudioDeviceID inDevice,
mtime_t current_date;
AudioTimeStamp host_time;
aout_buffer_t * p_buffer;
host_time.mFlags = kAudioTimeStampHostTimeValid;
AudioDeviceTranslateTime( inDevice, inOutputTime, &host_time );
current_date = p_sys->clock_diff
+ AudioConvertHostTimeToNanos(host_time.mHostTime) / 1000;
// msg_Dbg(p_aout, "Now fetching audio data");
p_buffer = aout_OutputNextBuffer( p_aout, current_date, (p_aout->output.output.i_format == VLC_FOURCC('s','p','d','i')) );
/* move data into output data buffer */
......@@ -260,14 +346,7 @@ static OSStatus IOCallback( AudioDeviceID inDevice,
BlockMoveData( p_buffer->p_buffer,
outOutputData->mBuffers[ 0 ].mData,
p_sys->i_buffer_size );
/* msg_Dbg(p_aout, "This buffer has %d bytes, i take %d: %f %f %f %f",
p_buffer->i_nb_bytes, p_sys->i_buffer_size,
((float*)p_buffer->p_buffer)[0], ((float*)p_buffer->p_buffer)[1],
((float*)p_buffer->p_buffer)[2], ((float*)p_buffer->p_buffer)[3]);
*/
// syslog(LOG_INFO, "convert: %08lX %08lX %08lX", ((long*)p_buffer->p_buffer)[0], ((long*)p_buffer->p_buffer)[1], ((long*)p_buffer->p_buffer)[2]);
aout_BufferFree( p_buffer );
}
else
......@@ -275,6 +354,9 @@ static OSStatus IOCallback( AudioDeviceID inDevice,
memset(outOutputData->mBuffers[ 0 ].mData, 0, p_sys->i_buffer_size);
}
// outOutputData->mBuffers[0].mDataByteSize=p_sys->i_buffer_size;
return noErr;
}
......@@ -3,7 +3,6 @@
//
//
// Created by Heiko Panther on Tue Sep 10 2002.
// Copyright (c) 2002 __MyCompanyName__. All rights reserved.
//
#import "asystm.h"
......
......@@ -2,7 +2,7 @@
* ipv4.c: IPv4 network abstraction layer
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: ipv4.c,v 1.6 2002/11/23 04:40:53 sam Exp $
* $Id: ipv4.c,v 1.7 2002/11/28 23:24:15 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Mathias Kretschmer <mathias@research.att.com>
......@@ -145,7 +145,7 @@ static int OpenUDP( vlc_object_t * p_this, network_socket_t * p_socket )
#endif
int i_handle, i_opt;
unsigned int i_opt_size;
socklen_t i_opt_size;
struct sockaddr_in sock;
if( i_bind_port == 0 )
......
......@@ -2,7 +2,7 @@
* ipv6.c: IPv6 network abstraction layer
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: ipv6.c,v 1.4 2002/11/19 20:56:45 gbazin Exp $
* $Id: ipv6.c,v 1.5 2002/11/28 23:24:15 massiot Exp $
*
* Authors: Alexis Guillard <alexis.guillard@bt.com>
* Christophe Massiot <massiot@via.ecp.fr>
......@@ -230,7 +230,7 @@ static int OpenUDP( vlc_object_t * p_this, network_socket_t * p_socket )
int i_server_port = p_socket->i_server_port;
int i_handle, i_opt;
unsigned int i_opt_size;
socklen_t i_opt_size;
struct sockaddr_in6 sock;
/* Open a SOCK_DGRAM (UDP) socket, in the AF_INET6 domain, automatic (0)
......
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