Commit b602fb16 authored by Jon Lech Johansen's avatar Jon Lech Johansen

* coreaudio: Fixed the failed to set buffer size: [nope] SPDIF issue.

parent a7620012
...@@ -37,8 +37,6 @@ ...@@ -37,8 +37,6 @@
#include <CoreAudio/CoreAudio.h> #include <CoreAudio/CoreAudio.h>
#define A52_FRAME_NB 1536
#define STREAM_FORMAT_MSG( pre, sfm ) \ #define STREAM_FORMAT_MSG( pre, sfm ) \
pre ": [%ld][%4.4s][%ld][%ld][%ld][%ld][%ld][%ld]", \ pre ": [%ld][%4.4s][%ld][%ld][%ld][%ld][%ld][%ld]", \
(UInt32)sfm.mSampleRate, (char *)&sfm.mFormatID, \ (UInt32)sfm.mSampleRate, (char *)&sfm.mFormatID, \
...@@ -164,7 +162,7 @@ struct aout_sys_t ...@@ -164,7 +162,7 @@ struct aout_sys_t
vlc_bool_t b_revert_sfmt; vlc_bool_t b_revert_sfmt;
AudioStreamBasicDescription sfmt_revert; AudioStreamBasicDescription sfmt_revert;
UInt32 i_buffer_size; UInt32 i_bufframe_size;
mtime_t clock_diff; mtime_t clock_diff;
}; };
...@@ -321,14 +319,14 @@ static int Open( vlc_object_t * p_this ) ...@@ -321,14 +319,14 @@ static int Open( vlc_object_t * p_this )
msg_Dbg( p_aout, STREAM_FORMAT_MSG( "using format", msg_Dbg( p_aout, STREAM_FORMAT_MSG( "using format",
p_sys->stream_format ) ); p_sys->stream_format ) );
/* Get the buffer size */ /* Get the bufframe size */
i_param_size = sizeof( p_sys->i_buffer_size ); i_param_size = sizeof( p_sys->i_bufframe_size );
err = AudioDeviceGetProperty( p_sys->devid, i_startingChannel, FALSE, err = AudioDeviceGetProperty( p_sys->devid, i_startingChannel, FALSE,
kAudioDevicePropertyBufferSize, kAudioDevicePropertyBufferFrameSize,
&i_param_size, &p_sys->i_buffer_size ); &i_param_size, &p_sys->i_bufframe_size );
if( err != noErr ) if( err != noErr )
{ {
msg_Err( p_aout, "failed to get buffer size: [%4.4s]", msg_Err( p_aout, "failed to get bufframe size: [%4.4s]",
(char *)&err ); (char *)&err );
FreeDevice( p_aout ); FreeDevice( p_aout );
FreeHardwareInfo( p_aout ); FreeHardwareInfo( p_aout );
...@@ -337,43 +335,23 @@ static int Open( vlc_object_t * p_this ) ...@@ -337,43 +335,23 @@ static int Open( vlc_object_t * p_this )
return( VLC_EGENERIC ); return( VLC_EGENERIC );
} }
msg_Dbg( p_aout, "device buffer size: [%ld]", p_sys->i_buffer_size ); msg_Dbg( p_aout, "device bufframe size: [%ld]", p_sys->i_bufframe_size );
msg_Dbg( p_aout, "device buffer index: [%ld]", p_sys->i_stream_index ); msg_Dbg( p_aout, "device buffer index: [%ld]", p_sys->i_stream_index );
/* If we do AC3 over SPDIF, set buffer size to one AC3 frame */ /* If we do AC3 over SPDIF, set buffer size to one AC3 frame */
if( ( p_sys->stream_format.mFormatID == kAudioFormat60958AC3 || if( ( p_sys->stream_format.mFormatID == kAudioFormat60958AC3 ||
p_sys->stream_format.mFormatID == 'IAC3' ) && p_sys->stream_format.mFormatID == 'IAC3' ) &&
p_sys->i_buffer_size != AOUT_SPDIF_SIZE ) p_sys->i_bufframe_size != A52_FRAME_NB )
{
p_sys->i_buffer_size = AOUT_SPDIF_SIZE;
i_param_size = sizeof( p_sys->i_buffer_size );
err = AudioDeviceSetProperty( p_sys->devid, 0, 0, FALSE,
kAudioDevicePropertyBufferSize,
i_param_size, &p_sys->i_buffer_size );
if( err != noErr )
{ {
msg_Err( p_aout, "failed to set buffer size: [%4.4s]", p_sys->i_bufframe_size = A52_FRAME_NB;
(char *)&err ); i_param_size = sizeof( p_sys->i_bufframe_size );
FreeDevice( p_aout );
FreeHardwareInfo( p_aout );
vlc_mutex_destroy( &p_sys->lock );
free( (void *)p_sys );
return( VLC_EGENERIC );
}
msg_Dbg( p_aout, "device buffer size set to: [%ld]",
p_sys->i_buffer_size );
/* Set buffer frame size */
i_param_size = sizeof( p_aout->output.i_nb_samples );
err = AudioDeviceSetProperty( p_sys->devid, 0, 0, FALSE, err = AudioDeviceSetProperty( p_sys->devid, 0, 0, FALSE,
kAudioDevicePropertyBufferFrameSize, kAudioDevicePropertyBufferFrameSize,
i_param_size, i_param_size, &p_sys->i_bufframe_size );
&p_aout->output.i_nb_samples );
if( err != noErr ) if( err != noErr )
{ {
msg_Err( p_aout, "failed to set buffer frame size: [%4.4s]", msg_Err( p_aout, "failed to set bufframe size (%ld): [%4.4s]",
(char *)&err ); p_sys->i_bufframe_size, (char *)&err );
FreeDevice( p_aout ); FreeDevice( p_aout );
FreeHardwareInfo( p_aout ); FreeHardwareInfo( p_aout );
vlc_mutex_destroy( &p_sys->lock ); vlc_mutex_destroy( &p_sys->lock );
...@@ -381,8 +359,8 @@ static int Open( vlc_object_t * p_this ) ...@@ -381,8 +359,8 @@ static int Open( vlc_object_t * p_this )
return( VLC_EGENERIC ); return( VLC_EGENERIC );
} }
msg_Dbg( p_aout, "device buffer frame size set to: [%d]", msg_Dbg( p_aout, "device bufframe size set to: [%ld]",
p_aout->output.i_nb_samples ); p_sys->i_bufframe_size );
} }
switch( p_sys->stream_format.mFormatID ) switch( p_sys->stream_format.mFormatID )
...@@ -432,8 +410,7 @@ static int Open( vlc_object_t * p_this ) ...@@ -432,8 +410,7 @@ static int Open( vlc_object_t * p_this )
return( VLC_EGENERIC ); return( VLC_EGENERIC );
} }
p_aout->output.i_nb_samples = (int)( p_sys->i_buffer_size / p_aout->output.i_nb_samples = p_sys->i_bufframe_size;
p_sys->stream_format.mBytesPerFrame );
aout_VolumeSoftInit( p_aout ); aout_VolumeSoftInit( p_aout );
break; break;
...@@ -630,8 +607,8 @@ static OSStatus IOCallback( AudioDeviceID inDevice, ...@@ -630,8 +607,8 @@ static OSStatus IOCallback( AudioDeviceID inDevice,
{ {
/* move data into output data buffer */ /* move data into output data buffer */
p_aout->p_vlc->pf_memcpy( outOutputData->mBuffers[ p_sys->i_stream_index ].mData, p_aout->p_vlc->pf_memcpy( outOutputData->mBuffers[ p_sys->i_stream_index ].mData,
p_buffer->p_buffer, p_buffer->p_buffer, p_sys->i_bufframe_size *
p_sys->i_buffer_size ); p_sys->stream_format.mBytesPerFrame );
aout_BufferFree( p_buffer ); aout_BufferFree( p_buffer );
} }
...@@ -639,7 +616,8 @@ static OSStatus IOCallback( AudioDeviceID inDevice, ...@@ -639,7 +616,8 @@ static OSStatus IOCallback( AudioDeviceID inDevice,
{ {
if( p_aout->output.output.i_format == VLC_FOURCC('f','l','3','2') ) if( p_aout->output.output.i_format == VLC_FOURCC('f','l','3','2') )
{ {
UInt32 i, i_size = p_sys->i_buffer_size / sizeof(float); UInt32 i, i_size = p_sys->i_bufframe_size *
p_sys->stream_format.mChannelsPerFrame;
float * p = (float *)outOutputData->mBuffers[ p_sys->i_stream_index ].mData; float * p = (float *)outOutputData->mBuffers[ p_sys->i_stream_index ].mData;
for( i = 0; i < i_size; i++ ) for( i = 0; i < i_size; i++ )
...@@ -650,7 +628,8 @@ static OSStatus IOCallback( AudioDeviceID inDevice, ...@@ -650,7 +628,8 @@ static OSStatus IOCallback( AudioDeviceID inDevice,
else else
{ {
memset( outOutputData->mBuffers[ p_sys->i_stream_index ].mData, memset( outOutputData->mBuffers[ p_sys->i_stream_index ].mData,
0, p_sys->i_buffer_size ); 0, p_sys->i_bufframe_size *
p_sys->stream_format.mBytesPerFrame );
} }
} }
......
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