• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Multimedia Subsystem Changelog
2
3## c1.multimedia.1 Behavior Change in the Audio Framework for Identifying USB Audio Device Types
4**Access Level**
5
6Public API
7
8**Reason for Change**
9
10Previously, all USB audio devices are recognized by the system as headset input/output devices. To improve recognition accuracy and meet the UX display requirements of applications, the system now differentiates between USB headsets and ordinary USB audio devices (such as speakers).
11
12**Impact of the Change**
13
14This change requires application adaptation.
15
16When audio devices are connected or disconnected, the system reports the type of audio device to the application. Applications can also actively query the available device types through interfaces. For applications targeting API levels before 18, the system behavior remains unchanged. For applications targeting API level 18 and later, the identification and reporting of USB devices have been changed as follows:
17
18TS APIs
19
20| Platform| Before Change| After Change|
21| --- | ----- | ----- |
22| General| If only an input device is present at a USB address, it is recognized as a USB_HEADSET.| If only an input device is present at a USB address, it is recognized as a USB_DEVICE.|
23| PC/2-in-1 device| If only an output device is present at a USB address, it is recognized as a USB_HEADSET.| If only an output device is present at a USB address, it is recognized as a USB_DEVICE.|
24
25NDK APIs
26| Platform| Before Change| After Change|
27| --- | ----- | ----- |
28| General| If only an input device is present at a USB address, it is recognized as an AUDIO_DEVICE_USB_HEADSET.| If only an input device is present at a USB address, it is recognized as an AUDIO_DEVICE_USB_DEVICE.|
29| PC/2-in-1 device| If only an output device is present at a USB address, it is recognized as an AUDIO_DEVICE_USB_HEADSET.| If only an output device is present at a USB address, it is recognized as an AUDIO_DEVICE_USB_DEVICE.|
30
31**Start API Level**
32
339
34
35**Change Since**
36
37OpenHarmony 5.1.0.53
38
39**Key API/Component Changes**
40
41After this change, when a single-input or single-output USB audio device is connected to the system, the device type returned by the following APIs changes:
42
43@ohos.multimedia.audio.d.ts ArkTS APIs:
44
45| Class | API |
46|---|---|
47| audio.AudioRoutingManager  |  getDevices(deviceFlag: DeviceFlag, callback: AsyncCallback\<AudioDeviceDescriptors>): void |
48| audio.AudioRoutingManager  |  getDevices(deviceFlag: DeviceFlag): Promise\<AudioDeviceDescriptors> |
49| audio.AudioRoutingManager  |  getDevicesSync(deviceFlag: DeviceFlag): AudioDeviceDescriptors |
50| audio.AudioRoutingManager  |  getAvailableDevices(deviceUsage: DeviceUsage): AudioDeviceDescriptors |
51| audio.AudioRoutingManager  |  on(type: 'availableDeviceChange', deviceUsage: DeviceUsage, callback: Callback\<DeviceChangeAction>): void |
52| audio.AudioRoutingManager  |  off(type: 'availableDeviceChange', callback?: Callback\<DeviceChangeAction>): void |
53
54C APIs in **native_audio_routing_manager.h**:
55
56| API|
57|--|
58| OH_AudioCommon_Result OH_AudioRoutingManager_GetDevices(OH_AudioRoutingManager *audioRoutingManager, OH_AudioDevice_Flag deviceFlag, OH_AudioDeviceDescriptorArray **audioDeviceDescriptorArray) |
59| OH_AudioCommon_Result OH_AudioRoutingManager_GetAvailableDevices(OH_AudioRoutingManager *audioRoutingManager, OH_AudioDevice_Usage deviceUsage, OH_AudioDeviceDescriptorArray **audioDeviceDescriptorArray) |
60
61**Adaptation Guide**
62
63TS APIs
64
65If your application has specific handling requirements for USB audio devices, you now need to handle both USB_HEADSET and USB_DEVICE types.
66```cpp
67// Perform special processing for the USB audio device.
68if (devicetype == DeviceType.USB_HEADSET) {
69  // do sth
70}
71```
72
73After the change, if your application has specific handling requirements for USB audio devices, you now need to handle both USB_HEADSET and USB_DEVICE types.
74```cpp
75// Perform special processing for the USB audio device.
76if (devicetype == DeviceType.USB_HEADSET || devicetype == DeviceType.USB_DEVICE) {
77  // do sth
78}
79```
80
81
82NDK APIs
83
84If your application has specific handling requirements for USB audio devices, you now need to handle both AUDIO_DEVICE_USB_HEADSET and AUDIO_DEVICE_USB_DEVICE types.
85
86Before the change, if your application has specific handling requirements for USB audio devices, you only need to handle AUDIO_DEVICE_USB_HEADSET.
87
88```cpp
89// Perform special processing for the USB audio device.
90if (devicetype == OH_AudioDevice_Type.AUDIO_DEVICE_USB_HEADSET) {
91  // do sth
92}
93```
94
95After the change, if your application has specific handling requirements for USB audio devices, you now need to handle both AUDIO_DEVICE_USB_HEADSET and AUDIO_DEVICE_USB_DEVICE types.
96```cpp
97// Perform special processing for the USB audio device.
98if (devicetype == OH_AudioDevice_Type.AUDIO_DEVICE_USB_HEADSET || devicetype == OH_AudioDevice_Type.AUDIO_DEVICE_USB_DEVICE) {
99  // do sth
100}
101```
102