名为 SpeakHere 的 Apple 演示 iPhone 应用程序不会响应 kAudioSessionOverrideAudioRoute_None

发布于 2024-09-16 07:58:25 字数 981 浏览 4 评论 0原文

我正在尝试 Apple 的示例应用程序 SpeakHere,并且想通过扬声器而不是耳机来收听。

我可以使用此代码打开免提扬声器:

    UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
    AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);    
    UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
    AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride); 

但此后应用程序将不再录音。它冻结了。这段代码没有任何用处:

    UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
    AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);    
    UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_None;
    AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride); 

天哪,如果您可以使用顶部代码打开扬声器,那么您应该能够使用其他代码将其关闭。秘密是什么?

I was trying out Apple's sample app SpeakHere, and wanted to listen through the speakerphone speaker instead of the ear speaker.

I was able to turn on the speakerphone speaker using this code:

    UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
    AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);    
    UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
    AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride); 

But after that the app will no longer record. It freezes. This code doesn't do any good:

    UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
    AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);    
    UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_None;
    AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride); 

Boy, it sure seems like if you can toggle the speaker on with top code, you ought to be able to toggle it off with the other code. What's the secret?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

诺曦 2024-09-23 07:58:25

您是否尝试在音频队列运行时执行此操作?或者您之前是否停止了音频队列并在更改音频会话后重新启动它?

您是否查看过所有音频会话和音频队列调用的错误返回值,以查看是否报告了错误?如果是这样,误差值是多少?

Are you trying to do this while your Audio Queue is running? Or did you stop the audio queue before and restart it after changing the audio session?

Have you looked at the error return values from all the audio session and audio queue calls to see if an error is being reported? And, if so, what is the error value?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文