• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 package com.android.bluetooth.le_audio;
18 
19 import android.bluetooth.BluetoothLeAudioCodecConfig;
20 import android.content.Context;
21 import android.media.AudioManager;
22 import android.util.Log;
23 /*
24  * LeAudio Codec Configuration setup.
25  */
26 class LeAudioCodecConfig {
27     private static final boolean DBG = true;
28     private static final String TAG = "LeAudioCodecConfig";
29 
30     private Context mContext;
31     private BluetoothLeAudioCodecConfig[] mCodecConfigOffloading =
32             new BluetoothLeAudioCodecConfig[0];
33 
LeAudioCodecConfig(Context context)34     LeAudioCodecConfig(Context context) {
35         Log.i(TAG, "LeAudioCodecConfig init");
36         mContext = context;
37 
38         AudioManager audioManager = mContext.getSystemService(AudioManager.class);
39         if (audioManager == null) {
40             Log.w(TAG, "Can't obtain the codec offloading prefernece from null AudioManager");
41             return;
42         }
43 
44         mCodecConfigOffloading = audioManager.getHwOffloadFormatsSupportedForLeAudio()
45                                              .toArray(mCodecConfigOffloading);
46 
47         if (DBG) {
48             Log.i(TAG, "mCodecConfigOffloading size for le -> " + mCodecConfigOffloading.length);
49 
50             for (int idx = 0; idx < mCodecConfigOffloading.length; idx++) {
51                 Log.i(TAG, String.format("mCodecConfigOffloading[%d] -> %s",
52                         idx, mCodecConfigOffloading[idx].toString()));
53             }
54         }
55     }
56 
getCodecConfigOffloading()57     BluetoothLeAudioCodecConfig[] getCodecConfigOffloading() {
58         return mCodecConfigOffloading;
59     }
60 }
61 
62