我刚刚告诉 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)
时,我什么也得不到。好像(这可能是真的)我没有正确使用它。