Added a DMX watchdog. Changed the play methos, now play reset to 0 and stop not.
This commit is contained in:
parent
a6909f8c16
commit
69ffe79742
13 changed files with 276 additions and 154 deletions
|
@ -106,16 +106,16 @@ void AudioDecoder::errorDecoding(QAudioDecoder::Error msg)
|
||||||
case QAudioDecoder::NoError:
|
case QAudioDecoder::NoError:
|
||||||
break;
|
break;
|
||||||
case QAudioDecoder::ResourceError:
|
case QAudioDecoder::ResourceError:
|
||||||
qWarning() << "A media resource couldn't be resolved: " << m_decoder->sourceFilename();
|
qWarning("A media resource couldn't be resolved: %s", m_decoder->sourceFilename().toLatin1().constData());
|
||||||
break;
|
break;
|
||||||
case QAudioDecoder::FormatError:
|
case QAudioDecoder::FormatError:
|
||||||
qWarning() << "The format of a media resource isn't supported: " << m_decoder->sourceFilename();;
|
qWarning("The format of a media resource isn't supported: %s", m_decoder->sourceFilename().toLatin1().constData());
|
||||||
break;
|
break;
|
||||||
case QAudioDecoder::AccessDeniedError:
|
case QAudioDecoder::AccessDeniedError:
|
||||||
qWarning() << "There are not the appropriate permissions to play a media resource" << m_decoder->sourceFilename();;
|
qWarning("There are not the appropriate permissions to play a media resource %s", m_decoder->sourceFilename().toLatin1().constData());
|
||||||
break;
|
break;
|
||||||
case QAudioDecoder::ServiceMissingError:
|
case QAudioDecoder::ServiceMissingError:
|
||||||
qWarning() << "A valid playback service was not found, playback cannot proceed.";
|
qWarning("A valid playback service was not found, playback cannot proceed");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,6 @@ qint64 AudioDecoder::readData(char *data, qint64 len)
|
||||||
qint64 total = 0;
|
qint64 total = 0;
|
||||||
while (len - total > 0) {
|
while (len - total > 0) {
|
||||||
const qint64 chunk = qMin((m_buffer.size() - m_pos), len - total);
|
const qint64 chunk = qMin((m_buffer.size() - m_pos), len - total);
|
||||||
// qWarning() << "Buffer Size: " << m_buffer.size() << "m_pos: " << m_pos;
|
|
||||||
memcpy(data + total, m_buffer.constData() + m_pos, chunk);
|
memcpy(data + total, m_buffer.constData() + m_pos, chunk);
|
||||||
// Controla Final del track
|
// Controla Final del track
|
||||||
if ( (m_pos + chunk ) >= ( m_buffer.size() )
|
if ( (m_pos + chunk ) >= ( m_buffer.size() )
|
||||||
|
@ -153,7 +152,7 @@ qint64 AudioDecoder::bytesAvailable() const
|
||||||
|
|
||||||
void AudioDecoder::decoderFinished()
|
void AudioDecoder::decoderFinished()
|
||||||
{
|
{
|
||||||
qDebug() << "AudioDecoder: Decoding file finished; " << m_decoder->sourceFilename();
|
qDebug("Decoding file finished %s ", m_decoder->sourceFilename().toLatin1().constData());
|
||||||
emit fileLoaded(m_decoder->sourceFilename());
|
emit fileLoaded(m_decoder->sourceFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,16 +9,22 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
||||||
QGroupBox(parent)
|
QGroupBox(parent)
|
||||||
, m_suspendResumeButton(0)
|
, m_suspendResumeButton(0)
|
||||||
, m_deviceBox(0)
|
, m_deviceBox(0)
|
||||||
|
, m_watchDMX(new QTimer(this))
|
||||||
, m_pullTimer(new QTimer(this))
|
, m_pullTimer(new QTimer(this))
|
||||||
, m_device(QAudioDeviceInfo::defaultOutputDevice())
|
, m_device(QAudioDeviceInfo::defaultOutputDevice())
|
||||||
, m_audioOutput(0)
|
, m_audioOutput(0)
|
||||||
, m_output(0)
|
, m_output(0)
|
||||||
, m_buffer(BufferSize, 0)
|
, m_buffer(BufferSize, 0)
|
||||||
, m_decoder(0)
|
, m_decoder(0)
|
||||||
|
, m_progressCounter(new QTime(0,0,0,1))
|
||||||
|
, m_progressMs(0)
|
||||||
|
, m_currentMedia(" ")
|
||||||
|
|
||||||
{
|
{
|
||||||
this->setTitle(name);
|
this->setTitle(name);
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
|
|
||||||
m_deviceBox = new QComboBox(this);
|
m_deviceBox = new QComboBox(this);
|
||||||
const QAudioDeviceInfo &defaultDeviceInfo = QAudioDeviceInfo::defaultOutputDevice();
|
const QAudioDeviceInfo &defaultDeviceInfo = QAudioDeviceInfo::defaultOutputDevice();
|
||||||
m_deviceBox->addItem(defaultDeviceInfo.deviceName(), qVariantFromValue(defaultDeviceInfo));
|
m_deviceBox->addItem(defaultDeviceInfo.deviceName(), qVariantFromValue(defaultDeviceInfo));
|
||||||
|
@ -26,6 +32,7 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
||||||
if (deviceInfo != defaultDeviceInfo)
|
if (deviceInfo != defaultDeviceInfo)
|
||||||
m_deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo));
|
m_deviceBox->addItem(deviceInfo.deviceName(), qVariantFromValue(deviceInfo));
|
||||||
}
|
}
|
||||||
|
m_deviceBox->setMaximumWidth(250);
|
||||||
connect(m_deviceBox,SIGNAL(activated(int)),
|
connect(m_deviceBox,SIGNAL(activated(int)),
|
||||||
this, SLOT(deviceChanged(int)));
|
this, SLOT(deviceChanged(int)));
|
||||||
layout->addWidget(m_deviceBox);
|
layout->addWidget(m_deviceBox);
|
||||||
|
@ -34,6 +41,10 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
||||||
m_statusLabel = new QLabel;
|
m_statusLabel = new QLabel;
|
||||||
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->setCheckable(false);
|
||||||
|
m_receiveDMX->setChecked(false);
|
||||||
|
status->addWidget(m_receiveDMX);
|
||||||
status->addWidget(m_statusLabel);
|
status->addWidget(m_statusLabel);
|
||||||
status->addWidget(m_statusValue);
|
status->addWidget(m_statusValue);
|
||||||
layout->addLayout(status);
|
layout->addLayout(status);
|
||||||
|
@ -54,23 +65,43 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
||||||
fileLoaded->addWidget(m_fileValue);
|
fileLoaded->addWidget(m_fileValue);
|
||||||
layout->addLayout(fileLoaded);
|
layout->addLayout(fileLoaded);
|
||||||
|
|
||||||
m_suspendResumeButton = new QPushButton(this);
|
|
||||||
m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
|
|
||||||
connect(m_suspendResumeButton, SIGNAL(clicked()), SLOT(toggleSuspendResume()));
|
|
||||||
layout->addWidget(m_suspendResumeButton);
|
|
||||||
|
|
||||||
QHBoxLayout *volumeBox = new QHBoxLayout;
|
QHBoxLayout *volumeBox = new QHBoxLayout;
|
||||||
m_volumeLabel = new QLabel;
|
m_volumeLabel = new QLabel;
|
||||||
m_volumeLabel->setText(tr(VOLUME_LABEL));
|
m_volumeLabel->setText(tr(VOLUME_LABEL));
|
||||||
m_volumeSlider = new QSlider(Qt::Horizontal);
|
m_volumeSlider = new QSlider(Qt::Horizontal);
|
||||||
m_volumeSlider->setMinimum(0);
|
m_volumeSlider->setMinimum(0);
|
||||||
m_volumeSlider->setMaximum(100);
|
m_volumeSlider->setMaximum(80);
|
||||||
m_volumeSlider->setSingleStep(1);
|
m_volumeSlider->setSingleStep(1);
|
||||||
connect(m_volumeSlider, SIGNAL(valueChanged(int)), this, SLOT(volumeChanged(int)));
|
connect(m_volumeSlider, SIGNAL(valueChanged(int)), this, SLOT(volumeChanged(int)));
|
||||||
volumeBox->addWidget(m_volumeLabel);
|
volumeBox->addWidget(m_volumeLabel);
|
||||||
volumeBox->addWidget(m_volumeSlider);
|
volumeBox->addWidget(m_volumeSlider);
|
||||||
layout->addLayout(volumeBox);
|
layout->addLayout(volumeBox);
|
||||||
|
|
||||||
|
QHBoxLayout *progressTime = new QHBoxLayout;
|
||||||
|
m_progressTimeLabel = new QLabel;
|
||||||
|
m_progressTimeLabel->setText(PROGRESS_TIME_LABEL);
|
||||||
|
m_progressTime = new QTimeEdit;
|
||||||
|
m_progressTime->setDisplayFormat("h:mm:ss:zzz");
|
||||||
|
m_progressTime->setReadOnly(true);
|
||||||
|
m_progressTime->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
||||||
|
m_progressTime->setMaximumWidth(90);
|
||||||
|
progressTime->addWidget(m_progressTimeLabel);
|
||||||
|
progressTime->addWidget(m_progressTime);
|
||||||
|
|
||||||
|
|
||||||
|
// QHBoxLayout *totalTime = new QHBoxLayout;
|
||||||
|
m_totalTimeLabel = new QLabel;
|
||||||
|
m_totalTimeLabel->setText(TOTAL_TIME_LABEL);
|
||||||
|
m_totalTimeValue = new QTimeEdit;
|
||||||
|
m_totalTimeValue->setDisplayFormat("h:mm:ss:zzz");
|
||||||
|
m_totalTimeValue->setReadOnly(true);
|
||||||
|
m_totalTimeValue->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
||||||
|
m_totalTimeValue->setMaximumWidth(90);
|
||||||
|
progressTime->addWidget(m_totalTimeLabel);
|
||||||
|
progressTime->addWidget(m_totalTimeValue);
|
||||||
|
// layout->addLayout(totalTime);
|
||||||
|
layout->addLayout(progressTime);
|
||||||
|
|
||||||
QHBoxLayout *progressSlider = new QHBoxLayout;
|
QHBoxLayout *progressSlider = new QHBoxLayout;
|
||||||
m_progressLabel = new QLabel;
|
m_progressLabel = new QLabel;
|
||||||
m_progressLabel->setText(PROGRESS_LABEL);
|
m_progressLabel->setText(PROGRESS_LABEL);
|
||||||
|
@ -79,22 +110,10 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
||||||
progressSlider->addWidget(m_progressSlider);
|
progressSlider->addWidget(m_progressSlider);
|
||||||
layout->addLayout(progressSlider);
|
layout->addLayout(progressSlider);
|
||||||
|
|
||||||
QHBoxLayout *progressTime = new QHBoxLayout;
|
m_suspendResumeButton = new QPushButton(this);
|
||||||
m_progressTimeLabel = new QLabel;
|
m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
|
||||||
m_progressTimeLabel->setText(PROGRESS_TIME_LABEL);
|
connect(m_suspendResumeButton, SIGNAL(clicked()), SLOT(toggleSuspendResume()));
|
||||||
m_progressTimeValue = new QLabel;
|
layout->addWidget(m_suspendResumeButton);
|
||||||
m_progressTimeValue->setText("0:00:00:000");
|
|
||||||
progressTime->addWidget(m_progressTimeLabel);
|
|
||||||
progressTime->addWidget(m_progressTimeValue);
|
|
||||||
layout->addLayout(progressTime);
|
|
||||||
|
|
||||||
QHBoxLayout *totalTime = new QHBoxLayout;
|
|
||||||
m_totalTimeLabel = new QLabel;
|
|
||||||
m_totalTimeLabel->setText(TOTAL_TIME_LABEL);
|
|
||||||
m_totalTimeValue = new QLabel;
|
|
||||||
totalTime->addWidget(m_totalTimeLabel);
|
|
||||||
totalTime->addWidget(m_totalTimeValue);
|
|
||||||
layout->addLayout(totalTime);
|
|
||||||
|
|
||||||
this->setLayout(layout);
|
this->setLayout(layout);
|
||||||
|
|
||||||
|
@ -107,7 +126,7 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
||||||
|
|
||||||
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
|
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
|
||||||
if (!info.isFormatSupported(m_format)) {
|
if (!info.isFormatSupported(m_format)) {
|
||||||
qWarning() << "Default format not supported - trying to use nearest";
|
qWarning("Default format not supported - trying to use nearest");
|
||||||
m_format = info.nearestFormat(m_format);
|
m_format = info.nearestFormat(m_format);
|
||||||
}
|
}
|
||||||
m_decoder = new AudioDecoder(m_format, this);
|
m_decoder = new AudioDecoder(m_format, this);
|
||||||
|
@ -116,6 +135,10 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name):
|
||||||
this, SLOT(durationChanged(qint64)));
|
this, SLOT(durationChanged(qint64)));
|
||||||
connect(m_pullTimer, SIGNAL(timeout()),
|
connect(m_pullTimer, SIGNAL(timeout()),
|
||||||
this, SLOT(pullTimerExpired()));
|
this, SLOT(pullTimerExpired()));
|
||||||
|
|
||||||
|
connect(m_watchDMX, SIGNAL(timeout()),
|
||||||
|
this, SLOT(watchDMXExpired()));
|
||||||
|
m_watchDMX->start(1000);
|
||||||
createAudioOutput();
|
createAudioOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,17 +150,17 @@ AudioLayerWidget::~AudioLayerWidget()
|
||||||
void AudioLayerWidget::createAudioOutput()
|
void AudioLayerWidget::createAudioOutput()
|
||||||
{
|
{
|
||||||
m_audioOutput = new QAudioOutput(m_device, m_format, this);
|
m_audioOutput = new QAudioOutput(m_device, m_format, this);
|
||||||
m_audioOutput->setNotifyInterval(100);
|
Q_CHECK_PTR(m_audioOutput);
|
||||||
|
m_audioOutput->setNotifyInterval(NOTIFY_INTERVAL);
|
||||||
connect(m_audioOutput, SIGNAL(notify()), SLOT(notified()));
|
connect(m_audioOutput, SIGNAL(notify()), SLOT(notified()));
|
||||||
|
reset();
|
||||||
|
m_statusValue->setText(PAUSE_LABEL);
|
||||||
connect(m_audioOutput, SIGNAL(stateChanged(QAudio::State)), SLOT(handleStateChanged(QAudio::State)));
|
connect(m_audioOutput, SIGNAL(stateChanged(QAudio::State)), SLOT(handleStateChanged(QAudio::State)));
|
||||||
m_output = m_audioOutput->start();
|
|
||||||
toggleSuspendResume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioLayerWidget::deviceChanged(int index)
|
void AudioLayerWidget::deviceChanged(int index)
|
||||||
{
|
{
|
||||||
m_pullTimer->stop();
|
m_pullTimer->stop();
|
||||||
m_decoder->stop();
|
|
||||||
m_audioOutput->stop();
|
m_audioOutput->stop();
|
||||||
m_audioOutput->disconnect(this);
|
m_audioOutput->disconnect(this);
|
||||||
m_device = m_deviceBox->itemData(index).value<QAudioDeviceInfo>();
|
m_device = m_deviceBox->itemData(index).value<QAudioDeviceInfo>();
|
||||||
|
@ -161,20 +184,31 @@ void AudioLayerWidget::setVol(qreal vol)
|
||||||
|
|
||||||
void AudioLayerWidget::loadMedia(QString file)
|
void AudioLayerWidget::loadMedia(QString file)
|
||||||
{
|
{
|
||||||
stop();
|
if (m_currentMedia == file)
|
||||||
|
return;
|
||||||
|
reset();
|
||||||
if (QFile::exists(file)){
|
if (QFile::exists(file)){
|
||||||
m_decoder->loadMedia(file);
|
m_decoder->loadMedia(file);
|
||||||
|
m_currentMedia = file;
|
||||||
fileLoaded(file);
|
fileLoaded(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioLayerWidget::fileLoaded(QString file)
|
||||||
|
{
|
||||||
|
QStringList list = file.split("/");
|
||||||
|
int size = list.size();
|
||||||
|
if (size >= 2) {
|
||||||
|
m_folderValue->setText(list.at(size - 2));
|
||||||
|
m_fileValue->setText(list.at(size - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AudioLayerWidget::notified()
|
void AudioLayerWidget::notified()
|
||||||
{
|
{
|
||||||
QTime real(0,0,0,0);
|
m_progressMs += m_progressCounter->restart();
|
||||||
qint64 ms = m_audioOutput->processedUSecs() / 1000 ;
|
m_progressTime->setTime(QTime::fromMSecsSinceStartOfDay(m_progressMs));
|
||||||
real = real.addMSecs(ms);
|
m_progressSlider->setValue(m_progressMs);
|
||||||
m_progressTimeValue->setText(real.toString("h:mm:ss:zzz"));
|
|
||||||
m_progressSlider->setValue(ms);
|
|
||||||
/* qDebug() << "bytesFree = " << m_audioOutput->bytesFree()
|
/* qDebug() << "bytesFree = " << m_audioOutput->bytesFree()
|
||||||
<< ", " << "elapsedUSecs = " << m_audioOutput->elapsedUSecs()
|
<< ", " << "elapsedUSecs = " << m_audioOutput->elapsedUSecs()
|
||||||
<< ", " << "processedUSecs = " << m_audioOutput->processedUSecs();
|
<< ", " << "processedUSecs = " << m_audioOutput->processedUSecs();
|
||||||
|
@ -189,7 +223,7 @@ void AudioLayerWidget::pullTimerExpired()
|
||||||
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) {
|
||||||
stop();
|
stop();
|
||||||
qDebug()<< this->title() << " End of file";
|
qDebug("End of file %s", this->title().toLatin1().constData());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (len) {
|
if (len) {
|
||||||
|
@ -205,72 +239,92 @@ void AudioLayerWidget::pullTimerExpired()
|
||||||
void AudioLayerWidget::toggleSuspendResume()
|
void AudioLayerWidget::toggleSuspendResume()
|
||||||
{
|
{
|
||||||
if (m_audioOutput->state() == QAudio::SuspendedState) {
|
if (m_audioOutput->state() == QAudio::SuspendedState) {
|
||||||
// qDebug() << "status: Suspended, resume()";
|
resume();
|
||||||
m_audioOutput->resume();
|
|
||||||
m_pullTimer->start(20);
|
|
||||||
m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
|
|
||||||
m_statusValue->setText(PLAY_LABEL);
|
|
||||||
} else if (m_audioOutput->state() == QAudio::ActiveState) {
|
} else if (m_audioOutput->state() == QAudio::ActiveState) {
|
||||||
// qDebug() << "status: Active, suspend()";
|
pause();
|
||||||
m_audioOutput->suspend();
|
|
||||||
m_pullTimer->stop();
|
|
||||||
m_suspendResumeButton->setText(tr(RESUME_LABEL));
|
|
||||||
m_statusValue->setText(PAUSE_LABEL);
|
|
||||||
} else if (m_audioOutput->state() == QAudio::StoppedState) {
|
} else if (m_audioOutput->state() == QAudio::StoppedState) {
|
||||||
// qDebug() << "status: Stopped, resume()";
|
|
||||||
play();
|
play();
|
||||||
} else if (m_audioOutput->state() == QAudio::IdleState) {
|
} else if (m_audioOutput->state() == QAudio::IdleState) {
|
||||||
// qDebug() << "status: IdleState";
|
qWarning("%s: IdleState", this->title().toLatin1().constData());
|
||||||
m_statusValue->setText(IDDLE_LABEL);
|
play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioLayerWidget::handleStateChanged(QAudio::State state)
|
void AudioLayerWidget::handleStateChanged(QAudio::State state)
|
||||||
{
|
{
|
||||||
qDebug() << this->title() << " state = " << state;
|
if (state == QAudio::SuspendedState) {
|
||||||
|
m_statusValue->setText(PAUSE_LABEL);
|
||||||
|
} else if (state == QAudio::ActiveState) {
|
||||||
|
m_statusValue->setText(PLAY_LABEL);
|
||||||
|
} else if (m_audioOutput->state() == QAudio::StoppedState) {
|
||||||
|
m_statusValue->setText(STOP_LABEL);
|
||||||
|
} else if (state == QAudio::IdleState) {
|
||||||
|
m_statusValue->setText(IDDLE_LABEL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioLayerWidget::durationChanged(qint64 dur)
|
void AudioLayerWidget::durationChanged(qint64 dur)
|
||||||
{
|
{
|
||||||
if (dur == -1)
|
if (dur == -1)
|
||||||
return;
|
return;
|
||||||
QTime temp(0,0,0,0);
|
m_totalTimeValue->setTime(QTime::fromMSecsSinceStartOfDay(dur));
|
||||||
QTime real = temp.addMSecs(dur);
|
|
||||||
m_totalTimeValue->setText(real.toString("h:mm:ss:zzz"));
|
|
||||||
m_progressSlider->setMaximum(dur);
|
m_progressSlider->setMaximum(dur);
|
||||||
qDebug() << this->title() << " Duration Changed: " << dur;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AudioLayerWidget::fileLoaded(QString file)
|
|
||||||
{
|
|
||||||
QStringList list = file.split("/");
|
|
||||||
int size = list.size();
|
|
||||||
if (size >= 2) {
|
|
||||||
m_folderValue->setText(list.at(size - 2));
|
|
||||||
m_fileValue->setText(list.at(size - 1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioLayerWidget::play()
|
void AudioLayerWidget::play()
|
||||||
{
|
{
|
||||||
// m_decoder->setPos(0);
|
setInitPosition();
|
||||||
m_pullTimer->start(20);
|
m_pullTimer->start(PULL_TIMER_INTERVAL);
|
||||||
m_audioOutput->resume();
|
m_audioOutput->resume();
|
||||||
m_statusValue->setText(PLAY_LABEL);
|
pullTimerExpired();
|
||||||
|
m_progressCounter->start();
|
||||||
m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
|
m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioLayerWidget::pause()
|
void AudioLayerWidget::pause()
|
||||||
{
|
{
|
||||||
toggleSuspendResume();
|
m_audioOutput->suspend();
|
||||||
|
m_pullTimer->stop();
|
||||||
|
m_suspendResumeButton->setText(tr(RESUME_LABEL));
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioLayerWidget::resume()
|
||||||
|
{
|
||||||
|
m_pullTimer->start(PULL_TIMER_INTERVAL);
|
||||||
|
m_audioOutput->resume();
|
||||||
|
pullTimerExpired();
|
||||||
|
m_progressCounter->start();
|
||||||
|
m_suspendResumeButton->setText(tr(SUSPEND_LABEL));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioLayerWidget::stop()
|
void AudioLayerWidget::stop()
|
||||||
{
|
{
|
||||||
m_audioOutput->suspend();
|
reset();
|
||||||
m_pullTimer->stop();
|
setInitPosition();
|
||||||
// m_audioOutput->reset();
|
}
|
||||||
m_decoder->setPos(44);
|
|
||||||
m_statusValue->setText(STOP_LABEL);
|
void AudioLayerWidget::reset()
|
||||||
m_suspendResumeButton->setText(tr(RESUME_LABEL));
|
{
|
||||||
|
m_pullTimer->stop();
|
||||||
|
m_audioOutput->reset();
|
||||||
|
m_output = m_audioOutput->start();
|
||||||
|
Q_CHECK_PTR(m_output);
|
||||||
|
pause();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioLayerWidget::setInitPosition()
|
||||||
|
{
|
||||||
|
m_decoder->setPos(0);
|
||||||
|
m_progressMs = 0;
|
||||||
|
m_progressTime->setTime(QTime::fromMSecsSinceStartOfDay(m_progressMs));
|
||||||
|
m_progressSlider->setValue(m_progressMs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioLayerWidget::watchDMXExpired() {
|
||||||
|
m_receiveDMX->setChecked(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AudioLayerWidget::updateWatchDMX(bool b)
|
||||||
|
{
|
||||||
|
m_receiveDMX->setChecked(b);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,10 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QTime>
|
||||||
|
#include <QTimeEdit>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
#include <QCheckBox>
|
||||||
|
|
||||||
#include "audiodecoder.h"
|
#include "audiodecoder.h"
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
@ -27,7 +30,9 @@ public:
|
||||||
void stop();
|
void stop();
|
||||||
void pause();
|
void pause();
|
||||||
void setVol(qreal vol);
|
void setVol(qreal vol);
|
||||||
|
void resume();
|
||||||
|
|
||||||
|
void updateWatchDMX(bool b);
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void toggleSuspendResume();
|
void toggleSuspendResume();
|
||||||
|
@ -47,10 +52,10 @@ private:
|
||||||
QSlider *m_progressSlider;
|
QSlider *m_progressSlider;
|
||||||
|
|
||||||
QLabel *m_progressTimeLabel;
|
QLabel *m_progressTimeLabel;
|
||||||
QLabel *m_progressTimeValue;
|
QTimeEdit *m_progressTime;
|
||||||
|
|
||||||
QLabel *m_totalTimeLabel;
|
QLabel *m_totalTimeLabel;
|
||||||
QLabel *m_totalTimeValue;
|
QTimeEdit *m_totalTimeValue;
|
||||||
|
|
||||||
QLabel *m_fileLabel;
|
QLabel *m_fileLabel;
|
||||||
QLabel *m_fileValue;
|
QLabel *m_fileValue;
|
||||||
|
@ -58,6 +63,9 @@ private:
|
||||||
QLabel * m_folderLabel;
|
QLabel * m_folderLabel;
|
||||||
QLabel * m_folderValue;
|
QLabel * m_folderValue;
|
||||||
|
|
||||||
|
QCheckBox *m_receiveDMX;
|
||||||
|
QTimer *m_watchDMX;
|
||||||
|
|
||||||
QTimer *m_pullTimer;
|
QTimer *m_pullTimer;
|
||||||
QAudioDeviceInfo m_device;
|
QAudioDeviceInfo m_device;
|
||||||
QAudioOutput *m_audioOutput;
|
QAudioOutput *m_audioOutput;
|
||||||
|
@ -66,8 +74,16 @@ private:
|
||||||
QByteArray m_buffer;
|
QByteArray m_buffer;
|
||||||
AudioDecoder *m_decoder;
|
AudioDecoder *m_decoder;
|
||||||
|
|
||||||
|
QTime *m_progressCounter;
|
||||||
|
quint64 m_progressMs;
|
||||||
|
|
||||||
|
QString m_currentMedia;
|
||||||
|
|
||||||
void createAudioOutput();
|
void createAudioOutput();
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
void setInitPosition();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void notified();
|
void notified();
|
||||||
void pullTimerExpired();
|
void pullTimerExpired();
|
||||||
|
@ -75,7 +91,7 @@ private slots:
|
||||||
void handleStateChanged(QAudio::State state);
|
void handleStateChanged(QAudio::State state);
|
||||||
void deviceChanged(int index);
|
void deviceChanged(int index);
|
||||||
void durationChanged(qint64 dur);
|
void durationChanged(qint64 dur);
|
||||||
|
void watchDMXExpired();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,11 +35,17 @@ void AudioWidget::playbackChanged(int layer, QAudio::State state)
|
||||||
dynamic_cast<AudioLayerWidget *>(item->widget())->play();
|
dynamic_cast<AudioLayerWidget *>(item->widget())->play();
|
||||||
break;
|
break;
|
||||||
case QAudio::StoppedState:
|
case QAudio::StoppedState:
|
||||||
dynamic_cast<AudioLayerWidget *>(item->widget())->stop();
|
dynamic_cast<AudioLayerWidget *>(item->widget())->pause();
|
||||||
break;
|
break;
|
||||||
case QAudio::SuspendedState:
|
case QAudio::SuspendedState:
|
||||||
dynamic_cast<AudioLayerWidget *>(item->widget())->toggleSuspendResume();
|
dynamic_cast<AudioLayerWidget *>(item->widget())->resume();
|
||||||
case QAudio::IdleState:
|
case QAudio::IdleState:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioWidget::layerReceived(int layer)
|
||||||
|
{
|
||||||
|
QLayoutItem * const item = layout->itemAt(layer);
|
||||||
|
dynamic_cast<AudioLayerWidget *>(item->widget())->updateWatchDMX(true);
|
||||||
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ public slots:
|
||||||
void mediaLoaded(int layer, QString media);
|
void mediaLoaded(int layer, QString media);
|
||||||
void volChanged(int layer, qreal vol);
|
void volChanged(int layer, qreal vol);
|
||||||
void playbackChanged(int layer, QAudio::State state);
|
void playbackChanged(int layer, QAudio::State state);
|
||||||
|
void layerReceived(int layer);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AUDIOWIDGET_H
|
#endif // AUDIOWIDGET_H
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#ifndef DEFINES_H
|
#ifndef DEFINES_H
|
||||||
#define DEFINES_H
|
#define DEFINES_H
|
||||||
|
|
||||||
|
|
||||||
#define VERSION "Libre Media Server Audio 0.1.0"
|
#define VERSION "Libre Media Server Audio 0.1.0"
|
||||||
#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"
|
||||||
|
@ -13,22 +12,27 @@
|
||||||
const int DurationSeconds = 1;
|
const int DurationSeconds = 1;
|
||||||
const int ToneSampleRateHz = 600;
|
const int ToneSampleRateHz = 600;
|
||||||
const int DataSampleRateHz = 44100;
|
const int DataSampleRateHz = 44100;
|
||||||
const int BufferSize = 32768;
|
const int BufferSize = 262144;
|
||||||
|
|
||||||
#define SUSPEND_LABEL "Suspend playback"
|
#define SUSPEND_LABEL "Pause playback"
|
||||||
#define RESUME_LABEL "Resume playback"
|
#define RESUME_LABEL "Resume playback"
|
||||||
#define PLAY_LABEL "Playing"
|
|
||||||
#define STOP_LABEL "Stopped"
|
#define PLAY_LABEL "Playing"
|
||||||
#define PAUSE_LABEL "Pause"
|
#define STOP_LABEL "Stopped"
|
||||||
#define IDDLE_LABEL "Iddle playback"
|
#define PAUSE_LABEL "Pause"
|
||||||
#define VOLUME_LABEL "Volume:"
|
#define IDDLE_LABEL "Iddle playback"
|
||||||
#define PROGRESS_LABEL "Progress: "
|
|
||||||
#define PROGRESS_TIME_LABEL "Current Time: "
|
#define VOLUME_LABEL "Volume"
|
||||||
|
#define PROGRESS_LABEL "Progress"
|
||||||
|
#define PROGRESS_TIME_LABEL "Current"
|
||||||
#define REMAINING_TIME "Remaining Time: "
|
#define REMAINING_TIME "Remaining Time: "
|
||||||
#define TOTAL_TIME_LABEL "Total Time: "
|
#define TOTAL_TIME_LABEL "Total"
|
||||||
#define FILE_LABEL "File: "
|
#define FILE_LABEL "File: "
|
||||||
#define FOLDER_LABEL "Folder: "
|
#define FOLDER_LABEL "Folder: "
|
||||||
#define STATUS_LABEL "Status: "
|
#define STATUS_LABEL " Status: "
|
||||||
|
|
||||||
|
#define NOTIFY_INTERVAL 150
|
||||||
|
#define PULL_TIMER_INTERVAL 10
|
||||||
|
|
||||||
// struct where save the DMX settings for each layer
|
// struct where save the DMX settings for each layer
|
||||||
struct dmxSetting {
|
struct dmxSetting {
|
||||||
|
|
|
@ -33,14 +33,21 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
|
||||||
Q_UNUSED(args);
|
Q_UNUSED(args);
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
|
|
||||||
// Inicia el widget Terminal
|
// Inicia la lectura de dmx a través de ola
|
||||||
textEdit = new QTextEdit;
|
ola = new olaThread();
|
||||||
textEdit->setReadOnly(true);
|
Q_CHECK_PTR(ola);
|
||||||
QDockWidget *bottomWidget = new QDockWidget(tr("Terminal"), this);
|
|
||||||
bottomWidget->setAllowedAreas(Qt::BottomDockWidgetArea);
|
|
||||||
bottomWidget->setWidget(textEdit);
|
|
||||||
addDockWidget(Qt::BottomDockWidgetArea, bottomWidget);
|
|
||||||
|
|
||||||
|
if (args.contains("-log")) {
|
||||||
|
// Inicia el widget Terminal
|
||||||
|
textEdit = new QTextEdit;
|
||||||
|
textEdit->setReadOnly(true);
|
||||||
|
QDockWidget *bottomWidget = new QDockWidget(tr("Terminal"), this);
|
||||||
|
bottomWidget->setAllowedAreas(Qt::BottomDockWidgetArea);
|
||||||
|
bottomWidget->setWidget(textEdit);
|
||||||
|
addDockWidget(Qt::BottomDockWidgetArea, bottomWidget);
|
||||||
|
connect(ola, SIGNAL(toTerminal(QString)),
|
||||||
|
textEdit, SLOT(append(QString)), Qt::QueuedConnection);
|
||||||
|
}
|
||||||
this->setWindowTitle(VERSION);
|
this->setWindowTitle(VERSION);
|
||||||
|
|
||||||
// qDebug() << QDate::currentDate().toString() << " "<< QTime::currentTime().toString();
|
// qDebug() << QDate::currentDate().toString() << " "<< QTime::currentTime().toString();
|
||||||
|
@ -52,13 +59,7 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
|
||||||
aw = new AudioWidget(this);
|
aw = new AudioWidget(this);
|
||||||
setCentralWidget(aw);
|
setCentralWidget(aw);
|
||||||
|
|
||||||
// Inicia la lectura de dmx a través de ola
|
// Inicia la lectur de datos DMX
|
||||||
ola = new olaThread();
|
|
||||||
Q_CHECK_PTR(ola);
|
|
||||||
|
|
||||||
connect(ola, SIGNAL(toTerminal(QString)),
|
|
||||||
textEdit, SLOT(append(QString)), Qt::QueuedConnection);
|
|
||||||
|
|
||||||
ola->blockSignals(true);
|
ola->blockSignals(true);
|
||||||
ola->start(QThread::TimeCriticalPriority );
|
ola->start(QThread::TimeCriticalPriority );
|
||||||
|
|
||||||
|
@ -88,13 +89,14 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
|
||||||
ola, SLOT( setLayersNumber(int)));
|
ola, SLOT( setLayersNumber(int)));
|
||||||
connect(set, SIGNAL( DMXConf(dmxSetting ) ),
|
connect(set, SIGNAL( DMXConf(dmxSetting ) ),
|
||||||
ola, SLOT( setDMXConf(dmxSetting) ) );
|
ola, SLOT( setDMXConf(dmxSetting) ) );
|
||||||
|
connect(ola, SIGNAL (layerReceived(int)),
|
||||||
connect(ola, SIGNAL( dmxOutput(int, int, int) ),
|
aw, SLOT(layerReceived(int)));
|
||||||
this, SLOT( dmxInput(int, int, int) ) );
|
|
||||||
|
|
||||||
// Lee la configuración por defecto
|
// Lee la configuración por defecto
|
||||||
set->readDefaultFile();
|
set->readDefaultFile();
|
||||||
ola->blockSignals(false);
|
ola->blockSignals(false);
|
||||||
|
connect(ola, SIGNAL( dmxOutput(int, int, int) ),
|
||||||
|
this, SLOT( dmxInput(int, int, int) ) );
|
||||||
ola->resendDmx();
|
ola->resendDmx();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,6 +175,8 @@ void libreMediaServerAudio::dmxInput(int layer, int channel, int value)
|
||||||
{
|
{
|
||||||
// This qDebug slows all the program. Uncomment only for debugging purpouse and comment again in normal use
|
// This qDebug slows all the program. Uncomment only for debugging purpouse and comment again in normal use
|
||||||
// qDebug() << tr("olaInterface|") << "newdmx layer" << layer << "channel" << channel << "value" << value;
|
// qDebug() << tr("olaInterface|") << "newdmx layer" << layer << "channel" << channel << "value" << value;
|
||||||
|
if (layer > LAYER_CHANNELS)
|
||||||
|
return;
|
||||||
QString mediaFile = NULL;
|
QString mediaFile = NULL;
|
||||||
int aux;
|
int aux;
|
||||||
qreal f;
|
qreal f;
|
||||||
|
@ -201,6 +205,8 @@ void libreMediaServerAudio::dmxInput(int layer, int channel, int value)
|
||||||
f = (float)value / 255;
|
f = (float)value / 255;
|
||||||
break;
|
break;
|
||||||
case PLAYBACK:
|
case PLAYBACK:
|
||||||
|
if (value == 0)
|
||||||
|
break;
|
||||||
aux = value / 25;
|
aux = value / 25;
|
||||||
switch (aux) {
|
switch (aux) {
|
||||||
case 0 :
|
case 0 :
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LIBREMEDIASERVER_H
|
#ifndef LIBREMEDIASERVERAUDIO_H
|
||||||
#define LIBREMEDIASERVER_H
|
#define LIBREMEDIASERVERAUDIO_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QDockWidget>
|
#include <QDockWidget>
|
||||||
|
@ -59,7 +59,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// void MessageHandler(QtMsgType type, const QMessageLogContext &logcontext, const QString &msg);
|
// void MessageHandler(QtMsgType type, const QMessageLogContext &logcontext, const QString &msg);
|
||||||
AudioMasterWidget *amw;
|
AudioMasterWidget *amw;
|
||||||
AudioWidget *aw;
|
AudioWidget *aw;
|
||||||
olaThread *ola;
|
olaThread *ola;
|
||||||
|
@ -88,4 +88,4 @@ private slots:
|
||||||
void ChangeMediaPath();// Change the path to medias
|
void ChangeMediaPath();// Change the path to medias
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LIBREMEDIASERVER_H
|
#endif // LIBREMEDIASERVERAUDIO_H
|
||||||
|
|
53
src/main.cpp
53
src/main.cpp
|
@ -79,29 +79,54 @@ void MessageHandler(QtMsgType type, const QMessageLogContext &context, const QSt
|
||||||
QString txt;
|
QString txt;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case QtDebugMsg:
|
case QtDebugMsg:
|
||||||
txt.append("Debug: ");
|
txt.append("Debug from File: ");
|
||||||
txt.append(context.file);
|
txt.append(context.file);
|
||||||
txt.append(context.line);
|
txt.append(" Line: ");
|
||||||
|
txt.append(QString::number(context.line));
|
||||||
|
txt.append(" Function: ");
|
||||||
txt.append(context.function);
|
txt.append(context.function);
|
||||||
|
txt.append(" Message: ");
|
||||||
txt.append(msg);
|
txt.append(msg);
|
||||||
// libreMediaServerAudio::textEdit->append(msg);, context.file, context.line, context.function);
|
// libreMediaServerAudio::textEdit->append(msg);, context.file, context.line, context.function);
|
||||||
libreMediaServerAudio::textEdit->append(txt);
|
libreMediaServerAudio::textEdit->append(txt);
|
||||||
break;
|
break;
|
||||||
case QtWarningMsg:
|
case QtWarningMsg:
|
||||||
// txt.append("Warning: ");
|
txt.append("Warning from File: ");
|
||||||
// txt.append(msg);
|
txt.append(context.file);
|
||||||
libreMediaServerAudio::textEdit->append(msg);
|
txt.append(" Line: ");
|
||||||
|
txt.append(QString::number(context.line));
|
||||||
|
txt.append(" Function: ");
|
||||||
|
txt.append(context.function);
|
||||||
|
txt.append(" Message: ");
|
||||||
|
txt.append(msg);
|
||||||
|
// libreMediaServerAudio::textEdit->append(msg);, context.file, context.line, context.function);
|
||||||
|
libreMediaServerAudio::textEdit->append(txt);
|
||||||
|
abort();
|
||||||
break;
|
break;
|
||||||
case QtCriticalMsg:
|
case QtCriticalMsg:
|
||||||
// txt.append("Critical: ");
|
// txt.append("Critical from File: ");
|
||||||
// txt.append(msg);
|
txt.append(context.file);
|
||||||
libreMediaServerAudio::textEdit->append(msg);
|
txt.append(" Line: ");
|
||||||
|
txt.append(QString::number(context.line));
|
||||||
|
txt.append(" Function: ");
|
||||||
|
txt.append(context.function);
|
||||||
|
txt.append(" Message ");
|
||||||
|
txt.append(msg);
|
||||||
|
// libreMediaServerAudio::textEdit->append(msg);, context.file, context.line, context.function);
|
||||||
|
libreMediaServerAudio::textEdit->append(txt);
|
||||||
|
abort();
|
||||||
break;
|
break;
|
||||||
case QtFatalMsg:
|
case QtFatalMsg:
|
||||||
// txt.append("Fatal: ");
|
// txt.append("Fatal from File: ");
|
||||||
// txt.append(msg);
|
txt.append(context.file);
|
||||||
libreMediaServerAudio::textEdit->append(msg);
|
txt.append(" Line: ");
|
||||||
// ts << txt << endl;
|
txt.append(QString::number(context.line));
|
||||||
|
txt.append(" Function: ");
|
||||||
|
txt.append(context.function);
|
||||||
|
txt.append(" Message: ");
|
||||||
|
txt.append(msg);
|
||||||
|
// libreMediaServerAudio::textEdit->append(msg);, context.file, context.line, context.function);
|
||||||
|
libreMediaServerAudio::textEdit->append(txt);// ts << txt << endl;
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
// outFile.write(txt.toLatin1().constData(), txt.size());
|
// outFile.write(txt.toLatin1().constData(), txt.size());
|
||||||
|
@ -120,9 +145,9 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
qInstallMessageHandler(MessageHandler);
|
qInstallMessageHandler(MessageHandler);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
|
||||||
qInstallMessageHandler(MessageHandler);
|
qInstallMessageHandler(MessageHandler);
|
||||||
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
QStringList args = app.arguments();
|
QStringList args = app.arguments();
|
||||||
// parse the command line
|
// parse the command line
|
||||||
if (args.size() > 1)
|
if (args.size() > 1)
|
||||||
|
|
|
@ -27,7 +27,7 @@ MediaLibrary::MediaLibrary(QObject *parent) :
|
||||||
void MediaLibrary::initMediaLibrary() {
|
void MediaLibrary::initMediaLibrary() {
|
||||||
QDir dir;
|
QDir dir;
|
||||||
if (!dir.cd(m_pathmedia)) {
|
if (!dir.cd(m_pathmedia)) {
|
||||||
qWarning() << "olaInterface::initMediaLibrary| Can not cd to the path: " << m_pathmedia.toLatin1().constData();
|
qWarning("Can not cd to the path: %s", m_pathmedia.toLatin1().constData());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_media = new QList<MediaFolder>;
|
m_media = new QList<MediaFolder>;
|
||||||
|
|
|
@ -75,18 +75,19 @@ void olaThread::NewDmx(const ola::client::DMXMetadata &data,
|
||||||
gettimeofday(&m_last_data, NULL);
|
gettimeofday(&m_last_data, NULL);
|
||||||
uint universe = data.universe;
|
uint universe = data.universe;
|
||||||
for (int i = 0; i < m_layersNumber; i++) { // loop for reading the channels by layer.
|
for (int i = 0; i < m_layersNumber; i++) { // loop for reading the channels by layer.
|
||||||
if((m_settings.at(i).universe == universe)
|
if(m_settings.at(i).universe == universe) { // Compare if the layer is from this universe
|
||||||
&& ( m_settings.at(i).address > -1 )) { // Compare if the layer is from this universe
|
if ( m_settings.at(i).address > -1 ) { // AND if the DMX address is 0 or greater, process this layer.
|
||||||
// AND if the DMX address is 0 or greater, process this layer.
|
emit layerReceived(i);
|
||||||
for (int j = 0; j < LAYER_CHANNELS; j++){
|
for (int j = 0; j < LAYER_CHANNELS; j++){
|
||||||
int value = buffer.Get((m_settings.at(i).address) + j); // Get the value for this channel.
|
int value = buffer.Get((m_settings.at(i).address) + j); // Get the value for this channel.
|
||||||
if (m_dmx[i][j] != value) { // Compare the new value with the old value.
|
if (m_dmx[i][j] != value) { // Compare the new value with the old value.
|
||||||
emit dmxOutput(i,j,value); // Connected with dmx slot in olaInterface.
|
emit dmxOutput(i,j,value);
|
||||||
m_dmx[i][j] = value;
|
m_dmx[i][j] = value;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,7 +109,13 @@ bool olaThread::CheckDataLoss() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void olaThread::setLayersNumber(int layersNumber) { m_layersNumber = layersNumber; }
|
void olaThread::setLayersNumber(int layersNumber)
|
||||||
|
{
|
||||||
|
if (layersNumber <= LAYERS_NUMBER)
|
||||||
|
m_layersNumber = layersNumber;
|
||||||
|
else
|
||||||
|
m_layersNumber = LAYERS_NUMBER;
|
||||||
|
}
|
||||||
|
|
||||||
void olaThread::resendDmx()
|
void olaThread::resendDmx()
|
||||||
{
|
{
|
||||||
|
@ -119,6 +126,17 @@ void olaThread::resendDmx()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void olaThread::setDMXConf(dmxSetting set)
|
||||||
|
{
|
||||||
|
if (set.layer >= m_layersNumber) { return; }
|
||||||
|
m_settings.replace(set.layer, set);
|
||||||
|
// ToDo: registro del nuevo universo si no está registrado ya
|
||||||
|
if (!m_universe->contains(set.universe)) {
|
||||||
|
registerUniverse(set.universe);
|
||||||
|
m_universe->append(set.universe);
|
||||||
|
}
|
||||||
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -67,10 +67,10 @@ private:
|
||||||
// typedef SingleUseCallback1<void, const Result&> ola::client::SetCallback
|
// typedef SingleUseCallback1<void, const Result&> ola::client::SetCallback
|
||||||
inline void RegisterComplete(const ola::client::Result &error) {
|
inline void RegisterComplete(const ola::client::Result &error) {
|
||||||
if (error.Success()) {
|
if (error.Success()) {
|
||||||
qDebug() << "Register Universe success";
|
// qDebug("Register Universe success");
|
||||||
emit toTerminal("Register Universe success");
|
emit toTerminal("Register Universe success");
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "olaThread|" << "Register command failed" << QString::fromStdString(error.Error());
|
// qWarning("Register command failed: %s", error.Error().c_str());
|
||||||
emit toTerminal("olaThread| Register command failed " + QString::fromStdString(error.Error()));
|
emit toTerminal("olaThread| Register command failed " + QString::fromStdString(error.Error()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,15 +84,7 @@ public slots:
|
||||||
|
|
||||||
void stop(); // Close the connection with olad.
|
void stop(); // Close the connection with olad.
|
||||||
void setLayersNumber(int layersNumber);
|
void setLayersNumber(int layersNumber);
|
||||||
inline void setDMXConf(dmxSetting set) {
|
void setDMXConf(dmxSetting set);
|
||||||
if (set.layer >= m_layersNumber) { return; }
|
|
||||||
m_settings.replace(set.layer, set);
|
|
||||||
// ToDo: registro del nuevo universo si no está registrado ya
|
|
||||||
if (!m_universe->contains(set.universe)) {
|
|
||||||
registerUniverse(set.universe);
|
|
||||||
m_universe->append(set.universe);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
|
|
||||||
|
@ -101,6 +93,7 @@ signals:
|
||||||
void finished(); // Signal for closing. Not used now.
|
void finished(); // Signal for closing. Not used now.
|
||||||
void dmxOutput(int layer, int channel, int value); // Signal when a channel has changed
|
void dmxOutput(int layer, int channel, int value); // Signal when a channel has changed
|
||||||
void toTerminal(QString message);
|
void toTerminal(QString message);
|
||||||
|
void layerReceived(int i);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OLATHREAD_H
|
#endif // OLATHREAD_H
|
||||||
|
|
|
@ -23,7 +23,7 @@ void Settings::readFromFile(QString file) {
|
||||||
QXmlStreamReader* xmlReader = new QXmlStreamReader(xmlFile);
|
QXmlStreamReader* xmlReader = new QXmlStreamReader(xmlFile);
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
//Parse the XML until we reach end of it
|
//Parse the XML until we reach end of it
|
||||||
while(!xmlReader->atEnd() && !xmlReader->hasError()) {
|
while(!xmlReader->atEnd() && !xmlReader->hasError() && counter < LAYERS_NUMBER) {
|
||||||
// Read next element
|
// Read next element
|
||||||
QXmlStreamReader::TokenType token = xmlReader->readNext();
|
QXmlStreamReader::TokenType token = xmlReader->readNext();
|
||||||
//If token is just StartDocument - go to next
|
//If token is just StartDocument - go to next
|
||||||
|
|
Loading…
Add table
Reference in a new issue