Convering CoreAudio renderer to AUHAL renderer.
Convering CoreAudio renderer to AUHAL renderer.
- Subject: Convering CoreAudio renderer to AUHAL renderer.
- From: Derk-Jan Hartman <email@hidden>
- Date: Sun, 10 Apr 2005 21:37:31 +0200
I want to convert VLC's older CoreAudio renderer, to an AUHAL renderer,
but my timestamping for the auhal seems incorrect.
It would help if I knew what I was doing, but I don't. So can anyone
tell me how to convert this?
aout_OutputNextBuffer( p_aout, current_date, B_SPDI );
Returns a buffer with the data for time: current_date (this should be
the expected rendertime what i can gather from the VLC docs.
/
************************************************************************
*****
* CoreAudio callback renderer
************************************************************************
*****/
static OSStatus IOCallback( AudioDeviceID inDevice,
const AudioTimeStamp * inNow,
const void * inInputData,
const AudioTimeStamp * inInputTime,
AudioBufferList * outOutputData,
const AudioTimeStamp * inOutputTime,
void * threadGlobals )
{
aout_buffer_t * p_buffer;
AudioTimeStamp host_time;
mtime_t current_date;
aout_instance_t * p_aout = (aout_instance_t *)threadGlobals;
struct aout_sys_t * p_sys = p_aout->output.p_sys;
host_time.mFlags = kAudioTimeStampHostTimeValid;
AudioDeviceTranslateTime( inDevice, inOutputTime, &host_time );
p_sys->clock_diff = - (mtime_t)
AudioConvertHostTimeToNanos( AudioGetCurrentHostTime() ) / 1000;
p_sys->clock_diff += mdate();
current_date = p_sys->clock_diff +
AudioConvertHostTimeToNanos( host_time.mHostTime ) /
1000;
#define B_SPDI (p_aout->output.output.i_format ==
VLC_FOURCC('s','p','d','i'))
p_buffer = aout_OutputNextBuffer( p_aout, current_date, B_SPDI );
#undef B_SPDI
#define BUFFER outOutputData->mBuffers[ p_sys->i_stream_index ]
if( p_buffer != NULL )
{
/* move data into output data buffer */
p_aout->p_vlc->pf_memcpy( BUFFER.mData,
p_buffer->p_buffer,
p_buffer->i_nb_bytes );
aout_BufferFree( p_buffer );
}
else
{
if( p_aout->output.output.i_format ==
VLC_FOURCC('f','l','3','2') )
{
UInt32 i, i_size = p_sys->i_bufframe_size *
p_sys->stream_format.mChannelsPerFrame;
float * p = (float *)BUFFER.mData;
for( i = 0; i < i_size; i++ )
{
*p++ = 0.0;
}
}
else
{
p_aout->p_vlc->pf_memset( BUFFER.mData, 0,
BUFFER.mDataByteSize );
}
}
#undef BUFFER
return( noErr );
}
/
************************************************************************
*****
* AUHAL renderer callback
************************************************************************
*****/
static OSStatus RenderCallbackAnalog( vlc_object_t *_p_aout,
AudioUnitRenderActionFlags
*ioActionFlags,
const AudioTimeStamp *inTimeStamp,
unsigned int inBusNummer,
unsigned int inNumberFrames,
AudioBufferList *ioData )
{
aout_buffer_t * p_buffer;
AudioTimeStamp host_time;
mtime_t current_date;
aout_instance_t * p_aout = (aout_instance_t *)_p_aout;
struct aout_sys_t * p_sys = p_aout->output.p_sys;
host_time.mFlags = kAudioTimeStampHostTimeValid;
AudioDeviceTranslateTime( p_sys->i_selected_dev, inTimeStamp,
&host_time );
p_sys->clock_diff = - (mtime_t)
AudioConvertHostTimeToNanos( AudioGetCurrentHostTime() ) / 1000;
p_sys->clock_diff += mdate();
current_date = p_sys->clock_diff +
AudioConvertHostTimeToNanos( host_time.mHostTime )
/ 1000;
#define B_SPDI (p_aout->output.output.i_format ==
VLC_FOURCC('s','p','d','i'))
p_buffer = aout_OutputNextBuffer( p_aout, current_date, VLC_FALSE );
#undef B_SPDI
if( p_buffer != NULL )
{
if( ioData != NULL && ioData->mNumberBuffers > 0 )
{
int i;
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 );
}
aout_BufferFree( p_buffer );
}
else msg_Dbg( p_aout, "no iodata or buffers");
}
else
{
if( p_aout->output.output.i_format ==
VLC_FOURCC('f','l','3','2') )
{
UInt32 i;
float * p = (float *)ioData->mBuffers[0].mData;
for( i = 0; i < ioData->mBuffers[0].mDataByteSize; i++ )
{
*p++ = 0.0;
}
}
else
{
p_aout->p_vlc->pf_memset( ioData->mBuffers[0].mData, 0,
ioData->mBuffers[0].mDataByteSize );
}
}
return( noErr );
}
---
Universiteit Twente
Derk-Jan Hartman (d.hartman at student.utwente dot nl)
http://home.student.utwente.nl/d.hartman
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden