MCPcopy Create free account
hub / github.com/android/ndk-samples / StartRecording

Function StartRecording

native-audio/app/src/main/cpp/native-audio-jni.cpp:864–898  ·  view source on GitHub ↗

set the recording state for the audio recorder

Source from the content-addressed store, hash-verified

862
863// set the recording state for the audio recorder
864void StartRecording(JNIEnv*, jclass) {
865 SLresult result;
866
867 if (pthread_mutex_trylock(&audioEngineLock)) {
868 return;
869 }
870 // in case already recording, stop recording and clear buffer queue
871 result =
872 (*recorderRecord)->SetRecordState(recorderRecord, SL_RECORDSTATE_STOPPED);
873 assert(SL_RESULT_SUCCESS == result);
874 (void)result;
875 result = (*recorderBufferQueue)->Clear(recorderBufferQueue);
876 assert(SL_RESULT_SUCCESS == result);
877 (void)result;
878
879 // the buffer is not valid for playback yet
880 recorderSize = 0;
881
882 // enqueue an empty buffer to be filled by the recorder
883 // (for streaming recording, we would enqueue at least 2 empty buffers to
884 // start things off)
885 result = (*recorderBufferQueue)
886 ->Enqueue(recorderBufferQueue, recorderBuffer,
887 RECORDER_FRAMES * sizeof(short));
888 // the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT,
889 // which for this code example would indicate a programming error
890 assert(SL_RESULT_SUCCESS == result);
891 (void)result;
892
893 // start recording
894 result = (*recorderRecord)
895 ->SetRecordState(recorderRecord, SL_RECORDSTATE_RECORDING);
896 assert(SL_RESULT_SUCCESS == result);
897 (void)result;
898}
899
900// shut down the native audio system
901void Shutdown(JNIEnv*, jclass) {

Callers

nothing calls this directly

Calls 1

ClearMethod · 0.80

Tested by

no test coverage detected