summaryrefslogtreecommitdiffstats
path: root/core/jni
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2013-09-09 10:31:59 -0700
committerSandeep Siddhartha <sansid@google.com>2013-09-10 18:03:10 -0700
commit357263da0ec2bc2be9d48c1becc3d94288c2f3ed (patch)
tree386ba527fe3820dea80bffdc4495cac6536e2a9a /core/jni
parentd9f4e0cf2c2466d9e05f8562e55d342934f7ed0d (diff)
downloadframeworks_base-357263da0ec2bc2be9d48c1becc3d94288c2f3ed.zip
frameworks_base-357263da0ec2bc2be9d48c1becc3d94288c2f3ed.tar.gz
frameworks_base-357263da0ec2bc2be9d48c1becc3d94288c2f3ed.tar.bz2
Add HOTWORD as an AudioSource
- This is a low-priority source that can be preempted by others - This is required for scenarios where someone wants an alway-on graceful microphone Bug: 10640877. Change-Id: Idb3577541103717cb713a7a93d3762ad2c2f4710
Diffstat (limited to 'core/jni')
-rw-r--r--core/jni/android_media_AudioRecord.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/core/jni/android_media_AudioRecord.cpp b/core/jni/android_media_AudioRecord.cpp
index 0cd6f4a..1c43cc5 100644
--- a/core/jni/android_media_AudioRecord.cpp
+++ b/core/jni/android_media_AudioRecord.cpp
@@ -190,7 +190,7 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
int frameSize = nbChannels * bytesPerSample;
size_t frameCount = buffSizeInBytes / frameSize;
- if (uint32_t(source) >= AUDIO_SOURCE_CNT) {
+ if ((uint32_t(source) >= AUDIO_SOURCE_CNT) && (uint32_t(source) != AUDIO_SOURCE_HOTWORD)) {
ALOGE("Error creating AudioRecord: unknown source.");
return AUDIORECORD_ERROR_SETUP_INVALIDSOURCE;
}
@@ -387,6 +387,9 @@ static jint android_media_AudioRecord_readInByteArray(JNIEnv *env, jobject thiz
(jint)recorderBuffSize : sizeInBytes );
env->ReleaseByteArrayElements(javaAudioData, recordBuff, 0);
+ if (readSize < 0) {
+ readSize = AUDIORECORD_ERROR_INVALID_OPERATION;
+ }
return (jint) readSize;
}
@@ -427,8 +430,12 @@ static jint android_media_AudioRecord_readInDirectBuffer(JNIEnv *env, jobject t
}
// read new data from the recorder
- return (jint) lpRecorder->read(nativeFromJavaBuf,
+ ssize_t readSize = lpRecorder->read(nativeFromJavaBuf,
capacity < sizeInBytes ? capacity : sizeInBytes);
+ if (readSize < 0) {
+ readSize = AUDIORECORD_ERROR_INVALID_OPERATION;
+ }
+ return (jint)readSize;
}