From 6b0b41cfe38a48d3d19ba61a339bb13c7c450a3d Mon Sep 17 00:00:00 2001 From: zhangwenting3652 Date: Tue, 20 May 2025 14:19:36 +0800 Subject: [PATCH] add fast status query apis Signed-off-by: zhangwenting3652 --- .../audio_capturer/native_audiocapturer.h | 28 ++++++++++++++++++ .../native_audio_stream_manager.h | 28 ++++++++++++++++++ .../audio_renderer/native_audiorenderer.h | 28 ++++++++++++++++++ .../common/native_audiostream_base.h | 16 ++++++++++ .../common/native_audiostreambuilder.h | 29 +++++++++++++++++++ multimedia/audio_framework/ohaudio.ndk.json | 24 +++++++++++++++ 6 files changed, 153 insertions(+) diff --git a/multimedia/audio_framework/audio_capturer/native_audiocapturer.h b/multimedia/audio_framework/audio_capturer/native_audiocapturer.h index f2f256e49..d8d5cdaf4 100644 --- a/multimedia/audio_framework/audio_capturer/native_audiocapturer.h +++ b/multimedia/audio_framework/audio_capturer/native_audiocapturer.h @@ -344,6 +344,34 @@ typedef void (*OH_AudioCapturer_OnInterruptCallback)(OH_AudioCapturer* capturer, typedef void (*OH_AudioCapturer_OnErrorCallback)(OH_AudioCapturer* renderer, void* userData, OH_AudioStream_Result error); +/** + * @brief Gets audio capturer running status, check if it works in fast status. + * + * @param capturer Reference created by OH_AudioStreamBuilder_GenerateCapturer. + * @param status Pointer to a variable to receive the status. + * @return + * {@link AUDIOSTREAM_SUCCESS} if the execution is successful. + * {@link AUDIOSTREAM_ERROR_INVALID_PARAM} the param of capturer is nullptr. + * {@link AUDIOSTREAM_ERROR_ILLEGAL_STATE} function called in invalid state, only available before release state. + * @since 20 + */ +OH_AudioStream_Result OH_AudioCapturer_GetFastStatus(OH_AudioCapturer* capturer, + OH_AudioStream_FastStatus* status); + +/** + * @brief Callback function of fast status change event for audio capturer. + * + * @param capturer Pointer to an audio capturer instance for which this callback occurs. + * @param userData Userdata which is passed by register. + * @param status Current fast status. + * @since 20 + */ +typedef void (*OH_AudioCapturer_OnFastStatusChange)( + OH_AudioCapturer* capturer, + void* userData, + OH_AudioStream_FastStatus status +); + #ifdef __cplusplus } #endif diff --git a/multimedia/audio_framework/audio_manager/native_audio_stream_manager.h b/multimedia/audio_framework/audio_manager/native_audio_stream_manager.h index 34b4af643..4069e6439 100644 --- a/multimedia/audio_framework/audio_manager/native_audio_stream_manager.h +++ b/multimedia/audio_framework/audio_manager/native_audio_stream_manager.h @@ -110,6 +110,34 @@ OH_AudioCommon_Result OH_AudioStreamManager_IsAcousticEchoCancelerSupported( OH_AudioStream_SourceType sourceType, bool *supported); +/** + * @brief Return if fast playback is supported for the specific audio stream info and usage type + * in current device situation. + * + * @param streamManager {@link OH_AudioStreamManager} handle + * provided by {@link OH_AudioManager_GetAudioStreamManager}. + * @param streamInfo reference of stream info structure to describe basic audio format. + * @param usage stream usage type used to decide the audio device and pipe type selection result. + * @return {@code true} if fast playback is supported in this situation. + * @since 20 + */ +bool OH_AudioStreamManager_IsFastPlaybackSupported( + OH_AudioStreamManager *streamManager, OH_AudioStreamInfo *streamInfo, OH_AudioStream_Usage usage); + +/** + * @brief Return if fast recording is supported for the specific audio stream info and source type + * in current device situation. + * + * @param streamManager {@link OH_AudioStreamManager} handle + * provided by {@link OH_AudioManager_GetAudioStreamManager}. + * @param streamInfo reference of stream info structure to describe basic audio format. + * @param source stream source type used to decide the audio device and pipe type selection result. + * @return {@code true} if fast recording is supported in this situation. + * @since 20 + */ +bool OH_AudioStreamManager_IsFastRecordingSupported( + OH_AudioStreamManager *streamManager, OH_AudioStreamInfo *streamInfo, OH_AudioStream_SourceType source); + #ifdef __cplusplus } #endif diff --git a/multimedia/audio_framework/audio_renderer/native_audiorenderer.h b/multimedia/audio_framework/audio_renderer/native_audiorenderer.h index f048de6e5..9ddc58e43 100644 --- a/multimedia/audio_framework/audio_renderer/native_audiorenderer.h +++ b/multimedia/audio_framework/audio_renderer/native_audiorenderer.h @@ -564,6 +564,34 @@ typedef void (*OH_AudioRenderer_OnInterruptCallback)(OH_AudioRenderer* renderer, typedef void (*OH_AudioRenderer_OnErrorCallback)(OH_AudioRenderer* renderer, void* userData, OH_AudioStream_Result error); +/** + * @brief Gets audio renderer running status, check if it works in fast status. + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer. + * @param status Pointer to a variable to receive the status. + * @return + * {@link AUDIOSTREAM_SUCCESS} if the execution is successful. + * {@link AUDIOSTREAM_ERROR_INVALID_PARAM} the param of renderer is nullptr. + * {@link AUDIOSTREAM_ERROR_ILLEGAL_STATE} function called in invalid state, only available before release state. + * @since 20 + */ +OH_AudioStream_Result OH_AudioRenderer_GetFastStatus(OH_AudioRenderer* renderer, + OH_AudioStream_FastStatus* status); + +/** + * @brief Callback function of fast status change event for audio renderer. + * + * @param renderer Pointer to an audio renderer instance for which this callback occurs. + * @param userData Userdata which is passed by register. + * @param status Current fast status. + * @since 20 + */ +typedef void (*OH_AudioRenderer_OnFastStatusChange)( + OH_AudioRenderer* renderer, + void* userData, + OH_AudioStream_FastStatus status +); + #ifdef __cplusplus } #endif diff --git a/multimedia/audio_framework/common/native_audiostream_base.h b/multimedia/audio_framework/common/native_audiostream_base.h index 28643a246..19cc1c4cd 100644 --- a/multimedia/audio_framework/common/native_audiostream_base.h +++ b/multimedia/audio_framework/common/native_audiostream_base.h @@ -591,6 +591,22 @@ typedef enum { EFFECT_DEFAULT = 1, } OH_AudioStream_AudioEffectMode; +/** + * @brief Defines the fast status. + * + * @since 20 + */ +typedef enum { + /** + * normal status + */ + AUDIOSTREAM_FASTSTATUS_NORMAL = 0, + /** + * fast status + */ + AUDIOSTREAM_FASTSTATUS_FAST = 1 +} OH_AudioStream_FastStatus; + /** * @brief Declaring the audio stream builder. * The instance of builder is used for creating audio stream. diff --git a/multimedia/audio_framework/common/native_audiostreambuilder.h b/multimedia/audio_framework/common/native_audiostreambuilder.h index dd84c6e46..cb9301247 100644 --- a/multimedia/audio_framework/common/native_audiostreambuilder.h +++ b/multimedia/audio_framework/common/native_audiostreambuilder.h @@ -517,6 +517,35 @@ OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerErrorCallback(OH_AudioStr OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerWillMuteWhenInterrupted(OH_AudioStreamBuilder* builder, bool muteWhenInterrupted); +/** + * @brief Set the callback of fast status change event for audio renderer. + * + * @param builder Builder provided by OH_AudioStreamBuilder_Create() + * @param callback Callback function that will recevie the fast status change event. + * @param userData Pointer to an application data structure that will be passed to the callback functions. + * @return + * {@link AUDIOSTREAM_SUCCESS} if the execution is successful. + * {@link AUDIOSTREAM_ERROR_INVALID_PARAM} the param of builder or callback is nullptr. + * @since 20 + */ +OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererFastStatusChangeCallback(OH_AudioStreamBuilder* builder, + OH_AudioRenderer_OnFastStatusChange callback, void* userData); + +/** + * @brief Set the callback of fast status change event for audio capturer. + * + * @param builder Builder provided by OH_AudioStreamBuilder_Create() + * @param callback Callback function that will recevie the fast status change event. + * @param userData Pointer to an application data structure that will be passed to the callback functions. + * @return + * {@link AUDIOSTREAM_SUCCESS} if the execution is successful. + * {@link AUDIOSTREAM_ERROR_INVALID_PARAM} the param of builder or callback is nullptr. + * @since 20 + */ +OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerFastStatusChangeCallback(OH_AudioStreamBuilder* builder, + OH_AudioCapturer_OnFastStatusChange callback, void* userData); + + #ifdef __cplusplus } #endif diff --git a/multimedia/audio_framework/ohaudio.ndk.json b/multimedia/audio_framework/ohaudio.ndk.json index 048a15b03..c430a3b74 100644 --- a/multimedia/audio_framework/ohaudio.ndk.json +++ b/multimedia/audio_framework/ohaudio.ndk.json @@ -474,5 +474,29 @@ { "first_introduced": "20", "name": "OH_AudioVolumeManager_UnregisterRingerModeChangeCallback" + }, + { + "first_introduced": "20", + "name": "OH_AudioRenderer_GetFastStatus" + }, + { + "first_introduced": "20", + "name": "OH_AudioCapturer_GetFastStatus" + }, + { + "first_introduced": "20", + "name": "OH_AudioStreamManager_IsFastPlaybackSupported" + }, + { + "first_introduced": "20", + "name": "OH_AudioStreamManager_IsFastRecordingSupported" + }, + { + "first_introduced": "20", + "name": "OH_AudioStreamBuilder_SetRendererFastStatusChangeCallback" + }, + { + "first_introduced": "20", + "name": "OH_AudioStreamBuilder_SetCapturerFastStatusChangeCallback" } ] -- Gitee