Use timestamp of audio output
This commit is contained in:
parent
b550104e18
commit
00acf0ee3e
@ -19,6 +19,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <f1x/aasdk/Messenger/Timestamp.hpp>
|
||||
#include <f1x/aasdk/Common/Data.hpp>
|
||||
|
||||
namespace f1x
|
||||
@ -39,7 +40,7 @@ public:
|
||||
virtual ~IAudioOutput() = default;
|
||||
|
||||
virtual bool open() = 0;
|
||||
virtual void write(const aasdk::common::DataConstBuffer& buffer) = 0;
|
||||
virtual void write(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer) = 0;
|
||||
virtual void start() = 0;
|
||||
virtual void stop() = 0;
|
||||
virtual void suspend() = 0;
|
||||
|
@ -39,7 +39,7 @@ class QtAudioOutput: public QObject, public IAudioOutput
|
||||
public:
|
||||
QtAudioOutput(uint32_t channelCount, uint32_t sampleSize, uint32_t sampleRate);
|
||||
bool open() override;
|
||||
void write(const aasdk::common::DataConstBuffer& buffer) override;
|
||||
void write(aasdk::messenger::Timestamp::ValueType, const aasdk::common::DataConstBuffer& buffer) override;
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void suspend() override;
|
||||
|
@ -36,7 +36,7 @@ class RtAudioOutput: public IAudioOutput
|
||||
public:
|
||||
RtAudioOutput(uint32_t channelCount, uint32_t sampleSize, uint32_t sampleRate);
|
||||
bool open() override;
|
||||
void write(const aasdk::common::DataConstBuffer& buffer) override;
|
||||
void write(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer) override;
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void suspend() override;
|
||||
|
@ -152,14 +152,9 @@ void AudioService::onAVChannelStopIndication(const aasdk::proto::messages::AVCha
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AudioService::onAVMediaWithTimestampIndication(aasdk::messenger::Timestamp::ValueType, const aasdk::common::DataConstBuffer& buffer)
|
||||
void AudioService::onAVMediaWithTimestampIndication(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer)
|
||||
{
|
||||
this->onAVMediaIndication(buffer);
|
||||
}
|
||||
|
||||
void AudioService::onAVMediaIndication(const aasdk::common::DataConstBuffer& buffer)
|
||||
{
|
||||
audioOutput_->write(buffer);
|
||||
audioOutput_->write(timestamp, buffer);
|
||||
aasdk::proto::messages::AVMediaAckIndication indication;
|
||||
indication.set_session(session_);
|
||||
indication.set_value(1);
|
||||
@ -170,6 +165,11 @@ void AudioService::onAVMediaIndication(const aasdk::common::DataConstBuffer& buf
|
||||
channel_->receive(this->shared_from_this());
|
||||
}
|
||||
|
||||
void AudioService::onAVMediaIndication(const aasdk::common::DataConstBuffer& buffer)
|
||||
{
|
||||
this->onAVMediaWithTimestampIndication(0, buffer);
|
||||
}
|
||||
|
||||
void AudioService::onChannelError(const aasdk::error::Error& e)
|
||||
{
|
||||
OPENAUTO_LOG(error) << "[AudioService] channel error: " << e.what()
|
||||
|
@ -58,7 +58,7 @@ bool QtAudioOutput::open()
|
||||
return audioBuffer_.open(QIODevice::ReadWrite);
|
||||
}
|
||||
|
||||
void QtAudioOutput::write(const aasdk::common::DataConstBuffer& buffer)
|
||||
void QtAudioOutput::write(aasdk::messenger::Timestamp::ValueType, const aasdk::common::DataConstBuffer& buffer)
|
||||
{
|
||||
audioBuffer_.write(reinterpret_cast<const char*>(buffer.cdata), buffer.size);
|
||||
}
|
||||
|
@ -70,9 +70,16 @@ bool RtAudioOutput::open()
|
||||
return false;
|
||||
}
|
||||
|
||||
void RtAudioOutput::write(const aasdk::common::DataConstBuffer& buffer)
|
||||
void RtAudioOutput::write(aasdk::messenger::Timestamp::ValueType timestamp, const aasdk::common::DataConstBuffer& buffer)
|
||||
{
|
||||
audioBuffer_.write(reinterpret_cast<const char*>(buffer.cdata), buffer.size);
|
||||
|
||||
std::lock_guard<decltype(mutex_)> lock(mutex_);
|
||||
|
||||
if(dac_->isStreamOpen())
|
||||
{
|
||||
dac_->setStreamTime(timestamp / 1000000);
|
||||
}
|
||||
}
|
||||
|
||||
void RtAudioOutput::start()
|
||||
|
Loading…
x
Reference in New Issue
Block a user