Skip to content

Commit

Permalink
Revert last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
f1xpl committed Mar 25, 2018
1 parent 18fa86b commit f9692b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
1 change: 0 additions & 1 deletion include/f1x/openauto/autoapp/Projection/RtAudioOutput.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class RtAudioOutput: public IAudioOutput
SequentialBuffer audioBuffer_;
std::unique_ptr<RtAudio> dac_;
std::mutex mutex_;
bool playbackRequested_;
};

}
Expand Down
17 changes: 5 additions & 12 deletions src/autoapp/Projection/RtAudioOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ RtAudioOutput::RtAudioOutput(uint32_t channelCount, uint32_t sampleSize, uint32_
: channelCount_(channelCount)
, sampleSize_(sampleSize)
, sampleRate_(sampleRate)
, playbackRequested_(false)
{
std::vector<RtAudio::Api> apis;
RtAudio::getCompiledApi(apis);
Expand All @@ -55,7 +54,7 @@ bool RtAudioOutput::open()
RtAudio::StreamOptions streamOptions;
streamOptions.numberOfBuffers = 1;
streamOptions.flags = RTAUDIO_MINIMIZE_LATENCY | RTAUDIO_SCHEDULE_REALTIME;
uint32_t bufferFrames = 256;
uint32_t bufferFrames = 64;
dac_->openStream(&parameters, nullptr, RTAUDIO_SINT16, sampleRate_, &bufferFrames, &RtAudioOutput::audioBufferReadHandler, static_cast<void*>(this), &streamOptions);
return audioBuffer_.open(QIODevice::ReadWrite);
}
Expand All @@ -75,10 +74,13 @@ bool RtAudioOutput::open()
void RtAudioOutput::write(const aasdk::common::DataConstBuffer& buffer)
{
audioBuffer_.write(reinterpret_cast<const char*>(buffer.cdata), buffer.size);
}

void RtAudioOutput::start()
{
std::lock_guard<decltype(mutex_)> lock(mutex_);

if(playbackRequested_ && dac_->isStreamOpen() && !dac_->isStreamRunning())
if(dac_->isStreamOpen() && !dac_->isStreamRunning())
{
try
{
Expand All @@ -89,15 +91,6 @@ void RtAudioOutput::write(const aasdk::common::DataConstBuffer& buffer)
OPENAUTO_LOG(error) << "[RtAudioOutput] Failed to start audio output, what: " << e.what();
}
}

playbackRequested_ = false;
}

void RtAudioOutput::start()
{
std::lock_guard<decltype(mutex_)> lock(mutex_);

playbackRequested_ = true;
}

void RtAudioOutput::stop()
Expand Down

0 comments on commit f9692b7

Please sign in to comment.