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 #include <hitrace_meter.h>
18 #ifdef AUDIO_HICOLLIE_ENABLE
19 #include "xcollie/xcollie.h"
20 #include "xcollie/xcollie_define.h"
21 #endif
22 
23 #define HICOLLIE_TIMEOUT 10
24 
HdfAudioStartTrace(const char * value,int valueLen)25 void HdfAudioStartTrace(const char* value, int valueLen)
26 {
27     (void) valueLen;
28     StartTrace(HITRACE_TAG_HDF, value);
29 }
30 
HdfAudioFinishTrace(void)31 void HdfAudioFinishTrace(void)
32 {
33     FinishTrace(HITRACE_TAG_HDF);
34 }
35 
SetTimer(const char * name)36 int32_t SetTimer(const char* name)
37 {
38     int32_t id = 0;
39 #ifdef AUDIO_HICOLLIE_ENABLE
40     id = OHOS::HiviewDFX::XCollie::GetInstance().SetTimer(name, HICOLLIE_TIMEOUT, nullptr, nullptr,
41         OHOS::HiviewDFX::XCOLLIE_FLAG_LOG | OHOS::HiviewDFX::XCOLLIE_FLAG_RECOVERY);
42 #else
43     (void)name;
44 #endif
45     return id;
46 }
47 
CancelTimer(int32_t id)48 void CancelTimer(int32_t id)
49 {
50 #ifdef AUDIO_HICOLLIE_ENABLE
51     if (id != 0) {
52         OHOS::HiviewDFX::XCollie::GetInstance().CancelTimer(id);
53     }
54 #else
55     (void)id;
56 #endif
57 }