summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorDima Zavin <dima@android.com>2011-04-19 22:30:36 -0700
committerDima Zavin <dima@android.com>2011-04-27 13:10:10 -0700
commit24fc2fb1c541e954b83fd31ea9f786a5e9b45501 (patch)
treee85b3ff86b73d56e16ab640919d251c046371c65 /core
parent4dc22e77cfd2a1c3671e5646ee87c5e4c15596a0 (diff)
downloadframeworks_base-24fc2fb1c541e954b83fd31ea9f786a5e9b45501.zip
frameworks_base-24fc2fb1c541e954b83fd31ea9f786a5e9b45501.tar.gz
frameworks_base-24fc2fb1c541e954b83fd31ea9f786a5e9b45501.tar.bz2
audio/media: convert to using the audio HAL and new audio defs
Change-Id: Ibc637918637329e4f2b62f4ac7781102fbc269f5 Signed-off-by: Dima Zavin <dima@android.com>
Diffstat (limited to 'core')
-rw-r--r--core/jni/android_media_AudioRecord.cpp13
-rw-r--r--core/jni/android_media_AudioSystem.cpp23
-rw-r--r--core/jni/android_media_AudioTrack.cpp51
3 files changed, 48 insertions, 39 deletions
diff --git a/core/jni/android_media_AudioRecord.cpp b/core/jni/android_media_AudioRecord.cpp
index 1b6b24f..0afc523 100644
--- a/core/jni/android_media_AudioRecord.cpp
+++ b/core/jni/android_media_AudioRecord.cpp
@@ -31,6 +31,9 @@
#include "media/AudioRecord.h"
#include "media/mediarecorder.h"
+#include <cutils/bitops.h>
+
+#include <hardware/audio.h>
// ----------------------------------------------------------------------------
@@ -130,11 +133,11 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
//LOGV("sampleRate=%d, audioFormat=%d, channels=%x, buffSizeInBytes=%d",
// sampleRateInHertz, audioFormat, channels, buffSizeInBytes);
- if (!AudioSystem::isInputChannel(channels)) {
+ if (!audio_is_input_channel(channels)) {
LOGE("Error creating AudioRecord: channel count is not 1 or 2.");
return AUDIORECORD_ERROR_SETUP_INVALIDCHANNELMASK;
}
- uint32_t nbChannels = AudioSystem::popCount(channels);
+ uint32_t nbChannels = popcount(channels);
// compare the format against the Java constants
if ((audioFormat != javaAudioRecordFields.PCM16)
@@ -145,7 +148,7 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
int bytesPerSample = audioFormat==javaAudioRecordFields.PCM16 ? 2 : 1;
int format = audioFormat==javaAudioRecordFields.PCM16 ?
- AudioSystem::PCM_16_BIT : AudioSystem::PCM_8_BIT;
+ AUDIO_FORMAT_PCM_16_BIT : AUDIO_FORMAT_PCM_8_BIT;
if (buffSizeInBytes == 0) {
LOGE("Error creating AudioRecord: frameCount is 0.");
@@ -154,7 +157,7 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
int frameSize = nbChannels * bytesPerSample;
size_t frameCount = buffSizeInBytes / frameSize;
- if (source >= AUDIO_SOURCE_LIST_END) {
+ if (source >= AUDIO_SOURCE_CNT) {
LOGE("Error creating AudioRecord: unknown source.");
return AUDIORECORD_ERROR_SETUP_INVALIDSOURCE;
}
@@ -463,7 +466,7 @@ static jint android_media_AudioRecord_get_min_buff_size(JNIEnv *env, jobject th
status_t result = AudioRecord::getMinFrameCount(&frameCount,
sampleRateInHertz,
(audioFormat == javaAudioRecordFields.PCM16 ?
- AudioSystem::PCM_16_BIT : AudioSystem::PCM_8_BIT),
+ AUDIO_FORMAT_PCM_16_BIT : AUDIO_FORMAT_PCM_8_BIT),
nbChannels);
if (result == BAD_VALUE) {
diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp
index 5016bf9..09c0953 100644
--- a/core/jni/android_media_AudioSystem.cpp
+++ b/core/jni/android_media_AudioSystem.cpp
@@ -30,6 +30,9 @@
#include <media/AudioSystem.h>
#include <media/AudioTrack.h>
+#include <hardware/audio.h>
+#include <hardware/audio_policy.h>
+
// ----------------------------------------------------------------------------
using namespace android;
@@ -129,8 +132,8 @@ static int
android_media_AudioSystem_setDeviceConnectionState(JNIEnv *env, jobject thiz, jint device, jint state, jstring device_address)
{
const char *c_address = env->GetStringUTFChars(device_address, NULL);
- int status = check_AudioSystem_Command(AudioSystem::setDeviceConnectionState(static_cast <AudioSystem::audio_devices>(device),
- static_cast <AudioSystem::device_connection_state>(state),
+ int status = check_AudioSystem_Command(AudioSystem::setDeviceConnectionState(static_cast <audio_devices_t>(device),
+ static_cast <audio_policy_dev_state_t>(state),
c_address));
env->ReleaseStringUTFChars(device_address, c_address);
return status;
@@ -140,7 +143,7 @@ static int
android_media_AudioSystem_getDeviceConnectionState(JNIEnv *env, jobject thiz, jint device, jstring device_address)
{
const char *c_address = env->GetStringUTFChars(device_address, NULL);
- int state = static_cast <int>(AudioSystem::getDeviceConnectionState(static_cast <AudioSystem::audio_devices>(device),
+ int state = static_cast <int>(AudioSystem::getDeviceConnectionState(static_cast <audio_devices_t>(device),
c_address));
env->ReleaseStringUTFChars(device_address, c_address);
return state;
@@ -161,20 +164,20 @@ android_media_AudioSystem_setRingerMode(JNIEnv *env, jobject thiz, jint mode, ji
static int
android_media_AudioSystem_setForceUse(JNIEnv *env, jobject thiz, jint usage, jint config)
{
- return check_AudioSystem_Command(AudioSystem::setForceUse(static_cast <AudioSystem::force_use>(usage),
- static_cast <AudioSystem::forced_config>(config)));
+ return check_AudioSystem_Command(AudioSystem::setForceUse(static_cast <audio_policy_force_use_t>(usage),
+ static_cast <audio_policy_forced_cfg_t>(config)));
}
static int
android_media_AudioSystem_getForceUse(JNIEnv *env, jobject thiz, jint usage)
{
- return static_cast <int>(AudioSystem::getForceUse(static_cast <AudioSystem::force_use>(usage)));
+ return static_cast <int>(AudioSystem::getForceUse(static_cast <audio_policy_force_use_t>(usage)));
}
static int
android_media_AudioSystem_initStreamVolume(JNIEnv *env, jobject thiz, jint stream, jint indexMin, jint indexMax)
{
- return check_AudioSystem_Command(AudioSystem::initStreamVolume(static_cast <AudioSystem::stream_type>(stream),
+ return check_AudioSystem_Command(AudioSystem::initStreamVolume(static_cast <audio_stream_type_t>(stream),
indexMin,
indexMax));
}
@@ -182,14 +185,14 @@ android_media_AudioSystem_initStreamVolume(JNIEnv *env, jobject thiz, jint strea
static int
android_media_AudioSystem_setStreamVolumeIndex(JNIEnv *env, jobject thiz, jint stream, jint index)
{
- return check_AudioSystem_Command(AudioSystem::setStreamVolumeIndex(static_cast <AudioSystem::stream_type>(stream), index));
+ return check_AudioSystem_Command(AudioSystem::setStreamVolumeIndex(static_cast <audio_stream_type_t>(stream), index));
}
static int
android_media_AudioSystem_getStreamVolumeIndex(JNIEnv *env, jobject thiz, jint stream)
{
int index;
- if (AudioSystem::getStreamVolumeIndex(static_cast <AudioSystem::stream_type>(stream), &index) != NO_ERROR) {
+ if (AudioSystem::getStreamVolumeIndex(static_cast <audio_stream_type_t>(stream), &index) != NO_ERROR) {
index = -1;
}
return index;
@@ -198,7 +201,7 @@ android_media_AudioSystem_getStreamVolumeIndex(JNIEnv *env, jobject thiz, jint s
static jint
android_media_AudioSystem_getDevicesForStream(JNIEnv *env, jobject thiz, jint stream)
{
- return (jint) AudioSystem::getDevicesForStream(static_cast <AudioSystem::stream_type>(stream));
+ return (jint) AudioSystem::getDevicesForStream(static_cast <audio_stream_type_t>(stream));
}
// ----------------------------------------------------------------------------
diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp
index 587a16c..e3b2f2c 100644
--- a/core/jni/android_media_AudioTrack.cpp
+++ b/core/jni/android_media_AudioTrack.cpp
@@ -33,6 +33,9 @@
#include <binder/MemoryHeapBase.h>
#include <binder/MemoryBase.h>
+#include <cutils/bitops.h>
+
+#include <hardware/audio.h>
// ----------------------------------------------------------------------------
@@ -77,7 +80,7 @@ class AudioTrackJniStorage {
AudioTrackJniStorage() {
mCallbackData.audioTrack_class = 0;
mCallbackData.audioTrack_ref = 0;
- mStreamType = AudioSystem::DEFAULT;
+ mStreamType = AUDIO_STREAM_DEFAULT;
}
~AudioTrackJniStorage() {
@@ -181,30 +184,30 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th
return AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM;
}
- if (!AudioSystem::isOutputChannel(channels)) {
+ if (!audio_is_output_channel(channels)) {
LOGE("Error creating AudioTrack: invalid channel mask.");
return AUDIOTRACK_ERROR_SETUP_INVALIDCHANNELMASK;
}
- int nbChannels = AudioSystem::popCount(channels);
+ int nbChannels = popcount(channels);
// check the stream type
- AudioSystem::stream_type atStreamType;
+ audio_stream_type_t atStreamType;
if (streamType == javaAudioTrackFields.STREAM_VOICE_CALL) {
- atStreamType = AudioSystem::VOICE_CALL;
+ atStreamType = AUDIO_STREAM_VOICE_CALL;
} else if (streamType == javaAudioTrackFields.STREAM_SYSTEM) {
- atStreamType = AudioSystem::SYSTEM;
+ atStreamType = AUDIO_STREAM_SYSTEM;
} else if (streamType == javaAudioTrackFields.STREAM_RING) {
- atStreamType = AudioSystem::RING;
+ atStreamType = AUDIO_STREAM_RING;
} else if (streamType == javaAudioTrackFields.STREAM_MUSIC) {
- atStreamType = AudioSystem::MUSIC;
+ atStreamType = AUDIO_STREAM_MUSIC;
} else if (streamType == javaAudioTrackFields.STREAM_ALARM) {
- atStreamType = AudioSystem::ALARM;
+ atStreamType = AUDIO_STREAM_ALARM;
} else if (streamType == javaAudioTrackFields.STREAM_NOTIFICATION) {
- atStreamType = AudioSystem::NOTIFICATION;
+ atStreamType = AUDIO_STREAM_NOTIFICATION;
} else if (streamType == javaAudioTrackFields.STREAM_BLUETOOTH_SCO) {
- atStreamType = AudioSystem::BLUETOOTH_SCO;
+ atStreamType = AUDIO_STREAM_BLUETOOTH_SCO;
} else if (streamType == javaAudioTrackFields.STREAM_DTMF) {
- atStreamType = AudioSystem::DTMF;
+ atStreamType = AUDIO_STREAM_DTMF;
} else {
LOGE("Error creating AudioTrack: unknown stream type.");
return AUDIOTRACK_ERROR_SETUP_INVALIDSTREAMTYPE;
@@ -233,7 +236,7 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th
// compute the frame count
int bytesPerSample = audioFormat == javaAudioTrackFields.PCM16 ? 2 : 1;
int format = audioFormat == javaAudioTrackFields.PCM16 ?
- AudioSystem::PCM_16_BIT : AudioSystem::PCM_8_BIT;
+ AUDIO_FORMAT_PCM_16_BIT : AUDIO_FORMAT_PCM_8_BIT;
int frameCount = buffSizeInBytes / (nbChannels * bytesPerSample);
AudioTrackJniStorage* lpJniStorage = new AudioTrackJniStorage();
@@ -755,25 +758,25 @@ static jint android_media_AudioTrack_get_output_sample_rate(JNIEnv *env, jobjec
int afSamplingRate;
// convert the stream type from Java to native value
// FIXME: code duplication with android_media_AudioTrack_native_setup()
- AudioSystem::stream_type nativeStreamType;
+ audio_stream_type_t nativeStreamType;
if (javaStreamType == javaAudioTrackFields.STREAM_VOICE_CALL) {
- nativeStreamType = AudioSystem::VOICE_CALL;
+ nativeStreamType = AUDIO_STREAM_VOICE_CALL;
} else if (javaStreamType == javaAudioTrackFields.STREAM_SYSTEM) {
- nativeStreamType = AudioSystem::SYSTEM;
+ nativeStreamType = AUDIO_STREAM_SYSTEM;
} else if (javaStreamType == javaAudioTrackFields.STREAM_RING) {
- nativeStreamType = AudioSystem::RING;
+ nativeStreamType = AUDIO_STREAM_RING;
} else if (javaStreamType == javaAudioTrackFields.STREAM_MUSIC) {
- nativeStreamType = AudioSystem::MUSIC;
+ nativeStreamType = AUDIO_STREAM_MUSIC;
} else if (javaStreamType == javaAudioTrackFields.STREAM_ALARM) {
- nativeStreamType = AudioSystem::ALARM;
+ nativeStreamType = AUDIO_STREAM_ALARM;
} else if (javaStreamType == javaAudioTrackFields.STREAM_NOTIFICATION) {
- nativeStreamType = AudioSystem::NOTIFICATION;
+ nativeStreamType = AUDIO_STREAM_NOTIFICATION;
} else if (javaStreamType == javaAudioTrackFields.STREAM_BLUETOOTH_SCO) {
- nativeStreamType = AudioSystem::BLUETOOTH_SCO;
+ nativeStreamType = AUDIO_STREAM_BLUETOOTH_SCO;
} else if (javaStreamType == javaAudioTrackFields.STREAM_DTMF) {
- nativeStreamType = AudioSystem::DTMF;
+ nativeStreamType = AUDIO_STREAM_DTMF;
} else {
- nativeStreamType = AudioSystem::DEFAULT;
+ nativeStreamType = AUDIO_STREAM_DEFAULT;
}
if (AudioSystem::getOutputSamplingRate(&afSamplingRate, nativeStreamType) != NO_ERROR) {
@@ -793,7 +796,7 @@ static jint android_media_AudioTrack_get_min_buff_size(JNIEnv *env, jobject thi
jint sampleRateInHertz, jint nbChannels, jint audioFormat) {
int frameCount = 0;
- if (AudioTrack::getMinFrameCount(&frameCount, AudioSystem::DEFAULT,
+ if (AudioTrack::getMinFrameCount(&frameCount, AUDIO_STREAM_DEFAULT,
sampleRateInHertz) != NO_ERROR) {
return -1;
}