Commit 31667804 authored by Adrien Béraud's avatar Adrien Béraud

process the data just recorded

parent 9fb15b5b
...@@ -598,21 +598,22 @@ OpenSLLayer::capture(SLAndroidSimpleBufferQueueItf queue) ...@@ -598,21 +598,22 @@ OpenSLLayer::capture(SLAndroidSimpleBufferQueueItf queue)
{ {
assert(nullptr != queue); assert(nullptr != queue);
AudioBuffer &buffer = getNextRecordBuffer(); AudioBuffer &old_buffer = getNextRecordBuffer();
incrementRecordIndex(); incrementRecordIndex();
AudioBuffer &buffer = getNextRecordBuffer();
SLresult result; SLresult result;
// enqueue an empty buffer to be filled by the recorder // enqueue an empty buffer to be filled by the recorder
// (for streaming recording, we enqueue at least 2 empty buffers to start things off) // (for streaming recording, we enqueue at least 2 empty buffers to start things off)
//result = (*recorderBufferQueue_)->Enqueue(recorderBufferQueue_, buffer.getData()[0].data(), buffer.getData()[0].size());
result = (*recorderBufferQueue_)->Enqueue(recorderBufferQueue_, buffer.getChannel(0)->data(), buffer.frames()*sizeof(SFLAudioSample)); result = (*recorderBufferQueue_)->Enqueue(recorderBufferQueue_, buffer.getChannel(0)->data(), buffer.frames()*sizeof(SFLAudioSample));
audioCaptureFillBuffer(old_buffer);
// the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT, // the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT,
// which for this code example would indicate a programming error // which for this code example would indicate a programming error
assert(SL_RESULT_SUCCESS == result); assert(SL_RESULT_SUCCESS == result);
audioCaptureFillBuffer(buffer);
#ifdef RECORD_AUDIO_TODISK #ifdef RECORD_AUDIO_TODISK
opensl_infile.write((char const *)(buffer.getChannel(0)->data()), buffer.frames()*sizeof(SFLAudioSample)); opensl_infile.write((char const *)(buffer.getChannel(0)->data()), buffer.frames()*sizeof(SFLAudioSample));
#endif #endif
...@@ -625,7 +626,6 @@ OpenSLLayer::audioCaptureCallback(SLAndroidSimpleBufferQueueItf queue, void *con ...@@ -625,7 +626,6 @@ OpenSLLayer::audioCaptureCallback(SLAndroidSimpleBufferQueueItf queue, void *con
static_cast<OpenSLLayer*>(context)->capture(queue); static_cast<OpenSLLayer*>(context)->capture(queue);
} }
void void
OpenSLLayer::updatePreference(AudioPreference &preference, int index, PCMType type) OpenSLLayer::updatePreference(AudioPreference &preference, int index, PCMType type)
{ {
...@@ -734,13 +734,10 @@ bool OpenSLLayer::audioPlaybackFillWithToneOrRingtone(AudioBuffer &buffer) ...@@ -734,13 +734,10 @@ bool OpenSLLayer::audioPlaybackFillWithToneOrRingtone(AudioBuffer &buffer)
// In case of a dtmf, the pointers will be set to nullptr once the dtmf length is // In case of a dtmf, the pointers will be set to nullptr once the dtmf length is
// reached. For this reason we need to fill audio buffer with zeros if pointer is nullptr // reached. For this reason we need to fill audio buffer with zeros if pointer is nullptr
if (tone) { if (tone) {
DEBUG("audioPlaybackFillWithToneOrRingtone tone\n");
tone->getNext(buffer, playbackGain_); tone->getNext(buffer, playbackGain_);
} else if (file_tone) { } else if (file_tone) {
DEBUG("audioPlaybackFillWithToneOrRingtone file_tone\n");
file_tone->getNext(buffer, playbackGain_); file_tone->getNext(buffer, playbackGain_);
} else { } else {
DEBUG("audioPlaybackFillWithToneOrRingtone reset\n");
buffer.reset(); buffer.reset();
} }
......
...@@ -257,8 +257,8 @@ class OpenSLLayer : public AudioLayer { ...@@ -257,8 +257,8 @@ class OpenSLLayer : public AudioLayer {
SLAndroidSimpleBufferQueueItf playbackBufferQueue_; SLAndroidSimpleBufferQueueItf playbackBufferQueue_;
SLAndroidSimpleBufferQueueItf recorderBufferQueue_; SLAndroidSimpleBufferQueueItf recorderBufferQueue_;
std::atomic<int> playbackBufferIndex_; int playbackBufferIndex_;
std::atomic<int> recordBufferIndex_; int recordBufferIndex_;
AudioBufferStack playbackBufferStack_; AudioBufferStack playbackBufferStack_;
AudioBufferStack recordBufferStack_; AudioBufferStack recordBufferStack_;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment