diff --git a/multimedia/audio_framework/audio_renderer/native_audiorenderer.h b/multimedia/audio_framework/audio_renderer/native_audiorenderer.h index 6bfcb82ae0aafb754cfa5abf49fe928a33e9c2da..18b2daa39230b048a6748ca3d8ad257e092fb905 100644 --- a/multimedia/audio_framework/audio_renderer/native_audiorenderer.h +++ b/multimedia/audio_framework/audio_renderer/native_audiorenderer.h @@ -504,6 +504,37 @@ OH_AudioStream_Result OH_AudioRenderer_GetSilentModeAndMixWithOthers( OH_AudioStream_Result OH_AudioRenderer_SetDefaultOutputDevice( OH_AudioRenderer* renderer, OH_AudioDevice_Type deviceType); +/** + * @brief Query the timestamp at which a particular frame was presented in clock monotonic timebase, + * the frame at the returned position was just committed to hardware. This is often used in + * video synchronization and recording stream alignment. + * + * Position is 0 and timestamp is fixed until stream really runs and frame is committed. Position + * will also be reset while flush function is called. When a audio route change happens, like in + * device or output type change situations, the position may also be reset but timestamp remains + * monotonically increasing. + * So it is better to use the values until they becomes regularly after the change. + * This interface also adapts to playback speed change. For example, the increseing speed for + * position will be double for 2x speed playback. + * + * @param renderer Reference created by OH_AudioStreamBuilder_GenerateRenderer() + * @param framePosition Pointer to a variable to receive the position + * @param timestamp Pointer to a variable to receive the timestamp + * @return Function result code: + * {@link AUDIOSTREAM_SUCCESS} If the execution is successful. + * {@link AUDIOSTREAM_ERROR_INVALID_PARAM}: + * 1.The param of renderer is nullptr; + * 2.The param of framePosition or timestamp is nullptr; + * {@link AUDIOSTREAM_ERROR_ILLEGAL_STATE}: + * 1.Only running state is legal for getting audio timestamp. + * {@link AUDIOSTREAM_ERROR_SYSTEM}: + * 1.Crash or blocking occurs in system process. + * 2.Other unexpected error from internal system. + * @since 15 + */ +OH_AudioStream_Result OH_AudioRenderer_GetAudioTimestampInfo(OH_AudioRenderer* renderer, + int64_t* framePosition, int64_t* timestamp); + #ifdef __cplusplus } #endif diff --git a/multimedia/audio_framework/ohaudio.ndk.json b/multimedia/audio_framework/ohaudio.ndk.json index 961c75daeeaa798a67c49fcf5724e2fdb7241a9f..e6d5a0cd2a5cacb6eeb2a19582af975900a2375e 100644 --- a/multimedia/audio_framework/ohaudio.ndk.json +++ b/multimedia/audio_framework/ohaudio.ndk.json @@ -378,5 +378,9 @@ { "first_introduced": "13", "name": "OH_AudioRoutingManager_SetMicBlockStatusCallback" + }, + { + "first_introduced": "15", + "name": "OH_AudioRenderer_GetAudioTimestampInfo" } ]