# Oboe: include/oboe/LatencyTuner.h Source File

LatencyTuner.h
/*
* Copyright 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OBOE_LATENCY_TUNER_
#define OBOE_LATENCY_TUNER_
#include <atomic>
#include <cstdint>
#include "oboe/Definitions.h"
#include "oboe/AudioStream.h"
namespace oboe {
class LatencyTuner {
public:
explicit LatencyTuner(AudioStream &stream);
explicit LatencyTuner(AudioStream &stream, int32_t maximumBufferSize);
Result tune();
void requestReset();
bool isAtMaximumBufferSize();
private:
void reset();
enum class State {
Idle,
Active,
AtMax,
Unsupported
} ;
// arbitrary number of calls to wait before bumping up the latency
static constexpr int32_t kIdleCount = 8;
AudioStream &mStream;
State mState = State::Idle;
int32_t mMaxBufferSize = 0;
int32_t mPreviousXRuns = 0;
int32_t mIdleCountDown = 0;
std::atomic<int32_t> mLatencyTriggerRequests{0}; // TODO user atomic requester from AAudio
std::atomic<int32_t> mLatencyTriggerResponses{0};
};
} // namespace oboe
#endif // OBOE_LATENCY_TUNER_
oboe::LatencyTuner::requestReset
void requestReset()
oboe::AudioStream
Definition: AudioStream.h:44
oboe::LatencyTuner::isAtMaximumBufferSize
bool isAtMaximumBufferSize()
oboe::LatencyTuner::LatencyTuner
LatencyTuner(AudioStream &stream)
oboe::LatencyTuner::tune
Result tune()
oboe::Result
Result
Definition: Definitions.h:131
oboe::LatencyTuner
Definition: LatencyTuner.h:41
oboe
Definition: AudioStream.h:31