AudioSteamer's state sometimes doesn't change to AS_PLAYING

197 views Asked by At

I use Matt Gallagher's AudioSteamer to implement the online music playing function, I found that sometimes the online music is playing but the audiostreamer's state doesn't change to AS_PLAYING, anybody meet the same problem? Can you tell me how to solve the question~~thanks~

I guess one of the reasons is that:

if (![[NSThread currentThread] isEqual:internalThread])
{
        [self
        performSelector:@selector(handlePropertyChange:)
        onThread:internalThread
        withObject:[NSNumber numberWithInt:inID]
        waitUntilDone:NO
        modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]];
    return;
}

after those code execute in

- (void)handlePropertyChangeForQueue:(AudioQueueRef)inAQ
    propertyID:(AudioQueuePropertyID)inID

the function:

- (void)handlePropertyChange:(NSNumber *)num
{
    [self handlePropertyChangeForQueue:NULL propertyID:[num intValue]];
}

doesn't execute... I really don't know how to fix it ...anybody help me? thanks..

1

There are 1 answers

0
xexe On

I also have this problem. I added this code:

if (state == AS_WAITING_FOR_QUEUE_TO_START){
        @synchronized(self){
            self.state = AS_PLAYING;
        }
    }

Into the method:

- (void)handlePropertyChangeForQueue:(AudioQueueRef)inAQ
propertyID:(AudioQueuePropertyID)inID

just before this call:

[self
    performSelector:@selector(handlePropertyChange:)
    onThread:internalThread
    withObject:[NSNumber numberWithInt:inID]
    waitUntilDone:NO
    modes:[NSArray arrayWithObject:NSDefaultRunLoopMode]];