spotify/cocoalibspotify — Issue #46: SPPlaybackManager and SPCircularBuffer crash when run on iOS 5 ARC
Author: cloudface
Created: 2012-02-27 19:36:31+00:00
State: open

I downloaded the Simple Player sample app and got it to work on iOS5 without ARC. I then tried to get it to work with ARC enabled but the SPPlaybackManager and SPCircularBuffer classes were causing problems. After removing the retain/release/autorelease calls and I still got the compiler error: Implicit conversion of an Objective-C pointer to 'void *' is disallowed with ARC. To fix this I used a bridge cast: (__bridge void*).

For the error: implicit conversion of a non-Objective-C pointer type 'void *' to 'SPPlaybackManager *' is disallowed with ARC i used the bridge cast: (__bridge SPPlaybackManager*)

For the error: Existing ivar 'delegate' for unsafe_unretained property 'delegate' must be __unsafe_unretained I simply removed the id delegate instance variable from the SPPlaybackManager's interface definition.

The project then compiles just fine. However, when I run the project, it crashes as soon as I try to create my SPPlaybackManager using the initWithPlaybackSession method. The error occurs inside the SPCircularBuffer's clear method:

-(void)clear {
@synchronized(buffer) {
memset(buffer, 0, maximumLength);
dataStartOffset = 0;
dataEndOffset = 0;
empty = YES;
}
}

To be exact, the error occurs at the @synchronized(buffer) line. The error message states: Thread 1: Program received signal: "EXC_BAD_ACCESS".

Does anyone know what the problem is? Am I using the wrong bridge cast? Is there any way you guys can release an SPPlaybackManager and SPCircular Buffer that works with ARC enabled? So far everything has worked fine in ARC except for the SPPlaybackManager and SPCircularBuffer :(. Thanks for the help. I appreciate it :)