Re: Loop notification
Re: Loop notification
- Subject: Re: Loop notification
- From: Mark Pauley <email@hidden>
- Date: Tue, 16 Oct 2007 12:23:15 -0700
Whoops, I see what you're saying... My suggestion only solves the low-
overhead pinging of the main-thread.
You would also need to determine how many packets into the current
pull you are on the MP3 side. What happens if you just return a short
packet-count and set a flag when your feeder hits the end? Then you
can check for the flag when the converter returns a short count and
signal the source on the main runloop at that point, right? You may
even be able to reset the feeder and pull the remaining number of
packets to satisfy the render request at that point.
Otherwise you would then reset the feeder's state and go back to
pulling as normal until you hit the end in the feeder again.
_Mark
On Oct 16, 2007, at 11:32 AM, Mark Pauley wrote:
I would use the CFRunLoopSource api: http://developer.apple.com/documentation/CoreFoundation/Reference/CFRunLoopSourceRef/Reference/reference.html
Essentially, you schedule a source on the main runloop from your
main thread and pass that to where ever you may need to signal the
source. Signal the source every time the event occurs, unschedule
the source when you're done with it.
_Mark
On Oct 16, 2007, at 2:36 AM, Andreas Falkenhahn wrote:
Hi,
how could I implement a loop notification in my double buffered
audio file
player? I want to post an event to the main thread's event queue
every
time an audio file is looped.
This does not seem to be as easy as it sounds, because the feeder
thread
I'm employing for my double buffer reads the data from the stream
(using
AudioFileReadPackets) in chunks of about 1 second's worth of audio
data.
Thus, I can't simply send the loop notification when my feeder thread
detects the end of the stream and moves its cursor back to 0,
because the
loop is not there yet. There's still audio left to be rendered.
I can't send the loop notification from the PreRender or PostRender
events
either, because my ACFillComplexBuffer() callback is also called
only in
intervals of about 1 second, which is too unprecise for a good loop
detection.
Could someone please point me in the direction I should take to
implement
a precise loop notification feature? Of course, I could do it using a
hacky way, i.e. set flag on audio end detection in feeder thread,
then on
the next PostRender notification calculate the remaining playing time
until loop, and then install a timer which fires after this remaining
playing time is up. But that doesn't look like a nice solution. Is
there a
better one?
Tks
Andreas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
@mac.com
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
_______________________________________________
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