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 bda03c68904c6cf0a26b58e3d543dad48a7963ef..84e3a41690397030067c74c4a823a80ea604cb47 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,15 @@ void AudioCommonAttrsToVdiAttrsVdi(const struct AudioSampleAttributes *attrs, st
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;
+ }
}
int32_t AudioCommonPortToVdiPortVdi(const struct AudioPort *port, struct AudioPortVdi *vdiPort)
@@ -406,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 b611a583f54b4d55adfced99cbff695d9dbe5060..af652e05e512e585c4720896a8d919b6f8bc88fb 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 5cd715ba3f3510489b8f4101fba1f95256b4ab80..e0403899e9899af10b1708934bf16cb1f153078e 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_include/include/i_audio_types.h b/audio/hdi_service/primary_impl/vendor_include/include/i_audio_types.h
index bc30302a42533c32b579fb0dd5233a050bd2a6dd..c243fcbecbed89c436d4e21fdcfe4beccc26d551 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 b1cb4612532eccdaacc4dd81db25df0c8f090bab..f2a7a049906d51deebf14258482441deb99b6e1c 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,15 @@ void AudioHwiCommonAttrsToHwiAttrs(const struct AudioSampleAttributes *attrs, st
hwiAttrs->silenceThreshold = attrs->silenceThreshold;
hwiAttrs->streamId = attrs->streamId;
hwiAttrs->sourceType = attrs->sourceType;
+ 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)
@@ -411,7 +420,15 @@ int32_t AudioHwiCommonSampleAttrToHwiSampleAttr(const struct AudioSampleAttribut
hwiAttrs->silenceThreshold = attrs->silenceThreshold;
hwiAttrs->streamId = attrs->streamId;
hwiAttrs->sourceType = attrs->sourceType;
-
+ 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;
}
@@ -434,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 f3b74a5e02f256102f18ddfdb29a99db12954a3f..820b97b4570eb9e8029fc64499965a8154aba613 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(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;
+ 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 fcb4f80efecba1c1fc22759659e43a4c7459c2d1..1bed6d8b5374e63eab5f93476a9b4efa3a906f23 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 a8ad9bde0d20395a008b706042fa725752a05ab8..f5a47a68528b9c9b66d97d26e8b4c74f9a491a4d 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,21 @@ 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 */
+ 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.
*/
@@ -223,7 +241,8 @@ struct AudioSampleAttributes {
uint32_t silenceThreshold; /**< Audio capture buffer threshold. */
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.
@@ -231,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/include/audio_control.h b/audio/interfaces/include/audio_control.h
index 536f8fe0a909024474eacce10ad1639b38a10ab6..c15f8b158e317a7bb760528f0cc3baf99bc4326e 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 affdc0c9eb9fc7801f24f707505f77c1593e8c5c..10f36f1edaba9ae8d4bc58fc58a885ea5003d787 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,21 @@ 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 */
+ 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.
*/
@@ -222,7 +240,8 @@ struct AudioSampleAttributes {
uint32_t silenceThreshold; /**< Audio capture buffer threshold. */
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.
diff --git a/audio/interfaces/sound/v1_0/audio_types_vdi.h b/audio/interfaces/sound/v1_0/audio_types_vdi.h
index c84b97a6208bc2448dd800c29345eb653b5dbd3a..309e450e5312ee4fc9b3587b745f0c7a971133fc 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;
+ enum AudioFormatVdi format;
+ 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;
+ struct AudioOffloadInfoVdi offloadInfo;
} __attribute__ ((aligned(8)));
struct AudioTimeStampVdi {
@@ -360,6 +374,30 @@ struct AudioEventVdi {
uint32_t deviceType;
} __attribute__ ((aligned(8)));
+/**
+ * @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.
+ *
+ * @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 AudioExtParamKeyVdi 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 f9aa29fab4b16b1fcf1a2f249201a2fb3a5dc069..68bf5be9a1257a0f6ff70e6c54d75da62e9806e5 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