1# Multimedia Subsystem Changelog
2
3## c1.multimedia.1 APIs setAudioParameter and getAudioParameter of the AudioManager Class in ohos.multimedia.audio Are Deprecated
4
5**Access Level**
6
7Public API
8
9**Reason for Change**
10
11Third-party applications and audio chips can no longer modify configurations through custom parameters. Instead, the configuration modification is now controlled by the system. Dedicated APIs are provided for common functionalities.
12
13**Change Impact**
14
15This change is a non-compatible change. You are advised to use new APIs.
16
17**Deprecated Since**
18
19OpenHarmony SDK 4.1.6.5
20
21**Deprecated APIs**
22
23In the **AudioManager** class:
24
25setAudioParameter(key: string, value: string, callback: AsyncCallback<void>): void;
26
27setAudioParameter(key: string, value: string): Promise<void>;
28
29getAudioParameter(key: string, callback: AsyncCallback<string>): void;
30
31getAudioParameter(key: string): Promise<string>;
32
33**Adaptation Guide**
34
35For system applications, use the alternative APIs according to the deprecated API hints.
36
37setExtraParameters(mainKey: string, kvpairs: Record<string, string>): Promise<void>;
38
39getExtraParameters(mainKey: string, subKeys?: Array<string>): Promise<Record<string, string>>;
40
41In the preceding APIs, **mainKey** is the same as the original parameter **key**, and **kvpairs** is the key-value pairs in the string of the original parameter **value**.
42
43For third-party applications, the preceding APIs are not available. Use the public APIs of the **AudioManager** class as required.
44
45The deprecated APIs will be retained for five more SDK versions. Make your adaptation plan as required.
46
47## c1.multimedia.2 API setMicrophoneMute of the AudioVolumeGroupManager Class in ohos.multimedia.audio Is Deprecated
48
49**Access Level**
50
51Public API
52
53**Reason for Change**
54
55The **setMicrophoneMute** API is a public API but requires the **ohos.permission.MANAGE_AUDIO_CONFIG** permission, which cannot be granted to third-party applications. According to the SDK specifications, the API is changed to a system API.
56
57**Change Impact**
58
59This change is a non-compatible change. You are advised to use new APIs.
60
61**Deprecated Since**
62
63OpenHarmony SDK 4.1.6.5
64
65**Deprecated APIs**
66
67In the **AudioVolumeGroupManager** class:
68
69setMicrophoneMute(mute: boolean, callback: AsyncCallback<void>): void;
70
71setMicrophoneMute(mute: boolean): Promise<void>;
72
73**Adaptation Guide**
74
75For system applications, use the alternative API according to the deprecated API hints. The alternative API provides the same functionality.
76
77setMicMute(mute: boolean): Promise<void>;
78
79Third-party applications cannot obtain the **ohos.permission.MANAGE_AUDIO_CONFIG** permission and therefore cannot actually use the original API. This change has no impact and requires no adaptation.
80
81The deprecated APIs will be retained for five more SDK versions. Make your adaptation plan as required.
82
83## c1.multimedia.3 Behavior of the usages Attribute of CaptureFilterOptions in ohos.multimedia.audio Is Changed
84
85**Access Level**
86
87Public API
88
89**Reason for Change**
90
91The **usages** attribute is used to filter audio clips by usage during internal audio recording. When the attribute is **STREAM_USAGE_VOICE_COMMUNICATION**, the application must have the **ohos.permission.CAPTURE_VOICE_DOWNLINK_AUDIO** permission, which cannot be granted to third-party applications. According to the SDK specifications, the attribute must be removed from the public API.
92
93**Change Impact**
94
95This change is a non-compatible change. You are advised to use new APIs.
96
97**Change Since**
98
99OpenHarmony SDK 4.1.6.5
100
101**Key API/Component Changes**
102
103Before change:
104```
105/**
106 * Filter by stream usages. If you want to capture voice streams, additional permission is needed.
107 * @permission ohos.permission.CAPTURE_VOICE_DOWNLINK_AUDIO
108 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture
109 * @since 10
110 */
111```
112An application can use **STREAM_USAGE_VOICE_COMMUNICATION** to filter audio clips, under the prerequisites that it has the **ohos.permission.CAPTURE_VOICE_DOWNLINK_AUDIO** permission.
113
114After change:
115```
116/**
117 * Filter by stream usages. But not allow to capture voice streams.
118 * @syscap SystemCapability.Multimedia.Audio.PlaybackCapture
119 * @since 11
120 */
121```
122Applications can no longer use **STREAM_USAGE_VOICE_COMMUNICATION** to filter audio clips, and the declaration of the **ohos.permission.CAPTURE_VOICE_DOWNLINK_AUDIO** permission is deleted. When an application without this permission uses **STREAM_USAGE_VOICE_COMMUNICATION**, an **AudioCapturer** object cannot be created and the **ERROR_SYSTEM** error is returned.
123
124**Adaptation Guide**
125
126Third-party applications cannot obtain the permission and therefore cannot actually use **STREAM_USAGE_VOICE_COMMUNICATION**. This change has no impact and requires no adaptation.
127
128System applications cannot use **STREAM_USAGE_VOICE_COMMUNICATION** even if they have the **ohos.permission.CAPTURE_VOICE_DOWNLINK_AUDIO** permission. Therefore, remove **STREAM_USAGE_VOICE_COMMUNICATION** from your code.
129
130## c1.multimedia.4 APIs for Subscribing to or Unsubscribing from the interrupt Event of the AudioManager Class in ohos.multimedia.audio Is Deprecated
131
132**Access Level**
133
134Public API
135
136**Reason for Change**
137
138In SDK 10, the system uses the built-in focus mode. For details, see [Audio Playback Concurrency Policy](../../../application-dev/media/audio-playback-concurrency.md).
139
140The APIs are related to the external focus and cannot be used to preempt the built-in focus. As such, they are deprecated.
141
142**Change Impact**
143
144This change is a non-compatible change. You are advised to use new APIs.
145
146**Deprecated Since**
147
148OpenHarmony SDK 4.1.6.5
149
150**Deprecated APIs**
151
152In the **AudioManager** class:
153
154on(type: 'interrupt', interrupt: AudioInterrupt, callback: Callback<InterruptAction>): void;
155
156off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback<InterruptAction>): void;
157
158**Adaptation Guide**
159
160Implement concurrency policy control for audio playback based on the built-in focus mode. For details, see [Audio Playback Concurrency Policy](../../../application-dev/media/audio-playback-concurrency.md).
161
162## c1.multimedia.5 API write of the AudioRenderer Class and read of the AudioCapturer Class in ohos.multimedia.audio Are Deprecated
163
164**Access Level**
165
166Public API
167
168**Reason for Change**
169
170The APIs for subscribing to the **'writeData'** and **'readData'** events are added to the **AudioRenderer** and **AudioCapturer** classes. Using the subscription APIs, you no longer need to manage data processing moments, avoiding the underrun/overrun problem caused by inaccurate data rotation time.
171
172**Change Impact**
173
174This change is a non-compatible change. You are advised to use new APIs.
175
176**Deprecated Since**
177
178OpenHarmony SDK 4.1.6.5
179
180**Deprecated APIs**
181
182In the **AudioRenderer** class:
183
184write(buffer: ArrayBuffer, callback: AsyncCallback<number>): void;
185
186write(buffer: ArrayBuffer): Promise<number>;
187
188In the **AudioCapturer** class:
189
190read(size: number, isBlockingRead: boolean, callback: AsyncCallback<ArrayBuffer>): void;
191
192read(size: number, isBlockingRead: boolean): Promise<ArrayBuffer>;
193
194**Adaptation Guide**
195
196Use the new APIs according to the deprecated API hints.
197
198New **AudioRenderer** APIs:
199
200on(type: 'writeData', callback: Callback<ArrayBuffer>): void;
201
202off(type: 'writeData', callback?: Callback<ArrayBuffer>): void;
203
204When the callback is received, the application needs to write the playback data to the ArrayBuffer. After the callback is complete, the system automatically obtains the data from the ArrayBuffer for output.
205
206New **AudioCapturer** APIs:
207
208on(type: 'readData', callback: Callback<ArrayBuffer>): void;
209
210off(type: 'readData', callback?: Callback<ArrayBuffer>): void;
211
212When the callback is received, the application needs to read the recording data from the ArrayBuffer. After the callback is complete, the system writes the subsequent recording data in the ArrayBuffer to prepare for the next callback trigger.
213
214The deprecated APIs will be retained for five more SDK versions. Make your adaptation plan as required.
215
216## c1.multimedia.6 Obtaining Preferred Recording Device Behavior in ohos.multimedia.audio Is Changed in the Internal Recording Scenario
217
218**Access Level**
219
220Public API
221
222**Reason for Change**
223
224In the internal recording scenario, no microphone is used for recording. The correct device type should be returned.
225
226**Change Impact**
227
228This change is a compatible change. No adaptation is required.
229
230**Change Since**
231
232OpenHarmony SDK 4.1.6.5
233
234**Key API/Component Changes**
235
236In the **AudioRoutingManager** class:
237
238getPreferredInputDeviceForCapturerInfo(capturerInfo: AudioCapturerInfo, callback: AsyncCallback<AudioDeviceDescriptors>): void
239
240getPreferredInputDeviceForCapturerInfo(capturerInfo: AudioCapturerInfo): Promise<AudioDeviceDescriptors>;
241
242Before change:
243
244When the input type is **SOURCE_TYPE_PLAYBACK_CAPTURE**, **AudioDeviceDescriptor** of a **DeviceType.MIC** device is returned.
245
246After change:
247
248When the input type is **SOURCE_TYPE_PLAYBACK_CAPTURE**, **AudioDeviceDescriptor** of a **DeviceType.INVALID** device is returned.
249
250**Adaptation Guide**
251
252The return value in the internal recording scenario is corrected. No adaptation is required.
253
254## c1.multimedia.7 Behavior of Subscription APIs of the AudioManager Class in ohos.multimedia.audio Is Changed
255
256**Access Level**
257
258Public API
259
260**Reason for Change**
261
262The implementation of the subscription APIs does not comply with the general subscription API specifications, and the subscription callbacks may be overwritten.
263
264**Change Impact**
265
266If an application makes multiple subscriptions, all subscribed-to callbacks will be traversed and triggered in sequence when the subscribed-to event occurs.
267
268**Change Since**
269
270OpenHarmony SDK 4.1.6.5
271
272**Key API/Component Changes**
273
274In the **AudioVolumeManager** class:
275
276on(type: 'volumeChange', callback: Callback<VolumeEvent>): void;
277
278In the **AudioVolumeGroupManager** class:
279
280on(type: 'ringerModeChange', callback: Callback<AudioRingMode>): void;
281
282on(type: 'micStateChange', callback: Callback<MicStateChangeEvent>): void;
283
284In the **AudioRoutingManager** class:
285
286on(type: 'deviceChange', deviceFlag: DeviceFlag, callback: Callback<DeviceChangeAction>): void;
287
288In the **AudioStreamManager** class:
289
290on(type: 'audioRendererChange', callback: Callback<AudioRendererChangeInfoArray>): void;
291
292on(type: 'audioCapturerChange', callback: Callback<AudioCapturerChangeInfoArray>): void;
293
294Before change:
295
296When an event is subscribed to for multiple times, only the last callback is triggered.
297
298After change:
299
300When an event is subscribed to for multiple times, all callbacks that are not unsubscribed from are triggered.
301
302**Adaptation Guide**
303
304If an event is subscribed to only once, no adaptation is required.
305
306If an event is subscribed to for multiple times, no adaptation is required if you want all subscribed-to callbacks will be traversed and triggered, no adaptation is required.
307
308If an event is subscribed to for multiple times, but you only want the last callback to be triggered, use **off** to unsubscribe from the previous callbacks.
309
310## c1.multimedia.8 Error Code Is Added for the System API availableDevice in ohos.multimedia.audio
311
312**Access Level**
313
314System API
315
316**Reason for Change**
317
318The corresponding error code is added to the system API.
319
320**Change Impact**
321
322This change is a compatible change. No adaptation is required.
323
324**Change Since**
325
326OpenHarmony SDK 4.1.6.5
327
328**Key API/Component Changes**
329
330In the **AudioRoutingManager** class:
331
332getAvailableDevices(deviceUsage: DeviceUsage): AudioDeviceDescriptors;
333
334on(type: 'availableDeviceChange', deviceUsage: DeviceUsage, callback: Callback<DeviceChangeAction>): void;
335
336off(type: 'availableDeviceChange', callback?: Callback<DeviceChangeAction>): void;
337
338Before change:
339
340When a third-party application calls these system APIs, the default result is returned but the subscription does not take effect.
341
342After change:
343
344When a third-party application calls these system APIs, error code 202 is thrown.
345
346**Adaptation Guide**
347
348For system applications, no adaptation is required.
349
350For third-party applications, they should not use system APIs.
351
352## c1.multimedia.9 Permission Statement Is Added for the createPlayer API in ohos.multimedia.audioHaptic
353
354**Access Level**
355
356Public API
357
358**Reason for Change**
359
360**AudioHapticPlayer** supports the haptic feedback, which depends on the **ohos.permission.VIBRATE** permission.
361
362**Change Impact**
363
364This change is a non-compatible change. To use the haptic feedback, your application must obtain the permission.
365
366**Change Since**
367
368OpenHarmony SDK 4.1.6.5
369
370**Key API/Component Changes**
371
372In the **AudioHapticManager** class:
373
374createPlayer(id: number, options?: AudioHapticPlayerOptions): Promise<AudioHapticPlayer>;
375
376Before change:
377
378```
379/**
380 * Create an audio haptic player. This method uses a promise to return the result.
381 * @param { number } id - Source id.
382 * @param { AudioHapticPlayerOptions } options - Options when creating audio haptic player.
383 * @returns { Promise<AudioHapticPlayer> } Promise used to return the result.
384 * @throws { BusinessError } 401 - The parameter check failed.
385 * @throws { BusinessError } 5400102 - Operation not allowed.
386 * @throws { BusinessError } 5400103 - I/O error.
387 * @throws { BusinessError } 5400106 - Unsupport format.
388 * @syscap SystemCapability.Multimedia.AudioHaptic.Core
389 * @since 11
390 */
391```
392
393There is no permission statement. However, applications without the permission cannot trigger the haptic feedback. Only audio playback is supported.
394
395After change:
396
397```
398/**
399 * Create an audio haptic player. This method uses a promise to return the result. If haptics is needed, caller
400 * should have the permission of ohos.permission.VIBRATE.
401 * @permission ohos.permission.VIBRATE
402 * @param { number } id - Source id.
403 * @param { AudioHapticPlayerOptions } options - Options when creating audio haptic player.
404 * @returns { Promise<AudioHapticPlayer> } Promise used to return the result.
405 * @throws { BusinessError } 201 - Permission denied.
406 * @throws { BusinessError } 401 - The parameter check failed.
407 * @throws { BusinessError } 5400102 - Operation not allowed.
408 * @throws { BusinessError } 5400103 - I/O error.
409 * @throws { BusinessError } 5400106 - Unsupport format.
410 * @syscap SystemCapability.Multimedia.AudioHaptic.Core
411 * @since 11
412 */
413```
414
415The **ohos.permission.VIBRATE** permission statement and permission usage comments are provided.
416
417**Adaptation Guide**
418
419The API behavior is not changed. To enable the haptic feedback, an application must request the **ohos.permission.VIBRATE** permission.
420
421## c1.multimedia.10 Error Code Implementation of the AudioManager Class in ohos.multimedia.audio Is Corrected
422
423**Access Level**
424
425Public API
426
427**Reason for Change**
428
429The error code is declared as a number, but the type string is used in the implementation.
430
431**Change Impact**
432
433The declaration remains unchanged. If your code complies with the API definition, no adaptation is required.
434
435**Change Since**
436
437OpenHarmony SDK 4.1.6.5
438
439**Key API/Component Changes**
440
441In the **AudioManager** class:
442
443getVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void;
444
445getVolume(volumeType: AudioVolumeType): Promise<number>;
446
447getMaxVolume(volumeType: AudioVolumeType, callback: AsyncCallback<number>): void;
448
449getMaxVolume(volumeType: AudioVolumeType): Promise<number>;
450
451isMute(volumeType: AudioVolumeType, callback: AsyncCallback<boolean>): void;
452
453isMute(volumeType: AudioVolumeType): Promise<boolean>;
454
455Before change:
456
457The value of **BusinessError.code** returned by the APIs asynchronously is of the string type.
458
459After change:
460
461The value of **BusinessError.code** returned by the APIs asynchronously is of the number type.
462
463**Adaptation Guide**
464
465The declaration is not changed. The error code is of the number type.
466
467If you found that the returned error code does not comply with the definition and used the string for verification, adapt to the original API definition and use the **AudioErrors** error code of the number type.
468