openharmony 鸿蒙 capi-native-audio-resource-manager-h

2026-08-25 浏览 (1)

native_audio_resource_manager.h

Overview

The file declares the functions related to an audio resource manager.

File to include: <ohaudio/native_audio_resource_manager.h>

Library: libohaudio.so

System capability: SystemCapability.Multimedia.Audio.Core

Since: 20

Related module: OHAudio

Summary

Structs

Nametypedef KeywordDescription
OH_AudioResourceManagerOH_AudioResourceManagerDescribes an audio resource manager, which is used to manage audio resources.
OH_AudioWorkgroupOH_AudioWorkgroupDescribes an audio group, which is used to group and manage key audio threads.

Functions

NameDescription
OH_AudioCommon_Result OH_AudioManager_GetAudioResourceManager(OH_AudioResourceManager **resourceManager)Obtains an audio resource manager.
Before using the features related to the audio resource manager, you must obtain an audio resource manager instance.
OH_AudioCommon_Result OH_AudioResourceManager_CreateWorkgroup(OH_AudioResourceManager *resourceManager, const char *name, OH_AudioWorkgroup **group)Creates an audio workgroup.
OH_AudioCommon_Result OH_AudioResourceManager_ReleaseWorkgroup(OH_AudioResourceManager *resourceManager, OH_AudioWorkgroup *group)Releases an audio workgroup.
OH_AudioCommon_Result OH_AudioWorkgroup_AddCurrentThread(OH_AudioWorkgroup *group, int32_t *tokenId)Adds a thread to an audio workgroup.
OH_AudioCommon_Result OH_AudioWorkgroup_RemoveThread(OH_AudioWorkgroup *group, int32_t tokenId)Removes a thread from an audio workgroup.
OH_AudioCommon_Result OH_AudioWorkgroup_Start(OH_AudioWorkgroup *group, uint64_t startTime, uint64_t deadlineTime)Notifies the system that an audio workgroup starts working and provides the expected end time of the workgroup.
OH_AudioCommon_Result OH_AudioWorkgroup_Stop(OH_AudioWorkgroup *group)Notifies the system that an audio workgroup finishes working.

Function Description

OH_AudioManager_GetAudioResourceManager()

OH_AudioCommon_Result OH_AudioManager_GetAudioResourceManager(OH_AudioResourceManager **resourceManager)

Description

Obtains an audio resource manager.
Before using the features related to the audio resource manager, you must obtain an audio resource manager instance.

Since: 20

Parameters

NameDescription
OH_AudioResourceManager **resourceManagerDouble pointer to an OH_AudioResourceManager instance, which is used to receive the created audio resource manager instance.

Returns

TypeDescription
OH_AudioCommon_ResultAUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully.
AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM: The resourceManager parameter is nullptr.

OH_AudioResourceManager_CreateWorkgroup()

OH_AudioCommon_Result OH_AudioResourceManager_CreateWorkgroup(OH_AudioResourceManager *resourceManager,const char *name, OH_AudioWorkgroup **group)

Description

Creates an audio workgroup.

Since: 20

Parameters

NameDescription
OH_AudioResourceManager *resourceManagerPointer to an OH_AudioResourceManager instance, which is created by calling OH_AudioManager_GetAudioResourceManager.
const char *namePointer to the name of the audio workgroup.
OH_AudioWorkgroup **groupDouble pointer to an OH_AudioWorkgroup instance, which is used to receive the created audio workgroup instance.

Returns

TypeDescription
OH_AudioCommon_ResultAUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully.
AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM:
1. The resourceManager parameter is nullptr.
2. The name parameter is nullptr.
3. The group parameter is nullptr.
AUDIOCOMMON_RESULT_ERROR_NO_MEMORY: The memory is insufficient.
AUDIOCOMMON_RESULT_ERROR_SYSTEM: A system processing error occurs.

OH_AudioResourceManager_ReleaseWorkgroup()

OH_AudioCommon_Result OH_AudioResourceManager_ReleaseWorkgroup(OH_AudioResourceManager *resourceManager,OH_AudioWorkgroup *group)

Description

Releases an audio workgroup.

Since: 20

Parameters

NameDescription
OH_AudioResourceManager *resourceManagerPointer to an OH_AudioResourceManager instance, which is created by calling OH_AudioManager_GetAudioResourceManager.
OH_AudioWorkgroup *groupPointer to an OH_AudioWorkgroup instance, which is created by calling OH_AudioResourceManager_CreateWorkgroup.

