improved audio pausing feedback
This commit is contained in:
@@ -78,10 +78,16 @@ void AudioManager::StartOutput(QIODevice *device)
|
||||
void AudioManager::StopOutput()
|
||||
{
|
||||
output_manager_.Stop();
|
||||
|
||||
if (output_ != nullptr) {
|
||||
output_->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void AudioManager::SetOutputDevice(const QAudioDeviceInfo &info)
|
||||
{
|
||||
qInfo() << "Output audio device to" << info.deviceName();
|
||||
|
||||
StopOutput();
|
||||
|
||||
QAudioFormat format;
|
||||
@@ -93,9 +99,11 @@ void AudioManager::SetOutputDevice(const QAudioDeviceInfo &info)
|
||||
format.setSampleType(QAudioFormat::Float);
|
||||
|
||||
output_ = std::unique_ptr<QAudioOutput>(new QAudioOutput(info, format, this));
|
||||
connect(output_.get(), SIGNAL(stateChanged(QAudio::State)), this, SLOT(OutputStateChanged(QAudio::State)));
|
||||
connect(output_.get(), SIGNAL(notify()), this, SLOT(OutputNotified()));
|
||||
output_device_info_ = info;
|
||||
|
||||
// Un-comment this to get debug information about what the audio output is doing
|
||||
//connect(output_.get(), SIGNAL(stateChanged(QAudio::State)), this, SLOT(OutputStateChanged(QAudio::State)));
|
||||
}
|
||||
|
||||
void AudioManager::SetInputDevice(const QAudioDeviceInfo &info)
|
||||
|
||||
@@ -51,6 +51,12 @@ private:
|
||||
QList<QAudioDeviceInfo> output_devices_;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Audio input and output management class
|
||||
*
|
||||
* Wraps around a QAudioOutput and AudioHybridDevice, connecting them together and exposing audio functionality to
|
||||
* the rest of the system.
|
||||
*/
|
||||
class AudioManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -74,7 +80,7 @@ public:
|
||||
void StartOutput(QIODevice* device);
|
||||
|
||||
/**
|
||||
* @brief Stop audio output
|
||||
* @brief Stop audio output immediately
|
||||
*/
|
||||
void StopOutput();
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "audio/audiomanager.h"
|
||||
#include "common/timecodefunctions.h"
|
||||
#include "config/config.h"
|
||||
|
||||
ViewerWidget::ViewerWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
@@ -222,7 +223,7 @@ void ViewerWidget::PlayInternal(int speed)
|
||||
void ViewerWidget::PushScrubbedAudio()
|
||||
{
|
||||
// FIXME: Test code
|
||||
if (!IsPlaying()) {
|
||||
if (Config::Current()["AudioScrubbing"].toBool() && !IsPlaying()) {
|
||||
int size_of_sample = qFloor(2 * 48000 * time_base_dbl_) * static_cast<int>(sizeof(float));
|
||||
test_file_.seek(static_cast<qint64>(qFloor(GetTime().toDouble() * 48000 * 2)) * static_cast<qint64>(sizeof(float)));
|
||||
QByteArray frame_audio = test_file_.read(size_of_sample);
|
||||
@@ -245,13 +246,12 @@ void ViewerWidget::Play()
|
||||
|
||||
void ViewerWidget::Pause()
|
||||
{
|
||||
playback_timer_.stop();
|
||||
|
||||
controls_->ShowPlayButton();
|
||||
|
||||
playback_speed_ = 0;
|
||||
|
||||
AudioManager::instance()->StopOutput();
|
||||
if (IsPlaying()) {
|
||||
AudioManager::instance()->StopOutput();
|
||||
playback_speed_ = 0;
|
||||
controls_->ShowPlayButton();
|
||||
playback_timer_.stop();
|
||||
}
|
||||
}
|
||||
|
||||
void ViewerWidget::GoToStart()
|
||||
|
||||
Reference in New Issue
Block a user