diff --git a/multimedia/audio_framework/audio_capturer/native_audiocapturer.h b/multimedia/audio_framework/audio_capturer/native_audiocapturer.h index caf548af2aac6738acf138c2e295d827db92b8cf..9f1644a90b9ca449eea68c8a0d9e2b416e13fcbb 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 34b4af643f192d43887a5e06814ac2c8b46e7c17..4069e64394a547f571e187c4bb6384ddc10fd8d3 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 6ad655177ad96299d6a6ffab73d5bbe12ed98aee..4c7b6c24b8f68935c3a7e80ce145af2a62204eed 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 a951df9adb415355e5ec86a8d49e2500c583ab04..9b763054bc9bff2e1bf5b9b4490f33b99a52fbce 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 acd0beba1f731ccdecaf783566d68ab09e3ed9bc..590880183b8d7c699076e08edbc75c4f162fbd0c 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 94c965bd4e4f20f523e1f28dd34a3737918bc69a..73e3be08e86836e8e8812bff4ed8b606c5574574 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" } ]