Returns

TypeDescription
OH_AudioCommon_ResultAUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully.
AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM:
1. The resourceManager parameter is nullptr.
2. The group parameter is nullptr.
AUDIOCOMMON_RESULT_ERROR_SYSTEM: A system processing error occurs.

OH_AudioWorkgroup_AddCurrentThread()

OH_AudioCommon_Result OH_AudioWorkgroup_AddCurrentThread(OH_AudioWorkgroup *group, int32_t *tokenId)

Description

Adds a thread to an audio workgroup.

Since: 20

Parameters

NameDescription
OH_AudioWorkgroup *groupPointer to an OH_AudioWorkgroup instance, which is created by calling OH_AudioResourceManager_CreateWorkgroup.
int32_t *tokenIdPointer to the ID of the thread to be added to the audio workgroup.

Returns

TypeDescription
OH_AudioCommon_ResultAUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully.
AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM:
1. The group parameter is nullptr.
2. The tokenId parameter is nullptr.
AUDIOCOMMON_RESULT_ERROR_NO_MEMORY: The memory is insufficient.
AUDIOCOMMON_RESULT_ERROR_SYSTEM: A system processing error occurs.

OH_AudioWorkgroup_RemoveThread()

OH_AudioCommon_Result OH_AudioWorkgroup_RemoveThread(OH_AudioWorkgroup *group, int32_t tokenId)

Description

Removes a thread from an audio workgroup.

Since: 20

Parameters

NameDescription
OH_AudioWorkgroup *groupPointer to an OH_AudioWorkgroup instance, which is created by calling OH_AudioResourceManager_CreateWorkgroup.
int32_t tokenIdID of the thread to be removed from the audio workgroup.

Returns

TypeDescription
OH_AudioCommon_ResultAUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully.
AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM:
1. The group parameter is nullptr.
2. The tokenId parameter is set to an invalid value.
AUDIOCOMMON_RESULT_ERROR_SYSTEM: A system processing error occurs.

OH_AudioWorkgroup_Start()

OH_AudioCommon_Result OH_AudioWorkgroup_Start(OH_AudioWorkgroup *group, uint64_t startTime, uint64_t deadlineTime)

Description

Notifies the system that an audio workgroup starts working and provides the expected end time of the workgroup.

Since: 20

Parameters

NameDescription
OH_AudioWorkgroup *groupPointer to an OH_AudioWorkgroup instance, which is created by calling OH_AudioResourceManager_CreateWorkgroup.
uint64_t startTimeTime when the audio workgroup starts working.
uint64_t deadlineTimeExpected end time of the audio workgroup.

Returns

TypeDescription
OH_AudioCommon_ResultAUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully.
AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM:
1. The group parameter is nullptr.
2. The startTime parameter is set to an invalid value.
3. The deadlineTime parameter is set to an invalid value.
AUDIOCOMMON_RESULT_ERROR_SYSTEM: A system processing error occurs.

OH_AudioWorkgroup_Stop()

OH_AudioCommon_Result OH_AudioWorkgroup_Stop(OH_AudioWorkgroup *group)

Description

Notifies the system that an audio workgroup finishes working.

Since: 20

Parameters

NameDescription
OH_AudioWorkgroup *groupPointer to an OH_AudioWorkgroup instance, which is created by calling OH_AudioResourceManager_CreateWorkgroup.

Returns

TypeDescription
OH_AudioCommon_ResultAUDIOCOMMON_RESULT_SUCCESS: The function is executed successfully.
AUDIOCOMMON_RESULT_ERROR_INVALID_PARAM: The group parameter is nullptr.
AUDIOCOMMON_RESULT_ERROR_SYSTEM: A system processing error occurs.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-native-audiostreambuilder-h

openharmony 鸿蒙 capi-ohaudiosuite

openharmony 鸿蒙 js-apis-inner-multimedia-systemSoundPlayer

openharmony 鸿蒙 arkts-apis-audio-i

openharmony 鸿蒙 capi-ohaudio

openharmony 鸿蒙 capi-ohmidi

openharmony 鸿蒙 arkts-apis-audio-AudioManager

openharmony 鸿蒙 capi-ohaudiosuite-oh-audiosuite-spacerenderpositionparams

openharmony 鸿蒙 capi-ohaudio-oh-audiostreaminfo

openharmony 鸿蒙 errorcode-ringtone

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/6PXMAYkg