1

I just told Xcode to compile everything as Objective-C++ and now I have errors from casting.

void audioRouteChangeListenerCallback (
                                       void                      *aInUserData,
                                       AudioSessionPropertyID    aInPropertyID,
                                       UInt32                    aInPropertyValueSize,
                                       const void                *aInPropertyValue
                                       ) {

    // Ensure that this callback was invoked because of an audio route change
    if (aInPropertyID != kAudioSessionProperty_AudioRouteChange) return;

    // This callback, being outside the implementation block, needs a reference to the MixerHostAudio
    //   object, which it receives in the inUserData parameter. You provide this reference when
    //   registering this callback (see the call to AudioSessionAddPropertyListener).
    TJUSimpleSequencer *lAudioObject = (TJUSimpleSequencer *) aInUserData;

    // if application sound is not playing, there's nothing to do, so return.
    if (NO == lAudioObject.isPlaying) {

        NSLog (@"Audio route change while application audio is stopped.");
        return;

    } else {

        // Determine the specific type of audio route change that occurred.
        CFDictionaryRef routeChangeDictionary = aInPropertyValue; // !!! invalid conversion from 'const void*' to 'const __CFDictionary*'

        CFNumberRef routeChangeReasonRef =
        CFDictionaryGetValue (
                              routeChangeDictionary,
                              CFSTR (kAudioSession_AudioRouteChangeKey_Reason)
                              ); // !!! invalid conversion from 'const void*' to 'const __CFNumber*'

When i try to use static_cast<CFDictionaryRef>(aInPropertyValue), I get nothing. As though (which is probably true) I am not using it correctly.

Jonathan Sterling
  • 18,320
  • 12
  • 67
  • 79
griotspeak
  • 13,022
  • 13
  • 43
  • 54

1 Answers1

1

Use regular C cast?

CFDictionaryRef routeChangeDictionary = ( CFDictionaryRef )aInPropertyValue;

Edit 0:

How about this for that function call (if you're sure it's a number :)

CFNumberRef routeChangeReasonRef =
    ( CFNumberRef )CFDictionaryGetValue ( ...

Edit 1:

Take a look at The Definitive C++ Book Guide and List then.

Community
  • 1
  • 1
Nikolai Fetissov
  • 82,306
  • 11
  • 110
  • 171