欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

iOS获取音频设备信息

程序员文章站 2022-07-03 21:02:25
iOS获取音频设备信息。 方法1: CFDictionaryRef descDictRef = nil; UInt32 refSize = sizeof(descDictRe...

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=[[AVAudioSessionsharedInstance]availableInputs];

打印信息如下:

Printing description of availableInputs:

<__NSSingleObjectArrayI 0x17400cb30>(

)

如果是蓝牙设备,采集的时候采样率设置比较高,传输的时候可能会丢数据,可以采样率设置小一点,后面再做重采样处理。