我正在编写一个 iPhoneApp,它将通过音频插孔从设备录制声音,我尝试编译我的代码,但它一直说
'无法使用'const void *'类型的左值初始化'CFDictionaryRef'(又名'const_CFDictionary *')类型的变量这是我的代码的一部分:
#pragma mark Audio session callbacks_______________________
// Audio session callback function for responding to audio route changes. If playing
// back application audio when the headset is unplugged, this callback pauses
// playback and displays an alert that notifies the user that power has been terminated.
//
// The system takes care of iPod audio pausing during route changes--this callback
// is not involved with pausing playback of iPod audio.
void audioRouteChangeListenerCallback (
void *inUserData,
AudioSessionPropertyID inPropertyID,
UInt32 inPropertyValueSize,
const void *inPropertyValue
) {
// ensure that this callback was invoked for a route change
if (inPropertyID != kAudioSessionProperty_AudioRouteChange) return;
// This callback, being outside the implementation block, needs a reference to the
// MainViewController object, which it receives in the inUserData parameter.
// You provide this reference when registering this callback (see the call to
// AudioSessionAddPropertyListener).
MaxViewController *controller = (__bridge MaxViewController *) inUserData;
// if application sound is not playing, there's nothing to do, so return.
if (controller.sound.playing == 0 ) {
NSLog (@"Audio route change while application audio is stopped.");
return;
} else {
// Determines the reason for the route change, to ensure that it is not // because of a category change.
CFDictionaryRef routeChangeDictionary = inPropertyValue;
CFNumberRef routeChangeReasonRef =
CFDictionaryGetValue (
routeChangeDictionary,
CFSTR (kAudioSession_AudioRouteChangeKey_Reason)
);
SInt32 routeChangeReason;
我已经在 stackoverflow 和其他地方搜索了所有可能的结果,但事实证明它失败了。任何帮助将不胜感激。提前致谢。