Skip to content

Commit

Permalink
latency tuner
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaji Khan committed Feb 27, 2024
1 parent dbaf48f commit d4b513d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
20 changes: 11 additions & 9 deletions app/src/main/cpp/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ oboe::Result Engine::openStreams() {
OUT ;
return result;
}

latencyTunerOut = new oboe::LatencyTuner ( *mPlayStream);
latencyTunerOut->tune();
warnIfNotLowLatency(mRecordingStream);

mFullDuplexPass.setInputStream(mRecordingStream);
Expand Down Expand Up @@ -511,15 +514,14 @@ std::string Engine::tuneLatency () {

latencyTuner->requestReset();
oboe::Result result = latencyTuner->tune() ;
char tmp [10];
latencyTunerOut->requestReset();
oboe::Result resultOut = latencyTunerOut->tune() ;
char tmp [400];
// hello, old friend
sprintf (tmp, "%f", mRecordingStream->getXRunCount());
std::string str = std::string ("Tuner: " +
std::to_string(static_cast<double>(result)) +
", Buffer: " + std::to_string(mRecordingStream->getBufferSizeInFrames())
+ ", Xruns: " + std::string (tmp));

LOGD ("%s",str.c_str());
sprintf (tmp, "Tuner: %d/%d, Xruns: %d/%d, Buffer size in frames: %d/%d", result, resultOut,
mRecordingStream->getXRunCount(),mPlayStream->getXRunCount(),
mRecordingStream->getBufferSizeInFrames(), mPlayStream->getBufferSizeInFrames());
LOGD ("%s",tmp);
OUT
return str ;
return std::string (tmp) ;
}
2 changes: 1 addition & 1 deletion app/src/main/cpp/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Engine : public oboe::AudioStreamCallback {
int32_t mRecordingDeviceId = oboe::kUnspecified;
int32_t mPlaybackDeviceId = oboe::kUnspecified;
oboe::AudioApi mAudioApi = oboe::AudioApi::AAudio;
oboe::LatencyTuner *latencyTuner;
oboe::LatencyTuner *latencyTuner, *latencyTunerOut;
oboe::Result openStreams();

void closeStreams();
Expand Down

0 comments on commit d4b513d

Please sign in to comment.