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_qosmanager.h" 17 #include <unistd.h> 18 #include <sys/types.h> 19 #include <cstring> 20 #include <unordered_map> 21 #include <set> 22 23 #ifdef QOSMANAGER_ENABLE 24 #include "qos.h" 25 #include "concurrent_task_client.h" 26 #endif 27 28 #include "audio_utils.h" 29 #include "audio_common_log.h" 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 36 using namespace OHOS::AudioStandard; 37 38 #ifdef QOSMANAGER_ENABLE SetThreadQosLevel()39void SetThreadQosLevel() 40 { 41 std::unordered_map<std::string, std::string> payload; 42 payload["pid"] = std::to_string(getpid()); 43 OHOS::ConcurrentTask::ConcurrentTaskClient::GetInstance().RequestAuth(payload); 44 OHOS::QOS::SetThreadQos(OHOS::QOS::QosLevel::QOS_USER_INTERACTIVE); 45 } ReSetThreadQosLevel()46void ReSetThreadQosLevel() 47 { 48 OHOS::QOS::ResetThreadQos(); 49 } 50 #else 51 void SetThreadQosLevel() {}; 52 void ReSetThreadQosLevel() {}; 53 #endif 54 55 56 #ifdef __cplusplus 57 } 58 #endif 59