1 /* 2 * Copyright (C) 2020 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.cts.verifier.audio.audiolib; 18 19 import android.content.Context; 20 import android.media.AudioManager; 21 22 public class AudioSystemParams { 23 // This value will be calculated in init() 24 private int mSystemSampleRate; 25 26 // This value will be calculated in init() 27 private int mSystemBufferFrames; 28 29 // The system burst buffer size as reported by AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER 30 // This value will be calculated in init() 31 private int mSystemBurstFrames; 32 init(Context context)33 public void init(Context context) { 34 AudioManager audioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE); 35 36 String framesPerBuffer = audioManager.getProperty( 37 AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER); 38 mSystemBurstFrames = Integer.parseInt(framesPerBuffer, 10); 39 40 mSystemBufferFrames = mSystemBurstFrames; 41 42 mSystemSampleRate = Integer.parseInt( 43 audioManager.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE)); 44 } 45 getSystemSampleRate()46 public int getSystemSampleRate() { 47 return mSystemSampleRate; 48 } 49 getSystemBufferFrames()50 public int getSystemBufferFrames() { 51 return mSystemBufferFrames; 52 } 53 getSystemBurstFrames()54 public int getSystemBurstFrames() { 55 return mSystemBurstFrames; 56 } 57 }