@@ -72,7 +72,7 @@ Mutex sLock;
7272#define AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED -20
7373
7474jint android_media_translateRecorderErrorCode (int code) {
75- switch (code) {
75+ switch (code) {
7676 case NO_ERROR:
7777 return AUDIORECORD_SUCCESS;
7878 case BAD_VALUE:
@@ -81,7 +81,7 @@ jint android_media_translateRecorderErrorCode(int code) {
8181 return AUDIORECORD_ERROR_INVALID_OPERATION;
8282 default :
8383 return AUDIORECORD_ERROR;
84- }
84+ }
8585}
8686
8787
@@ -90,14 +90,14 @@ static void recorderCallback(int event, void* user, void *info) {
9090 if (event == AudioRecord::EVENT_MORE_DATA) {
9191 // set size to 0 to signal we're not using the callback to read more data
9292 AudioRecord::Buffer* pBuff = (AudioRecord::Buffer*)info;
93- pBuff->size = 0 ;
94-
93+ pBuff->size = 0 ;
94+
9595 } else if (event == AudioRecord::EVENT_MARKER) {
9696 audiorecord_callback_cookie *callbackInfo = (audiorecord_callback_cookie *)user;
9797 JNIEnv *env = AndroidRuntime::getJNIEnv ();
9898 if (user && env) {
9999 env->CallStaticVoidMethod (
100- callbackInfo->audioRecord_class ,
100+ callbackInfo->audioRecord_class ,
101101 javaAudioRecordFields.postNativeEventInJava ,
102102 callbackInfo->audioRecord_ref , event, 0 ,0 , NULL );
103103 if (env->ExceptionCheck ()) {
@@ -111,7 +111,7 @@ static void recorderCallback(int event, void* user, void *info) {
111111 JNIEnv *env = AndroidRuntime::getJNIEnv ();
112112 if (user && env) {
113113 env->CallStaticVoidMethod (
114- callbackInfo->audioRecord_class ,
114+ callbackInfo->audioRecord_class ,
115115 javaAudioRecordFields.postNativeEventInJava ,
116116 callbackInfo->audioRecord_ref , event, 0 ,0 , NULL );
117117 if (env->ExceptionCheck ()) {
@@ -140,7 +140,7 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
140140 uint32_t nbChannels = popcount (channels);
141141
142142 // compare the format against the Java constants
143- if ((audioFormat != javaAudioRecordFields.PCM16 )
143+ if ((audioFormat != javaAudioRecordFields.PCM16 )
144144 && (audioFormat != javaAudioRecordFields.PCM8 )) {
145145 ALOGE (" Error creating AudioRecord: unsupported audio format." );
146146 return AUDIORECORD_ERROR_SETUP_INVALIDFORMAT;
@@ -156,7 +156,7 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
156156 }
157157 int frameSize = nbChannels * bytesPerSample;
158158 size_t frameCount = buffSizeInBytes / frameSize;
159-
159+
160160 if (uint32_t (source) >= AUDIO_SOURCE_CNT) {
161161 ALOGE (" Error creating AudioRecord: unknown source." );
162162 return AUDIORECORD_ERROR_SETUP_INVALIDSOURCE;
@@ -181,11 +181,11 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
181181
182182 // create an uninitialized AudioRecord object
183183 lpRecorder = new AudioRecord ();
184- if (lpRecorder == NULL ) {
184+ if (lpRecorder == NULL ) {
185185 ALOGE (" Error creating AudioRecord instance." );
186186 return AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED;
187187 }
188-
188+
189189 // create the callback information:
190190 // this data will be passed with every AudioRecord callback
191191 jclass clazz = env->GetObjectClass (thiz);
@@ -197,7 +197,7 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
197197 lpCallbackData->audioRecord_class = (jclass)env->NewGlobalRef (clazz);
198198 // we use a weak reference so the AudioRecord object can be garbage collected.
199199 lpCallbackData->audioRecord_ref = env->NewGlobalRef (weak_this);
200-
200+
201201 lpRecorder->set ((audio_source_t ) source,
202202 sampleRateInHertz,
203203 format, // word length, PCM
@@ -210,7 +210,7 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
210210 true , // threadCanCallJava)
211211 sessionId);
212212
213- if (lpRecorder->initCheck () != NO_ERROR) {
213+ if (lpRecorder->initCheck () != NO_ERROR) {
214214 ALOGE (" Error creating AudioRecord instance: initialization check failed." );
215215 goto native_init_failure;
216216 }
@@ -225,16 +225,16 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
225225 env->ReleasePrimitiveArrayCritical (jSession, nSession, 0 );
226226 nSession = NULL ;
227227
228- // save our newly created C++ AudioRecord in the "nativeRecorderInJavaObj" field
228+ // save our newly created C++ AudioRecord in the "nativeRecorderInJavaObj" field
229229 // of the Java object
230230 env->SetIntField (thiz, javaAudioRecordFields.nativeRecorderInJavaObj , (int )lpRecorder);
231-
231+
232232 // save our newly created callback information in the "nativeCallbackCookie" field
233233 // of the Java object (in mNativeCallbackCookie) so we can free the memory in finalize()
234234 env->SetIntField (thiz, javaAudioRecordFields.nativeCallbackCookie , (int )lpCallbackData);
235-
235+
236236 return AUDIORECORD_SUCCESS;
237-
237+
238238 // failure:
239239native_init_failure:
240240 env->DeleteGlobalRef (lpCallbackData->audioRecord_class );
@@ -246,7 +246,7 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
246246
247247 env->SetIntField (thiz, javaAudioRecordFields.nativeRecorderInJavaObj , 0 );
248248 env->SetIntField (thiz, javaAudioRecordFields.nativeCallbackCookie , 0 );
249-
249+
250250 return AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED;
251251}
252252
@@ -256,13 +256,13 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
256256static int
257257android_media_AudioRecord_start (JNIEnv *env, jobject thiz)
258258{
259- AudioRecord *lpRecorder =
259+ AudioRecord *lpRecorder =
260260 (AudioRecord *)env->GetIntField (thiz, javaAudioRecordFields.nativeRecorderInJavaObj );
261261 if (lpRecorder == NULL ) {
262262 jniThrowException (env, " java/lang/IllegalStateException" , NULL );
263263 return AUDIORECORD_ERROR;
264264 }
265-
265+
266266 return android_media_translateRecorderErrorCode (lpRecorder->start ());
267267}
268268
@@ -271,7 +271,7 @@ android_media_AudioRecord_start(JNIEnv *env, jobject thiz)
271271static void
272272android_media_AudioRecord_stop (JNIEnv *env, jobject thiz)
273273{
274- AudioRecord *lpRecorder =
274+ AudioRecord *lpRecorder =
275275 (AudioRecord *)env->GetIntField (thiz, javaAudioRecordFields.nativeRecorderInJavaObj );
276276 if (lpRecorder == NULL ) {
277277 jniThrowException (env, " java/lang/IllegalStateException" , NULL );
@@ -288,7 +288,7 @@ static void android_media_AudioRecord_release(JNIEnv *env, jobject thiz) {
288288
289289 // serialize access. Ugly, but functional.
290290 Mutex::Autolock lock (&sLock );
291- AudioRecord *lpRecorder =
291+ AudioRecord *lpRecorder =
292292 (AudioRecord *)env->GetIntField (thiz, javaAudioRecordFields.nativeRecorderInJavaObj );
293293 audiorecord_callback_cookie *lpCookie = (audiorecord_callback_cookie *)env->GetIntField (
294294 thiz, javaAudioRecordFields.nativeCallbackCookie );
@@ -304,7 +304,7 @@ static void android_media_AudioRecord_release(JNIEnv *env, jobject thiz) {
304304 lpRecorder->stop ();
305305 delete lpRecorder;
306306 }
307-
307+
308308 // delete the callback information
309309 if (lpCookie) {
310310 ALOGV (" deleting lpCookie: %x\n " , (int )lpCookie);
@@ -329,7 +329,7 @@ static jint android_media_AudioRecord_readInByteArray(JNIEnv *env, jobject thiz
329329 AudioRecord *lpRecorder = NULL ;
330330
331331 // get the audio recorder from which we'll read new audio samples
332- lpRecorder =
332+ lpRecorder =
333333 (AudioRecord *)env->GetIntField (thiz, javaAudioRecordFields.nativeRecorderInJavaObj );
334334 if (lpRecorder == NULL ) {
335335 ALOGE (" Unable to retrieve AudioRecord object, can't record" );
@@ -355,8 +355,8 @@ static jint android_media_AudioRecord_readInByteArray(JNIEnv *env, jobject thiz
355355
356356 // read the new audio data from the native AudioRecord object
357357 ssize_t recorderBuffSize = lpRecorder->frameCount ()*lpRecorder->frameSize ();
358- ssize_t readSize = lpRecorder->read (recordBuff + offsetInBytes,
359- sizeInBytes > (jint)recorderBuffSize ?
358+ ssize_t readSize = lpRecorder->read (recordBuff + offsetInBytes,
359+ sizeInBytes > (jint)recorderBuffSize ?
360360 (jint)recorderBuffSize : sizeInBytes );
361361 env->ReleaseByteArrayElements (javaAudioData, recordBuff, 0 );
362362
@@ -381,41 +381,41 @@ static jint android_media_AudioRecord_readInDirectBuffer(JNIEnv *env, jobject t
381381 // ALOGV("Entering android_media_AudioRecord_readInBuffer");
382382
383383 // get the audio recorder from which we'll read new audio samples
384- lpRecorder =
384+ lpRecorder =
385385 (AudioRecord *)env->GetIntField (thiz, javaAudioRecordFields.nativeRecorderInJavaObj );
386- if (lpRecorder==NULL )
386+ if (lpRecorder==NULL )
387387 return 0 ;
388388
389389 // direct buffer and direct access supported?
390390 long capacity = env->GetDirectBufferCapacity (jBuffer);
391- if (capacity == -1 ) {
391+ if (capacity == -1 ) {
392392 // buffer direct access is not supported
393393 ALOGE (" Buffer direct access is not supported, can't record" );
394394 return 0 ;
395395 }
396396 // ALOGV("capacity = %ld", capacity);
397397 jbyte* nativeFromJavaBuf = (jbyte*) env->GetDirectBufferAddress (jBuffer);
398- if (nativeFromJavaBuf==NULL ) {
398+ if (nativeFromJavaBuf==NULL ) {
399399 ALOGE (" Buffer direct access is not supported, can't record" );
400400 return 0 ;
401- }
401+ }
402402
403403 // read new data from the recorder
404- return (jint) lpRecorder->read (nativeFromJavaBuf,
404+ return (jint) lpRecorder->read (nativeFromJavaBuf,
405405 capacity < sizeInBytes ? capacity : sizeInBytes);
406406}
407407
408408
409409// ----------------------------------------------------------------------------
410- static jint android_media_AudioRecord_set_marker_pos (JNIEnv *env, jobject thiz,
410+ static jint android_media_AudioRecord_set_marker_pos (JNIEnv *env, jobject thiz,
411411 jint markerPos) {
412-
412+
413413 AudioRecord *lpRecorder = (AudioRecord *)env->GetIntField (
414414 thiz, javaAudioRecordFields.nativeRecorderInJavaObj );
415-
415+
416416 if (lpRecorder) {
417- return
418- android_media_translateRecorderErrorCode ( lpRecorder->setMarkerPosition (markerPos) );
417+ return
418+ android_media_translateRecorderErrorCode ( lpRecorder->setMarkerPosition (markerPos) );
419419 } else {
420420 jniThrowException (env, " java/lang/IllegalStateException" ,
421421 " Unable to retrieve AudioRecord pointer for setMarkerPosition()" );
@@ -426,11 +426,11 @@ static jint android_media_AudioRecord_set_marker_pos(JNIEnv *env, jobject thiz,
426426
427427// ----------------------------------------------------------------------------
428428static jint android_media_AudioRecord_get_marker_pos (JNIEnv *env, jobject thiz) {
429-
429+
430430 AudioRecord *lpRecorder = (AudioRecord *)env->GetIntField (
431431 thiz, javaAudioRecordFields.nativeRecorderInJavaObj );
432432 uint32_t markerPos = 0 ;
433-
433+
434434 if (lpRecorder) {
435435 lpRecorder->getMarkerPosition (&markerPos);
436436 return (jint)markerPos;
@@ -445,28 +445,28 @@ static jint android_media_AudioRecord_get_marker_pos(JNIEnv *env, jobject thiz)
445445// ----------------------------------------------------------------------------
446446static jint android_media_AudioRecord_set_pos_update_period (JNIEnv *env, jobject thiz,
447447 jint period) {
448-
448+
449449 AudioRecord *lpRecorder = (AudioRecord *)env->GetIntField (
450450 thiz, javaAudioRecordFields.nativeRecorderInJavaObj );
451-
451+
452452 if (lpRecorder) {
453- return
454- android_media_translateRecorderErrorCode ( lpRecorder->setPositionUpdatePeriod (period) );
453+ return
454+ android_media_translateRecorderErrorCode ( lpRecorder->setPositionUpdatePeriod (period) );
455455 } else {
456456 jniThrowException (env, " java/lang/IllegalStateException" ,
457457 " Unable to retrieve AudioRecord pointer for setPositionUpdatePeriod()" );
458458 return AUDIORECORD_ERROR;
459- }
459+ }
460460}
461461
462462
463463// ----------------------------------------------------------------------------
464464static jint android_media_AudioRecord_get_pos_update_period (JNIEnv *env, jobject thiz) {
465-
465+
466466 AudioRecord *lpRecorder = (AudioRecord *)env->GetIntField (
467467 thiz, javaAudioRecordFields.nativeRecorderInJavaObj );
468468 uint32_t period = 0 ;
469-
469+
470470 if (lpRecorder) {
471471 lpRecorder->getPositionUpdatePeriod (&period);
472472 return (jint)period;
@@ -514,7 +514,7 @@ static JNINativeMethod gMethods[] = {
514514 (void *)android_media_AudioRecord_setup},
515515 {" native_finalize" , " ()V" , (void *)android_media_AudioRecord_finalize},
516516 {" native_release" , " ()V" , (void *)android_media_AudioRecord_release},
517- {" native_read_in_byte_array" ,
517+ {" native_read_in_byte_array" ,
518518 " ([BII)I" , (void *)android_media_AudioRecord_readInByteArray},
519519 {" native_read_in_short_array" ,
520520 " ([SII)I" , (void *)android_media_AudioRecord_readInShortArray},
@@ -541,7 +541,7 @@ static JNINativeMethod gMethods[] = {
541541
542542// ----------------------------------------------------------------------------
543543
544- extern bool android_media_getIntConstantFromClass (JNIEnv* pEnv,
544+ extern bool android_media_getIntConstantFromClass (JNIEnv* pEnv,
545545 jclass theClass, const char * className, const char * constName, int * constVal);
546546
547547// ----------------------------------------------------------------------------
@@ -550,7 +550,7 @@ int register_android_media_AudioRecord(JNIEnv *env)
550550 javaAudioRecordFields.postNativeEventInJava = NULL ;
551551 javaAudioRecordFields.nativeRecorderInJavaObj = NULL ;
552552 javaAudioRecordFields.nativeCallbackCookie = NULL ;
553-
553+
554554
555555 // Get the AudioRecord class
556556 jclass audioRecordClass = env->FindClass (kClassPathName );
@@ -569,7 +569,7 @@ int register_android_media_AudioRecord(JNIEnv *env)
569569
570570 // Get the variables
571571 // mNativeRecorderInJavaObj
572- javaAudioRecordFields.nativeRecorderInJavaObj =
572+ javaAudioRecordFields.nativeRecorderInJavaObj =
573573 env->GetFieldID (audioRecordClass,
574574 JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME, " I" );
575575 if (javaAudioRecordFields.nativeRecorderInJavaObj == NULL ) {
@@ -592,13 +592,13 @@ int register_android_media_AudioRecord(JNIEnv *env)
592592 ALOGE (" Can't find %s" , JAVA_AUDIOFORMAT_CLASS_NAME);
593593 return -1 ;
594594 }
595- if ( !android_media_getIntConstantFromClass (env, audioFormatClass,
596- JAVA_AUDIOFORMAT_CLASS_NAME,
595+ if ( !android_media_getIntConstantFromClass (env, audioFormatClass,
596+ JAVA_AUDIOFORMAT_CLASS_NAME,
597597 JAVA_CONST_PCM16_NAME, &(javaAudioRecordFields.PCM16 ))
598- || !android_media_getIntConstantFromClass (env, audioFormatClass,
599- JAVA_AUDIOFORMAT_CLASS_NAME,
598+ || !android_media_getIntConstantFromClass (env, audioFormatClass,
599+ JAVA_AUDIOFORMAT_CLASS_NAME,
600600 JAVA_CONST_PCM8_NAME, &(javaAudioRecordFields.PCM8 )) ) {
601- // error log performed in getIntConstantFromClass()
601+ // error log performed in getIntConstantFromClass()
602602 return -1 ;
603603 }
604604
0 commit comments