!11184 新增TS音频数据回调返回值定义

Merge pull request !11184 from ancimoon/callback_result
This commit is contained in:
openharmony_ci 2024-05-28 02:53:59 +00:00 committed by Gitee
commit 72019e48e3
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -4322,6 +4322,41 @@ declare namespace audio {
changeReason: AudioStreamDeviceChangeReason;
}
/**
* Enumerates callback result.
* @enum {number}
* @syscap SystemCapability.Multimedia.Audio.Core
* @since 12
*/
enum AudioDataCallbackResult {
/**
* Indicates data of this callback is invalid.
* @syscap SystemCapability.Multimedia.Audio.Core
* @since 12
*/
INVALID = -1,
/**
* Indicates data of this callback is valid.
* @syscap SystemCapability.Multimedia.Audio.Core
* @since 12
*/
VALID = 0,
}
/**
* Type definition of callback function for audio renderer write data.
*
* @typedef {function} AudioRendererWriteDataCallback
* @param {ArrayBuffer} data - audio data array buffer.
* @returns {AudioDataCallbackResult | void} result of callback or void. If void or AudioDataCallbackResult.VALID is
* returned, it indicates the data is valid and will be played. If AudioDataCallbackResult.INVALID is returned, it
* indicates the data is will not be played.
* @syscap SystemCapability.Multimedia.Audio.Renderer
* @since 12
*/
type AudioRendererWriteDataCallback = (data: ArrayBuffer) => AudioDataCallbackResult | void;
/**
* Provides audio playback APIs.
* @typedef AudioRenderer
@ -4964,7 +4999,19 @@ declare namespace audio {
* @syscap SystemCapability.Multimedia.Audio.Renderer
* @since 11
*/
on(type: 'writeData', callback: Callback<ArrayBuffer>): void;
/**
* Subscribes audio data callback.
* The event is triggered when audio buffer is available for writing more data.
* @param { 'writeData' } type - Type of the event to listen for.
* @param { AudioRendererWriteDataCallback } callback - Audio renderer write data callback.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 6800101 - Parameter verification failed.
* @syscap SystemCapability.Multimedia.Audio.Renderer
* @since 12
*/
on(type: 'writeData', callback: AudioRendererWriteDataCallback): void;
/**
* Unsubscribes audio data callback.
@ -4977,7 +5024,18 @@ declare namespace audio {
* @syscap SystemCapability.Multimedia.Audio.Renderer
* @since 11
*/
off(type: 'writeData', callback?: Callback<ArrayBuffer>): void;
/**
* Unsubscribes audio data callback.
* @param { 'writeData' } type - Type of the event to listen for.
* @param { AudioRendererWriteDataCallback } callback - Audio renderer write data callback.
* @throws { BusinessError } 401 - Parameter error. Possible causes:
* 1.Mandatory parameters are left unspecified;
* 2.Incorrect parameter types.
* @throws { BusinessError } 6800101 - Parameter verification failed.
* @syscap SystemCapability.Multimedia.Audio.Renderer
* @since 12
*/
off(type: 'writeData', callback?: AudioRendererWriteDataCallback): void;
}
/**