1

XcodeにすべてをObjective-C++としてコンパイルするように指示しましたが、キャストでエラーが発生しました。

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*'

使用しようとするとstatic_cast<CFDictionaryRef>(aInPropertyValue)何も得られません。まるで(おそらく本当です)私はそれを正しく使用していません。

4

1 に答える 1

1

通常のCキャストを使用しますか?

CFDictionaryRef routeChangeDictionary = ( CFDictionaryRef )aInPropertyValue;

編集0:

その関数呼び出しについてはどうですか(それが番号であることが確実な場合:)

CFNumberRef routeChangeReasonRef =
    ( CFNumberRef )CFDictionaryGetValue ( ...

編集1:

次に、 The Definitive C ++ Book GuideandListをご覧ください。

于 2011-04-10T02:09:23.433 に答える