• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
how to avoid skips?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to avoid skips?


  • Subject: how to avoid skips?
  • From: Tobias Rundström <email@hidden>
  • Date: Tue, 30 Mar 2004 09:41:49 +0200

Hello!

I have a audio application that uses CoreAudio on the OSX platform for audio output. The application decodes a lot of different formats. Internaly it has two ringbuffers, on the buffers the filesystem and one that buffers the decoded data (that should be written to the output).
The CA plugin is written so it reads from the second ringbuffer when I change the internal status to play. The callback for reading from the buffer is non-blocking (except for a threadlock that makes sure that noone writes to it at the same time) and don't seem to get underruns, but I still get a lot of skips and bleeps when I put some pressure on the system. Is there a buffer internaly in CoreAudio that I could change size of? Or is there something in my setup that is flawed?

Here are some relevant functions from the CA plugin:


First the callback that reads from the buffer. Here I have to convert the data from shorts to floats.

static OSStatus
xmms_ca_write_cb (AudioDeviceID inDevice,
const AudioTimeStamp *inNow,
const AudioBufferList *inInputData,
const AudioTimeStamp *inInputTime,
AudioBufferList *outOutputData,
const AudioTimeStamp *inOutputTime,
void *inClientData)
{

...

for (b = 0; b < outOutputData->mNumberBuffers; ++b) {
gint m;
gint i;
gint ret;
gint16 *buffer;

m = outOutputData->mBuffers[b].mDataByteSize;

buffer = g_new0 (gint16, m/2);

ret = xmms_output_read (output,
(gchar *)buffer,
m/2);

for (i = 0; i < (ret/2) ; i++) {
((gfloat*)outOutputData->mBuffers[0].mData)[i] = ((gfloat) buffer[i] + 32768.0) / (32768.0*2);
}

g_free (buffer);
}

this is how I init coreaudio:

static gboolean
xmms_ca_new (xmms_output_t *output)
{
xmms_ca_data_t *data;
OSStatus res;
UInt32 size;

g_return_val_if_fail (output, FALSE);

data = g_new0 (xmms_ca_data_t, 1);

size = sizeof (data->outputdevice);

/* Maybe the kAudio... could be configurable ? */
res = AudioHardwareGetProperty (kAudioHardwarePropertyDefaultOutputDevice,
&size, &data->outputdevice);

if (res) {
XMMS_DBG ("Error %d from CoreAudio", (int) res);
return FALSE;
}

res = AudioDeviceAddIOProc (data->outputdevice, xmms_ca_write_cb, (void *) output);

xmms_output_private_data_set (output, data);

XMMS_DBG ("CoreAudio initilized!");

return TRUE;
}

After this I just call AudioDeviceStart when there is data in the ringbuffer.

Any input on this issue would be appricated.

Regards Tobias
_______________________________________________
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.


  • Prev by Date: Time signature and meta events in MusicSequence
  • Next by Date: Re: Temporarily Stopping IOAudioEngine From Inside
  • Previous by thread: Re: Time signature and meta events in MusicSequence
  • Next by thread: new SDK problems
  • Index(es):
    • Date
    • Thread