The bug stills remains, it seems a bug in the reset() function in QAudioOutput not relly resetting the audio buffer...
This commit is contained in:
parent
ad89b51aa3
commit
6ddd7c3232
2 changed files with 11 additions and 12 deletions
|
@ -42,7 +42,6 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
||||||
m_statusLabel->setText(STATUS_LABEL);
|
m_statusLabel->setText(STATUS_LABEL);
|
||||||
m_statusValue = new QLabel;
|
m_statusValue = new QLabel;
|
||||||
m_receiveDMX = new QCheckBox("Receiving DMX", this);
|
m_receiveDMX = new QCheckBox("Receiving DMX", this);
|
||||||
// m_receiveDMX->setCheckable(false);
|
|
||||||
m_receiveDMX->setChecked(false);
|
m_receiveDMX->setChecked(false);
|
||||||
status->addWidget(m_receiveDMX);
|
status->addWidget(m_receiveDMX);
|
||||||
status->addWidget(m_statusLabel);
|
status->addWidget(m_statusLabel);
|
||||||
|
@ -90,8 +89,6 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
||||||
progressTime->addWidget(m_progressTimeLabel);
|
progressTime->addWidget(m_progressTimeLabel);
|
||||||
progressTime->addWidget(m_progressTime);
|
progressTime->addWidget(m_progressTime);
|
||||||
|
|
||||||
|
|
||||||
// QHBoxLayout *totalTime = new QHBoxLayout;
|
|
||||||
m_totalTimeLabel = new QLabel;
|
m_totalTimeLabel = new QLabel;
|
||||||
m_totalTimeLabel->setText(TOTAL_TIME_LABEL);
|
m_totalTimeLabel->setText(TOTAL_TIME_LABEL);
|
||||||
m_totalTimeValue = new QTimeEdit;
|
m_totalTimeValue = new QTimeEdit;
|
||||||
|
@ -101,7 +98,6 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
||||||
m_totalTimeValue->setMaximumWidth(90);
|
m_totalTimeValue->setMaximumWidth(90);
|
||||||
progressTime->addWidget(m_totalTimeLabel);
|
progressTime->addWidget(m_totalTimeLabel);
|
||||||
progressTime->addWidget(m_totalTimeValue);
|
progressTime->addWidget(m_totalTimeValue);
|
||||||
// layout->addLayout(totalTime);
|
|
||||||
layout->addLayout(progressTime);
|
layout->addLayout(progressTime);
|
||||||
|
|
||||||
QHBoxLayout *progressSlider = new QHBoxLayout;
|
QHBoxLayout *progressSlider = new QHBoxLayout;
|
||||||
|
@ -141,7 +137,9 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
||||||
connect(m_watchDMX, SIGNAL(timeout()),
|
connect(m_watchDMX, SIGNAL(timeout()),
|
||||||
this, SLOT(watchDMXExpired()));
|
this, SLOT(watchDMXExpired()));
|
||||||
m_watchDMX->start(1000);
|
m_watchDMX->start(1000);
|
||||||
|
|
||||||
createAudioOutput();
|
createAudioOutput();
|
||||||
|
pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
AudioLayerWidget::~AudioLayerWidget()
|
AudioLayerWidget::~AudioLayerWidget()
|
||||||
|
@ -189,8 +187,8 @@ void AudioLayerWidget::loadMedia(QString file)
|
||||||
if (m_currentMedia == file)
|
if (m_currentMedia == file)
|
||||||
return;
|
return;
|
||||||
if (QFile::exists(file)){
|
if (QFile::exists(file)){
|
||||||
reset();
|
|
||||||
m_decoder->loadMedia(file);
|
m_decoder->loadMedia(file);
|
||||||
|
setInitPosition();
|
||||||
m_currentMedia = file;
|
m_currentMedia = file;
|
||||||
fileLoaded(file);
|
fileLoaded(file);
|
||||||
}
|
}
|
||||||
|
@ -220,7 +218,7 @@ void AudioLayerWidget::notified()
|
||||||
void AudioLayerWidget::pullTimerExpired()
|
void AudioLayerWidget::pullTimerExpired()
|
||||||
{
|
{
|
||||||
if (m_audioOutput && m_audioOutput->state() != QAudio::StoppedState) {
|
if (m_audioOutput && m_audioOutput->state() != QAudio::StoppedState) {
|
||||||
int chunks = m_audioOutput->bytesFree()/m_audioOutput->periodSize();
|
int chunks = m_audioOutput->bytesFree() / m_audioOutput->periodSize();
|
||||||
while (chunks) {
|
while (chunks) {
|
||||||
const qint64 len = m_decoder->read(m_buffer.data(), m_audioOutput->periodSize());
|
const qint64 len = m_decoder->read(m_buffer.data(), m_audioOutput->periodSize());
|
||||||
if ( len == -1) {
|
if ( len == -1) {
|
||||||
|
@ -255,11 +253,11 @@ void AudioLayerWidget::toggleSuspendResume()
|
||||||
void AudioLayerWidget::handleStateChanged(QAudio::State state)
|
void AudioLayerWidget::handleStateChanged(QAudio::State state)
|
||||||
{
|
{
|
||||||
if (state == QAudio::SuspendedState) {
|
if (state == QAudio::SuspendedState) {
|
||||||
m_statusValue->setText(PAUSE_LABEL);
|
m_statusValue->setText(PAUSE_LABEL);
|
||||||
} else if (state == QAudio::ActiveState) {
|
} else if (state == QAudio::ActiveState) {
|
||||||
m_statusValue->setText(PLAY_LABEL);
|
m_statusValue->setText(PLAY_LABEL);
|
||||||
} else if (m_audioOutput->state() == QAudio::StoppedState) {
|
} else if (m_audioOutput->state() == QAudio::StoppedState) {
|
||||||
m_statusValue->setText(STOP_LABEL);
|
m_statusValue->setText(STOP_LABEL);
|
||||||
} else if (state == QAudio::IdleState) {
|
} else if (state == QAudio::IdleState) {
|
||||||
m_statusValue->setText(IDDLE_LABEL);
|
m_statusValue->setText(IDDLE_LABEL);
|
||||||
}
|
}
|
||||||
|
@ -275,6 +273,7 @@ void AudioLayerWidget::durationChanged(qint64 dur)
|
||||||
|
|
||||||
void AudioLayerWidget::play()
|
void AudioLayerWidget::play()
|
||||||
{
|
{
|
||||||
|
// reset();
|
||||||
setInitPosition();
|
setInitPosition();
|
||||||
m_pullTimer->start(PULL_TIMER_INTERVAL);
|
m_pullTimer->start(PULL_TIMER_INTERVAL);
|
||||||
m_audioOutput->resume();
|
m_audioOutput->resume();
|
||||||
|
@ -311,12 +310,12 @@ void AudioLayerWidget::reset()
|
||||||
m_audioOutput->reset();
|
m_audioOutput->reset();
|
||||||
m_output = m_audioOutput->start();
|
m_output = m_audioOutput->start();
|
||||||
Q_CHECK_PTR(m_output);
|
Q_CHECK_PTR(m_output);
|
||||||
pause();
|
// pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioLayerWidget::setInitPosition()
|
void AudioLayerWidget::setInitPosition()
|
||||||
{
|
{
|
||||||
// m_buffer.clear();
|
reset();
|
||||||
m_decoder->setPos(0);
|
m_decoder->setPos(0);
|
||||||
m_progressMs = 0;
|
m_progressMs = 0;
|
||||||
m_progressTime->setTime(QTime::fromMSecsSinceStartOfDay(m_progressMs));
|
m_progressTime->setTime(QTime::fromMSecsSinceStartOfDay(m_progressMs));
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#define COPYRIGHT "(C) 2014 Santi Norena libremediaserver@gmail.com"
|
#define COPYRIGHT "(C) 2014 Santi Norena libremediaserver@gmail.com"
|
||||||
#define LICENSE "GPL 3 License. See LICENSE.txt and credits.txt for details"
|
#define LICENSE "GPL 3 License. See LICENSE.txt and credits.txt for details"
|
||||||
|
|
||||||
#define LAYERS_NUMBER 4
|
#define LAYERS_NUMBER 3
|
||||||
|
|
||||||
#define DEFAULT_FILE "lms-audio.xlm"
|
#define DEFAULT_FILE "lms-audio.xlm"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue