diff --git a/src/audiolayerwidget.cpp b/src/audiolayerwidget.cpp index 3372692..79eba4c 100644 --- a/src/audiolayerwidget.cpp +++ b/src/audiolayerwidget.cpp @@ -7,14 +7,10 @@ #include #include -//#include // nanosleep y la chapuza de liberar el buffer - AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name): QGroupBox(parent) - , m_suspendResumeButton(0) + , m_suspendResumeButton(0) , m_watchDMX(new QTimer(this)) -// , m_progressCounter(new QTime(0,0,0,1)) -// , m_progressMs(0) , m_currentMedia(" ") , m_running(false) { @@ -105,6 +101,8 @@ AudioLayerWidget::AudioLayerWidget(QWidget *parent, QString name): connect(m_watchDMX, SIGNAL(timeout()), this, SLOT(watchDMXExpired())); m_watchDMX->start(243); + + m_music.setAttenuation(0); } AudioLayerWidget::~AudioLayerWidget() @@ -117,7 +115,6 @@ void AudioLayerWidget::volumeChanged(int value) m_music.setVolume(value); } -// volume range 0 -100 void AudioLayerWidget::setVol(qreal vol) { m_music.setVolume(vol); @@ -128,8 +125,7 @@ void AudioLayerWidget::setVol(qreal vol) void AudioLayerWidget::loadMedia(QString file) { - if (m_currentMedia == file ) { - fileLoaded(file); + if (m_currentMedia.compare(file) == 0 ) { return; } if (!QFile::exists(file)) { @@ -141,9 +137,8 @@ void AudioLayerWidget::loadMedia(QString file) qWarning("Can not open file %s", file.toLatin1().constData()); return; } - m_music.setAttenuation(0); -// m_progressCounter->restart(); + m_currentMedia = file; durationChanged(m_music.getDuration().asMilliseconds()); fileLoaded(file); @@ -162,16 +157,8 @@ void AudioLayerWidget::fileLoaded(QString file) m_folderValue->setText(list.at(size - 2)); m_fileValue->setText(list.at(size - 1)); } -// m_progressMs = 0; -// m_progressTime->setTime(QTime::fromMSecsSinceStartOfDay(m_progressMs)); } -/* -void AudioLayerWidget::notified() -{ -} -*/ -// duration in miliseconds void AudioLayerWidget::durationChanged(qint64 dur) { m_progressSlider->setMaximum(dur); @@ -181,13 +168,11 @@ void AudioLayerWidget::durationChanged(qint64 dur) void AudioLayerWidget::play() { m_music.play(); -// m_progressCounter->restart(); } void AudioLayerWidget::pause() { m_music.pause(); -// m_progressCounter->restart(); } void AudioLayerWidget::stop() @@ -200,7 +185,6 @@ void AudioLayerWidget::watchDMXExpired() { int progress; switch (m_music.getStatus()) { case sf::SoundSource::Playing: -// m_progressMs += m_progressCounter->restart(); progress = m_music.getPlayingOffset().asMilliseconds(); m_progressSlider->setValue(progress); m_progressTime->setTime(QTime::fromMSecsSinceStartOfDay(progress)); @@ -212,8 +196,6 @@ void AudioLayerWidget::watchDMXExpired() { m_suspendResumeButton->setText(tr(RESUME_LABEL)); break; case sf::SoundSource::Stopped: -// m_progressCounter->restart(); -// m_progressMs = 0; m_progressTime->setTime(QTime::fromMSecsSinceStartOfDay(0)); m_statusValue->setText(STOP_LABEL); m_suspendResumeButton->setText(tr(RESUME_LABEL)); @@ -221,20 +203,13 @@ void AudioLayerWidget::watchDMXExpired() { break; } } -/* -void AudioLayerWidget::updateWatchDMX(bool b) -{ -// m_receiveDMX->setChecked(b); -} -*/ + void AudioLayerWidget::toggleSuspendResume() { if (m_music.getStatus() == sf::SoundSource::Playing) { m_music.pause(); -// m_suspendResumeButton->setText(tr(SUSPEND_LABEL)); } else { m_music.play(); -// m_suspendResumeButton->setText(tr(PLAY_LABEL)); } } diff --git a/src/audiolayerwidget.h b/src/audiolayerwidget.h index 6f3da58..d026263 100644 --- a/src/audiolayerwidget.h +++ b/src/audiolayerwidget.h @@ -26,17 +26,49 @@ public: explicit AudioLayerWidget(QWidget *parent = 0, QString name = "Layer"); ~AudioLayerWidget(); + /** + * @brief load a new media file + * @param file name with full path + */ void loadMedia(QString file); + + /** + * @brief play + */ void play(); + + /** + * @brief stop + */ void stop(); + + /** + * @brief pause + */ void pause(); + + /** + * @brief set the Volume + * @param vol volume range 0 -100 + */ void setVol(qreal vol); + + /** + * @brief resume + */ void resume(); -// void updateWatchDMX(bool b); public slots: + /** + * @brief connected with the button + */ void toggleSuspendResume(); + + /** + * @brief Conencted with the slider + * @param volume 0 -100 range + */ void volumeChanged(int vol); private: @@ -67,9 +99,6 @@ private: QCheckBox *m_receiveDMX; QTimer *m_watchDMX; -// QTime *m_progressCounter; -// quint64 m_progressMs; - QString m_currentMedia; bool m_running; @@ -77,9 +106,22 @@ private: sf::Music m_music; private slots: -// void notified(); + + /** + * @brief Update the GUI elements with the name of the new file loaded + * @param file + */ void fileLoaded(QString file); + + /** + * @brief Update the GUI elements with the duration of the new file loaded + * @param dur The duration of the track in miliseconds + */ void durationChanged(qint64 dur); + + /** + * @brief Update the variable elements in GUI + */ void watchDMXExpired(); }; diff --git a/src/libremediaserver-audio.cpp b/src/libremediaserver-audio.cpp index ef06a5c..28cfed8 100755 --- a/src/libremediaserver-audio.cpp +++ b/src/libremediaserver-audio.cpp @@ -94,7 +94,6 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent) ola->blockSignals(false); connect(ola, SIGNAL( dmxOutput(int, int, int) ), this, SLOT( dmxInput(int, int, int) ) ); - ola->resendDmx(); qDebug("Init Complete"); } diff --git a/src/olathread.cpp b/src/olathread.cpp index fe5c6e0..eea1d4e 100644 --- a/src/olathread.cpp +++ b/src/olathread.cpp @@ -7,7 +7,7 @@ olaThread::olaThread(QObject *parent) Q_UNUSED(parent); m_counter = 0; gettimeofday(&m_last_data, NULL); -// Init the dmx buffer to 0 + // Init the dmx buffer to 0 for (int i=0; i < LAYERS_NUMBER; i++) { for (int j=0; j < LAYER_CHANNELS; j++) @@ -62,7 +62,7 @@ void olaThread::stop() } } -// ToDo: It can be more efficient making the dmx buffer a DmxBuffer class instead a int array and compare with the new if there is changes at start. Also all access to the buffer it should be get/set. I should profile this + void olaThread::NewDmx(const ola::client::DMXMetadata &data, const ola::DmxBuffer &buffer) { @@ -107,7 +107,7 @@ void olaThread::resendDmx() // qDebug() << "Resending DMX info"; for (int i = 0; i < Settings::getInstance()->getLayersNumber(); i++) { // loop for reading the channels by layer. for (int j = 0; j < LAYER_CHANNELS; j++){ - emit dmxOutput(i, j, m_dmx[i][j]); // Connected with dmx slot in olaInterface. + emit dmxOutput(i, j, m_dmx[i][j]); } } } @@ -116,15 +116,9 @@ void olaThread::socketClosed() { qWarning("ola close the connection. Trying reopening it... "); emit toTerminal("OLA closed the connection. Tryin reopening it... "); - // Qúe limpiamos? todo? el thread? - if (!m_client->Stop()) - { - qWarning("Can not stop the ola client"); - } + m_clientWrapper->GetSelectServer()->Terminate(); -// delete m_client; m_client = NULL; -// delete m_clientWrapper; m_clientWrapper = NULL; // set up ola connection diff --git a/src/olathread.h b/src/olathread.h index 4e8e1b1..5df00f9 100644 --- a/src/olathread.h +++ b/src/olathread.h @@ -131,7 +131,7 @@ protected slots: 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 toTerminal(QString message); void universeReceived(uint universe);