From 2596e2cfb3fa9ac1df03146a8325aa81115d3c12 Mon Sep 17 00:00:00 2001 From: whoselittlelion Date: Tue, 12 Sep 2023 15:29:02 +0800 Subject: [PATCH 01/10] fix:add offload stream Signed-off-by: whoselittlelion --- .../primary_impl/vdi_src/audio_common_vdi.c | 1 + .../primary_impl/vdi_src/audio_render_vdi.c | 54 ++++++++++++++++++- .../vendor_include/include/i_audio_control.h | 9 ++++ .../vendor_src/audio_common_vendor.c | 3 +- .../vendor_src/audio_render_vendor.c | 54 ++++++++++++++++++- audio/interfaces/2.0/include/audio_control.h | 9 ++++ audio/interfaces/2.0/include/audio_types.h | 18 +++++++ audio/interfaces/include/audio_control.h | 9 ++++ audio/interfaces/include/audio_types.h | 18 +++++++ audio/interfaces/sound/v1_0/audio_types_vdi.h | 29 ++++++++++ .../interfaces/sound/v1_0/iaudio_render_vdi.h | 3 +- 11 files changed, 203 insertions(+), 4 deletions(-) diff --git a/audio/hdi_service/primary_impl/vdi_src/audio_common_vdi.c b/audio/hdi_service/primary_impl/vdi_src/audio_common_vdi.c index bda03c6890..14f22f8614 100644 --- a/audio/hdi_service/primary_impl/vdi_src/audio_common_vdi.c +++ b/audio/hdi_service/primary_impl/vdi_src/audio_common_vdi.c @@ -55,6 +55,7 @@ void AudioCommonAttrsToVdiAttrsVdi(const struct AudioSampleAttributes *attrs, st vdiAttrs->silenceThreshold = attrs->silenceThreshold; vdiAttrs->streamId = attrs->streamId; vdiAttrs->sourceType = attrs->sourceType; + vdiAttrs->offloadInfo = attrs->offloadInfo; } int32_t AudioCommonPortToVdiPortVdi(const struct AudioPort *port, struct AudioPortVdi *vdiPort) diff --git a/audio/hdi_service/primary_impl/vdi_src/audio_render_vdi.c b/audio/hdi_service/primary_impl/vdi_src/audio_render_vdi.c index b611a583f5..1b1f14e764 100644 --- a/audio/hdi_service/primary_impl/vdi_src/audio_render_vdi.c +++ b/audio/hdi_service/primary_impl/vdi_src/audio_render_vdi.c @@ -33,6 +33,8 @@ struct AudioRenderInfo { struct IAudioRenderVdi *vdiRender; uint32_t renderId; unsigned int usrCount; + struct IAudioCallback *callback; + bool isRegCb; }; struct AudioRenderPrivVdi { @@ -154,6 +156,42 @@ int32_t AudioGetRenderSpeedVdi(struct IAudioRender *render, float *speed) return HDF_SUCCESS; } +static int32_t AudioRenderCallbackVdi(enum AudioCallbackTypeVdi type, void *reserved, void *cookie) +{ + CHECK_NULL_PTR_RETURN_VALUE(render, HDF_ERR_INVALID_PARAM); + struct AudioRenderInfo *renderInfo = (struct AudioRenderInfo *)render; + struct IAudioCallback *cb = renderInfo->callback; + CHECK_NULL_PTR_RETURN_VALUE(cb, HDF_ERR_INVALID_PARAM); + int8_t newCookie = 0; + int8_t newReserved = 0; + int32_t ret = cb->RenderCallback(cb, (enum AudioCallbackType)type, &newReserved, &newCookie); + if (ret != HDF_SUCCESS) { + AUDIO_FUNC_LOGE("audio render AudioHwiRenderCallback fail, ret=%{public}d", ret); + return HDF_FAILURE; + } + return HDF_SUCCESS; +} + +int32_t AudioRenderRegCallbackVdi(struct IAudioRender *render, struct IAudioCallback *audioCallback, int8_t cookie) +{ + CHECK_NULL_PTR_RETURN_VALUE(render, HDF_ERR_INVALID_PARAM); + CHECK_NULL_PTR_RETURN_VALUE(audioCallback, HDF_ERR_INVALID_PARAM); + + struct AudioRenderInfo *renderInfo = (struct AudioRenderInfo *)render; + struct IAudioRenderVdi *vdiRender = renderInfo->vdiRender; + CHECK_NULL_PTR_RETURN_VALUE(vdiRender, HDF_ERR_INVALID_PARAM); + CHECK_NULL_PTR_RETURN_VALUE(vdiRender->RegCallback, HDF_ERR_INVALID_PARAM); + + int32_t ret = vdiRender->RegCallback(vdiRender, AudioRenderCallbackVdi, (void *)render); + if (ret != HDF_SUCCESS) { + AUDIO_FUNC_LOGE("audio render regCallback fail, ret=%{public}d", ret); + return HDF_FAILURE; + } + renderInfo->callback = audioCallback; + renderInfo->isRegCb = true; + return HDF_SUCCESS; +} + int32_t AudioRenderSetChannelModeVdi(struct IAudioRender *render, enum AudioChannelMode mode) { CHECK_NULL_PTR_RETURN_VALUE(render, HDF_ERR_INVALID_PARAM); @@ -804,6 +842,15 @@ int32_t AudioRenderIsSupportsPauseAndResumeVdi(struct IAudioRender *render, bool return vdiRender->IsSupportsPauseAndResume(vdiRender, supportPause, supportResume); } +int32_t AudioRenderSetbufferSize(struct IAudioRender *render, uint32_t size) +{ + CHECK_NULL_PTR_RETURN_VALUE(render, HDF_ERR_INVALID_PARAM); + struct AudioRenderInfo *renderInfo = (struct AudioRenderInfo *)render; + struct IAudioRenderVdi *vdiRender = renderInfo->vdiRender; + CHECK_NULL_PTR_RETURN_VALUE(vdiRender, HDF_ERR_INVALID_PARAM); + return vdiRender->SetBufferSize(vdiRender, size); +} + static void AudioInitRenderInstanceVdi(struct IAudioRender *render) { render->GetLatency = AudioGetLatencyVdi; @@ -811,6 +858,7 @@ static void AudioInitRenderInstanceVdi(struct IAudioRender *render) render->GetRenderPosition = AudioGetRenderPositionVdi; render->SetRenderSpeed = AudioSetRenderSpeedVdi; render->GetRenderSpeed = AudioGetRenderSpeedVdi; + render->RegCallback = AudioRenderRegCallbackVdi; render->SetChannelMode = AudioRenderSetChannelModeVdi; render->GetChannelMode = AudioRenderGetChannelModeVdi; render->DrainBuffer = AudioRenderDrainBufferVdi; @@ -844,6 +892,7 @@ static void AudioInitRenderInstanceVdi(struct IAudioRender *render) render->TurnStandbyMode = AudioRenderTurnStandbyModeVdi; render->AudioDevDump = AudioRenderAudioDevDumpVdi; render->IsSupportsPauseAndResume = AudioRenderIsSupportsPauseAndResumeVdi; + render->SetBufferSize = AudioRenderSetbufferSize; } struct IAudioRender *FindRenderCreated(enum AudioPortPin pin, const struct AudioSampleAttributes *attrs, @@ -932,6 +981,8 @@ struct IAudioRender *AudioCreateRenderByIdVdi(const struct AudioSampleAttributes priv->renderInfos[*renderId]->desc.desc = strdup(desc->desc); priv->renderInfos[*renderId]->renderId = *renderId; priv->renderInfos[*renderId]->usrCount = 1; + priv->renderInfos[*renderId]->callback = NULL; + priv->renderInfos[*renderId]->isRegCb = false; render = &(priv->renderInfos[*renderId]->render); AudioInitRenderInstanceVdi(render); @@ -974,7 +1025,8 @@ void AudioDestroyRenderByIdVdi(uint32_t renderId) priv->renderInfos[renderId]->desc.desc = NULL; priv->renderInfos[renderId]->desc.portId = UINT_MAX; priv->renderInfos[renderId]->desc.pins = PIN_NONE; - + priv->renderInfos[*renderId]->callback = NULL; + priv->renderInfos[*renderId]->isRegCb = false; OsalMemFree(priv->renderInfos[renderId]); priv->renderInfos[renderId] = NULL; } diff --git a/audio/hdi_service/primary_impl/vendor_include/include/i_audio_control.h b/audio/hdi_service/primary_impl/vendor_include/include/i_audio_control.h index 5cd715ba3f..e0403899e9 100644 --- a/audio/hdi_service/primary_impl/vendor_include/include/i_audio_control.h +++ b/audio/hdi_service/primary_impl/vendor_include/include/i_audio_control.h @@ -125,6 +125,15 @@ struct AudioControlHwi { * @see IsSupportsPauseAndResume */ int32_t (*IsSupportsPauseAndResume)(AudioHandle handle, bool *supportPause, bool *supportResume); + + /** + * @brief Set offload buffer size. + * + * @param handle Indicates the audio handle. + * @param size Indicates the buffer size which contains the audio data. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + */ + int32_t (*SetBufferSize)(AudioHandle handle, uint32_t size); }; #endif /* I_AUDIO_CONTROL_H */ diff --git a/audio/hdi_service/primary_impl/vendor_src/audio_common_vendor.c b/audio/hdi_service/primary_impl/vendor_src/audio_common_vendor.c index b1cb461253..4707a908b3 100644 --- a/audio/hdi_service/primary_impl/vendor_src/audio_common_vendor.c +++ b/audio/hdi_service/primary_impl/vendor_src/audio_common_vendor.c @@ -56,6 +56,7 @@ void AudioHwiCommonAttrsToHwiAttrs(const struct AudioSampleAttributes *attrs, st hwiAttrs->silenceThreshold = attrs->silenceThreshold; hwiAttrs->streamId = attrs->streamId; hwiAttrs->sourceType = attrs->sourceType; + hwiAttrs->offloadInfo = attrs->offloadInfo; } int32_t AudioHwiCommonPortToHwiPort(const struct AudioPort *port, struct AudioHwiPort *hwiPort) @@ -411,7 +412,7 @@ int32_t AudioHwiCommonSampleAttrToHwiSampleAttr(const struct AudioSampleAttribut hwiAttrs->silenceThreshold = attrs->silenceThreshold; hwiAttrs->streamId = attrs->streamId; hwiAttrs->sourceType = attrs->sourceType; - + hwiAttrs->offloadInfo = attrs->offloadInfo; return HDF_SUCCESS; } diff --git a/audio/hdi_service/primary_impl/vendor_src/audio_render_vendor.c b/audio/hdi_service/primary_impl/vendor_src/audio_render_vendor.c index f3b74a5e02..98f6bd9f96 100644 --- a/audio/hdi_service/primary_impl/vendor_src/audio_render_vendor.c +++ b/audio/hdi_service/primary_impl/vendor_src/audio_render_vendor.c @@ -33,6 +33,8 @@ struct AudioRenderInfo { struct AudioHwiRender *hwiRender; uint32_t renderId; unsigned int usrCount; + struct IAudioCallback *callback; + bool isRegCb; }; struct AudioHwiRenderPriv { @@ -187,6 +189,42 @@ int32_t AudioHwiRenderGetChannelMode(struct IAudioRender *render, enum AudioChan return ret; } +static int32_t AudioHwiRenderCallback(enum AudioHwiCallbackType type, void *reserved, void *cookie) +{ + CHECK_NULL_PTR_RETURN_VALUE(render, HDF_ERR_INVALID_PARAM); + struct AudioRenderInfo *renderInfo = (struct AudioRenderInfo *)render; + struct IAudioCallback *cb = renderInfo->callback; + CHECK_NULL_PTR_RETURN_VALUE(cb, HDF_ERR_INVALID_PARAM); + int8_t newCookie = 0; + int8_t newReserved = 0; + int32_t ret = cb->RenderCallback(cb, (enum AudioCallbackType)type, &newReserved, &newCookie); + if (ret != HDF_SUCCESS) { + AUDIO_FUNC_LOGE("audio render AudioHwiRenderCallback fail, ret=%{public}d", ret); + return HDF_FAILURE; + } + return HDF_SUCCESS; +} + +int32_t AudioHwiRenderRegCallback(struct IAudioRender *render, struct IAudioCallback *audioCallback, int8_t cookie) +{ + CHECK_NULL_PTR_RETURN_VALUE(render, HDF_ERR_INVALID_PARAM); + CHECK_NULL_PTR_RETURN_VALUE(audioCallback, HDF_ERR_INVALID_PARAM); + + struct AudioRenderInfo *renderInfo = (struct AudioRenderInfo *)render; + struct IAudioRender *hwiRender = renderInfo->hwiRender; + CHECK_NULL_PTR_RETURN_VALUE(hwiRender, HDF_ERR_INVALID_PARAM); + CHECK_NULL_PTR_RETURN_VALUE(hwiRender->RegCallback, HDF_ERR_INVALID_PARAM); + + int32_t ret = hwiRender->RegCallback(hwiRender, AudioHwiRenderCallback, (void *)render); + if (ret != HDF_SUCCESS) { + AUDIO_FUNC_LOGE("audio render regCallback fail, ret=%{public}d", ret); + return HDF_FAILURE; + } + renderInfo->callback = audioCallback; + renderInfo->isRegCb = true; + return HDF_SUCCESS; +} + int32_t AudioHwiRenderDrainBuffer(struct IAudioRender *render, enum AudioDrainNotifyType *type) { CHECK_NULL_PTR_RETURN_VALUE(render, HDF_ERR_INVALID_PARAM); @@ -772,6 +810,15 @@ int32_t AudioHwiRenderIsSupportsPauseAndResume(struct IAudioRender *render, bool return hwiRender->control.IsSupportsPauseAndResume(hwiRender, supportPause, supportResume); } +int32_t AudioHwiRenderSetbufferSize(struct IAudioRender *render, uint32_t size) +{ + CHECK_NULL_PTR_RETURN_VALUE(render, HDF_ERR_INVALID_PARAM); + struct AudioRenderInfo *renderInfo = (struct AudioRenderInfo *)render; + struct IAudioHwiRender *hwiRender = renderInfo->hwiRender; + CHECK_NULL_PTR_RETURN_VALUE(hwiRender, HDF_ERR_INVALID_PARAM); + return hwiRender->control.SetBufferSize(hwiRender, size); +} + static void AudioHwiInitRenderInstance(struct IAudioRender *render) { render->GetLatency = AudioHwiGetLatency; @@ -779,6 +826,7 @@ static void AudioHwiInitRenderInstance(struct IAudioRender *render) render->GetRenderPosition = AudioHwiGetRenderPosition; render->SetRenderSpeed = AudioHwiSetRenderSpeed; render->GetRenderSpeed = AudioHwiGetRenderSpeed; + render->RegCallback = AudioHwiRenderRegCallback; render->SetChannelMode = AudioHwiRenderSetChannelMode; render->GetChannelMode = AudioHwiRenderGetChannelMode; render->DrainBuffer = AudioHwiRenderDrainBuffer; @@ -812,6 +860,7 @@ static void AudioHwiInitRenderInstance(struct IAudioRender *render) render->TurnStandbyMode = AudioHwiRenderTurnStandbyMode; render->AudioDevDump = AudioHwiRenderAudioDevDump; render->IsSupportsPauseAndResume = AudioHwiRenderIsSupportsPauseAndResume; + render->SetBufferSize = AudioHwiRenderSetBufferSize; } struct IAudioRender *FindRenderCreated(enum AudioPortPin pin, const struct AudioSampleAttributes *attrs, @@ -901,6 +950,8 @@ struct IAudioRender *AudioHwiCreateRenderById(const struct AudioSampleAttributes priv->renderInfos[*renderId]->desc.desc = strdup(desc->desc); priv->renderInfos[*renderId]->renderId = *renderId; priv->renderInfos[*renderId]->usrCount = 1; + priv->renderInfos[*renderId]->callback = NULL; + priv->renderInfos[*renderId]->isRegCb = false; render = &(priv->renderInfos[*renderId]->render); AudioHwiInitRenderInstance(render); @@ -943,7 +994,8 @@ void AudioHwiDestroyRenderById(uint32_t renderId) priv->renderInfos[renderId]->desc.desc = NULL; priv->renderInfos[renderId]->desc.portId = UINT_MAX; priv->renderInfos[renderId]->desc.pins = PIN_NONE; - + priv->renderInfos[*renderId]->callback = NULL; + priv->renderInfos[*renderId]->isRegCb = false; OsalMemFree(priv->renderInfos[renderId]); priv->renderInfos[renderId] = NULL; } diff --git a/audio/interfaces/2.0/include/audio_control.h b/audio/interfaces/2.0/include/audio_control.h index fcb4f80efe..1bed6d8b53 100644 --- a/audio/interfaces/2.0/include/audio_control.h +++ b/audio/interfaces/2.0/include/audio_control.h @@ -126,6 +126,15 @@ struct AudioControl { * @see IsSupportsPauseAndResume */ int32_t (*IsSupportsPauseAndResume)(AudioHandle handle, bool *supportPause, bool *supportResume); + + /** + * @brief Set offload buffer size. + * + * @param handle Indicates the audio handle. + * @param size Indicates the buffer size which contains the audio data. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + */ + int32_t (*SetBufferSize)(AudioHandle handle, uint32_t size); }; } /* end of OHOS */ #endif /* AUDIO_CONTROL_H */ diff --git a/audio/interfaces/2.0/include/audio_types.h b/audio/interfaces/2.0/include/audio_types.h index a8ad9bde0d..1cc70d6209 100644 --- a/audio/interfaces/2.0/include/audio_types.h +++ b/audio/interfaces/2.0/include/audio_types.h @@ -117,6 +117,7 @@ enum AudioCategory { AUDIO_IN_RINGTONE, /**< Ringtone */ AUDIO_IN_CALL, /**< Call */ AUDIO_MMAP_NOIRQ, /**< Mmap mode */ + AUDIO_OFFLOAD, /**< offlaod */ }; /** @@ -141,6 +142,8 @@ enum AudioFormat { AUDIO_FORMAT_TYPE_PCM_16_BIT = 0x2u, /**< 16-bit PCM */ AUDIO_FORMAT_TYPE_PCM_24_BIT = 0x3u, /**< 24-bit PCM */ AUDIO_FORMAT_TYPE_PCM_32_BIT = 0x4u, /**< 32-bit PCM */ + AUDIO_FORMAT_TYPE_PCM_FLOAT = 0x5u, /**< PCM */ + AUDIO_FORMAT_TYPE_MP3 = 0x1000000u, /**< MP3 */ AUDIO_FORMAT_TYPE_AAC_MAIN = 0x1000001u, /**< AAC main */ AUDIO_FORMAT_TYPE_AAC_LC = 0x1000002u, /**< AAC LC */ AUDIO_FORMAT_TYPE_AAC_LD = 0x1000003u, /**< AAC LD */ @@ -203,6 +206,20 @@ enum AudioInputType { AUDIO_INPUT_VOICE_COMMUNICATION_TYPE = 1 << 2, AUDIO_INPUT_VOICE_RECOGNITION_TYPE = 1 << 3, }; + +/** + * @brief Defines audio offload attributes. + */ +struct AudioOffloadInfo +{ + uint32_t sampleRate; /**< Audio sampling rate */ + uint32_t channelCount; /**< Number of audio channels */ + uint32_t bitRate; /**< bitRate of compressed audio data */ + uint32_t bitWidth; /**< bitwidth of audio data */ + uint32_t offloadBufferSize; /**< buffersize for offload audio data */ + uint64_t duration; +}; + /** * @brief Defines audio sampling attributes. */ @@ -223,6 +240,7 @@ struct AudioSampleAttributes { uint32_t silenceThreshold; /**< Audio capture buffer threshold. */ int32_t streamId; /**< Audio Identifier of render or capture */ int32_t sourceType; + AudioOffloadInfo offloadInfo; /**< offload info for offload stream */ }; /** diff --git a/audio/interfaces/include/audio_control.h b/audio/interfaces/include/audio_control.h index 536f8fe0a9..c15f8b158e 100644 --- a/audio/interfaces/include/audio_control.h +++ b/audio/interfaces/include/audio_control.h @@ -125,6 +125,15 @@ struct AudioControl { * @see IsSupportsPauseAndResume */ int32_t (*IsSupportsPauseAndResume)(AudioHandle handle, bool *supportPause, bool *supportResume); + + /** + * @brief Set offload buffer size. + * + * @param handle Indicates the audio handle. + * @param size Indicates the buffer size which contains the audio data. + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + */ + int32_t (*SetBufferSize)(AudioHandle handle, uint32_t size); }; #endif /* AUDIO_CONTROL_H */ diff --git a/audio/interfaces/include/audio_types.h b/audio/interfaces/include/audio_types.h index affdc0c9eb..7fa8801dfd 100644 --- a/audio/interfaces/include/audio_types.h +++ b/audio/interfaces/include/audio_types.h @@ -116,6 +116,7 @@ enum AudioCategory { AUDIO_IN_RINGTONE, /**< Ringtone */ AUDIO_IN_CALL, /**< Call */ AUDIO_MMAP_NOIRQ, /**< Mmap mode */ + AUDIO_OFFLOAD, /**< offlaod */ }; /** @@ -140,6 +141,8 @@ enum AudioFormat { AUDIO_FORMAT_TYPE_PCM_16_BIT = 0x2u, /**< 16-bit PCM */ AUDIO_FORMAT_TYPE_PCM_24_BIT = 0x3u, /**< 24-bit PCM */ AUDIO_FORMAT_TYPE_PCM_32_BIT = 0x4u, /**< 32-bit PCM */ + AUDIO_FORMAT_TYPE_PCM_FLOAT = 0x5u, /**< PCM */ + AUDIO_FORMAT_TYPE_MP3 = 0x1000000u, /**< MP3 */ AUDIO_FORMAT_TYPE_AAC_MAIN = 0x1000001u, /**< AAC main */ AUDIO_FORMAT_TYPE_AAC_LC = 0x1000002u, /**< AAC LC */ AUDIO_FORMAT_TYPE_AAC_LD = 0x1000003u, /**< AAC LD */ @@ -202,6 +205,20 @@ enum AudioInputType { AUDIO_INPUT_VOICE_COMMUNICATION_TYPE = 1 << 2, AUDIO_INPUT_VOICE_RECOGNITION_TYPE = 1 << 3, }; + +/** + * @brief Defines audio offload attributes. + */ +struct AudioOffloadInfo +{ + uint32_t sampleRate; /**< Audio sampling rate */ + uint32_t channelCount; /**< Number of audio channels */ + uint32_t bitRate; /**< bitRate of compressed audio data */ + uint32_t bitWidth; /**< bitwidth of audio data */ + uint32_t offloadBufferSize; /**< buffersize for offload audio data */ + uint64_t duration; +}; + /** * @brief Defines audio sampling attributes. */ @@ -222,6 +239,7 @@ struct AudioSampleAttributes { uint32_t silenceThreshold; /**< Audio capture buffer threshold. */ int32_t streamId; /**< Audio Identifier of render or capture */ int32_t sourceType; + AudioOffloadInfo offloadInfo; /**< offload info for offload stream */ }; /** diff --git a/audio/interfaces/sound/v1_0/audio_types_vdi.h b/audio/interfaces/sound/v1_0/audio_types_vdi.h index c84b97a620..2ccbd77046 100644 --- a/audio/interfaces/sound/v1_0/audio_types_vdi.h +++ b/audio/interfaces/sound/v1_0/audio_types_vdi.h @@ -57,6 +57,7 @@ enum AudioCategoryVdi { AUDIO_VDI_IN_RINGTONE = 2, AUDIO_VDI_IN_CALL = 3, AUDIO_VDI_MMAP_NOIRQ = 4, + AUDIO_VDI_OFFLOAD = 5, AUDIO_VDI_CATEGORY_BUTT, }; @@ -65,6 +66,8 @@ enum AudioFormatVdi { AUDIO_VDI_FORMAT_TYPE_PCM_16_BIT = 1 << 1, AUDIO_VDI_FORMAT_TYPE_PCM_24_BIT = 1 << 1 | 1 << 0, AUDIO_VDI_FORMAT_TYPE_PCM_32_BIT = 1 << 2, + AUDIO_FORMAT_TYPE_PCM_FLOAT = 1 << 2 | 1 << 0, + AUDIO_FORMAT_TYPE_MP3 = 1 << 24, AUDIO_VDI_FORMAT_TYPE_AAC_MAIN = 1 << 24 | 1 << 0, AUDIO_VDI_FORMAT_TYPE_AAC_LC = 1 << 24 | 1 << 1, AUDIO_VDI_FORMAT_TYPE_AAC_LD = 1 << 24 | 1 << 1 | 1 << 0, @@ -265,6 +268,16 @@ enum AudioInputTypeVdi { AUDIO_VDI_INPUT_VOICE_RECOGNITION_TYPE = 1 << 3, }; +struct AudioOffloadInfoVdi +{ + uint32_t sampleRate; + uint32_t channelCount; + uint32_t bitRate; + uint32_t bitWidth; + uint32_t offloadBufferSize; + uint64_t duration; +}; + struct AudioSampleAttributesVdi { enum AudioCategoryVdi type; bool interleaved; @@ -280,6 +293,7 @@ struct AudioSampleAttributesVdi { uint32_t silenceThreshold; int32_t streamId; int32_t sourceType; + AudioOffloadInfoVdi offloadInfo; } __attribute__ ((aligned(8))); struct AudioTimeStampVdi { @@ -360,6 +374,21 @@ struct AudioEventVdi { uint32_t deviceType; } __attribute__ ((aligned(8))); +typedef int32_t (*RenderCallbackVdi)(enum AudioCallbackType, void *reserved, void *cookie); + +/** + * @brief Register audio extra param callback that will be invoked during audio param event. + * + * @param key Indicates param change event. + * @param condition Indicates the param condition. + * @param value Indicates the param value. + * @param reserved Indicates reserved param. + * @param cookie Indicates the pointer to the callback parameters; + * @return Returns 0 if the operation is successful; returns a negative value otherwise. + */ +typedef int32_t (*ParamCallbackVdi)(enum AudioExtParamKey key, const char *condition, const char *value, void *reserved, + void *cookie); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/audio/interfaces/sound/v1_0/iaudio_render_vdi.h b/audio/interfaces/sound/v1_0/iaudio_render_vdi.h index f9aa29fab4..68bf5be9a1 100644 --- a/audio/interfaces/sound/v1_0/iaudio_render_vdi.h +++ b/audio/interfaces/sound/v1_0/iaudio_render_vdi.h @@ -36,7 +36,7 @@ struct IAudioRenderVdi { int32_t (*GetRenderSpeed)(struct IAudioRenderVdi *self, float *speed); int32_t (*SetChannelMode)(struct IAudioRenderVdi *self, enum AudioChannelModeVdi mode); int32_t (*GetChannelMode)(struct IAudioRenderVdi *self, enum AudioChannelModeVdi *mode); - int32_t (*RegCallback)(struct IAudioRenderVdi *self, struct IAudioCallbackVdi *audioCallback, int8_t cookie); + int32_t (*RegCallback)(struct IAudioRenderVdi *self, RenderCallbackVdi audioCallback, void *cookie); int32_t (*DrainBuffer)(struct IAudioRenderVdi *self, enum AudioDrainNotifyTypeVdi *type); int32_t (*IsSupportsDrain)(struct IAudioRenderVdi *self, bool *support); int32_t (*CheckSceneCapability)(struct IAudioRenderVdi *self, const struct AudioSceneDescriptorVdi *scene, @@ -69,6 +69,7 @@ struct IAudioRenderVdi { int32_t (*TurnStandbyMode)(struct IAudioRenderVdi *self); int32_t (*AudioDevDump)(struct IAudioRenderVdi *self, int32_t range, int32_t fd); int32_t (*IsSupportsPauseAndResume)(struct IAudioRenderVdi *self, bool *supportPause, bool *supportResume); + int32_t (*SetBufferSize)(struct IAudioRenderVdi *self, uint32_t size); }; #ifdef __cplusplus -- Gitee From d8051c6205fcd2189f9d694719e0bb4a19dc6da1 Mon Sep 17 00:00:00 2001 From: whoselittlelion Date: Wed, 13 Sep 2023 13:17:10 +0000 Subject: [PATCH 02/10] update audio/interfaces/2.0/include/audio_types.h. Signed-off-by: whoselittlelion --- audio/interfaces/2.0/include/audio_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/interfaces/2.0/include/audio_types.h b/audio/interfaces/2.0/include/audio_types.h index 1cc70d6209..3b36282cb7 100644 --- a/audio/interfaces/2.0/include/audio_types.h +++ b/audio/interfaces/2.0/include/audio_types.h @@ -240,7 +240,7 @@ struct AudioSampleAttributes { uint32_t silenceThreshold; /**< Audio capture buffer threshold. */ int32_t streamId; /**< Audio Identifier of render or capture */ int32_t sourceType; - AudioOffloadInfo offloadInfo; /**< offload info for offload stream */ + struct AudioOffloadInfo offloadInfo; /**< offload info for offload stream */ }; /** -- Gitee From 60357e5acd8feeb081803c5160bdde4e12158dc7 Mon Sep 17 00:00:00 2001 From: whoselittlelion Date: Wed, 13 Sep 2023 13:20:11 +0000 Subject: [PATCH 03/10] update audio/interfaces/include/audio_types.h. Signed-off-by: whoselittlelion --- audio/interfaces/include/audio_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/interfaces/include/audio_types.h b/audio/interfaces/include/audio_types.h index 7fa8801dfd..177e1eed91 100644 --- a/audio/interfaces/include/audio_types.h +++ b/audio/interfaces/include/audio_types.h @@ -239,7 +239,7 @@ struct AudioSampleAttributes { uint32_t silenceThreshold; /**< Audio capture buffer threshold. */ int32_t streamId; /**< Audio Identifier of render or capture */ int32_t sourceType; - AudioOffloadInfo offloadInfo; /**< offload info for offload stream */ + struct AudioOffloadInfo offloadInfo; /**< offload info for offload stream */ }; /** -- Gitee From 2093a5703890dd80cccde3b5b61ebd8b72132805 Mon Sep 17 00:00:00 2001 From: whoselittlelion Date: Wed, 13 Sep 2023 13:21:27 +0000 Subject: [PATCH 04/10] update audio/interfaces/sound/v1_0/audio_types_vdi.h. Signed-off-by: whoselittlelion --- audio/interfaces/sound/v1_0/audio_types_vdi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/interfaces/sound/v1_0/audio_types_vdi.h b/audio/interfaces/sound/v1_0/audio_types_vdi.h index 2ccbd77046..3cb399961f 100644 --- a/audio/interfaces/sound/v1_0/audio_types_vdi.h +++ b/audio/interfaces/sound/v1_0/audio_types_vdi.h @@ -293,7 +293,7 @@ struct AudioSampleAttributesVdi { uint32_t silenceThreshold; int32_t streamId; int32_t sourceType; - AudioOffloadInfoVdi offloadInfo; + struct AudioOffloadInfoVdi offloadInfo; } __attribute__ ((aligned(8))); struct AudioTimeStampVdi { -- Gitee From 9690451d856838fd239d7b703cdc37d710a48472 Mon Sep 17 00:00:00 2001 From: whoselittlelion Date: Thu, 14 Sep 2023 11:54:18 +0000 Subject: [PATCH 05/10] update audio/interfaces/2.0/include/audio_types.h. Signed-off-by: whoselittlelion --- audio/interfaces/2.0/include/audio_types.h | 1 + 1 file changed, 1 insertion(+) diff --git a/audio/interfaces/2.0/include/audio_types.h b/audio/interfaces/2.0/include/audio_types.h index 3b36282cb7..93b70bf978 100644 --- a/audio/interfaces/2.0/include/audio_types.h +++ b/audio/interfaces/2.0/include/audio_types.h @@ -216,6 +216,7 @@ struct AudioOffloadInfo uint32_t channelCount; /**< Number of audio channels */ uint32_t bitRate; /**< bitRate of compressed audio data */ uint32_t bitWidth; /**< bitwidth of audio data */ + enum AudioFormat format; /**< Audio data format. uint32_t offloadBufferSize; /**< buffersize for offload audio data */ uint64_t duration; }; -- Gitee From 4e64b05c2a4abac1b19a17fbc4a0346e8d86c5ed Mon Sep 17 00:00:00 2001 From: whoselittlelion Date: Thu, 14 Sep 2023 12:01:35 +0000 Subject: [PATCH 06/10] update audio/interfaces/2.0/include/audio_types.h. Signed-off-by: whoselittlelion --- audio/interfaces/2.0/include/audio_types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/interfaces/2.0/include/audio_types.h b/audio/interfaces/2.0/include/audio_types.h index 93b70bf978..2fa29509b4 100644 --- a/audio/interfaces/2.0/include/audio_types.h +++ b/audio/interfaces/2.0/include/audio_types.h @@ -219,7 +219,7 @@ struct AudioOffloadInfo enum AudioFormat format; /**< Audio data format. uint32_t offloadBufferSize; /**< buffersize for offload audio data */ uint64_t duration; -}; +} __attribute__ ((aligned(8))); /** * @brief Defines audio sampling attributes. @@ -242,7 +242,7 @@ struct AudioSampleAttributes { int32_t streamId; /**< Audio Identifier of render or capture */ int32_t sourceType; struct AudioOffloadInfo offloadInfo; /**< offload info for offload stream */ -}; +} __attribute__ ((aligned(8))); /** * @brief Defines the audio timestamp, which is a substitute for POSIX timespec. -- Gitee From 01c63039e161c8e71a72930c8cc5187dc22f4686 Mon Sep 17 00:00:00 2001 From: whoselittlelion Date: Thu, 14 Sep 2023 12:02:04 +0000 Subject: [PATCH 07/10] update audio/interfaces/sound/v1_0/audio_types_vdi.h. Signed-off-by: whoselittlelion --- audio/interfaces/sound/v1_0/audio_types_vdi.h | 1 + 1 file changed, 1 insertion(+) diff --git a/audio/interfaces/sound/v1_0/audio_types_vdi.h b/audio/interfaces/sound/v1_0/audio_types_vdi.h index 3cb399961f..eb993f9fcc 100644 --- a/audio/interfaces/sound/v1_0/audio_types_vdi.h +++ b/audio/interfaces/sound/v1_0/audio_types_vdi.h @@ -274,6 +274,7 @@ struct AudioOffloadInfoVdi uint32_t channelCount; uint32_t bitRate; uint32_t bitWidth; + enum AudioFormatVdi format; uint32_t offloadBufferSize; uint64_t duration; }; -- Gitee From 18d0ac51c0c9668c2c6d04e8dc1ffd943fbd198c Mon Sep 17 00:00:00 2001 From: whoselittlelion Date: Thu, 14 Sep 2023 12:03:38 +0000 Subject: [PATCH 08/10] update audio/interfaces/include/audio_types.h. Signed-off-by: whoselittlelion --- audio/interfaces/include/audio_types.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/audio/interfaces/include/audio_types.h b/audio/interfaces/include/audio_types.h index 177e1eed91..10f36f1eda 100644 --- a/audio/interfaces/include/audio_types.h +++ b/audio/interfaces/include/audio_types.h @@ -215,9 +215,10 @@ struct AudioOffloadInfo uint32_t channelCount; /**< Number of audio channels */ uint32_t bitRate; /**< bitRate of compressed audio data */ uint32_t bitWidth; /**< bitwidth of audio data */ + enum AudioFormat format; /**< Audio data format. */ uint32_t offloadBufferSize; /**< buffersize for offload audio data */ uint64_t duration; -}; +} __attribute__ ((aligned(8))); /** * @brief Defines audio sampling attributes. @@ -240,7 +241,7 @@ struct AudioSampleAttributes { int32_t streamId; /**< Audio Identifier of render or capture */ int32_t sourceType; struct AudioOffloadInfo offloadInfo; /**< offload info for offload stream */ -}; +} __attribute__ ((aligned(8))); /** * @brief Defines the audio timestamp, which is a substitute for POSIX timespec. -- Gitee From 211df6a3dfbbd30621da9bf8b50ebcb06ef7541c Mon Sep 17 00:00:00 2001 From: whoselittlelion Date: Thu, 14 Sep 2023 12:03:41 +0000 Subject: [PATCH 09/10] update audio/interfaces/2.0/include/audio_types.h. Signed-off-by: whoselittlelion --- audio/interfaces/2.0/include/audio_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/interfaces/2.0/include/audio_types.h b/audio/interfaces/2.0/include/audio_types.h index 2fa29509b4..8e68161f6b 100644 --- a/audio/interfaces/2.0/include/audio_types.h +++ b/audio/interfaces/2.0/include/audio_types.h @@ -216,7 +216,7 @@ struct AudioOffloadInfo uint32_t channelCount; /**< Number of audio channels */ uint32_t bitRate; /**< bitRate of compressed audio data */ uint32_t bitWidth; /**< bitwidth of audio data */ - enum AudioFormat format; /**< Audio data format. + enum AudioFormat format; /**< Audio data format. */ uint32_t offloadBufferSize; /**< buffersize for offload audio data */ uint64_t duration; } __attribute__ ((aligned(8))); -- Gitee From 28c728d5f937d5d57af0b59cec52900b3403a95e Mon Sep 17 00:00:00 2001 From: whoselittlelion Date: Fri, 15 Sep 2023 00:58:45 +0000 Subject: [PATCH 10/10] update audio/interfaces/sound/v1_0/audio_types_vdi.h. Signed-off-by: whoselittlelion --- .../primary_impl/vdi_src/audio_common_vdi.c | 20 +++++++++++-- .../primary_impl/vdi_src/audio_render_vdi.c | 4 +-- .../vendor_include/include/i_audio_types.h | 19 ++++++++++++ .../vendor_src/audio_common_vendor.c | 30 +++++++++++++++++-- .../vendor_src/audio_render_vendor.c | 8 ++--- audio/interfaces/2.0/include/audio_types.h | 2 +- audio/interfaces/sound/v1_0/audio_types_vdi.h | 16 +++++++--- 7 files changed, 83 insertions(+), 16 deletions(-) diff --git a/audio/hdi_service/primary_impl/vdi_src/audio_common_vdi.c b/audio/hdi_service/primary_impl/vdi_src/audio_common_vdi.c index 14f22f8614..84e3a41690 100644 --- a/audio/hdi_service/primary_impl/vdi_src/audio_common_vdi.c +++ b/audio/hdi_service/primary_impl/vdi_src/audio_common_vdi.c @@ -55,7 +55,15 @@ void AudioCommonAttrsToVdiAttrsVdi(const struct AudioSampleAttributes *attrs, st vdiAttrs->silenceThreshold = attrs->silenceThreshold; vdiAttrs->streamId = attrs->streamId; vdiAttrs->sourceType = attrs->sourceType; - vdiAttrs->offloadInfo = attrs->offloadInfo; + if (vdiAttrs->type == AUDIO_VDI_OFFLOAD) { + vdiAttrs->offloadInfo.sampleRate = attrs->offloadInfo.sampleRate; + vdiAttrs->offloadInfo.channelCount = attrs->offloadInfo.channelCount; + vdiAttrs->offloadInfo.bitRate = attrs->offloadInfo.bitRate; + vdiAttrs->offloadInfo.bitWidth = attrs->offloadInfo.bitWidth; + vdiAttrs->offloadInfo.format = (enum AudioFormatVdi)attrs->offloadInfo.format; + vdiAttrs->offloadInfo.offloadBuffersize = attrs->offloadInfo.offloadBuffersize; + vdiAttrs->offloadInfo.duration = attrs->offloadInfo.duration; + } } int32_t AudioCommonPortToVdiPortVdi(const struct AudioPort *port, struct AudioPortVdi *vdiPort) @@ -407,7 +415,15 @@ int32_t AudioCommonSampleAttrToVdiSampleAttrVdi(const struct AudioSampleAttribut vdiAttrs->silenceThreshold = attrs->silenceThreshold; vdiAttrs->streamId = attrs->streamId; vdiAttrs->sourceType = attrs->sourceType; - + if (vdiAttrs->type == AUDIO_VDI_OFFLOAD) { + vdiAttrs->offloadInfo.sampleRate = attrs->offloadInfo.sampleRate; + vdiAttrs->offloadInfo.channelCount = attrs->offloadInfo.channelCount; + vdiAttrs->offloadInfo.bitRate = attrs->offloadInfo.bitRate; + vdiAttrs->offloadInfo.bitWidth = attrs->offloadInfo.bitWidth; + vdiAttrs->offloadInfo.format = (enum AudioFormatVdi)attrs->offloadInfo.format; + vdiAttrs->offloadInfo.offloadBuffersize = attrs->offloadInfo.offloadBuffersize; + vdiAttrs->offloadInfo.duration = attrs->offloadInfo.duration; + } return HDF_SUCCESS; } diff --git a/audio/hdi_service/primary_impl/vdi_src/audio_render_vdi.c b/audio/hdi_service/primary_impl/vdi_src/audio_render_vdi.c index 1b1f14e764..af652e05e5 100644 --- a/audio/hdi_service/primary_impl/vdi_src/audio_render_vdi.c +++ b/audio/hdi_service/primary_impl/vdi_src/audio_render_vdi.c @@ -1025,8 +1025,8 @@ void AudioDestroyRenderByIdVdi(uint32_t renderId) priv->renderInfos[renderId]->desc.desc = NULL; priv->renderInfos[renderId]->desc.portId = UINT_MAX; priv->renderInfos[renderId]->desc.pins = PIN_NONE; - priv->renderInfos[*renderId]->callback = NULL; - priv->renderInfos[*renderId]->isRegCb = false; + priv->renderInfos[renderId]->callback = NULL; + priv->renderInfos[renderId]->isRegCb = false; OsalMemFree(priv->renderInfos[renderId]); priv->renderInfos[renderId] = NULL; } diff --git a/audio/hdi_service/primary_impl/vendor_include/include/i_audio_types.h b/audio/hdi_service/primary_impl/vendor_include/include/i_audio_types.h index bc30302a42..c243fcbecb 100644 --- a/audio/hdi_service/primary_impl/vendor_include/include/i_audio_types.h +++ b/audio/hdi_service/primary_impl/vendor_include/include/i_audio_types.h @@ -119,6 +119,7 @@ enum AudioHwiCategory { HW_AUDIO_IN_RINGTONE, /**< Ringtone */ HW_AUDIO_IN_CALL, /**< Call */ HW_AUDIO_MMAP_NOIRQ, /**< Mmap mode */ + HW_AUDIO_OFFLOAD, }; /** @@ -143,6 +144,8 @@ enum AudioHwiFormat { AUDIO_HW_FORMAT_TYPE_PCM_16_BIT = 0x2u, /**< 16-bit PCM */ AUDIO_HW_FORMAT_TYPE_PCM_24_BIT = 0x3u, /**< 24-bit PCM */ AUDIO_HW_FORMAT_TYPE_PCM_32_BIT = 0x4u, /**< 32-bit PCM */ + AUDIO_HW_FORMAT_TYPE_PCM_FLOAT = 0x5u, /**< PCM */ + AUDIO_HW_FORMAT_TYPE_MP3 = 0x1000000u, /**< MP3 */ AUDIO_HW_FORMAT_TYPE_AAC_MAIN = 0x1000001u, /**< AAC main */ AUDIO_HW_FORMAT_TYPE_AAC_LC = 0x1000002u, /**< AAC LC */ AUDIO_HW_FORMAT_TYPE_AAC_LD = 0x1000003u, /**< AAC LD */ @@ -206,6 +209,21 @@ enum AudioHwiInputType { AUDIO_HW_INPUT_VOICE_COMMUNICATION_TYPE = 1 << 2, AUDIO_HW_INPUT_VOICE_RECOGNITION_TYPE = 1 << 3, }; + +/** + * @brief Defines audio offload attributes. + */ +struct AudioHwiOffloadInfo +{ + uint32_t sampleRate; /**< Audio sampling rate */ + uint32_t channelCount; /**< Number of audio channels */ + uint32_t bitRate; /**< bitRate of compressed audio data */ + uint32_t bitWidth; /**< bitwidth of audio data */ + enum AudioHwiFormat format; /**< Audio data format. */ + uint32_t offloadBufferSize; /**< buffersize for offload audio data */ + uint64_t duration; +}; + /** * @brief Defines audio sampling attributes. */ @@ -226,6 +244,7 @@ struct AudioHwiSampleAttributes { uint32_t silenceThreshold; /**< Audio capture buffer threshold. */ int32_t streamId; /**< Audio Identifier of render or capture */ int32_t sourceType; + struct AudioHwiOffloadInfo offloadInfo; }; /** diff --git a/audio/hdi_service/primary_impl/vendor_src/audio_common_vendor.c b/audio/hdi_service/primary_impl/vendor_src/audio_common_vendor.c index 4707a908b3..f2a7a04990 100644 --- a/audio/hdi_service/primary_impl/vendor_src/audio_common_vendor.c +++ b/audio/hdi_service/primary_impl/vendor_src/audio_common_vendor.c @@ -56,7 +56,15 @@ void AudioHwiCommonAttrsToHwiAttrs(const struct AudioSampleAttributes *attrs, st hwiAttrs->silenceThreshold = attrs->silenceThreshold; hwiAttrs->streamId = attrs->streamId; hwiAttrs->sourceType = attrs->sourceType; - hwiAttrs->offloadInfo = attrs->offloadInfo; + if (hwiAttrs->type == HW_AUDIO_OFFLOAD) { + hwiAttrs->offloadInfo.sampleRate = attrs->offloadInfo.sampleRate; + hwiAttrs->offloadInfo.channelCount = attrs->offloadInfo.channelCount; + hwiAttrs->offloadInfo.bitRate = attrs->offloadInfo.bitRate; + hwiAttrs->offloadInfo.bitWidth = attrs->offloadInfo.bitWidth; + hwiAttrs->offloadInfo.format = (enum AudioHwiFormat)attrs->offloadInfo.format; + hwiAttrs->offloadInfo.offloadBuffersize = attrs->offloadInfo.offloadBuffersize; + hwiAttrs->offloadInfo.duration = attrs->offloadInfo.duration; + } } int32_t AudioHwiCommonPortToHwiPort(const struct AudioPort *port, struct AudioHwiPort *hwiPort) @@ -412,7 +420,15 @@ int32_t AudioHwiCommonSampleAttrToHwiSampleAttr(const struct AudioSampleAttribut hwiAttrs->silenceThreshold = attrs->silenceThreshold; hwiAttrs->streamId = attrs->streamId; hwiAttrs->sourceType = attrs->sourceType; - hwiAttrs->offloadInfo = attrs->offloadInfo; + if (hwiAttrs->type == HW_AUDIO_OFFLOAD) { + hwiAttrs->offloadInfo.sampleRate = attrs->offloadInfo.sampleRate; + hwiAttrs->offloadInfo.channelCount = attrs->offloadInfo.channelCount; + hwiAttrs->offloadInfo.bitRate = attrs->offloadInfo.bitRate; + hwiAttrs->offloadInfo.bitWidth = attrs->offloadInfo.bitWidth; + hwiAttrs->offloadInfo.format = (enum AudioHwiFormat)attrs->offloadInfo.format; + hwiAttrs->offloadInfo.offloadBuffersize = attrs->offloadInfo.offloadBuffersize; + hwiAttrs->offloadInfo.duration = attrs->offloadInfo.duration; + } return HDF_SUCCESS; } @@ -435,6 +451,14 @@ int32_t AudioHwiCommonHwiSampleAttrToSampleAttr(const struct AudioHwiSampleAttri attrs->stopThreshold = hwiAttrs->stopThreshold; attrs->silenceThreshold = hwiAttrs->silenceThreshold; attrs->streamId = hwiAttrs->streamId; - + if (attrs->type == AUDIO_OFFLOAD) { + attrs->offloadInfo.sampleRate = hwiAttrs->offloadInfo.sampleRate; + attrs->offloadInfo.channelCount = hwiAttrs->offloadInfo.channelCount; + attrs->offloadInfo.bitRate = hwiAttrs->offloadInfo.bitRate; + attrs->offloadInfo.bitWidth = hwiAttrs->offloadInfo.bitWidth; + attrs->offloadInfo.format = (enum AudioFormat)hwiAttrs->offloadInfo.format; + attrs->offloadInfo.offloadBuffersize = hwiAttrs->offloadInfo.offloadBuffersize; + attrs->offloadInfo.duration = hwiAttrs->offloadInfo.duration; + } return HDF_SUCCESS; } diff --git a/audio/hdi_service/primary_impl/vendor_src/audio_render_vendor.c b/audio/hdi_service/primary_impl/vendor_src/audio_render_vendor.c index 98f6bd9f96..820b97b457 100644 --- a/audio/hdi_service/primary_impl/vendor_src/audio_render_vendor.c +++ b/audio/hdi_service/primary_impl/vendor_src/audio_render_vendor.c @@ -191,8 +191,8 @@ int32_t AudioHwiRenderGetChannelMode(struct IAudioRender *render, enum AudioChan static int32_t AudioHwiRenderCallback(enum AudioHwiCallbackType type, void *reserved, void *cookie) { - CHECK_NULL_PTR_RETURN_VALUE(render, HDF_ERR_INVALID_PARAM); - struct AudioRenderInfo *renderInfo = (struct AudioRenderInfo *)render; + CHECK_NULL_PTR_RETURN_VALUE(cookie, HDF_ERR_INVALID_PARAM); + struct AudioRenderInfo *renderInfo = (struct AudioRenderInfo *)cookie; struct IAudioCallback *cb = renderInfo->callback; CHECK_NULL_PTR_RETURN_VALUE(cb, HDF_ERR_INVALID_PARAM); int8_t newCookie = 0; @@ -994,8 +994,8 @@ void AudioHwiDestroyRenderById(uint32_t renderId) priv->renderInfos[renderId]->desc.desc = NULL; priv->renderInfos[renderId]->desc.portId = UINT_MAX; priv->renderInfos[renderId]->desc.pins = PIN_NONE; - priv->renderInfos[*renderId]->callback = NULL; - priv->renderInfos[*renderId]->isRegCb = false; + priv->renderInfos[renderId]->callback = NULL; + priv->renderInfos[renderId]->isRegCb = false; OsalMemFree(priv->renderInfos[renderId]); priv->renderInfos[renderId] = NULL; } diff --git a/audio/interfaces/2.0/include/audio_types.h b/audio/interfaces/2.0/include/audio_types.h index 8e68161f6b..f5a47a6852 100644 --- a/audio/interfaces/2.0/include/audio_types.h +++ b/audio/interfaces/2.0/include/audio_types.h @@ -250,7 +250,7 @@ struct AudioSampleAttributes { struct AudioTimeStamp { int64_t tvSec; /**< Seconds */ int64_t tvNSec; /**< Nanoseconds */ -}; +} __attribute__ ((aligned(8))); /** * @brief Enumerates the passthrough data transmission mode of an audio port. diff --git a/audio/interfaces/sound/v1_0/audio_types_vdi.h b/audio/interfaces/sound/v1_0/audio_types_vdi.h index eb993f9fcc..309e450e53 100644 --- a/audio/interfaces/sound/v1_0/audio_types_vdi.h +++ b/audio/interfaces/sound/v1_0/audio_types_vdi.h @@ -268,8 +268,7 @@ enum AudioInputTypeVdi { AUDIO_VDI_INPUT_VOICE_RECOGNITION_TYPE = 1 << 3, }; -struct AudioOffloadInfoVdi -{ +struct AudioOffloadInfoVdi { uint32_t sampleRate; uint32_t channelCount; uint32_t bitRate; @@ -375,7 +374,16 @@ struct AudioEventVdi { uint32_t deviceType; } __attribute__ ((aligned(8))); -typedef int32_t (*RenderCallbackVdi)(enum AudioCallbackType, void *reserved, void *cookie); +/** + * @brief Called when an event defined in {@link AudioCallbackType} occurs. + * + * @param AudioCallbackTypeVdi Indicates the occurred event that triggers this callback. + * @param reserved Indicates the pointer to a reserved field. + * @param cookie Indicates the pointer to the cookie for data transmission. + * @return Returns 0 if the callback is successfully executed; returns a negative value otherwise. + * @see RegCallback + */ +typedef int32_t (*RenderCallbackVdi)(enum AudioCallbackTypeVdi, void *reserved, void *cookie); /** * @brief Register audio extra param callback that will be invoked during audio param event. @@ -387,7 +395,7 @@ typedef int32_t (*RenderCallbackVdi)(enum AudioCallbackType, void *reserved, voi * @param cookie Indicates the pointer to the callback parameters; * @return Returns 0 if the operation is successful; returns a negative value otherwise. */ -typedef int32_t (*ParamCallbackVdi)(enum AudioExtParamKey key, const char *condition, const char *value, void *reserved, +typedef int32_t (*ParamCallbackVdi)(enum AudioExtParamKeyVdi key, const char *condition, const char *value, void *reserved, void *cookie); #ifdef __cplusplus -- Gitee