繁体   English   中英

初始化AUGraph后的AVAudioSession属性

[英]AVAudioSession properties after Initializing AUGraph

要开始通话,我们的VOIP应用会设置一个AVAudioSession,然后构建,初始化并运行AUGraph。

在通话期间,我们允许用户使用以下代码在扬声器模式之间来回切换:

avSession = [AVAudioSession sharedInstance];
AVAudioSessionCategoryOptions categoryOptions = [avSession categoryOptions];
categoryOptions |= AVAudioSessionCategoryOptionDefaultToSpeaker;
NSLog(@"AudioService:setSpeaker:setProperty:DefaultToSpeaker=1 categoryOptions = %lx", (unsigned long)categoryOptions);
BOOL success = [avSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:categoryOptions error:&error];

哪个很好。 但是,如果我们在初始化AUGraph之后尝试对某些AVAudioSession查询,例如:

    AVAudioSessionDataSourceDescription *myInputDataSource = [avSession inputDataSource];

结果为空。 在执行AUGraphInitialize之前,运行同一行代码会给出正确的非空结果。 谁能解释这是怎么回事,以及在使用AUGraph时如何正确访问AVAudioSession属性/方法?

根据开发人员文档,这是预期的行为,如果无法切换源, inputDataSource应该返回nil 因此,Apple确实不会通过配置错误而让任何不好的事情发生,但是无来源也可能会带来错误的想法。 希望这可以帮助。

Discussion
The value of this property is nil if switching between multiple input
sources is not currently possible. This feature is supported only on
certain devices and peripherals–for example, on an iPhone equipped with
both front- and rear-facing microphones.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM