• 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
Re: Buffer overrun management with TPCircularBuffer.. best way to do so?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Buffer overrun management with TPCircularBuffer.. best way to do so?


  • Subject: Re: Buffer overrun management with TPCircularBuffer.. best way to do so?
  • From: Douglas Carmichael <email@hidden>
  • Date: Thu, 01 May 2014 10:55:58 -0500

Kevin:

Thanks for the advice!

Currently, I’m not using two threads, but have the buffer reading in my rendering callback.

Proof-of-concept: https://gist.github.com/douglas-carmichael/37abe32b9341e5a17a46
 
If I uncomment the second xmp_play_frame/TPCircularBufferProduceBytes bit after the usleep in the playback loop, I do get coherently-sounding audio. But, it plays faster than usual and it has crackle/pop sounds as well.

If I comment it out, I get one frame of ‘good’ audio, but then smaller fragments get sent to the callback:
2014-05-01 10:54:48.189 xmpAUTest-badLoop[38221:12c0b] Outputting zeroes. 2004 bytes available, 2048 bytes expected.
2014-05-01 10:55:26.590 xmpAUTest-badLoop[38234:12c0b] Outputting zeroes. 1720 bytes available, 2048 bytes expected.

Would there be any way to tell the callback to ‘sleep’, so to speak?
Any ideas on how I can improve what I have?

Thanks in advance!

—Douglas

On Apr 30, 2014, at 7:07 PM, Kevin Dixon <email@hidden> wrote:

Do "length" - "fillCount" to see how much space is available. If this is less than your threshold, cause the producer thread to sleep until the buffer is sufficiently drained.

-Kevin


On Wed, Apr 16, 2014 at 3:49 AM, Douglas Carmichael <email@hidden> wrote:
To whom it may concern:

I’ve started working on using TPCircularBuffer to manage the output of a music playback library (libxmp: http://xmp.sourceforge.net/libxmp.html), but I’m stumped on the best way to manage overruns.

Currently, my code does take the audio data into the buffer and render it out on the rendering callback, but there doesn’t seem to be a way to check if the buffer is full with a TPCircularBuffer before pushing data into the buffer.

What should I be doing in my code to make it work?

(I was able to send equal-size chunks of audio from the library in my rendering callback without issue, but the ring buffer will work better for the app I want to build.)

Thanks in advance for any help!

—Douglas


 _______________________________________________
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


 _______________________________________________
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

  • Follow-Ups:
    • Re: Buffer overrun management with TPCircularBuffer.. best way to do so?
      • From: Kevin Dixon <email@hidden>
  • Next by Date: Re: kAudioUnitProperty_AUHostIdentifier
  • Next by thread: Re: Buffer overrun management with TPCircularBuffer.. best way to do so?
  • Index(es):
    • Date
    • Thread