150a07fd2Sopenharmony_ci/* 250a07fd2Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 350a07fd2Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 450a07fd2Sopenharmony_ci * you may not use this file except in compliance with the License. 550a07fd2Sopenharmony_ci * You may obtain a copy of the License at 650a07fd2Sopenharmony_ci * 750a07fd2Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 850a07fd2Sopenharmony_ci * 950a07fd2Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1050a07fd2Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1150a07fd2Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1250a07fd2Sopenharmony_ci * See the License for the specific language governing permissions and 1350a07fd2Sopenharmony_ci * limitations under the License. 1450a07fd2Sopenharmony_ci */ 1550a07fd2Sopenharmony_ci 1650a07fd2Sopenharmony_ci#include "daudio_hitrace.h" 1750a07fd2Sopenharmony_ci 1850a07fd2Sopenharmony_ci#undef DH_LOG_TAG 1950a07fd2Sopenharmony_ci#define DH_LOG_TAG "DAudioHitrace" 2050a07fd2Sopenharmony_ci 2150a07fd2Sopenharmony_cinamespace OHOS { 2250a07fd2Sopenharmony_cinamespace DistributedHardware { 2350a07fd2Sopenharmony_civoid DAudioHitrace::Count(const std::string &value, int64_t count, bool isEnable) 2450a07fd2Sopenharmony_ci{ 2550a07fd2Sopenharmony_ci CountTraceDebug(isEnable, HITRACE_TAG_ZAUDIO, value, count); 2650a07fd2Sopenharmony_ci} 2750a07fd2Sopenharmony_ci 2850a07fd2Sopenharmony_ciDAudioHitrace::DAudioHitrace(const std::string &value, bool isShowLog, bool isEnable) 2950a07fd2Sopenharmony_ci{ 3050a07fd2Sopenharmony_ci value_ = value; 3150a07fd2Sopenharmony_ci isShowLog_ = isShowLog; 3250a07fd2Sopenharmony_ci isEnable_ = isEnable; 3350a07fd2Sopenharmony_ci isFinished_ = false; 3450a07fd2Sopenharmony_ci if (isShowLog) { 3550a07fd2Sopenharmony_ci isShowLog_ = true; 3650a07fd2Sopenharmony_ci DHLOGI("%{public}s start.", value_.c_str()); 3750a07fd2Sopenharmony_ci } 3850a07fd2Sopenharmony_ci StartTraceDebug(isEnable_, HITRACE_TAG_ZAUDIO, value); 3950a07fd2Sopenharmony_ci} 4050a07fd2Sopenharmony_ci 4150a07fd2Sopenharmony_civoid DAudioHitrace::End() 4250a07fd2Sopenharmony_ci{ 4350a07fd2Sopenharmony_ci if (!isFinished_) { 4450a07fd2Sopenharmony_ci FinishTraceDebug(isEnable_, HITRACE_TAG_ZAUDIO); 4550a07fd2Sopenharmony_ci isFinished_ = true; 4650a07fd2Sopenharmony_ci if (isShowLog_) { 4750a07fd2Sopenharmony_ci DHLOGI("%{public}s end.", value_.c_str()); 4850a07fd2Sopenharmony_ci } 4950a07fd2Sopenharmony_ci } 5050a07fd2Sopenharmony_ci} 5150a07fd2Sopenharmony_ci 5250a07fd2Sopenharmony_ciDAudioHitrace::~DAudioHitrace() 5350a07fd2Sopenharmony_ci{ 5450a07fd2Sopenharmony_ci End(); 5550a07fd2Sopenharmony_ci} 5650a07fd2Sopenharmony_ci} // namespace DistributedHardware 5750a07fd2Sopenharmony_ci} // namespace OHOS