音频会话:在iOS 7.1中使用测量模式会导致音量低/无声音 [英] Audio Session: Using measurement mode causes low volume / no sound in iOS 7.1

查看:287
本文介绍了音频会话:在iOS 7.1中使用测量模式会导致音量低/无声音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将AVAudioSessionModeMeasurement与AVAudioSessionCategoryPlayAndRecord一起使用曾在iOS 5.x,6.x和7.0下正常工作,但现在导致iOS 7.1下某些(并非所有)设备的扬声器音量低/没有声音.这是代码:

Using AVAudioSessionModeMeasurement with AVAudioSessionCategoryPlayAndRecord used to work fine under iOS 5.x, 6.x, and 7.0, but it now results in low volume / no sound from the speaker on some (not all) devices under iOS 7.1. Here's the code:

NSError* error = nil;
// Set Aduio Session category
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord
              withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker
                    error:&error];
if( error ) ...

// Set Audio Session mode
[audioSession setMode:AVAudioSessionModeMeasurement error:&error];
if( error ) ...

侧面说明:较旧版本的代码使用AudioSessionSetProperty函数设置kAudioSessionProperty_OverrideCategoryDe​​faultToSpeaker,但在iOS 7.1下仍然存在相同的问题.

Side note: Older versions of the code used the AudioSessionSetProperty function to set kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, but still had the same issue under iOS 7.1.

到目前为止,似乎仅在iPad 4设备上出现了音量低(或无声音)的问题.我不知道它是否会在所有iPad 4上或仅在部分iPad上发生,但只有拥有iPad 4的客户在升级到iOS 7.1后才与我们联系以解决此问题.删除将模式设置为AVAudioSessionModeMeasurement的代码可解决此问题;以正常音量听到音频.但是,不使用测量模式会影响我们对录制的音频进行的信号处理,因此绝对不希望如此.

So far it looks like the low volume (or no sound) issue occurs only on iPad 4 devices. I don't know if it happens on all iPad 4's or only a subset, but only customers with iPad 4's have contacted us with this issue after upgrading to iOS 7.1. Removing the code that sets the mode to AVAudioSessionModeMeasurement fixes the issue; audio is heard at normal volume. However, not using the measurement mode affects the signal processing we do on the recorded audio, so it's definitely not desirable.

音频的播放方式似乎并不重要.设置测量"模式时,AVAudioPlayer和音频队列服务"都显示相同的低音量/无声音问题.

It doesn't seem to matter how the audio is played. Both AVAudioPlayer and Audio Queue Services exhibit the same low volume / no sound issue when the Measurement mode is set.

因为此问题似乎仅影响iPad,所以我尝试删除了AVAudioSessionCategoryOptionDefaultToSpeaker选项(iPhone通常需要此选项)以查看是否有帮助,但这并没有改变.

Because this issue only seems to affect iPad, I've tried removing the AVAudioSessionCategoryOptionDefaultToSpeaker option (which is normally needed for iPhones) to see if that would help, but that didn't make a change.

插入耳机可解决此问题;通过耳机以正常音量听到音频.

Plugging in headphones fixes the issue; audio is heard at normal volume through the headphones.

假设这是一个iOS 7.1错误,我已经向Apple报告了该错误.但是,我想请大家看看我是否可能错过了有关iPad 4的一些特别提示,或者我的音频会话设置中是否还有其他疑问.如果您有一个播放音频的应用程序(通过AVAudioPlayer或音频队列服务),即使您将类别更改为AVAudioSessionCategoryPlayAndRecord并将模式更改为AVAudioSessionModeMeasurement后,即使让我知道音频在iPad 4上是否仍能正常播放,这也将有所帮助极大地.您的应用无需实际录制任何音频;无论是否正在录制音频,都会发生此问题.

Assuming this is an iOS 7.1 bug, I've already reported it as a bug to Apple. However I wanted to ask you guys to see if I might have missed something special about iPad 4's, or maybe something else in my audio session setup. If you have an app that plays back audio (via AVAudioPlayer or Audio Queue Services), even if you let me know if audio still plays back fine on your iPad 4 after you change the category to AVAudioSessionCategoryPlayAndRecord and the mode to AVAudioSessionModeMeasurement, that would help tremendously. Your app doesn't need to actually record any audio; the issue happens whether audio is being recording or not.

在此先感谢您的帮助.

推荐答案

我肯定在iOS 7的iPad上自己遇到了这个问题.

I've definitely run into this issue myself on iPads in iOS 7.

录制时,AVAudioSessionModeMeasurement确实会更改iOS 7上的播放音量.

When recording, AVAudioSessionModeMeasurement does change playback volume on iOS 7.

Apple的文档状态: 如果您的应用正在执行音频输入或输出的测量,请指定此模式. ...如果在具有多个内置麦克风的设备上录制,则使用主麦克风.

Apple's docs state: Specify this mode if your app is performing measurement of audio input or output. ... If recording on devices with more than one built-in microphone, the primary microphone is used.

在具有两个扬声器和两个麦克风的iPhone上,这种感觉很有意义.在电话底部的麦克风外录音时,它会从听筒扬声器中播放音频,因此可以避免干扰.在免提模式下使用时,它会在扬声器中使用底部较大的扬声器和麦克风.

On iPhones, which have two speakers and two microphones, this sort can sort of make sense. When recording out of the microphone on the bottom of the phone, it plays audio out of the earpiece speaker so prevent interference. When being used in speakerphone mode, it uses the loud bottom speakers and a microphone in the earpiece.

在iOS 7中的iPad上,似乎通过单方面降低播放音量来复制此行为.

On iPads in iOS 7, it seems to replicate this behavior by unilaterally lowering the playback volume.

直接回答您的问题:是的,我相信这是一个错误,或者至少是一个非常未经记录的功能.

To answer your question directly: Yes, I believe this is a bug, or at least a very undocumented feature.

完成录制和测量后,可以使用以下方法重置静音的音频:

After you are done recording and measuring, you can reset the silenced audio with:

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&err];
if(err) NSLog(@"AudioSession reset category error at %s:%d", __FILE__, __LINE__);

[[AVAudioSession sharedInstance] setMode:AVAudioSessionModeDefault error:&err];
if(err) NSLog(@"AudioSession reset mode error at %s:%d", __FILE__, __LINE__);

虽然不一定有帮助,但根据我确认的发现,不使用AVAudioSessionModeMeasurement也可以解决此问题.

Although that doesn't necessarily help, likewise with my confirmed findings that not using AVAudioSessionModeMeasurement solves the issue.

这篇关于音频会话:在iOS 7.1中使用测量模式会导致音量低/无声音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