mirror of https://github.com/f1xpl/openauto.git
Adjust audio device buffer size
parent
75297a84d7
commit
2c8daca961
|
@ -51,8 +51,10 @@ bool RtAudioOutput::open()
|
|||
|
||||
try
|
||||
{
|
||||
uint32_t bufferFrames = 128;
|
||||
dac_->openStream(¶meters, nullptr, RTAUDIO_SINT16, sampleRate_, &bufferFrames, &RtAudioOutput::audioBufferReadHandler, static_cast<void*>(this), nullptr);
|
||||
RtAudio::StreamOptions streamOptions;
|
||||
streamOptions.flags = RTAUDIO_MINIMIZE_LATENCY | RTAUDIO_SCHEDULE_REALTIME;
|
||||
uint32_t bufferFrames = sampleRate_ == 16000 ? 1024 : 2048; //according to the observation of audio packets
|
||||
dac_->openStream(¶meters, nullptr, RTAUDIO_SINT16, sampleRate_, &bufferFrames, &RtAudioOutput::audioBufferReadHandler, static_cast<void*>(this), &streamOptions);
|
||||
return audioBuffer_.open(QIODevice::ReadWrite);
|
||||
}
|
||||
catch(const RtAudioError& e)
|
||||
|
@ -104,8 +106,7 @@ void RtAudioOutput::stop()
|
|||
|
||||
void RtAudioOutput::suspend()
|
||||
{
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
this->doSuspend();
|
||||
//not needed
|
||||
}
|
||||
|
||||
uint32_t RtAudioOutput::getSampleSize() const
|
||||
|
@ -125,7 +126,7 @@ uint32_t RtAudioOutput::getSampleRate() const
|
|||
|
||||
void RtAudioOutput::doSuspend()
|
||||
{
|
||||
if(!dac_->isStreamOpen() && !dac_->isStreamRunning())
|
||||
if(dac_->isStreamOpen() && dac_->isStreamRunning())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue