Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AudioDecoder problems under ARC #4

Closed
indragiek opened this issue Aug 5, 2011 · 6 comments
Closed

AudioDecoder problems under ARC #4

indragiek opened this issue Aug 5, 2011 · 6 comments

Comments

@indragiek
Copy link

AudioDecoder's methods for setting callbacks uses a void* parameter for the context. This construct isn't supported under Objective-C ARC so it won't compile (I'm not talking about compiling SFBAudioEngine under ARC, just using AudioDecoder in my own ARC-compiled code).

@sbooth
Copy link
Owner

sbooth commented Aug 6, 2011

I haven't yet used ARC, but I think you can work around this problem by using objc_unretainedObject and objc_unretainedPointer:

// To set the callback
decoder->SetDecodingStartedCallback(decodingStarted, objc_unretainedPointer(self));
// In the callback
id me = objc_unretainedObject(context);

@indragiek
Copy link
Author

Thanks for the reply, using objc_unretainedObject gives me "Cannot initialize a parameter of type 'void *' with an rvalue of type 'objc_objectptr_t'"

@sbooth
Copy link
Owner

sbooth commented Aug 7, 2011

Until Xcode 4.2 is officially released I don't think I'll be much help with this, because I don't have it installed yet.

@sbooth
Copy link
Owner

sbooth commented Aug 7, 2011

One other thought- objc_objectptr_t is a typedef for const void *. Did you try explicitly casting context to const void * in the call to objc_unretainedObject?

@sbooth
Copy link
Owner

sbooth commented Aug 7, 2011

Yet another idea, and I think this may be the correct answer:

// To set the callback
decoder->SetDecodingStartedCallback(decodingStarted, (__bridge void *)self);
// In the callback
id me = (__bridge id)context;

@indragiek indragiek reopened this Aug 8, 2011
@indragiek
Copy link
Author

The last solution seems to have done the trick :) This might be worth a note in the README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants