Hello, all ...

I'm experiencing a hang in my app when I do things too quickly. When I pause the app and examine the callstack, I see this:

#0  0x31467b18 in semaphore_timedwait_signal_trap ()
#1  0x3145e984 in semaphore_timedwait_signal ()
#2  0x3145b104 in _pthread_cond_wait ()
#3  0x3145b260 in pthread_cond_timedwait_relative_np ()
#4  0x348cbd58 in CAGuard::WaitFor ()
#5  0x34909954 in ClientAudioQueue::ServicePendingCallbacks ()
#6  0x34909ab8 in AudioQueueStop ()
#7 0x00014334 in -[AudioStreamer stop] (self=0x895800, _cmd=0x3018cc44) at /Users/jmzorko/work/root/Magnatune/Classes/ AudioStreamer.m:529 #8 0x00003566 in -[MagnatuneAppDelegate stopStream] (self=0x11cc40, _cmd=0x18694) at /Users/jmzorko/work/root/Magnatune/Classes/ MagnatuneAppDelegate.m:237 #9 0x0000f8d2 in -[SongController tableView:didSelectRowAtIndexPath:] (self=0x12e4c0, _cmd=0x300f1a90, tableView=0x186080, indexPath=0x1491a0) at /Users/jmzorko/work/root/Magnatune/Classes/ SongController.m:212

This is happening inside my observeValueForKeyPath method ... basically the background thread that does the Core Audio stuff has been told to stop via AudioQueueStop(), and the IsRunning callback set the value of a boolean called isPlaying to false. I've registered as an observer to this boolean, and usually things work well. However, when I select a new song to play too soon after a previous song, observeValueForKeyPath seems to hang. Here is observeValueForKeyPath:

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
                                                change:(NSDictionary *)change 
context:(void *)context
{
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

NSLog(@"observeValueForKeyPath -- current thread ID: %x, keypath: %s", [NSThread currentThread], [keyPath UTF8String]);

        if ([keyPath isEqualToString:@"isPlaying"])
        {
                NSLog(@"calling handleIsPlaying");
[self performSelectorOnMainThread:@selector(handleIsPlaying:) withObject:keyPath waitUntilDone:YES];
                [pool release];
                return;
        }
        
        .
        .
        .
        
        [pool release];
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}

... and here is handleIsPlaying:

- (void)handleIsPlaying:(NSString *)isPlaying
{
        NSLog(@"inside handleIsPlaying");
        
        if ([streamer isPlaying])
        {
NSLog(@"handleIsPlaying reports that the streamer is currently playing");
        }
        else
        {
                NSLog(@"stopping and releasing audio engine");
                [streamer removeObserver:self forKeyPath:@"isPlaying"];
                [streamer removeObserver:self forKeyPath:@"failed"];
                
                if (!self.toldAudioStreamerToStop)
                {
                        [streamer removeObserver:self 
forKeyPath:@"buffersEmpty"];
                }
                
                [streamer release];
                //streamer = nil;
NSLog(@"audio engine is released -- streamer not nil yet because thread might not have stopped yet");
        }
        
        NSLog(@"finished handleIsPlaying");
}

... I can't immediately see why handleIsPlaying() or observeValueForKeyPath() would hang, but according to the callstack, it's waiting for something. The last thing I see in my console log is:

2008-11-28 06:29:44.459 Magnatune[1357:20b] calling AudioQueueStop() from AudioStreamer stop method 2008-11-28 06:29:44.990 Magnatune[1357:ba0f] ---------------- audio queue callback called 2008-11-28 06:29:45.001 Magnatune[1357:ba0f] observeValueForKeyPath -- current thread ID: 1a3860, keypath: isPlaying
2008-11-28 06:29:45.007 Magnatune[1357:ba0f] calling handleIsPlaying

If anyone could illuminate me as to what the problem is (what is CAGuard supposed to guard against, and why am I running into this issue?), i'd be very appreciative.

Regards,

John

Falling You - exploring the beauty of voice and sound
http://www.fallingyou.com











_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to