Re: mDataByteSize == 0?
Re: mDataByteSize == 0?
- Subject: Re: mDataByteSize == 0?
- From: Michael Thornburgh <email@hidden>
- Date: Sat, 17 Apr 2004 16:11:20 -0700
john and i discussed this off-list, and found the problem. i believe
it's either a bug in the HAL's operation, or documentation. :)
the problem is: if you set mDataByteSize to 0 in your IOProc, it'll
still be 0 when the HAL calls you next time. this can happen if you
pass outOutputData directly to AudioConverterFillComplexBuffer() in
your IOProc, and the AudioConverter converted 0 frames.
this section of AudioHardware.h makes it sound like you should be able
to set mDataByteSize to match the number of frames written into the
AudioBuffers:
// On exiting, the IOProc should set the mDataByteSize field of
each AudioBuffer
// (if any) in the output AudioBufferList. On input, this value is
set to the
// size of the buffer, so it will only need to be changed for
cases where
// the number of bytes for the buffer size
(kAudioDevicePropertyBufferFrameSize)
// of the IO transaction. This may be the case for compressed
formats like AC-3.
i'll grant that it's ambiguous for the case of non-compressed formats
(like canonical Float32 LPCM).
the following program illustrates this behavior:
------
#import <unistd.h>
#import <stdio.h>
#import <CoreAudio/CoreAudio.h>
OSStatus playbackIOProc (
AudioDeviceID inDevice,
const AudioTimeStamp* inNow,
const AudioBufferList* inInputData,
const AudioTimeStamp* inInputTime,
AudioBufferList* outOutputData,
const AudioTimeStamp* inOutputTime,
void* inClientData
)
{
printf ( "output mDataByteSize: %u\n",
outOutputData->mBuffers[0].mDataByteSize );
if ( outOutputData->mBuffers[0].mDataByteSize > 0 )
{
printf ( "set to 0\n" );
outOutputData->mBuffers[0].mDataByteSize = 0;
}
return noErr;
}
main()
{
AudioDeviceID outDeviceID;
OSStatus theStatus;
UInt32 theSize;
theSize = sizeof(AudioDeviceID);
theStatus = AudioHardwareGetProperty (
kAudioHardwarePropertyDefaultOutputDevice, &theSize, &outDeviceID );
AudioDeviceAddIOProc ( outDeviceID, playbackIOProc, NULL );
AudioDeviceStart ( outDeviceID, playbackIOProc );
sleep(10);
return 0;
}
------
which prints out
output mDataByteSize: 4096
set to 0
output mDataByteSize: 0
output mDataByteSize: 0
output mDataByteSize: 0
...
-mike
On Apr 16, 2004, at 10:54 PM, john wrote:
Hi,
I'm running into a situation where my HAL output ioproc is being
called and is working. However, when I change the output sample rate
using Audio MIDI Setup to anything but 44100 the
outOutputData->mBuffers[0].mDataByteSize becomes 0.
Now I'm setup to receive a notification when the audio stream
description changes, and when that's called, I reset some audio
converters to the new format. If I comment out that code the problem
doesn't happen.
Any ideas?
-- John
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.