From afe8ef84c112ebdb171e60e52fdec0e4ddbbaa80 Mon Sep 17 00:00:00 2001 From: zhangdi Date: Sun, 4 Feb 2024 17:36:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9D=99=E6=80=81=E6=A3=80=E6=9F=A5=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=92=8C2B2B=E9=87=8D=E5=A4=8D=E7=8E=87=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangdi --- frameworks/js/avplayer/avplayer_callback.cpp | 5 +++-- frameworks/js/avplayer/avplayer_napi.cpp | 16 +++++++++------- frameworks/js/avrecorder/avrecorder_callback.cpp | 1 + .../playbin_adapter/playbin_ctrler_base.cpp | 2 +- .../common/playbin_adapter/playbin_state.cpp | 2 +- .../gstreamer/player/player_codec_ctrl.cpp | 2 +- .../gstreamer/player/player_engine_gst_impl.cpp | 2 +- .../gstreamer/player/player_sinkprovider.cpp | 2 +- .../gstreamer/player/player_track_parse.cpp | 2 +- .../sink/audiosink/src/audio_sink_sv_impl.cpp | 8 ++++---- .../services/player/server/player_server.cpp | 3 ++- .../player/server/player_server_task_mgr.cpp | 3 ++- test/fuzztest/common/test_recorder.cpp | 15 ++++++++------- 13 files changed, 35 insertions(+), 28 deletions(-) diff --git a/frameworks/js/avplayer/avplayer_callback.cpp b/frameworks/js/avplayer/avplayer_callback.cpp index 7863306f6..8d1d6a678 100644 --- a/frameworks/js/avplayer/avplayer_callback.cpp +++ b/frameworks/js/avplayer/avplayer_callback.cpp @@ -708,7 +708,8 @@ void AVPlayerCallback::OnSeekDoneCb(const int32_t extra, const Format &infoBody) (void)infoBody; CHECK_AND_RETURN_LOG(isloaded_.load(), "current source is unready"); int32_t currentPositon = extra; - MEDIA_LOGI("OnSeekDone is called, currentPositon: %{public}d", currentPositon); + MEDIA_LOGI("0x%{public}06" PRIXPTR " OnSeekDone is called, currentPositon: %{public}d", + FAKE_POINTER(this), currentPositon); if (refMap_.find(AVPlayerEvent::EVENT_SEEK_DONE) == refMap_.end()) { MEDIA_LOGW("can not find seekdone callback!"); return; @@ -800,7 +801,7 @@ void AVPlayerCallback::OnDurationUpdateCb(const int32_t extra, const Format &inf } if (refMap_.find(AVPlayerEvent::EVENT_DURATION_UPDATE) == refMap_.end()) { - MEDIA_LOGW("can not find duration update callback!"); + MEDIA_LOGW("0x%{public}06" PRIXPTR " can not find duration update callback!", FAKE_POINTER(this)); return; } diff --git a/frameworks/js/avplayer/avplayer_napi.cpp b/frameworks/js/avplayer/avplayer_napi.cpp index 9b53fa93a..1fb4dec17 100644 --- a/frameworks/js/avplayer/avplayer_napi.cpp +++ b/frameworks/js/avplayer/avplayer_napi.cpp @@ -703,7 +703,7 @@ napi_value AVPlayerNapi::JsSeek(napi_env env, napi_callback_info info) } auto task = std::make_shared>([jsPlayer, time, mode]() { - MEDIA_LOGI("Seek Task"); + MEDIA_LOGD("Seek Task"); if (jsPlayer->player_ != nullptr) { (void)jsPlayer->player_->Seek(time, static_cast(mode)); } @@ -1795,7 +1795,8 @@ napi_value AVPlayerNapi::JsGetCurrentTime(napi_env env, napi_callback_info info) napi_value value = nullptr; (void)napi_create_int32(env, currentTime, &value); std::string curState = jsPlayer->GetCurrentState(); - MEDIA_LOGI("JsGetCurrenTime Out, state %{public}s, time: %{public}d", curState.c_str(), currentTime); + MEDIA_LOGI("0x%{public}06" PRIXPTR " JsGetCurrenTime Out, state %{public}s, time: %{public}d", + FAKE_POINTER(jsPlayer), curState.c_str(), currentTime); return value; } @@ -2154,7 +2155,7 @@ napi_value AVPlayerNapi::JsSetOnCallback(napi_env env, napi_callback_info info) } std::string callbackName = CommonNapi::GetStringArgument(env, args[0]); - MEDIA_LOGI("set callbackName: %{public}s", callbackName.c_str()); + MEDIA_LOGI("0x%{public}06" PRIXPTR " set callbackName: %{public}s", FAKE_POINTER(jsPlayer), callbackName.c_str()); napi_ref ref = nullptr; napi_status status = napi_create_reference(env, args[1], 1, &ref); @@ -2163,7 +2164,8 @@ napi_value AVPlayerNapi::JsSetOnCallback(napi_env env, napi_callback_info info) std::shared_ptr autoRef = std::make_shared(env, ref); jsPlayer->SaveCallbackReference(callbackName, autoRef); - MEDIA_LOGI("JsSetOnCallback callbackName: %{public}s success", callbackName.c_str()); + MEDIA_LOGI("0x%{public}06" PRIXPTR " JsSetOnCallback callbackName: %{public}s success", + FAKE_POINTER(jsPlayer), callbackName.c_str()); return result; } @@ -2172,7 +2174,7 @@ napi_value AVPlayerNapi::JsClearOnCallback(napi_env env, napi_callback_info info MediaTrace trace("AVPlayerNapi::off"); napi_value result = nullptr; napi_get_undefined(env, &result); - MEDIA_LOGI("JsClearOnCallback In"); + MEDIA_LOGD("JsClearOnCallback In"); napi_value args[2] = { nullptr }; // args[0]:type, args[1]:callback size_t argCount = 2; // args[0]:type, args[1]:callback @@ -2191,10 +2193,10 @@ napi_value AVPlayerNapi::JsClearOnCallback(napi_env env, napi_callback_info info } std::string callbackName = CommonNapi::GetStringArgument(env, args[0]); - MEDIA_LOGI("set callbackName: %{public}s", callbackName.c_str()); + MEDIA_LOGI("0x%{public}06" PRIXPTR " set callbackName: %{public}s", FAKE_POINTER(jsPlayer), callbackName.c_str()); jsPlayer->ClearCallbackReference(callbackName); - MEDIA_LOGI("JsClearOnCallback Out"); + MEDIA_LOGI("0x%{public}06" PRIXPTR " JsClearOnCallback success", FAKE_POINTER(jsPlayer)); return result; } diff --git a/frameworks/js/avrecorder/avrecorder_callback.cpp b/frameworks/js/avrecorder/avrecorder_callback.cpp index 73291fdc5..abd43ee3e 100644 --- a/frameworks/js/avrecorder/avrecorder_callback.cpp +++ b/frameworks/js/avrecorder/avrecorder_callback.cpp @@ -415,6 +415,7 @@ napi_status AudioCaptureChangeInfoJsCallback::SetDeviceInfo(napi_env env, setRet = CommonNapi::AddArrayInt(env, sampleRates, std::vector(value_.inputDeviceInfo.audioStreamInfo.samplingRate.begin(), value_.inputDeviceInfo.audioStreamInfo.samplingRate.end())); + CHECK_AND_RETURN_RET(setRet == true, napi_generic_failure); napi_set_named_property(env, element, "sampleRates", sampleRates); napi_value channelCounts; diff --git a/services/engine/gstreamer/common/playbin_adapter/playbin_ctrler_base.cpp b/services/engine/gstreamer/common/playbin_adapter/playbin_ctrler_base.cpp index fef3eb52c..c2f431e68 100644 --- a/services/engine/gstreamer/common/playbin_adapter/playbin_ctrler_base.cpp +++ b/services/engine/gstreamer/common/playbin_adapter/playbin_ctrler_base.cpp @@ -905,7 +905,7 @@ void PlayBinCtrlerBase::QueryDuration() gint64 duration = -1; gboolean ret = gst_element_query_duration(GST_ELEMENT_CAST(playbin_), GST_FORMAT_TIME, &duration); - CHECK_AND_RETURN_LOG(ret, "query duration failed"); + CHECK_AND_RETURN_LOG(ret, "0x%{public}06" PRIXPTR " query duration failed", FAKE_POINTER(this)); if (duration >= 0) { duration_ = duration / NANO_SEC_PER_USEC; diff --git a/services/engine/gstreamer/common/playbin_adapter/playbin_state.cpp b/services/engine/gstreamer/common/playbin_adapter/playbin_state.cpp index 998247c1c..142575f7e 100644 --- a/services/engine/gstreamer/common/playbin_adapter/playbin_state.cpp +++ b/services/engine/gstreamer/common/playbin_adapter/playbin_state.cpp @@ -764,7 +764,7 @@ int32_t PlayBinCtrlerBase::PlaybackCompletedState::SetRate(double rate) void PlayBinCtrlerBase::PlaybackCompletedState::ProcessStateChange(const InnerMessage &msg) { - MEDIA_LOGI("PlaybackCompletedState::ProcessStateChange"); + MEDIA_LOGD("PlaybackCompletedState::ProcessStateChange"); if (msg.detail2 == GST_STATE_PLAYING) { if (ctrler_.isUserSetPlay_) { ctrler_.isUserSetPlay_ = false; diff --git a/services/engine/gstreamer/player/player_codec_ctrl.cpp b/services/engine/gstreamer/player/player_codec_ctrl.cpp index 06953d560..552c2f95a 100644 --- a/services/engine/gstreamer/player/player_codec_ctrl.cpp +++ b/services/engine/gstreamer/player/player_codec_ctrl.cpp @@ -91,7 +91,7 @@ void PlayerCodecCtrl::DetectCodecSetup(const std::string &metaStr, GstElement *s SetupCodecCb(metaStr, src, videoSink, notifier); if (IsFirstCodecSetup()) { SetupCodecBufferNum(metaStr, videoSink); - MEDIA_LOGI("Set isHardwareDec_ %{public}d", isHardwareDec_); + MEDIA_LOGI("0x%{public}06" PRIXPTR " Set isHardwareDec_ %{public}d", FAKE_POINTER(this), isHardwareDec_); g_object_set(videoSink, "is-hardware-decoder", isHardwareDec_, nullptr); isHEBCMode_ = isHardwareDec_; } diff --git a/services/engine/gstreamer/player/player_engine_gst_impl.cpp b/services/engine/gstreamer/player/player_engine_gst_impl.cpp index d40e153d2..656b4d1cc 100644 --- a/services/engine/gstreamer/player/player_engine_gst_impl.cpp +++ b/services/engine/gstreamer/player/player_engine_gst_impl.cpp @@ -503,7 +503,7 @@ void PlayerEngineGstImpl::HandleInterruptMessage(const PlayBinMessage &msg) void PlayerEngineGstImpl::HandleAudioFirstFrameMessage(const PlayBinMessage &msg) { - MEDIA_LOGI("Audio first frame event in"); + MEDIA_LOGI("0x%{public}06" PRIXPTR " Audio first frame event in", FAKE_POINTER(this)); uint64_t value = std::any_cast(msg.extra); std::shared_ptr notifyObs = obs_.lock(); if (notifyObs != nullptr) { diff --git a/services/engine/gstreamer/player/player_sinkprovider.cpp b/services/engine/gstreamer/player/player_sinkprovider.cpp index d40f51dc8..25242b4df 100644 --- a/services/engine/gstreamer/player/player_sinkprovider.cpp +++ b/services/engine/gstreamer/player/player_sinkprovider.cpp @@ -294,7 +294,7 @@ void PlayerSinkProvider::EosCb(GstMemSink *memSink, gpointer userData) GstFlowReturn PlayerSinkProvider::NewPrerollCb(GstMemSink *memSink, GstBuffer *sample, gpointer userData) { (void)userData; - MEDIA_LOGI("NewPrerollCb in"); + MEDIA_LOGD("NewPrerollCb in"); MediaTrace trace("PlayerSinkProvider::NewPrerollCb"); CHECK_AND_RETURN_RET(gst_mem_sink_app_preroll_render(memSink, sample) == GST_FLOW_OK, GST_FLOW_ERROR); return GST_FLOW_OK; diff --git a/services/engine/gstreamer/player/player_track_parse.cpp b/services/engine/gstreamer/player/player_track_parse.cpp index e298443ce..320238e86 100644 --- a/services/engine/gstreamer/player/player_track_parse.cpp +++ b/services/engine/gstreamer/player/player_track_parse.cpp @@ -121,7 +121,7 @@ void PlayerTrackParse::OnElementUnSetup(GstElement &elem) if (inputSelectMap_.empty()) { findTrackInfo_ = false; - MEDIA_LOGI("Remove all inputselect plugins"); + MEDIA_LOGI("0x%{public}06" PRIXPTR " Remove all inputselect plugins", FAKE_POINTER(this)); } } diff --git a/services/engine/gstreamer/plugins/sink/audiosink/src/audio_sink_sv_impl.cpp b/services/engine/gstreamer/plugins/sink/audiosink/src/audio_sink_sv_impl.cpp index 61c7c42be..faea39e6f 100644 --- a/services/engine/gstreamer/plugins/sink/audiosink/src/audio_sink_sv_impl.cpp +++ b/services/engine/gstreamer/plugins/sink/audiosink/src/audio_sink_sv_impl.cpp @@ -293,14 +293,14 @@ int32_t AudioSinkSvImpl::Prepare(int32_t appUid, int32_t appPid, uint32_t appTok int32_t AudioSinkSvImpl::Start() { MediaTrace trace("AudioSink::Start"); - MEDIA_LOGI("audioRenderer Start In"); + MEDIA_LOGD("audioRenderer Start In"); CHECK_AND_RETURN_RET(audioRenderer_ != nullptr, MSERR_AUD_RENDER_FAILED); bool ret = false; LISTENER( ret = audioRenderer_->Start(), "AudioRenderer::Start", PlayerXCollie::timerTimeout) - MEDIA_LOGI("audioRenderer Start Out"); + MEDIA_LOGI("0x%{public}06" PRIXPTR " audioRenderer Start Out", FAKE_POINTER(this)); return ret ? MSERR_OK : MSERR_INVALID_OPERATION; } @@ -317,7 +317,7 @@ int32_t AudioSinkSvImpl::Stop() int32_t AudioSinkSvImpl::Pause() { MediaTrace trace("AudioSink::Pause"); - MEDIA_LOGI("audioRenderer Pause In"); + MEDIA_LOGD("audioRenderer Pause In"); CHECK_AND_RETURN_RET(audioRenderer_ != nullptr, MSERR_AUD_RENDER_FAILED); if (audioRenderer_->GetStatus() == OHOS::AudioStandard::RENDERER_RUNNING) { LISTENER( @@ -329,7 +329,7 @@ int32_t AudioSinkSvImpl::Pause() "AudioRenderer::Pause", PlayerXCollie::timerTimeout) } - MEDIA_LOGI("audioRenderer Pause Out"); + MEDIA_LOGI("0x%{public}06" PRIXPTR " audioRenderer Pause Out", FAKE_POINTER(this)); return MSERR_OK; } diff --git a/services/services/player/server/player_server.cpp b/services/services/player/server/player_server.cpp index 8947a07c4..aa566c38d 100755 --- a/services/services/player/server/player_server.cpp +++ b/services/services/player/server/player_server.cpp @@ -1000,7 +1000,8 @@ bool PlayerServer::IsPlaying() { std::lock_guard lock(mutex_); if (lastOpStatus_ == PLAYER_STATE_ERROR) { - MEDIA_LOGE("Can not judge IsPlaying, currentState is PLAYER_STATE_ERROR"); + MEDIA_LOGE("0x%{public}06" PRIXPTR " Can not judge IsPlaying, currentState is PLAYER_STATE_ERROR", + FAKE_POINTER(this)); return false; } diff --git a/services/services/player/server/player_server_task_mgr.cpp b/services/services/player/server/player_server_task_mgr.cpp index 07b63f6a4..16319d382 100644 --- a/services/services/player/server/player_server_task_mgr.cpp +++ b/services/services/player/server/player_server_task_mgr.cpp @@ -125,7 +125,8 @@ int32_t PlayerServerTaskMgr::EnqueueSeekTask(const std::shared_ptr currTwoPhaseTaskName_ = taskName; currentSeekMode_ = seekMode; currentSeekTime_ = seekTime; - MEDIA_LOGI("seek task[%{public}s] start", currTwoPhaseTaskName_.c_str()); + MEDIA_LOGI("0x%{public}06" PRIXPTR " seek task[%{public}s] start", + FAKE_POINTER(this), currTwoPhaseTaskName_.c_str()); return MSERR_OK; } diff --git a/test/fuzztest/common/test_recorder.cpp b/test/fuzztest/common/test_recorder.cpp index dd9550525..82f8bd2e4 100644 --- a/test/fuzztest/common/test_recorder.cpp +++ b/test/fuzztest/common/test_recorder.cpp @@ -20,11 +20,17 @@ #include "aw_common.h" #include "securec.h" #include "test_recorder.h" +#include "media_log.h" using namespace std; using namespace OHOS; using namespace OHOS::Media; using namespace OHOS::Media::RecorderTestParam; + +namespace { + constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN, "RecorderFuzzTest"}; +} + constexpr uint32_t STUB_STREAM_SIZE = 602; constexpr uint32_t FRAME_RATE = 30000; constexpr uint32_t CODEC_BUFFER_WIDTH = 1024; @@ -352,9 +358,7 @@ void TestRecorder::HDICreateESBuffer() { const uint32_t *frameLenArray = HIGH_VIDEO_FRAME_SIZE; while (nowFrame < STUB_STREAM_SIZE) { - if (isExit_.load()) { - break; - } + CHECK_AND_BREAK(!isExit_.load()); usleep(FRAME_RATE); OHOS::sptr buffer; int32_t releaseFence; @@ -362,10 +366,7 @@ void TestRecorder::HDICreateESBuffer() if (retValue == OHOS::SURFACE_ERROR_NO_BUFFER) { continue; } - if ((retValue != SURFACE_ERROR_OK) || (buffer == nullptr)) { - break; - } - + CHECK_AND_BREAK((retValue == SURFACE_ERROR_OK) && (buffer != nullptr)); sptr syncFence = new SyncFence(releaseFence); syncFence->Wait(100); // 100ms -- Gitee