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
|
try
|
||||||
{
|
{
|
||||||
uint32_t bufferFrames = 128;
|
RtAudio::StreamOptions streamOptions;
|
||||||
dac_->openStream(¶meters, nullptr, RTAUDIO_SINT16, sampleRate_, &bufferFrames, &RtAudioOutput::audioBufferReadHandler, static_cast<void*>(this), nullptr);
|
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);
|
return audioBuffer_.open(QIODevice::ReadWrite);
|
||||||
}
|
}
|
||||||
catch(const RtAudioError& e)
|
catch(const RtAudioError& e)
|
||||||
|
@ -104,8 +106,7 @@ void RtAudioOutput::stop()
|
||||||
|
|
||||||
void RtAudioOutput::suspend()
|
void RtAudioOutput::suspend()
|
||||||
{
|
{
|
||||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
//not needed
|
||||||
this->doSuspend();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t RtAudioOutput::getSampleSize() const
|
uint32_t RtAudioOutput::getSampleSize() const
|
||||||
|
@ -125,7 +126,7 @@ uint32_t RtAudioOutput::getSampleRate() const
|
||||||
|
|
||||||
void RtAudioOutput::doSuspend()
|
void RtAudioOutput::doSuspend()
|
||||||
{
|
{
|
||||||
if(!dac_->isStreamOpen() && !dac_->isStreamRunning())
|
if(dac_->isStreamOpen() && dac_->isStreamRunning())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue