From 63c605b1399826a76226019d697d1c8107bda2c4 Mon Sep 17 00:00:00 2001 From: magekkkk Date: Tue, 10 May 2022 08:13:59 +0000 Subject: [PATCH 1/6] add tone api Signed-off-by: magekkkk --- api/@ohos.multimedia.audio.d.ts | 91 +++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index d6f0a0353e..82d911a818 100644 --- a/api/@ohos.multimedia.audio.d.ts +++ b/api/@ohos.multimedia.audio.d.ts @@ -66,6 +66,24 @@ declare namespace audio { */ function createAudioRenderer(options: AudioRendererOptions): Promise; + /** + * Obtains a TonePlayer instance. This method uses an asynchronous callback to return the renderer instance. + * @param options Tone playing attribute. + * @return Promise used to return the tone player instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + function createTonePlayer(options: AudioRendererInfo, callback: AsyncCallback): void; + + /** + * Obtains a TonePlayer instance. This method uses a promise to return the renderer instance. + * @param options Tone playing attribute. + * @return Promise used to return the tone player instance. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + function createTonePlayer(options: AudioRendererInfo): Promise; + /** * Enumerates the audio states. * @since 8 @@ -1828,6 +1846,79 @@ declare namespace audio { */ on(type: "stateChange", callback: Callback): void; } + + enum ToneType { + + } + + /** + * Provides APIs for tone playing. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + interface TonePlayer { + /** + * Starts player. This method uses an asynchronous callback to return the result. + * @param type Tone type to play. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + load(type: ToneType, callback: AsyncCallback): void; + /** + * Starts tplayerone. This method uses a promise to return the result. + * @param type Tone type to play. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + load(type: ToneType): Promise; + + /** + * Starts player. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + start(callback: AsyncCallback): void; + /** + * Starts player. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + start(): Promise; + + /** + * Stops player. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + stop(callback: AsyncCallback): void; + /** + * Stops player. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + stop(): Promise; + + /** + * Releases the player. This method uses an asynchronous callback to return the result. + * @param callback Callback used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + release(callback: AsyncCallback): void; + /** + * Releases the player. This method uses a promise to return the result. + * @return Promise used to return the result. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Tone + */ + release(): Promise; + } } export default audio; -- Gitee From 69d0a3dbfbda468fa5235dac461303f6235eabf3 Mon Sep 17 00:00:00 2001 From: magekkkk Date: Thu, 12 May 2022 12:52:54 +0000 Subject: [PATCH 2/6] add stream listener api Signed-off-by: magekkkk --- api/@ohos.multimedia.audio.d.ts | 154 ++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index 82d911a818..13916a1320 100644 --- a/api/@ohos.multimedia.audio.d.ts +++ b/api/@ohos.multimedia.audio.d.ts @@ -1216,6 +1216,160 @@ declare namespace audio { * @syscap SystemCapability.Multimedia.Audio.Renderer */ off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback): void; + + /** + * Get infos of current existing audio renderers. + * @param callback Callback used to return the infos of current existing audio renderers. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getCurrentAudioRendererInfos(callback: AsyncCallback): void; + + /** + * Get infos of current existing audio renderers. + * @return Promise used to return the infos of current existing audio renderers. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getCurrentAudioRendererInfos(): Promise; + + /** + * Get infos of current existing audio capturers. + * @param callback Callback used to return the infos of current existing audio capturers. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getCurrentAudioCapturerInfos(callback: AsyncCallback): void; + + /** + * Get infos of current existing audio capturers. + * @return Promise used to return the infos of current existing audio capturers. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + getCurrentAudioCapturerInfos(): Promise; + + /** + * Listens for audio renderer change events. When there is any audio renderer change, + * registered clients will receive the callback. + * @param type Type of the event to listen for. Only the audioRendererChange event is supported. + * @param callback Callback invoked for the audio renderer change event. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + on(type: "audioRendererChange", callback: Callback): void; + + /** + * UnSubscribes to audio renderer change events. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + off(type: "audioRendererChange"); + + /** + * Listens for audio capturer change events. When there is any audio capturer change, + * registered clients will receive the callback. + * @param type Type of the event to listen for. Only the audioCapturerChange event is supported. + * @param callback Callback invoked for the audio capturer change event. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + on(type: "audioCapturerChange", callback: Callback): void; + + /** + * UnSubscribes to audio capturer change events. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + off(type: "audioCapturerChange"); + } + + /** + * Array of AudioRendererChangeInfo, which is read-only. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + type AudioRendererChangeInfos = Array>; + + /** + * Describes audio renderer change information. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + interface AudioRendererChangeInfo { + /** + * Session id. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + readonly sessionId: number; + + /** + * Uid for audio renderer client application. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @systemapi + */ + readonly clientUid: number; + + /** + * Audio renderer information. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + readonly rendererInfo: AudioRendererInfo; + + /** + * Audio state. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + * @systemapi + */ + readonly rendererState: AudioState; + } + + /** + * Array of AudioCapturerChangeInfo, which is read-only. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + type AudioCapturerChangeInfos = Array>; + + /** + * Describes audio capturer change information. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + interface AudioCapturerChangeInfo { + /** + * Session id. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + readonly sessionId: number; + + /** + * Uid for audio capturer client application. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @systemapi + */ + readonly clientUid: number; + + /** + * Audio capturer information. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + */ + readonly capturerInfo: AudioCapturerInfo; + + /** + * Audio state. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Capturer + * @systemapi + */ + readonly capturerState: AudioState; } /** -- Gitee From 4cfb9df16a4380c4d929fbee8bc3fc37d60f0613 Mon Sep 17 00:00:00 2001 From: magekkkk Date: Fri, 20 May 2022 02:55:16 +0000 Subject: [PATCH 3/6] add some tonetypes Signed-off-by: magekkkk --- api/@ohos.multimedia.audio.d.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index 13916a1320..3789977400 100644 --- a/api/@ohos.multimedia.audio.d.ts +++ b/api/@ohos.multimedia.audio.d.ts @@ -2002,7 +2002,26 @@ declare namespace audio { } enum ToneType { - + TONE_TYPE_DIAL_0 = 0, // 0 key + TONE_TYPE_DIAL_1, // 1 key + TONE_TYPE_DIAL_2, // 2 key + TONE_TYPE_DIAL_3, // 3 key + TONE_TYPE_DIAL_4, // 4 key + TONE_TYPE_DIAL_5, // 5 key + TONE_TYPE_DIAL_6, // 6 key + TONE_TYPE_DIAL_7, // 7 key + TONE_TYPE_DIAL_8, // 8 key + TONE_TYPE_DIAL_9, // 9 key + TONE_TYPE_DIAL_S, // * key + TONE_TYPE_DIAL_P, // # key + TONE_TYPE_DIAL_A, // A key + TONE_TYPE_DIAL_B, // B key + TONE_TYPE_DIAL_C, // C key + TONE_TYPE_DIAL_D, // D key + + TONE_TYPE_CALL_SUP_DIAL = 100, + + TONE_TYPE_CALL_PROP_BEEP = 200, } /** -- Gitee From e7ccaa890e4850c6be006cd92bdd147c3210ef83 Mon Sep 17 00:00:00 2001 From: magekkkk Date: Fri, 20 May 2022 03:10:58 +0000 Subject: [PATCH 4/6] add lowlatency related apis Signed-off-by: magekkkk --- api/@ohos.multimedia.audio.d.ts | 62 +++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index 3789977400..c12b4fbfcb 100644 --- a/api/@ohos.multimedia.audio.d.ts +++ b/api/@ohos.multimedia.audio.d.ts @@ -606,6 +606,26 @@ declare namespace audio { rendererFlags: number; } + /** + * Audio renderer flags used to decide output strategy. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + enum AudioRendererFlag { + /** + * No special strategy. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + FLAG_NONE = 0, + /** + * Flag to use low latency process. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + FLAG_LOW_LATENCY = 1 + } + /** * Describes audio renderer configuration options. * @since 8 @@ -1282,6 +1302,20 @@ declare namespace audio { * @syscap SystemCapability.Multimedia.Audio.Capturer */ off(type: "audioCapturerChange"); + + /** + * Check if system support low latency configuration in audio renderer. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + isAudioRendererLowLatencySupported(streaminfo: AudioStreamInfo, callback: Callback): void; + + /** + * Check if system support low latency configuration in audio renderer. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + isAudioRendererLowLatencySupported(streaminfo: AudioStreamInfo): Promise; } /** @@ -1751,6 +1785,34 @@ declare namespace audio { * @syscap SystemCapability.Multimedia.Audio.Renderer */ on(type: "stateChange", callback: Callback): void; + + /** + * Subscribes audio data requeset event callback. + * @param callback Callback invoked when need audio data. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + on(type: "dataRequest", callback: Callback): void; + } + + /** + * Describe data info. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + interface AudioRendererDataInfo { + /** + * Buffer to fill. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + buffer: ArrayBuffer; + /** + * Extend info with buffer. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Renderer + */ + flags: number; } /** -- Gitee From 25467a14999c07319a3be80fdf765ea3252f78a7 Mon Sep 17 00:00:00 2001 From: magekkkk Date: Mon, 23 May 2022 14:53:45 +0800 Subject: [PATCH 5/6] remain only lowlatency apis Signed-off-by: magekkkk --- api/@ohos.multimedia.audio.d.ts | 264 -------------------------------- 1 file changed, 264 deletions(-) diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index c12b4fbfcb..030df46c10 100644 --- a/api/@ohos.multimedia.audio.d.ts +++ b/api/@ohos.multimedia.audio.d.ts @@ -66,24 +66,6 @@ declare namespace audio { */ function createAudioRenderer(options: AudioRendererOptions): Promise; - /** - * Obtains a TonePlayer instance. This method uses an asynchronous callback to return the renderer instance. - * @param options Tone playing attribute. - * @return Promise used to return the tone player instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Tone - */ - function createTonePlayer(options: AudioRendererInfo, callback: AsyncCallback): void; - - /** - * Obtains a TonePlayer instance. This method uses a promise to return the renderer instance. - * @param options Tone playing attribute. - * @return Promise used to return the tone player instance. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Tone - */ - function createTonePlayer(options: AudioRendererInfo): Promise; - /** * Enumerates the audio states. * @since 8 @@ -1237,72 +1219,6 @@ declare namespace audio { */ off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback): void; - /** - * Get infos of current existing audio renderers. - * @param callback Callback used to return the infos of current existing audio renderers. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - */ - getCurrentAudioRendererInfos(callback: AsyncCallback): void; - - /** - * Get infos of current existing audio renderers. - * @return Promise used to return the infos of current existing audio renderers. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - */ - getCurrentAudioRendererInfos(): Promise; - - /** - * Get infos of current existing audio capturers. - * @param callback Callback used to return the infos of current existing audio capturers. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - */ - getCurrentAudioCapturerInfos(callback: AsyncCallback): void; - - /** - * Get infos of current existing audio capturers. - * @return Promise used to return the infos of current existing audio capturers. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - */ - getCurrentAudioCapturerInfos(): Promise; - - /** - * Listens for audio renderer change events. When there is any audio renderer change, - * registered clients will receive the callback. - * @param type Type of the event to listen for. Only the audioRendererChange event is supported. - * @param callback Callback invoked for the audio renderer change event. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - */ - on(type: "audioRendererChange", callback: Callback): void; - - /** - * UnSubscribes to audio renderer change events. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - */ - off(type: "audioRendererChange"); - - /** - * Listens for audio capturer change events. When there is any audio capturer change, - * registered clients will receive the callback. - * @param type Type of the event to listen for. Only the audioCapturerChange event is supported. - * @param callback Callback invoked for the audio capturer change event. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Capturer - */ - on(type: "audioCapturerChange", callback: Callback): void; - - /** - * UnSubscribes to audio capturer change events. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Capturer - */ - off(type: "audioCapturerChange"); - /** * Check if system support low latency configuration in audio renderer. * @since 9 @@ -1318,94 +1234,6 @@ declare namespace audio { isAudioRendererLowLatencySupported(streaminfo: AudioStreamInfo): Promise; } - /** - * Array of AudioRendererChangeInfo, which is read-only. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - */ - type AudioRendererChangeInfos = Array>; - - /** - * Describes audio renderer change information. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - */ - interface AudioRendererChangeInfo { - /** - * Session id. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - */ - readonly sessionId: number; - - /** - * Uid for audio renderer client application. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - * @systemapi - */ - readonly clientUid: number; - - /** - * Audio renderer information. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - */ - readonly rendererInfo: AudioRendererInfo; - - /** - * Audio state. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Renderer - * @systemapi - */ - readonly rendererState: AudioState; - } - - /** - * Array of AudioCapturerChangeInfo, which is read-only. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Capturer - */ - type AudioCapturerChangeInfos = Array>; - - /** - * Describes audio capturer change information. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Capturer - */ - interface AudioCapturerChangeInfo { - /** - * Session id. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Capturer - */ - readonly sessionId: number; - - /** - * Uid for audio capturer client application. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Capturer - * @systemapi - */ - readonly clientUid: number; - - /** - * Audio capturer information. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Capturer - */ - readonly capturerInfo: AudioCapturerInfo; - - /** - * Audio state. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Capturer - * @systemapi - */ - readonly capturerState: AudioState; - } - /** * Describes an audio device. * @since 7 @@ -2062,98 +1890,6 @@ declare namespace audio { */ on(type: "stateChange", callback: Callback): void; } - - enum ToneType { - TONE_TYPE_DIAL_0 = 0, // 0 key - TONE_TYPE_DIAL_1, // 1 key - TONE_TYPE_DIAL_2, // 2 key - TONE_TYPE_DIAL_3, // 3 key - TONE_TYPE_DIAL_4, // 4 key - TONE_TYPE_DIAL_5, // 5 key - TONE_TYPE_DIAL_6, // 6 key - TONE_TYPE_DIAL_7, // 7 key - TONE_TYPE_DIAL_8, // 8 key - TONE_TYPE_DIAL_9, // 9 key - TONE_TYPE_DIAL_S, // * key - TONE_TYPE_DIAL_P, // # key - TONE_TYPE_DIAL_A, // A key - TONE_TYPE_DIAL_B, // B key - TONE_TYPE_DIAL_C, // C key - TONE_TYPE_DIAL_D, // D key - - TONE_TYPE_CALL_SUP_DIAL = 100, - - TONE_TYPE_CALL_PROP_BEEP = 200, - } - - /** - * Provides APIs for tone playing. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Tone - */ - interface TonePlayer { - /** - * Starts player. This method uses an asynchronous callback to return the result. - * @param type Tone type to play. - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Tone - */ - load(type: ToneType, callback: AsyncCallback): void; - /** - * Starts tplayerone. This method uses a promise to return the result. - * @param type Tone type to play. - * @return Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Tone - */ - load(type: ToneType): Promise; - - /** - * Starts player. This method uses an asynchronous callback to return the result. - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Tone - */ - start(callback: AsyncCallback): void; - /** - * Starts player. This method uses a promise to return the result. - * @return Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Tone - */ - start(): Promise; - - /** - * Stops player. This method uses an asynchronous callback to return the result. - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Tone - */ - stop(callback: AsyncCallback): void; - /** - * Stops player. This method uses a promise to return the result. - * @return Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Tone - */ - stop(): Promise; - - /** - * Releases the player. This method uses an asynchronous callback to return the result. - * @param callback Callback used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Tone - */ - release(callback: AsyncCallback): void; - /** - * Releases the player. This method uses a promise to return the result. - * @return Promise used to return the result. - * @since 9 - * @syscap SystemCapability.Multimedia.Audio.Tone - */ - release(): Promise; - } } export default audio; -- Gitee From 8204bf05698fe3aa6c4a068b67479959fbc42f1b Mon Sep 17 00:00:00 2001 From: magekkkk Date: Tue, 24 May 2022 18:49:53 +0800 Subject: [PATCH 6/6] move to stream manager spliter Signed-off-by: magekkkk --- api/@ohos.multimedia.audio.d.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/@ohos.multimedia.audio.d.ts b/api/@ohos.multimedia.audio.d.ts index 030df46c10..bd01855457 100644 --- a/api/@ohos.multimedia.audio.d.ts +++ b/api/@ohos.multimedia.audio.d.ts @@ -1218,7 +1218,14 @@ declare namespace audio { * @syscap SystemCapability.Multimedia.Audio.Renderer */ off(type: 'interrupt', interrupt: AudioInterrupt, callback?: Callback): void; + } + /** + * Implements audio stream management. + * @since 9 + * @syscap SystemCapability.Multimedia.Audio.Core + */ + interface AudioStreamManager { /** * Check if system support low latency configuration in audio renderer. * @since 9 -- Gitee