Merge "Implement android.media.AudioManager.getProperty()" into jb-mr1-dev

This commit is contained in:
Glenn Kasten
2012-09-26 08:51:32 -07:00
committed by Android (Google) Code Review
3 changed files with 29 additions and 2 deletions

View File

@@ -242,6 +242,18 @@ android_media_AudioSystem_getDevicesForStream(JNIEnv *env, jobject thiz, jint st
return (jint) AudioSystem::getDevicesForStream(static_cast <audio_stream_type_t>(stream));
}
static jint
android_media_AudioSystem_getPrimaryOutputSamplingRate(JNIEnv *env, jobject clazz)
{
return (jint) AudioSystem::getPrimaryOutputSamplingRate();
}
static jint
android_media_AudioSystem_getPrimaryOutputFrameCount(JNIEnv *env, jobject clazz)
{
return (jint) AudioSystem::getPrimaryOutputFrameCount();
}
// ----------------------------------------------------------------------------
static JNINativeMethod gMethods[] = {
@@ -263,6 +275,8 @@ static JNINativeMethod gMethods[] = {
{"setMasterMute", "(Z)I", (void *)android_media_AudioSystem_setMasterMute},
{"getMasterMute", "()Z", (void *)android_media_AudioSystem_getMasterMute},
{"getDevicesForStream", "(I)I", (void *)android_media_AudioSystem_getDevicesForStream},
{"getPrimaryOutputSamplingRate", "()I", (void *)android_media_AudioSystem_getPrimaryOutputSamplingRate},
{"getPrimaryOutputFrameCount", "()I", (void *)android_media_AudioSystem_getPrimaryOutputFrameCount},
};
int register_android_media_AudioSystem(JNIEnv *env)

View File

@@ -2474,8 +2474,16 @@ public class AudioManager {
* or null if there is no value for that key.
*/
public String getProperty(String key) {
// implementation to be written
return null;
if (PROPERTY_OUTPUT_SAMPLE_RATE.equals(key)) {
int outputSampleRate = AudioSystem.getPrimaryOutputSamplingRate();
return outputSampleRate > 0 ? Integer.toString(outputSampleRate) : null;
} else if (PROPERTY_OUTPUT_FRAMES_PER_BUFFER.equals(key)) {
int outputFramesPerBuffer = AudioSystem.getPrimaryOutputFrameCount();
return outputFramesPerBuffer > 0 ? Integer.toString(outputFramesPerBuffer) : null;
} else {
// null or unknown key
return null;
}
}
}

View File

@@ -381,4 +381,9 @@ public class AudioSystem
public static native int setMasterMute(boolean mute);
public static native boolean getMasterMute();
public static native int getDevicesForStream(int stream);
// helpers for android.media.AudioManager.getProperty(), see description there for meaning
public static native int getPrimaryOutputSamplingRate();
public static native int getPrimaryOutputFrameCount();
}