blob: 7775de4f9cb51166cd1389e57f28b9ffabdc28a0 [file] [log] [blame]
package com.google.oboe.samples.liveEffect;
/*
* Copyright 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import android.content.Context;
import android.media.AudioManager;
import android.os.Build;
public enum LiveEffectEngine {
INSTANCE;
// Load native library
static {
System.loadLibrary("liveEffect");
}
// Native methods
static native boolean create();
static native boolean isAAudioRecommended();
static native boolean setAPI(int apiType);
static native boolean setEffectOn(boolean isEffectOn);
static native void setRecordingDeviceId(int deviceId);
static native void setPlaybackDeviceId(int deviceId);
static native void delete();
static native void native_setDefaultStreamValues(int defaultSampleRate, int defaultFramesPerBurst);
static void setDefaultStreamValues(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1){
AudioManager myAudioMgr = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
String sampleRateStr = myAudioMgr.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
int defaultSampleRate = Integer.parseInt(sampleRateStr);
String framesPerBurstStr = myAudioMgr.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER);
int defaultFramesPerBurst = Integer.parseInt(framesPerBurstStr);
native_setDefaultStreamValues(defaultSampleRate, defaultFramesPerBurst);
}
}
}