implement audio device to pull directly from renderer
This commit is contained in:
@@ -94,11 +94,8 @@ void AudioManager::PushToOutput(const QByteArray &samples)
|
||||
emit OutputPushed(samples);
|
||||
}
|
||||
|
||||
void AudioManager::StartOutput(AudioPlaybackCache *cache, qint64 offset, int playback_speed)
|
||||
void AudioManager::StartOutput(QIODevice *device, int playback_speed)
|
||||
{
|
||||
// Create device
|
||||
QIODevice* device = cache->CreatePlaybackDevice();
|
||||
|
||||
// Move to output manager's thread
|
||||
device->moveToThread(&output_thread_);
|
||||
|
||||
@@ -107,10 +104,7 @@ void AudioManager::StartOutput(AudioPlaybackCache *cache, qint64 offset, int pla
|
||||
"PullFromDevice",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(QIODevice*, device),
|
||||
Q_ARG(qint64, offset),
|
||||
Q_ARG(int, playback_speed));
|
||||
|
||||
emit OutputDeviceStarted(cache, offset, playback_speed);
|
||||
}
|
||||
|
||||
void AudioManager::StopOutput()
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
/**
|
||||
* @brief Start playing audio from AudioPlaybackCache
|
||||
*/
|
||||
void StartOutput(AudioPlaybackCache* cache, qint64 offset, int playback_speed);
|
||||
void StartOutput(QIODevice *device, int playback_speed);
|
||||
|
||||
/**
|
||||
* @brief Stop audio output immediately
|
||||
@@ -93,8 +93,6 @@ signals:
|
||||
|
||||
void OutputNotified();
|
||||
|
||||
void OutputDeviceStarted(AudioPlaybackCache* cache, qint64 offset, int playback_speed);
|
||||
|
||||
void OutputWaveformStarted(const AudioVisualWaveform* waveform, const rational &start, int playback_speed);
|
||||
|
||||
void AudioParamsChanged(const AudioParams& params);
|
||||
|
||||
@@ -35,24 +35,17 @@ void AudioOutputDeviceProxy::SetParameters(const AudioParams ¶ms)
|
||||
params_ = params;
|
||||
}
|
||||
|
||||
void AudioOutputDeviceProxy::SetDevice(QIODevice* device, qint64 offset, int playback_speed)
|
||||
void AudioOutputDeviceProxy::SetDevice(QIODevice* device, int playback_speed)
|
||||
{
|
||||
if (device_) {
|
||||
delete device_;
|
||||
}
|
||||
|
||||
device_ = device;
|
||||
device_->setParent(this);
|
||||
|
||||
if (!device_->open(QFile::ReadOnly)) {
|
||||
qCritical() << "Failed to open IO device for audio playback";
|
||||
delete device_;
|
||||
device_ = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
device_->seek(offset);
|
||||
|
||||
playback_speed_ = playback_speed;
|
||||
|
||||
if (qAbs(playback_speed_) != 1) {
|
||||
@@ -64,7 +57,6 @@ void AudioOutputDeviceProxy::close()
|
||||
{
|
||||
QIODevice::close();
|
||||
|
||||
delete device_;
|
||||
device_ = nullptr;
|
||||
|
||||
if (tempo_processor_.IsOpen()) {
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
|
||||
void SetParameters(const AudioParams& params);
|
||||
|
||||
void SetDevice(QIODevice *device, qint64 offset, int playback_speed);
|
||||
void SetDevice(QIODevice *device, int playback_speed);
|
||||
|
||||
virtual void close() override;
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ void AudioOutputManager::Close()
|
||||
}
|
||||
}
|
||||
|
||||
void AudioOutputManager::PullFromDevice(QIODevice *device, qint64 offset, int playback_speed)
|
||||
void AudioOutputManager::PullFromDevice(QIODevice *device, int playback_speed)
|
||||
{
|
||||
if (!output_) {
|
||||
return;
|
||||
@@ -102,7 +102,7 @@ void AudioOutputManager::PullFromDevice(QIODevice *device, qint64 offset, int pl
|
||||
push_samples_.clear();
|
||||
|
||||
// Pull from the device
|
||||
device_proxy_.SetDevice(device, offset, playback_speed);
|
||||
device_proxy_.SetDevice(device, playback_speed);
|
||||
device_proxy_.open(QIODevice::ReadOnly);
|
||||
output_->start(&device_proxy_);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public slots:
|
||||
* This will clear any pushed samples or QIODevices currently being read and will start reading from this next time
|
||||
* the audio output requests data.
|
||||
*/
|
||||
void PullFromDevice(QIODevice* device, qint64 offset, int playback_speed);
|
||||
void PullFromDevice(QIODevice* device, int playback_speed);
|
||||
|
||||
// Queued
|
||||
void ResetToPushMode();
|
||||
|
||||
Reference in New Issue
Block a user