MCPcopy Create free account
hub / github.com/audeering/opensmile / recordingThreadLoop

Method recordingThreadLoop

src/android/openslesSource.cpp:432–477  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

430}
431
432void cOpenslesSource::recordingThreadLoop()
433{
434 //int16_t * inbuffer = (int16_t *)calloc(1, sizeof(int16_t) * audioBuffersize_);
435 smileMutexLock(threadMutex_);
436 threadActive_ = true;
437 int threadActive = threadActive_;
438 smileMutexUnlock(threadMutex_);
439 SMILE_IMSG(3, "OpenSLES audio recording thread initialized");
440 if (audioDevice_ == NULL) {
441 SMILE_IERR(2, "No openSLES audio device opened, terminating openSLES audio recording thread.");
442 //free(inbuffer);
443 return;
444 }
445 if (openSLstartRecording(audioDevice_) != SL_RESULT_SUCCESS) {
446 SMILE_IERR(1, "Failed to start recording, terminating openSLES audio recording thread.");
447 //free(inbuffer);
448 return;
449 }
450 sWaveParameters pcmParam;
451 pcmParam.nBits = nBits_;
452 pcmParam.nBPS = nBPS_;
453 pcmParam.nChan = nChannels_;
454 // NOTE: we open device before tick-loop to know whether the settings are supported
455 // However we need to check what happens to audio that is recorded while configuration is still going
456 // buffers discarded?
457 // TERMINATING:
458 // 1. set threadActive_ = 0 to terminate the thread (while having mutex threadMutex locked, but unlock after)
459 // 2. notify the audioDevice_->recorderCondition_ to unlock the recorder thread waiting for new audio
460 // 3.
461 while (threadActive) {
462 android_AudioIn2(audioDevice_, &pcmParam);
463 //SMILE_IMSG(4, "read nSamples = %i in thread.", nSamples);
464 // update the thread active status
465 smileMutexLock(threadMutex_);
466 threadActive = threadActive_;
467 smileMutexUnlock(threadMutex_);
468 }
469 SMILE_IMSG(3, "OpenSLES thread was signaled to end.");
470 openSLstopRecording(audioDevice_);
471 SMILE_IMSG(4, "Recording stopped.");
472 //free(inbuffer);
473 smileMutexLock(threadMutex_);
474 threadActive_ = false;
475 threadStarted_ = false;
476 smileMutexUnlock(threadMutex_);
477}
478
479
480

Callers 1

recordingThreadEntryMethod · 0.80

Calls 4

smileMutexLockFunction · 0.85
smileMutexUnlockFunction · 0.85
openSLstartRecordingFunction · 0.85
openSLstopRecordingFunction · 0.85

Tested by

no test coverage detected