FreeStreamer
FreeStreamer copied to clipboard
Wrong state callback when paused immediately after playing
When state changed to PLAYING, pause immediately, after a while, PLAYING state comes! audio is not really playing actually.
Blame code below, I just can NOT figure it out why this timer is needed? I try to comment these, works well.
if (THIS->m_state != PLAYING && !THIS->m_stateSetTimer) {
// Set the playing state in the main thread
CFRunLoopTimerContext ctx = {0, THIS, NULL, NULL, NULL};
THIS->m_stateSetTimer = CFRunLoopTimerCreate(NULL, 0, 0, 0, 0,
stateSetTimerCallback,
&ctx);
CFRunLoopAddTimer(THIS->m_mainRunLoop, THIS->m_stateSetTimer, kCFRunLoopCommonModes);
}
Notifications should come from the main thread and the easiest way for this is to use a runloop timer. If you mix the main thread and other threads, you are making difficult to spot crashes because the de facto Cocoa convention is that notifications come 99% of the cases from the main thread. So this works well may work for you 95% time and then for 5% time you get a bunch of weird crashes without proper synchronisation.
void Audio_Stream::audioQueueStateChanged(Audio_Queue::State state)
this callback always notify PLAYING state for now, so I think the timer might be duplicated.
If there is a problem, @muhku how to fix this problem below?
When state changed to PLAYING, pause immediately, after a while, PLAYING state comes! audio is not really playing actually.
Have this problem too, when the player state is buffering, pause/stop is not working. Did you resolve this problem? @IvanChan
same problem