Cog Audio: Also commit synchronization delay on new track playback
This commit is contained in:
parent
c8d2864862
commit
083dbbf18b
1 changed files with 23 additions and 15 deletions
|
@ -65,6 +65,8 @@
|
||||||
|
|
||||||
- (void)play:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi startPaused:(BOOL)paused andSeekTo:(double)time
|
- (void)play:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi startPaused:(BOOL)paused andSeekTo:(double)time
|
||||||
{
|
{
|
||||||
|
[self waitUntilCallbacksExit];
|
||||||
|
|
||||||
output = [[OutputNode alloc] initWithController:self previous:nil];
|
output = [[OutputNode alloc] initWithController:self previous:nil];
|
||||||
[output setup];
|
[output setup];
|
||||||
[output setVolume: volume];
|
[output setVolume: volume];
|
||||||
|
@ -194,21 +196,8 @@
|
||||||
// Called when the playlist changed before we actually started playing a requested stream. We will re-request.
|
// Called when the playlist changed before we actually started playing a requested stream. We will re-request.
|
||||||
- (void)resetNextStreams
|
- (void)resetNextStreams
|
||||||
{
|
{
|
||||||
// This sucks! And since the thread that's inside the function can be calling
|
[self waitUntilCallbacksExit];
|
||||||
// event dispatches, we have to pump the message queue if we're on the main
|
|
||||||
// thread. Damn.
|
|
||||||
if (atomic_load_explicit(&refCount, memory_order_relaxed) != 0) {
|
|
||||||
BOOL mainThread = (dispatch_queue_get_label(dispatch_get_main_queue()) == dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL));
|
|
||||||
atomic_store(&resettingNow, true);
|
|
||||||
while (atomic_load_explicit(&refCount, memory_order_relaxed) != 0) {
|
|
||||||
[semaphore signal]; // Gotta poke this periodically
|
|
||||||
if (mainThread)
|
|
||||||
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.001]];
|
|
||||||
else
|
|
||||||
usleep(500);
|
|
||||||
}
|
|
||||||
atomic_store(&resettingNow, false);
|
|
||||||
}
|
|
||||||
@synchronized (chainQueue) {
|
@synchronized (chainQueue) {
|
||||||
for (id anObject in chainQueue) {
|
for (id anObject in chainQueue) {
|
||||||
[anObject setShouldContinue:NO];
|
[anObject setShouldContinue:NO];
|
||||||
|
@ -532,5 +521,24 @@
|
||||||
return newVolume;
|
return newVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)waitUntilCallbacksExit
|
||||||
|
{
|
||||||
|
// This sucks! And since the thread that's inside the function can be calling
|
||||||
|
// event dispatches, we have to pump the message queue if we're on the main
|
||||||
|
// thread. Damn.
|
||||||
|
if (atomic_load_explicit(&refCount, memory_order_relaxed) != 0) {
|
||||||
|
BOOL mainThread = (dispatch_queue_get_label(dispatch_get_main_queue()) == dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL));
|
||||||
|
atomic_store(&resettingNow, true);
|
||||||
|
while (atomic_load_explicit(&refCount, memory_order_relaxed) != 0) {
|
||||||
|
[semaphore signal]; // Gotta poke this periodically
|
||||||
|
if (mainThread)
|
||||||
|
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.001]];
|
||||||
|
else
|
||||||
|
usleep(500);
|
||||||
|
}
|
||||||
|
atomic_store(&resettingNow, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in a new issue