1 /* 2 * Copyright (c) 2025 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 #ifndef ST_AUDIO_INTERRUPT_DFX_COLLECTOR_H 17 #define ST_AUDIO_INTERRUPT_DFX_COLLECTOR_H 18 19 #include <map> 20 #include <tuple> 21 22 #include "dfx_collector.h" 23 #include "audio_info.h" 24 #include "audio_interrupt_info.h" 25 26 namespace OHOS { 27 namespace AudioStandard { 28 29 class AudioInterruptDfxCollector : public DfxCollector<InterruptDfxInfo> { 30 public: 31 void FlushDfxMsg(uint32_t index, int32_t appUid) override; 32 std::tuple<uint8_t, uint8_t> &GetDfxIndexes(uint32_t index); 33 private: 34 std::map<uint32_t, std::tuple<uint8_t, uint8_t>> dfxIdx2InfoIdx_; 35 }; 36 37 class InterruptDfxBuilder { 38 public: 39 InterruptDfxBuilder &WriteActionMsg(uint8_t infoIndex, uint8_t effectIdx, InterruptStage stage); 40 InterruptDfxBuilder &WriteInfoMsg(const AudioInterrupt &audioInterrupt, const AudioSessionStrategy &strategy, 41 InterruptRole interruptType); 42 InterruptDfxBuilder &WriteEffectMsg(uint8_t appstate, const std::string &bundleName, 43 const AudioInterrupt &audioInterrupt, const InterruptHint &hintType); 44 InterruptDfxInfo GetResult(); 45 private: 46 InterruptDfxInfo dfxInfo_{}; 47 }; 48 49 } // namespace AudioStandard 50 } // namespace OHOS 51 52 #endif // ST_AUDIO_INTERRUPT_DFX_COLLECTOR_H