Commit 7dc21c6f authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* backport of auhal.c [11020] trough [11310] from trunk

* backport of [110311]
parent a0d0abff
$Id$ $Id$
Changes between 0.8.1 and 0.8.2-test1: Changes between 0.8.1 and 0.8.2-test2:
----------------------------------------------------- -----------------------------------------------------
Core support: Core support:
...@@ -105,6 +105,11 @@ Windows port: ...@@ -105,6 +105,11 @@ Windows port:
MacOS X port: MacOS X port:
* Many Tiger related fixes * Many Tiger related fixes
* A new audio module that should work more reliable for analog audio output in various configurations.
- Supports multichannel discrete analog output
- Digital audio output requires you to change a preference setting because it
is not yet available in the new module
- Please read the README.MacOSX.rtf file for more information.
BeOS port: BeOS port:
* Support for single-buffered overlay * Support for single-buffered overlay
...@@ -116,7 +121,7 @@ Pocket PC port: ...@@ -116,7 +121,7 @@ Pocket PC port:
Mozilla Plugin: Mozilla Plugin:
* Javascript fixes * Javascript fixes
* Mozilla plugin for MacOS X is back * Mozilla plugin for MacOS X is back (not yet distributed)
IE Plugin: IE Plugin:
* Brand new Internet Explorer ActiveX plugin * Brand new Internet Explorer ActiveX plugin
...@@ -133,6 +138,7 @@ Translations: ...@@ -133,6 +138,7 @@ Translations:
* Tagalog * Tagalog
* Bengali * Bengali
Changes between 0.8.0 and 0.8.1: Changes between 0.8.0 and 0.8.1:
----------------------------------------------------- -----------------------------------------------------
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;\f2\fmodern\fcharset77 Courier; {\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;\f2\fmodern\fcharset77 Courier;
} }
{\colortbl;\red255\green255\blue255;} {\colortbl;\red255\green255\blue255;}
\vieww17160\viewh15400\viewkind0 \vieww9000\viewh9000\viewkind0
\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc \pard\tx1440\tx2880\tx4320\tx5760\tx7200\qc
\f0\fs48 \cf0 VLC media player, version 0.8\ \f0\fs48 \cf0 VLC media player, version 0.8\
...@@ -15,7 +15,7 @@ Mac OS X-specific information ...@@ -15,7 +15,7 @@ Mac OS X-specific information
\cf0 Welcome to the VLC media player! VLC media player is a multi-purpose multimedia tool. It can play DVDs, VCDs or read a stream from the network. It plays DivX/MPEG-4 files (and many other files) and is unaffected by the dreaded .avi bug which can cause choppy sound when playing DivX in QuickTime Player. You can also stream content to the network or a file.\ \cf0 Welcome to the VLC media player! VLC media player is a multi-purpose multimedia tool. It can play DVDs, VCDs or read a stream from the network. It plays DivX/MPEG-4 files (and many other files) and is unaffected by the dreaded .avi bug which can cause choppy sound when playing DivX in QuickTime Player. You can also stream content to the network or a file.\
For a full list of features visit: \ul http://www.videolan.org/vlc/features.html\ulnone \ For a full list of features visit: \ul http://www.videolan.org/vlc/features.html\ulnone \
\ \
VLC media player was originally developed for GNU/Linux systems, but has been ported to numerous operating systems, including Mac OS X and Win32. Though there probably are bugs, we are always working hard to improve VLC media player and if you think you can help us in any way, please drop us a line: \ul http://www.videolan.org/support/lists.html\ VLC media player was originally developed for GNU/Linux systems, but has been ported to numerous operating systems, including Mac OS X and Win32. Though there probably are bugs, we are always working hard to improve VLC media player and if you think you can help us in any way, please drop us a line: \ul http://www.videolan.org/support/lists.html \ulnone or\ul \
http://forum.videolan.org/\ulnone \ http://forum.videolan.org/\ulnone \
\ \
The following frequently asked questions are answered below :\ The following frequently asked questions are answered below :\
...@@ -33,7 +33,12 @@ The following frequently asked questions are answered below :\ ...@@ -33,7 +33,12 @@ The following frequently asked questions are answered below :\
11. How do i get fullscreen video on my other monitor ?\ 11. How do i get fullscreen video on my other monitor ?\
12. Multiple sound-devices and multi-channel sound? 12. Multiple sound-devices and multi-channel sound?
\f0\b0 \ulnone \ \f0\b0 \ulnone \
\ \pard\tx1440\tx2880\tx4320\tx5760\tx7200\qj
\f1\b \cf0 \ul \ulc0 13. I have a problem or a feature request \
\pard\tx1440\tx2880\tx4320\tx5760\tx7200\qj
\f0\b0 \cf0 \ulnone \
\ \
\f1\b \ul 1. How do I install ? \f1\b \ul 1. How do I install ?
...@@ -98,13 +103,12 @@ Simply drag VLC from the place where you had installed it, to the Trash.\ ...@@ -98,13 +103,12 @@ Simply drag VLC from the place where you had installed it, to the Trash.\
\f1\b \ul 9. Support for files with subtitles.\ \f1\b \ul 9. Support for files with subtitles.\
\f0\b0 \ulnone - VLC will autodected subtitle files when they are in the same directory as your movie and contain the movie name.\ \f0\b0 \ulnone - VLC will autodetect subtitle files when they are in the same directory as your movie and contain the movie's filename.\
- DVD and autodectected subtitles can be enabled trough the Controls->Subtitles menu-item.\ - DVD and autodetected subtitles can be enabled trough the Video -> Subtitles Track menu-item.\
- Only Vobsub, MicroDVD, SubRIP, SSA1-4. SAMI and vplayer subtitle files are supported at the moment.\ - Only Vobsub, MicroDVD, SubRIP, SSA1-4. SAMI and vplayer subtitle files are supported at the moment.\
- You cannot change anything about DVD and Vobsub subtitles.\ - You cannot change anything about DVD and Vobsub subtitles.\
- You can add any subtitle files to a video file via the Open.. dialog.\ - You can add any subtitle files to a video file via the Open.. dialog.\
- A text-encoding and fontsize is automatically chosen, but for some people this can be incorrect. You can change these by using the Open File menu entry and setting the subtitle options when you open a movie.\ - A text-encoding and fontsize is automatically chosen, but for some people this can be incorrect. You can change these by using the Open File menu entry and setting the subtitle settngs when you open a movie.\
- Text subtitles are by default centered. If you want them to be aligned left or right you can change this in Preferences -> Modules -> decoder -> subsdec\
- For Arabic, Hebrew and Japanese etc, you need to select a font compatible with these languages. You can change the default font in Preferences -> Modules -> text-renderer -> freetype\ - For Arabic, Hebrew and Japanese etc, you need to select a font compatible with these languages. You can change the default font in Preferences -> Modules -> text-renderer -> freetype\
- You cannot change the font color or the thickness of the outlines.\ - You cannot change the font color or the thickness of the outlines.\
\ \
...@@ -118,21 +122,25 @@ Hold your mouse still on top of an option for just over a second and a ToolTip w ...@@ -118,21 +122,25 @@ Hold your mouse still on top of an option for just over a second and a ToolTip w
\f1\b \ul 11. How do I get fullscreen video on my other monitor ? \f1\b \ul 11. How do I get fullscreen video on my other monitor ?
\f0\b0 \ulnone \ \f0\b0 \ulnone \
If you want to use your second screen for fullscreen playback, then look at the Video->Screen menuitem. You can set this option permanently by going into the Preferences and choosing Modules -> video output -> macosx -> video device (You will need to choose "Show Advanced options" first).\ If you want to use your second screen for fullscreen playback, then look at the Video->Video Device menuitem. You can set this option permanently by going into the Preferences and choosing Interface -> General -> macosx -> video device (You will need to choose "Show Advanced options" first).\
\ \
\ \
\f1\b \ul 12. Multiple sound-devices and multi-channel sound? \ \f1\b \ul 12. Multiple sound-devices and multi-channel sound? \
\f0\b0 \ulnone Look at the Audio->Device menuitem. You can set this option permanently by going into the Preferences and choosing Modules -> audio output -> coreaudio -> audio device (You will need to choose "Show Advanced options" first).\ \f0\b0 \ulnone Look at the Audio->Device menuitem. You can set this option permanently by going into the Preferences and choosing Modules -> audio output -> coreaudio -> audio device (You will need to choose "Show Advanced options" first).\
- AC3 over SPDIF with M-Audio Sonica Theater does not work. This is most likely a driver bug which has been reported to M-Audio.\ - You should change your speakerlayout in the Audio Midi Setup utility. The program is located in /Applications/Utilities.\
- VLC is known to have lots of problems on G5's. Try going into the preferences -> Modules -> audio output -> coreaudio. Now change the device value from 0 to 1. Choose Save and Quit and restart VLC.\ Select your audio device in "Properties For:", then click the "Configure Speakers" button. Choose "Multichannel". Even if these settings are correct, you should change them and click "Apply", then change them back and again click "Apply". This is important, otherwise VLC cannot reliably detect which speakers are connected.\
- Many problems might still exist. Multiple channel audio support is pretty new on Mac OS X and there are many bugs in the system software, the device drivers and probably in VLC media player as well.\ - We are in a transitional phase for our Mac OS X audio system. Therefore it is currently not possible to use Digital audio without changing a Preferences setting. The setting is in Audio->Output modules. Change this from default to "CoreAudio output". This is the module that was also used in previous versions of VLC. It has several issues with Analog audio, but it also supports Digital audio, which the new module does not yet support. You should ONLY use this module for Digital output.\
- Someone with CoreAudio knowledge is very much invited to assist is in fixing all the bugs that linger in this area.\
\ \
\ \
Thanks for reading this file. For additional information and support, please see: \ul http://www.videolan.org/support\ulnone \ \pard\tx1440\tx2880\tx4320\tx5760\tx7200\qj
\f1\b \cf0 \ul \ulc0 13. I have a problem or a feature request \
\f0\b0 \ulnone Your first stop is \ul http://www.videolan.org/doc\ulnone . The documentation on this page can usually help you with your problems. If you cannot find an aswer there then please visit \ul http://forum.videolan.org.\ulnone Use the Search function there and see if someone else might have already answered your question or run into your problem. Feature requests can also be made in the Request forum.\
\
For additional information and support, please see: \ul http://www.videolan.org/support\ulnone \
-- \ -- \
Christophe Massiot and\
Derk-Jan Hartman for the VideoLAN team.\ Derk-Jan Hartman for the VideoLAN team.\
$Id$} $Id$}
\ No newline at end of file
...@@ -3381,13 +3381,7 @@ if test "${enable_coreaudio}" != "no" && ...@@ -3381,13 +3381,7 @@ if test "${enable_coreaudio}" != "no" &&
then then
AC_CHECK_HEADERS(CoreAudio/CoreAudio.h, AC_CHECK_HEADERS(CoreAudio/CoreAudio.h,
[ VLC_ADD_BUILTINS([coreaudio auhal]) [ VLC_ADD_BUILTINS([coreaudio auhal])
VLC_ADD_LDFLAGS([coreaudio auhal],[-framework CoreAudio -framework AudioUnit]) VLC_ADD_LDFLAGS([coreaudio auhal],[-framework CoreAudio -framework AudioUnit -framework AudioToolbox])
AC_MSG_CHECKING(for kAudioConverterPrimeMethod in AudioToolbox/AudioConverter.h)
AC_EGREP_HEADER(kAudioConverterPrimeMethod,AudioToolbox/AudioConverter.h,[
AC_MSG_RESULT(yes)
VLC_ADD_PLUGINS([coreaudio_resampler])
VLC_ADD_LDFLAGS([coreaudio_resampler auhal],[-framework AudioToolbox])
],[ AC_MSG_RESULT(no) ])
], [ AC_MSG_ERROR([cannot find CoreAudio headers]) ]) ], [ AC_MSG_ERROR([cannot find CoreAudio headers]) ])
fi fi
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
sfm.mFramesPerPacket, sfm.mBytesPerFrame, \ sfm.mFramesPerPacket, sfm.mBytesPerFrame, \
sfm.mChannelsPerFrame, sfm.mBitsPerChannel sfm.mChannelsPerFrame, sfm.mBitsPerChannel
#define BUFSIZE 0xffffff
/***************************************************************************** /*****************************************************************************
* aout_sys_t: private audio output method descriptor * aout_sys_t: private audio output method descriptor
...@@ -63,6 +64,12 @@ struct aout_sys_t ...@@ -63,6 +64,12 @@ struct aout_sys_t
Component au_component; /* The Audiocomponent we use */ Component au_component; /* The Audiocomponent we use */
AudioUnit au_unit; /* The AudioUnit we use */ AudioUnit au_unit; /* The AudioUnit we use */
mtime_t clock_diff; mtime_t clock_diff;
uint8_t p_remainder_buffer[BUFSIZE];
uint32_t i_read_bytes;
uint32_t i_total_bytes;
audio_date_t end_date_t;
}; };
/***************************************************************************** /*****************************************************************************
...@@ -73,7 +80,7 @@ static void Close ( vlc_object_t * ); ...@@ -73,7 +80,7 @@ static void Close ( vlc_object_t * );
static void Play ( aout_instance_t *); static void Play ( aout_instance_t *);
static int DevicesList ( aout_instance_t * ); static int Probe ( aout_instance_t * );
static int DeviceDigitalMode ( aout_instance_t *, AudioDeviceID ); static int DeviceDigitalMode ( aout_instance_t *, AudioDeviceID );
static int DigitalInit ( aout_instance_t * ); static int DigitalInit ( aout_instance_t * );
...@@ -92,7 +99,7 @@ static OSStatus HardwareListener ( AudioHardwarePropertyID, void *); ...@@ -92,7 +99,7 @@ static OSStatus HardwareListener ( AudioHardwarePropertyID, void *);
vlc_module_begin(); vlc_module_begin();
set_shortname( "auhal" ); set_shortname( "auhal" );
set_description( _("HAL AudioUnit output") ); set_description( _("HAL AudioUnit output") );
set_capability( "audio output", 50 ); set_capability( "audio output", 101 );
set_category( CAT_AUDIO ); set_category( CAT_AUDIO );
set_subcategory( SUBCAT_AUDIO_AOUT ); set_subcategory( SUBCAT_AUDIO_AOUT );
set_callbacks( Open, Close ); set_callbacks( Open, Close );
...@@ -131,10 +138,10 @@ static int Open( vlc_object_t * p_this ) ...@@ -131,10 +138,10 @@ static int Open( vlc_object_t * p_this )
/* Build a list of devices */ /* Build a list of devices */
if( var_Type( p_aout, "audio-device" ) == 0 ) if( var_Type( p_aout, "audio-device" ) == 0 )
{ {
DevicesList( p_aout ); Probe( p_aout );
/*if( DevicesList( p_aout ) != VLC_SUCCESS ); /*if( Probe( p_aout ) != VLC_SUCCESS );
{ {
msg_Err( p_aout, "DevicesList failed" ); msg_Err( p_aout, "Probe failed" );
free( p_sys ); free( p_sys );
return VLC_EGENERIC; return VLC_EGENERIC;
}*/ }*/
...@@ -254,7 +261,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -254,7 +261,7 @@ static int Open( vlc_object_t * p_this )
&i_param_size, &i_param_size,
layout )); layout ));
} }
msg_Dbg( p_aout, "Layout of AUHAL has %d channels" , (int)layout->mNumberChannelDescriptions ); msg_Dbg( p_aout, "Layout of AUHAL has %d channels" , (int)layout->mNumberChannelDescriptions );
p_aout->output.output.i_physical_channels = 0; p_aout->output.output.i_physical_channels = 0;
...@@ -293,7 +300,37 @@ static int Open( vlc_object_t * p_this ) ...@@ -293,7 +300,37 @@ static int Open( vlc_object_t * p_this )
continue; continue;
default: default:
msg_Warn( p_aout, "Unrecognized channel form provided by driver: %d", (int)layout->mChannelDescriptions[i].mChannelLabel ); msg_Warn( p_aout, "Unrecognized channel form provided by driver: %d", (int)layout->mChannelDescriptions[i].mChannelLabel );
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; switch( layout->mNumberChannelDescriptions )
{
/* We make assumptions based on number of channels here.
* Unfortunatly Apple has provided no 100% method to retrieve the speaker configuration */
case 1:
p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER;
break;
case 4:
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
break;
case 6:
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
AOUT_CHAN_CENTER | AOUT_CHAN_LFE |
AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
break;
case 7:
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
AOUT_CHAN_CENTER | AOUT_CHAN_LFE |
AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_REARCENTER;
break;
case 8:
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
AOUT_CHAN_CENTER | AOUT_CHAN_LFE |
AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT |
AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
break;
case 2:
default:
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
}
break; break;
} }
} }
...@@ -301,6 +338,63 @@ static int Open( vlc_object_t * p_this ) ...@@ -301,6 +338,63 @@ static int Open( vlc_object_t * p_this )
msg_Dbg( p_aout, "defined %d physical channels for vlc core", aout_FormatNbChannels( &p_aout->output.output ) ); msg_Dbg( p_aout, "defined %d physical channels for vlc core", aout_FormatNbChannels( &p_aout->output.output ) );
msg_Dbg( p_aout, "%s", aout_FormatPrintChannels( &p_aout->output.output )); msg_Dbg( p_aout, "%s", aout_FormatPrintChannels( &p_aout->output.output ));
AudioChannelLayout new_layout;
memset (&new_layout, 0, sizeof(new_layout));
switch( aout_FormatNbChannels( &p_aout->output.output ) )
{
case 1:
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_Mono;
break;
case 2:
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_Stereo;
break;
case 3:
if( p_aout->output.output.i_physical_channels & AOUT_CHAN_CENTER )
{
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_7; // L R C
}
else if( p_aout->output.output.i_physical_channels & AOUT_CHAN_LFE )
{
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_4; // L R LFE
}
break;
case 4:
if( p_aout->output.output.i_physical_channels & ( AOUT_CHAN_CENTER | AOUT_CHAN_LFE ) )
{
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_10; // L R C LFE
}
else if( p_aout->output.output.i_physical_channels & ( AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT ) )
{
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_3; // L R Ls Rs
}
else if( p_aout->output.output.i_physical_channels & ( AOUT_CHAN_CENTER | AOUT_CHAN_REARCENTER ) )
{
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_3; // L R C Cs
}
break;
case 5:
if( p_aout->output.output.i_physical_channels & ( AOUT_CHAN_CENTER ) )
{
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_19; // L R Ls Rs C
}
else if( p_aout->output.output.i_physical_channels & ( AOUT_CHAN_LFE ) )
{
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_18; // L R Ls Rs LFE
}
break;
case 6:
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_DVD_20; // L R Ls Rs C LFE
break;
case 7:
/* FIXME: This is incorrect. VLC uses the internal ordering: L R Lm Rm Lr Rr C LFE but this is wrong */
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_MPEG_6_1_A; // L R C LFE Ls Rs Cs
break;
case 8:
/* FIXME: This is incorrect. VLC uses the internal ordering: L R Lm Rm Lr Rr C LFE but this is wrong */
new_layout.mChannelLayoutTag = kAudioChannelLayoutTag_MPEG_7_1_A; // L R C LFE Ls Rs Lc Rc
break;
}
/* Set up the format to be used */ /* Set up the format to be used */
DeviceFormat.mSampleRate = p_aout->output.output.i_rate; DeviceFormat.mSampleRate = p_aout->output.output.i_rate;
...@@ -314,9 +408,9 @@ static int Open( vlc_object_t * p_this ) ...@@ -314,9 +408,9 @@ static int Open( vlc_object_t * p_this )
/* Calculate framesizes and stuff */ /* Calculate framesizes and stuff */
aout_FormatPrepare( &p_aout->output.output ); aout_FormatPrepare( &p_aout->output.output );
DeviceFormat.mBytesPerFrame = p_aout->output.output.i_bytes_per_frame; DeviceFormat.mFramesPerPacket = 1;
DeviceFormat.mFramesPerPacket = p_aout->output.output.i_frame_length; DeviceFormat.mBytesPerFrame = DeviceFormat.mBitsPerChannel * DeviceFormat.mChannelsPerFrame / 8;
DeviceFormat.mBytesPerPacket = p_aout->output.output.i_bytes_per_frame * p_aout->output.output.i_frame_length; DeviceFormat.mBytesPerPacket = DeviceFormat.mBytesPerFrame * DeviceFormat.mFramesPerPacket;
i_param_size = sizeof(AudioStreamBasicDescription); i_param_size = sizeof(AudioStreamBasicDescription);
/* Set desired format (Use CAStreamBasicDescription )*/ /* Set desired format (Use CAStreamBasicDescription )*/
...@@ -338,14 +432,17 @@ static int Open( vlc_object_t * p_this ) ...@@ -338,14 +432,17 @@ static int Open( vlc_object_t * p_this )
&i_param_size )); &i_param_size ));
msg_Dbg( p_aout, STREAM_FORMAT_MSG( "the actual set AU format is " , DeviceFormat ) ); msg_Dbg( p_aout, STREAM_FORMAT_MSG( "the actual set AU format is " , DeviceFormat ) );
p_aout->output.i_nb_samples = 69 * p_aout->output.output.i_frame_length; p_aout->output.i_nb_samples = 2048;
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
/* Let's pray for the following operation to be atomic... */ /* Let's pray for the following operation to be atomic... */
p_sys->clock_diff = - (mtime_t) p_sys->clock_diff = - (mtime_t)
AudioConvertHostTimeToNanos( AudioGetCurrentHostTime() ) / 1000; AudioConvertHostTimeToNanos( AudioGetCurrentHostTime() ) / 1000;
p_sys->clock_diff += mdate(); p_sys->clock_diff += mdate();
p_sys->i_read_bytes = 0;
p_sys->i_total_bytes = 0;
/* set the IOproc callback */ /* set the IOproc callback */
AURenderCallbackStruct input; AURenderCallbackStruct input;
...@@ -356,12 +453,20 @@ static int Open( vlc_object_t * p_this ) ...@@ -356,12 +453,20 @@ static int Open( vlc_object_t * p_this )
kAudioUnitProperty_SetRenderCallback, kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Input, kAudioUnitScope_Input,
0, &input, sizeof( input ) ) ); 0, &input, sizeof( input ) ) );
input.inputProc = (AURenderCallback) RenderCallbackAnalog;
input.inputProcRefCon = p_aout;
/* Set the new_layout as the layout VLC feeds to the AU unit */
verify_noerr( AudioUnitSetProperty( p_sys->au_unit,
kAudioUnitProperty_AudioChannelLayout,
kAudioUnitScope_Input,
0, &new_layout, sizeof(new_layout) ) );
/* AU initiliaze */ /* AU initiliaze */
verify_noerr( AudioUnitInitialize(p_sys->au_unit) ); verify_noerr( AudioUnitInitialize(p_sys->au_unit) );
verify_noerr( AudioOutputUnitStart(p_sys->au_unit) ); verify_noerr( AudioOutputUnitStart(p_sys->au_unit) );
return( VLC_SUCCESS ); return( VLC_SUCCESS );
} }
...@@ -391,9 +496,9 @@ static void Play( aout_instance_t * p_aout ) ...@@ -391,9 +496,9 @@ static void Play( aout_instance_t * p_aout )
/***************************************************************************** /*****************************************************************************
* DevicesList * Probe
*****************************************************************************/ *****************************************************************************/
static int DevicesList( aout_instance_t * p_aout ) static int Probe( aout_instance_t * p_aout )
{ {
OSStatus err = noErr; OSStatus err = noErr;
UInt32 i, i_param_size; UInt32 i, i_param_size;
...@@ -492,7 +597,7 @@ static int DevicesList( aout_instance_t * p_aout ) ...@@ -492,7 +597,7 @@ static int DevicesList( aout_instance_t * p_aout )
var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL ); var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
/* attach a Listener so that we are notified of a change in the Device setup */ /* attach a Listener so that we are notified of a change in the Device setup */
/*err = AudioHardwareAddPropertyListener( kAudioHardwarePropertyDevices, /* err = AudioHardwareAddPropertyListener( kAudioHardwarePropertyDevices,
HardwareListener, HardwareListener,
(void *)p_aout ); (void *)p_aout );
if( err ) if( err )
...@@ -566,6 +671,8 @@ static int DeviceDigitalMode( aout_instance_t *p_aout, AudioDeviceID i_dev_id ) ...@@ -566,6 +671,8 @@ static int DeviceDigitalMode( aout_instance_t *p_aout, AudioDeviceID i_dev_id )
/***************************************************************************** /*****************************************************************************
* RenderCallbackAnalog: This function is called everytime the AudioUnit wants * RenderCallbackAnalog: This function is called everytime the AudioUnit wants
* us to provide some more audio data. * us to provide some more audio data.
* Don't print anything during normal playback, calling blocking function from
* this callback is not allowed.
*****************************************************************************/ *****************************************************************************/
static OSStatus RenderCallbackAnalog( vlc_object_t *_p_aout, static OSStatus RenderCallbackAnalog( vlc_object_t *_p_aout,
AudioUnitRenderActionFlags *ioActionFlags, AudioUnitRenderActionFlags *ioActionFlags,
...@@ -574,78 +681,76 @@ static OSStatus RenderCallbackAnalog( vlc_object_t *_p_aout, ...@@ -574,78 +681,76 @@ static OSStatus RenderCallbackAnalog( vlc_object_t *_p_aout,
unsigned int inNumberFrames, unsigned int inNumberFrames,
AudioBufferList *ioData ) AudioBufferList *ioData )
{ {
aout_buffer_t * p_buffer;
AudioTimeStamp host_time; AudioTimeStamp host_time;
mtime_t current_date; mtime_t current_date = 0;
uint32_t i_mData_bytes = 0;
aout_instance_t * p_aout = (aout_instance_t *)_p_aout; aout_instance_t * p_aout = (aout_instance_t *)_p_aout;
struct aout_sys_t * p_sys = p_aout->output.p_sys; struct aout_sys_t * p_sys = p_aout->output.p_sys;
msg_Dbg( p_aout, "start audio packet");
msg_Dbg( p_aout, "inbusnummer: %d",inBusNummer );
msg_Dbg( p_aout, "inNumberFrames: %d", inNumberFrames);
host_time.mFlags = kAudioTimeStampHostTimeValid; host_time.mFlags = kAudioTimeStampHostTimeValid;
AudioDeviceTranslateTime( p_sys->i_selected_dev, inTimeStamp, &host_time ); AudioDeviceTranslateTime( p_sys->i_selected_dev, inTimeStamp, &host_time );
p_sys->clock_diff = - (mtime_t) p_sys->clock_diff = - (mtime_t)
AudioConvertHostTimeToNanos( AudioGetCurrentHostTime() ) / 1000; AudioConvertHostTimeToNanos( AudioGetCurrentHostTime() ) / 1000;
p_sys->clock_diff += mdate(); p_sys->clock_diff += mdate();
current_date = p_sys->clock_diff +
AudioConvertHostTimeToNanos( host_time.mHostTime ) / 1000;
current_date = (mtime_t) p_sys->clock_diff + mdate() + if( ioData == NULL && ioData->mNumberBuffers < 1 )
(mtime_t) ( 1000000 * 1 ); {
msg_Err( p_aout, "no iodata or buffers");
#define B_SPDI (p_aout->output.output.i_format == VLC_FOURCC('s','p','d','i')) return 0;
p_buffer = aout_OutputNextBuffer( p_aout, current_date, VLC_FALSE ); }
#undef B_SPDI if( ioData->mNumberBuffers > 1 )
msg_Err( p_aout, "well this is weird. seems like there is more than one buffer..." );
msg_Dbg( p_aout, "start audio packet BADABOEM");
if( p_buffer != NULL ) if( p_sys->i_total_bytes > 0 )
{ {
if( ioData != NULL && ioData->mNumberBuffers > 0 ) i_mData_bytes = __MIN( p_sys->i_total_bytes - p_sys->i_read_bytes, ioData->mBuffers[0].mDataByteSize );
{ p_aout->p_vlc->pf_memcpy( ioData->mBuffers[0].mData, &p_sys->p_remainder_buffer[p_sys->i_read_bytes], i_mData_bytes );
if( p_buffer->i_nb_bytes*8 != ioData->mBuffers[0].mDataByteSize ) p_sys->i_read_bytes += i_mData_bytes;
{ current_date += (mtime_t) ( (mtime_t) 1000000 / p_aout->output.output.i_rate ) *
msg_Dbg( p_aout, "byte sizes don't match %d:%d", p_buffer->i_nb_bytes*8, ioData->mBuffers[0].mDataByteSize); ( i_mData_bytes / 4 / aout_FormatNbChannels( &p_aout->output.output ) ); // 4 is fl32 specific
}
else if( p_sys->i_read_bytes >= p_sys->i_total_bytes )
{ p_sys->i_read_bytes = p_sys->i_total_bytes = 0;
unsigned int i;
/* move data into output data buffer */
msg_Dbg( p_aout, "#buffers: %d", (int)ioData->mNumberBuffers );
for( i = 0; i < ioData->mNumberBuffers; i++ )
{
p_aout->p_vlc->pf_memcpy( ioData->mBuffers[i].mData,
p_buffer->p_buffer, ioData->mBuffers[i].mDataByteSize );
}
msg_Dbg( p_aout, "yeah first:" );
aout_BufferFree( p_buffer );
msg_Dbg( p_aout, "yeah" );
}
}
else msg_Dbg( p_aout, "no iodata or buffers");
} }
else
while( i_mData_bytes < ioData->mBuffers[0].mDataByteSize )
{ {
msg_Dbg( p_aout, "aout_OutputNextBuffer failed" ); /* We don't have enough data yet */
if( p_aout->output.output.i_format == VLC_FOURCC('f','l','3','2') ) aout_buffer_t * p_buffer;
p_buffer = aout_OutputNextBuffer( p_aout, current_date , VLC_FALSE );
if( p_buffer != NULL )
{ {
UInt32 i; uint32_t i_second_mData_bytes = __MIN( p_buffer->i_nb_bytes, ioData->mBuffers[0].mDataByteSize - i_mData_bytes );
float * p = (float *)ioData->mBuffers[0].mData;
p_aout->p_vlc->pf_memcpy( (uint8_t *)ioData->mBuffers[0].mData + i_mData_bytes, p_buffer->p_buffer, i_second_mData_bytes );
i_mData_bytes += i_second_mData_bytes;
for( i = 0; i < ioData->mBuffers[0].mDataByteSize; i++ ) if( i_mData_bytes >= ioData->mBuffers[0].mDataByteSize )
{
p_sys->i_total_bytes = p_buffer->i_nb_bytes - i_second_mData_bytes;
p_aout->p_vlc->pf_memcpy( p_sys->p_remainder_buffer, &p_buffer->p_buffer[i_second_mData_bytes], p_sys->i_total_bytes );
}
else
{ {
*p++ = 0.0; // update current_date
current_date += (mtime_t) ( (mtime_t) 1000000 / p_aout->output.output.i_rate ) *
( i_second_mData_bytes / 4 / aout_FormatNbChannels( &p_aout->output.output ) ); // 4 is fl32 specific
} }
aout_BufferFree( p_buffer );
} }
else else
{ {
p_aout->p_vlc->pf_memset( ioData->mBuffers[0].mData, 0, ioData->mBuffers[0].mDataByteSize ); p_aout->p_vlc->pf_memset( (uint8_t *)ioData->mBuffers[0].mData +i_mData_bytes, 0, ioData->mBuffers[0].mDataByteSize - i_mData_bytes );
i_mData_bytes += ioData->mBuffers[0].mDataByteSize - i_mData_bytes;
} }
} }
msg_Dbg( p_aout, "eof audio packet");
return( noErr ); return( noErr );
} }
......
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