1 /*
2 * Copyright 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #pragma once
18
19 #include <bluetooth/log.h>
20
21 #include "audio_aidl_interfaces.h"
22
23 namespace bluetooth {
24 namespace audio {
25 namespace aidl {
26
27 enum class BluetoothAudioCtrlAck : uint8_t {
28 SUCCESS_FINISHED = 0,
29 SUCCESS_RECONFIGURATION,
30 PENDING,
31 FAILURE_UNSUPPORTED,
32 FAILURE_BUSY,
33 FAILURE_DISCONNECTING,
34 FAILURE
35 };
36
37 std::ostream& operator<<(std::ostream& os, const BluetoothAudioCtrlAck& ack);
38
39 inline ::aidl::android::hardware::bluetooth::audio::BluetoothAudioStatus
BluetoothAudioCtrlAckToHalStatus(const BluetoothAudioCtrlAck & ack)40 BluetoothAudioCtrlAckToHalStatus(const BluetoothAudioCtrlAck& ack) {
41 using ::aidl::android::hardware::bluetooth::audio::BluetoothAudioStatus;
42 switch (ack) {
43 case BluetoothAudioCtrlAck::SUCCESS_FINISHED:
44 return BluetoothAudioStatus::SUCCESS;
45 case BluetoothAudioCtrlAck::FAILURE_UNSUPPORTED:
46 return BluetoothAudioStatus::UNSUPPORTED_CODEC_CONFIGURATION;
47 case BluetoothAudioCtrlAck::PENDING:
48 return BluetoothAudioStatus::FAILURE;
49 case BluetoothAudioCtrlAck::FAILURE_BUSY:
50 return BluetoothAudioStatus::FAILURE;
51 case BluetoothAudioCtrlAck::FAILURE_DISCONNECTING:
52 return BluetoothAudioStatus::FAILURE;
53 case BluetoothAudioCtrlAck::SUCCESS_RECONFIGURATION:
54 return BluetoothAudioStatus::RECONFIGURATION;
55 default:
56 return BluetoothAudioStatus::FAILURE;
57 }
58 }
59
60 } // namespace aidl
61 } // namespace audio
62 } // namespace bluetooth
63
64 namespace std {
65 template <>
66 struct formatter<bluetooth::audio::aidl::BluetoothAudioCtrlAck> : ostream_formatter {};
67 } // namespace std
68