Commit b6126ba4 authored by Alexandre Savard's avatar Alexandre Savard

#15223: Fix audiortp too slow bug using usleep

added audio record-to-disk debug
parent ab62e7d9
......@@ -225,6 +225,12 @@ bool AudioLayer::audioPlaybackFillBuffer(AudioBuffer &buffer) {
return bufferFilled;
}
// #define RECORD_TOMAIN_TODISK
#ifdef RECORD_TOMAIN_TODISK
#include <fstream>
std::ofstream opensl_tomainbuffer("/data/data/com.savoirfairelinux.sflphone/opensl_tomain.raw", std::ofstream::out | std::ofstream::binary);
#endif
void AudioLayer::audioCaptureFillBuffer(AudioBuffer &buffer) {
const int toGetBytes = buffer.size();
const int toGetSamples = buffer.length();
......@@ -248,6 +254,9 @@ void AudioLayer::audioCaptureFillBuffer(AudioBuffer &buffer) {
mbuffer.putData(rsmpl_out_ptr, rsmpl_out.size(), MainBuffer::DEFAULT_ID);
} else {
dcblocker_.process(in_ptr, in_ptr, toGetSamples);
#ifdef RECORD_TOMAIN_TODISK
opensl_tomainbuffer.write((char const *)in_ptr, toGetBytes/);
#endif
mbuffer.putData(in_ptr, toGetBytes, MainBuffer::DEFAULT_ID);
}
}
......@@ -44,10 +44,16 @@
namespace sfl {
// #define RTP_RECTODISK
#ifdef RTP_RECTODISK
std::ofstream beforedecode("/data/data/beforedecoding.raw", std::ofstream::binary);
std::ofstream afterdecode("/data/data/afterdecoding.raw", std::ofstream::binary);
// #define RTP_DECODE_RECTODISK
#ifdef RTP_DECODE_RECTODISK
std::ofstream beforedecode("/data/data/com.savoirfairelinux.sflphone/beforedecoding.raw", std::ofstream::binary);
std::ofstream afterdecode("/data/data/com.savoirfairelinux.sflphone/afterdecoding.raw", std::ofstream::binary);
#endif
// #define RTP_ENCODE_RECTODISK
#ifdef RTP_ENCODE_RECTODISK
std::ofstream beforeencode("/data/data/com.savoirfairelinux.sflphone/beforeencode.raw", std::ofstream::binary);
std::ofstream beforesend("/data/data/com.savoirfairelinux.sflphone/beforesend.raw", std::ofstream::binary);
#endif
DTMFEvent::DTMFEvent(int digit) : payload(), newevent(true), length(1000)
......@@ -96,7 +102,7 @@ bool AudioRtpRecord::isDead()
AudioRtpRecord::~AudioRtpRecord()
{
dead_ = true;
#ifdef RTP_RECTODISK
#ifdef RTP_DECODE_RECTODISK
beforedecode.close();
afterdecode.close();
#endif
......@@ -197,6 +203,10 @@ int AudioRtpRecordHandler::processDataEncode()
SFLDataFormat *micData = audioRtpRecord_.decData_.data();
const size_t bytes = Manager::instance().getMainBuffer().getData(micData, bytesToGet, id_);
#ifdef RTP_ENCODE_RECTODISK
beforeencode.write((const char *)micData, bytesToGet);
#endif
if (bytes != bytesToGet) {
ERROR("Asked for %d bytes from mainbuffer, got %d", bytesToGet, bytes);
return 0;
......@@ -228,6 +238,10 @@ int AudioRtpRecordHandler::processDataEncode()
}
#endif
#ifdef RTP_ENCODE_RECTODISK
beforesend.write((const char *)(micData), getCodecFrameSize()*2);
#endif
{
ost::MutexLock lock(audioRtpRecord_.audioCodecMutex_);
RETURN_IF_NULL(audioRtpRecord_.audioCodec_, 0, "Audio codec already destroyed");
......@@ -244,7 +258,7 @@ void AudioRtpRecordHandler::processDataDecode(unsigned char *spkrData, size_t si
if (audioRtpRecord_.isDead() or getCodecPayloadType() != payloadType)
return;
#ifdef RTP_RECTODISK
#ifdef RTP_DECODE_RECTODISK
beforedecode.write((const char *)spkrData, size);
#endif
......@@ -258,10 +272,10 @@ void AudioRtpRecordHandler::processDataDecode(unsigned char *spkrData, size_t si
inSamples = audioRtpRecord_.audioCodec_->decode(spkrDataDecoded, spkrData, size);
}
#ifdef RTP_RECTODISK
#ifdef RTP_DECODE_RECTODISK
afterdecode.write((const char *)spkrDataDecoded, inSamples*sizeof(SFLDataFormat));
#endif
#undef RTP_RECTODISK
#undef RTP_DECODE_RECTODISK
#if HAVE_SPEEXDSP
if (Manager::instance().audioPreference.getNoiseReduce()) {
......
......@@ -72,7 +72,11 @@ void AudioSymmetricRtpSession::AudioRtpThread::run()
else
rtpSession_.sendMicData();
#ifdef ANDROID
usleep(20000);
#else
Thread::sleep(TimerPort::getTimer());
#endif
TimerPort::incTimer(rtpSession_.transportRate_);
}
......
......@@ -137,7 +137,11 @@ void AudioZrtpSession::AudioZrtpThread::run()
else
zrtpSession_.sendMicData();
#ifdef ANDROID
usleep(20000);
#else
Thread::sleep(TimerPort::getTimer());
#endif
TimerPort::incTimer(zrtpSession_.transportRate_);
}
......
......@@ -129,10 +129,11 @@ OpenSLLayer::~OpenSLLayer()
stopStream();
}
// #define RECORD_AUDIO_TODISK
//#define RECORD_AUDIO_TODISK
#ifdef RECORD_AUDIO_TODISK
#include <fstream>
std::ofstream opensl_outfile;
std::ofstream opensl_infile;
#endif
void
......@@ -141,9 +142,12 @@ OpenSLLayer::startStream()
if(isStarted_)
return;
DEBUG("Start OpenSL audio layer");
if (audioThread_ == NULL) {
#ifdef RECORD_AUDIO_TODISK
opensl_outfile.open("/data/data/opensl_playback.raw", std::ofstream::out | std::ofstream::binary);
opensl_outfile.open("/data/data/com.savoirfairelinux.sflphone/opensl_playback.raw", std::ofstream::out | std::ofstream::binary);
opensl_infile.open("/data/data/com.savoirfairelinux.sflphone/opensl_record.raw", std::ofstream::out | std::ofstream::binary);
#endif
audioThread_ = new OpenSLThread(this);
......@@ -159,12 +163,18 @@ OpenSLLayer::stopStream()
if(not isStarted_)
return;
DEBUG("Stop OpenSL audio layer");
stopAudioPlayback();
stopAudioCapture();
isStarted_ = false;
delete audioThread_;
audioThread_ = NULL;
#ifdef RECORD_AUDIO_TODISK
opensl_outfile.close();
opensl_infile.close();
#endif
}
......@@ -480,7 +490,6 @@ void OpenSLLayer::audioPlaybackCallback(SLAndroidSimpleBufferQueueItf queue, voi
bool bufferFilled = opensl->audioPlaybackFillBuffer(buffer);
if(bufferFilled) {
#ifdef RECORD_AUDIO_TODISK
opensl_outfile.write((char const *)(buffer.data()), buffer.size());
......@@ -516,9 +525,13 @@ void OpenSLLayer::audioCaptureCallback(SLAndroidSimpleBufferQueueItf queue, void
// which for this code example would indicate a programming error
assert(SL_RESULT_SUCCESS == result);
AudioBuffer &previousbuffer = opensl->getNextRecordBuffer();
// AudioBuffer &previousbuffer = opensl->getNextRecordBuffer();
opensl->audioCaptureFillBuffer(previousbuffer);
opensl->audioCaptureFillBuffer(buffer);
#ifdef RECORD_AUDIO_TODISK
opensl_infile.write((char const *)(buffer.data()), buffer.size());
#endif
// opensl->audioCaptureFillBuffer(previousbuffer);
}
void OpenSLLayer::updatePreference(AudioPreference &preference, int index, PCMType type)
......
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