iOS獲取音頻設備信息

方法1

        CFDictionaryRef descDictRef = nil;

        UInt32 refSize = sizeof(descDictRef);

        status = AudioSessionGetProperty(kAudioSessionProperty_AudioRouteDescription, &refSize, &descDictRef);


打印信息如下:

Printing description of dictRef:

{

    "RouteDetailedDescription_Outputs" =     (

                {

            "RouteDetailedDescriptionKey_EndpointType" = Headphones;

            "RouteDetailedDescription_ChannelDescriptions" =             (

                                {

                    "ChannelDescription_Label" = 1;

                    "ChannelDescription_Name" = "AirPods \U5de6";

                },

                                {

                    "ChannelDescription_Label" = 2;

                    "ChannelDescription_Name" = "AirPods \U53f3";

                }

            );

            "RouteDetailedDescription_ID" = 486;

            "RouteDetailedDescription_IsHeadphones" = 1;

            "RouteDetailedDescription_IsVoiceProcessingSupported" = 0;

            "RouteDetailedDescription_Name" = AirPods;

            "RouteDetailedDescription_NumberOfChannels" = 2;

            "RouteDetailedDescription_PortType" = BluetoothA2DPOutput;

            "RouteDetailedDescription_UID" = "7C:04:D0:8A:43:33-tacl";

        }

    );

}



方法2

NSArray* availableInputs = [[AVAudioSession sharedInstance] availableInputs];  


打印信息如下:

Printing description of availableInputs:

<__NSSingleObjectArrayI 0x17400cb30>(

<AVAudioSessionPortDescription: 0x17400cae0, type = MicrophoneBuiltIn; name = iPhone 麥克風; UID = Built-In Microphone; selectedDataSource = >

)


如果是藍牙設備,採集的時候採樣率設置比較高,傳輸的時候可能會丟數據,可以採樣率設置小一點,後面再做重採樣處理。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章