iOS - 开始录制时,蓝牙设备认为我正在拨打电话

时间:2014-06-30 17:14:27

标签: ios bluetooth avaudiorecorder avaudiosession

我有一个录音应用程序。我遇到了一个问题,当我打开我的应用程序并且手机与蓝牙设备配对时,一旦我开始录制,蓝牙设备就会认为我正在打电话。它发出呼出声,并在屏幕上显示" ON CALL" (总是谈论BT设备),但当然没有实际的电话。

这就是我目前正在初始化会话的方式:

[[AVAudioSession sharedInstance] overrideOutputAudioPort:AVAudioSessionPortOverrideNone
                                                   error:nil];

[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord
                                 withOptions:AVAudioSessionCategoryOptionMixWithOthers | 
                                             AVAudioSessionCategoryOptionAllowBluetooth
                                       error: nil];

我在2个不同的蓝牙设备上尝试过,同样的结果也是如此。两人都试图建立电话。

在查看BlueTooth日志之后,我发现了一些关于它正在做什么的线索:

12:24:07.185 A2DPClient.cpp:390        StopStreaming        A2DP       Notice     Stopping A2DP audio streaming
12:24:07.186 A2DPClient.cpp:415        StopStreaming        A2DP       Notice     Sending 'A2DP audio disconnected' event for device 00:19:B5:FE:05:9B "VW_RADIO_55"
12:24:07.201 HandsfreeAudioPlugIn.cpp:971 audioDataAvailable   Handsfree  Notice     HandsfreeAudioPlugIn:: Audio available event for 00:19:B5:FE:05:9B, reason: 2
12:24:07.203 HandsfreeAudioPlugIn.cpp:971 audioDataAvailable   Handsfree  Notice     HandsfreeAudioPlugIn:: Audio available event for 00:19:B5:FE:05:9B, reason: 4
12:24:07.203 HandsfreeAudioPlugIn.cpp:971 audioDataAvailable   Handsfree  Notice     HandsfreeAudioPlugIn:: Audio available event for 00:19:B5:FE:05:9B, reason: 1
12:24:07.203 HandsfreeGateway.cpp:699  createVisualVoicemai Handsfree  Notice     Setting up virtual call
12:24:07.205 AudioSendThread.cpp:91    run                  Audio      Notice     AudioSendThread stopping
12:24:07.207 HandsfreeGateway.cpp:1540 initiateScoConnectio Handsfree  Notice     Initiating SCO connection with delay of 20 milliseconds
12:24:07.207 HandsfreeGateway.cpp:3179 handleUpdateCallStat Handsfree  Notice     Updating call status for call(s): [ [#1: Outgoing to +XXXXXXXXXXXXX "My Number" (voicemail)] ]
12:24:07.207 HandsfreeGateway.cpp:1523 delayScoConnection   Handsfree  Notice     Delaying SCO connection by 20 milliseconds
12:24:07.208 HandsfreeGateway.cpp:3183 handleUpdateCallStat Handsfree  Notice     callPresent: no, callState: 1, callSetup: outgoing, heldStatus: none, heldChanged: no, visualVoicemail: yes
12:24:07.208 HandsfreeGateway.cpp:2871 tellEveryOneAboutVVM Handsfree  Notice     Sending call setup "outgoing" to device 00:19:B5:FE:05:9B "VW_RADIO_55"
12:24:07.208 HandsfreeGateway.cpp:2877 tellEveryOneAboutVVM Handsfree  Notice     Sending call status "call active" to device 00:19:B5:FE:05:9B "VW_RADIO_55"
12:24:07.208 HandsfreeGateway.cpp:2760 operator()           Handsfree  Notice     Sending call setup "none" to device 00:19:B5:FE:05:9B "VW_RADIO_55"
12:24:07.229 HandsfreeGateway.cpp:1626 internalConnectAudio Handsfree  Notice     Making outgoing audio connection to device 00:19:B5:FE:05:9B "VW_RADIO_55"
12:24:07.457 HandsfreeGateway.cpp:1161 audioEvent           Handsfree  Notice     Received audio connected event for device 00:19:B5:FE:05:9B "VW_RADIO_55"
12:24:07.471 A2DPClient.cpp:1384       SuspendCfm           A2DP       Notice     Successfully suspended stream to device 00:19:B5:FE:05:9B "VW_RADIO_55"
12:25:36.959 LeObserver.cpp:904        scanTimer            Discovery  Notice     Session "wirelessproxd-central-35-1" is now at scan level 3
12:25:59.599 HandsfreeAudioPlugIn.cpp:1050 audioPauseNotificati Handsfree  Notice     HandsfreeGateway::audioPauseNotification
12:25:59.599 HandsfreeGateway.cpp:726  deleteVisualVoicemai Handsfree  Notice     Cleaning up virtual call
12:25:59.599 HandsfreeGateway.cpp:1567 internalDisconnectAu Handsfree  Notice     Disconnecting audio from device 00:19:B5:FE:05:9B "VW_RADIO_55"

什么是设置虚拟通话???我在代码中唯一能做的就是

[self.audioRecorder record];

self.audioRecorder当然是AVAudioRecorder的一个实例。

我该如何防止这种情况?

1 个答案:

答案 0 :(得分:0)

每当您想要开始录制并且不允许蓝牙时,请更改AVAudioRecorder选项:

- (void)audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder successfully:(BOOL)flag

完成录制后,在AVAudioSession实例的委托调用中:

AVAudioSessionCategoryOptionAllowBluetooth

设置回AVAudioSession选项以允许蓝牙{{1}}这样{{1}}不会认为录制输入应作为来自所连接BT设备的语音呼叫处理。