1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "audio_dfx_vdi.h"
17 #ifdef AUDIO_HITRACE_ENABLE
18 #include <hitrace_meter.h>
19 #endif
20 #ifdef AUDIO_HICOLLIE_ENABLE
21 #include "xcollie/xcollie.h"
22 #include "xcollie/xcollie_define.h"
23 #endif
24 
25 #define HICOLLIE_TIMEOUT 8
26 
HdfAudioStartTrace(const char* value, int valueLen)27 void HdfAudioStartTrace(const char* value, int valueLen)
28 {
29     (void) valueLen;
30 #ifdef AUDIO_HITRACE_ENABLE
31     StartTrace(HITRACE_TAG_HDF, value);
32 #else
33     (void) value;
34 #endif
35 }
36 
HdfAudioFinishTrace(void)37 void HdfAudioFinishTrace(void)
38 {
39 #ifdef AUDIO_HITRACE_ENABLE
40     FinishTrace(HITRACE_TAG_HDF);
41 #endif
42 }
43 
SetTimer(const char* name)44 int32_t SetTimer(const char* name)
45 {
46     int32_t id = 0;
47 #ifdef AUDIO_HICOLLIE_ENABLE
48     id = OHOS::HiviewDFX::XCollie::GetInstance().SetTimer(name, HICOLLIE_TIMEOUT, nullptr, nullptr,
49         OHOS::HiviewDFX::XCOLLIE_FLAG_LOG | OHOS::HiviewDFX::XCOLLIE_FLAG_RECOVERY);
50 #else
51     (void)name;
52 #endif
53     return id;
54 }
55 
CancelTimer(int32_t id)56 void CancelTimer(int32_t id)
57 {
58 #ifdef AUDIO_HICOLLIE_ENABLE
59     if (id != 0) {
60         OHOS::HiviewDFX::XCollie::GetInstance().CancelTimer(id);
61     }
62 #else
63     (void)id;
64 #endif
65 }