1 /*
2  * Copyright (C) 2018 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 android.media;
18 
19 /**
20  * Helper class used by native code to reduce JNI calls from native side.
21  * @hide
22  */
23 public class MediaPlayer2Utils {
24     /**
25      * Returns whether audio offloading is supported for the given audio format.
26      *
27      * @param encoding the type of encoding defined in {@link AudioFormat}
28      * @param sampleRate the sampling rate of the stream
29      * @param channelMask the channel mask defined in {@link AudioFormat}
30      */
31     // @CalledByNative
isOffloadedAudioPlaybackSupported( int encoding, int sampleRate, int channelMask)32     public static boolean isOffloadedAudioPlaybackSupported(
33             int encoding, int sampleRate, int channelMask) {
34         final AudioFormat format = new AudioFormat.Builder()
35                 .setEncoding(encoding)
36                 .setSampleRate(sampleRate)
37                 .setChannelMask(channelMask)
38                 .build();
39         //TODO MP2 needs to pass AudioAttributes for this query, instead of using default attr
40         return AudioManager.isOffloadedPlaybackSupported(format,
41                 (new AudioAttributes.Builder()).build());
42     }
43 }
44