fix inner_impl nullptr

Signed-off-by: peng <yangpeng43@huawei.com>
This commit is contained in:
peng 2024-08-23 04:14:16 +00:00
parent 22a54cc43c
commit 284a6ac062
2 changed files with 29 additions and 1 deletions

View File

@ -88,6 +88,8 @@ int32_t AVCodecAudioCodecInnerImpl::Init(AVCodecType type, bool isMimeType, cons
int32_t AVCodecAudioCodecInnerImpl::Configure(const std::shared_ptr<Media::Meta> &meta)
{
AVCODEC_LOGI("AVCodecAudioCodecInnerImpl Configure");
CHECK_AND_RETURN_RET_LOG(codecService_ != nullptr, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION,
"service died");
int32_t ret = codecService_->Configure(meta);
return ret;
}
@ -96,6 +98,8 @@ int32_t AVCodecAudioCodecInnerImpl::SetOutputBufferQueue(
const sptr<Media::AVBufferQueueProducer> &bufferQueueProducer)
{
AVCODEC_LOGI("AVCodecAudioCodecInnerImpl SetOutputBufferQueue");
CHECK_AND_RETURN_RET_LOG(codecService_ != nullptr, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION,
"service died");
int32_t ret = codecService_->SetOutputBufferQueue(bufferQueueProducer);
return ret;
}
@ -103,6 +107,8 @@ int32_t AVCodecAudioCodecInnerImpl::SetOutputBufferQueue(
int32_t AVCodecAudioCodecInnerImpl::Prepare()
{
AVCODEC_LOGI("AVCodecAudioCodecInnerImpl Prepare");
CHECK_AND_RETURN_RET_LOG(codecService_ != nullptr, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION,
"service died");
int32_t ret = codecService_->Prepare();
return ret;
}
@ -110,12 +116,16 @@ int32_t AVCodecAudioCodecInnerImpl::Prepare()
sptr<Media::AVBufferQueueProducer> AVCodecAudioCodecInnerImpl::GetInputBufferQueue()
{
AVCODEC_LOGI("AVCodecAudioCodecInnerImpl GetInputBufferQueue");
CHECK_AND_RETURN_RET_LOG(codecService_ != nullptr, nullptr,
"service died");
return codecService_->GetInputBufferQueue();
}
int32_t AVCodecAudioCodecInnerImpl::Start()
{
AVCODEC_LOGI("AVCodecAudioCodecInnerImpl Start");
CHECK_AND_RETURN_RET_LOG(codecService_ != nullptr, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION,
"service died");
int32_t ret = codecService_->Start();
return ret;
}
@ -123,6 +133,8 @@ int32_t AVCodecAudioCodecInnerImpl::Start()
int32_t AVCodecAudioCodecInnerImpl::Stop()
{
AVCODEC_LOGI("AVCodecAudioCodecInnerImpl Stop");
CHECK_AND_RETURN_RET_LOG(codecService_ != nullptr, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION,
"service died");
int32_t ret = codecService_->Stop();
return ret;
}
@ -130,6 +142,8 @@ int32_t AVCodecAudioCodecInnerImpl::Stop()
int32_t AVCodecAudioCodecInnerImpl::Flush()
{
AVCODEC_LOGI("AVCodecAudioCodecInnerImpl Flush");
CHECK_AND_RETURN_RET_LOG(codecService_ != nullptr, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION,
"service died");
int32_t ret = codecService_->Flush();
return ret;
}
@ -137,6 +151,8 @@ int32_t AVCodecAudioCodecInnerImpl::Flush()
int32_t AVCodecAudioCodecInnerImpl::Reset()
{
AVCODEC_LOGI("AVCodecAudioCodecInnerImpl Reset");
CHECK_AND_RETURN_RET_LOG(codecService_ != nullptr, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION,
"service died");
int32_t ret = codecService_->Reset();
return ret;
}
@ -144,6 +160,8 @@ int32_t AVCodecAudioCodecInnerImpl::Reset()
int32_t AVCodecAudioCodecInnerImpl::Release()
{
AVCODEC_LOGI("AVCodecAudioCodecInnerImpl Release");
CHECK_AND_RETURN_RET_LOG(codecService_ != nullptr, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION,
"service died");
int32_t ret = codecService_->Release();
return ret;
}
@ -151,6 +169,8 @@ int32_t AVCodecAudioCodecInnerImpl::Release()
int32_t AVCodecAudioCodecInnerImpl::NotifyEos()
{
AVCODEC_LOGI("AVCodecAudioCodecInnerImpl NotifyEos");
CHECK_AND_RETURN_RET_LOG(codecService_ != nullptr, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION,
"service died");
int32_t ret = codecService_->NotifyEos();
return ret;
}
@ -158,6 +178,8 @@ int32_t AVCodecAudioCodecInnerImpl::NotifyEos()
int32_t AVCodecAudioCodecInnerImpl::SetParameter(const std::shared_ptr<Media::Meta> &parameter)
{
AVCODEC_LOGI("AVCodecAudioCodecInnerImpl SetParameter");
CHECK_AND_RETURN_RET_LOG(codecService_ != nullptr, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION,
"service died");
int32_t ret = codecService_->SetParameter(parameter);
return ret;
}
@ -165,6 +187,8 @@ int32_t AVCodecAudioCodecInnerImpl::SetParameter(const std::shared_ptr<Media::Me
int32_t AVCodecAudioCodecInnerImpl::GetOutputFormat(std::shared_ptr<Media::Meta> &parameter)
{
AVCODEC_LOGD_LIMIT(10, "AVCodecAudioCodecInnerImpl GetOutputFormat"); // limit10
CHECK_AND_RETURN_RET_LOG(codecService_ != nullptr, AVCodecServiceErrCode::AVCS_ERR_INVALID_OPERATION,
"service died");
int32_t ret = codecService_->GetOutputFormat(parameter);
return ret;
}
@ -172,6 +196,7 @@ int32_t AVCodecAudioCodecInnerImpl::GetOutputFormat(std::shared_ptr<Media::Meta>
void AVCodecAudioCodecInnerImpl::ProcessInputBuffer()
{
AVCODEC_LOGI("AVCodecAudioCodecInnerImpl ProcessInputBuffer");
CHECK_AND_RETURN_LOG(codecService_ != nullptr, "service died");
codecService_->ProcessInputBuffer();
}

View File

@ -93,6 +93,9 @@ Status FFmpegVorbisDecoderPlugin::SetParameter(const std::shared_ptr<Meta> &para
AVCODEC_LOGE("AllocateContext failed, ret=%{public}d", ret);
return ret;
}
if (!CheckSampleFormat(parameter)) {
return Status::ERROR_INVALID_PARAMETER;
}
ret = basePlugin->InitContext(parameter);
if (ret != Status::OK) {
AVCODEC_LOGE("InitContext failed, ret=%{public}d", ret);
@ -156,7 +159,7 @@ bool FFmpegVorbisDecoderPlugin::CheckSampleFormat(const std::shared_ptr<Meta> &f
bool FFmpegVorbisDecoderPlugin::CheckFormat(const std::shared_ptr<Meta> &format)
{
if (!CheckChannelCount(format) || !CheckSampleFormat(format) || !CheckSampleRate(format)) {
if (!CheckChannelCount(format) || !CheckSampleRate(format)) {
return false;
}
return true;