diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/qmmp/inputsource.cpp | 14 | ||||
| -rw-r--r-- | src/qmmp/inputsource.h | 7 | ||||
| -rw-r--r-- | src/qmmp/qmmpaudioengine.cpp | 19 | ||||
| -rw-r--r-- | src/qmmp/qmmpaudioengine.h | 1 | ||||
| -rw-r--r-- | src/qmmp/soundcore.cpp | 3 | ||||
| -rw-r--r-- | src/qmmp/soundcore.h | 2 | ||||
| -rw-r--r-- | src/qmmpui/mediaplayer.cpp | 6 | ||||
| -rw-r--r-- | src/qmmpui/mediaplayer.h | 4 | ||||
| -rw-r--r-- | src/ui/mainwindow.cpp | 5 |
9 files changed, 45 insertions, 16 deletions
diff --git a/src/qmmp/inputsource.cpp b/src/qmmp/inputsource.cpp index c26322a29..885195398 100644 --- a/src/qmmp/inputsource.cpp +++ b/src/qmmp/inputsource.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009 by Ilya Kotov * + * Copyright (C) 2009-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -31,13 +31,23 @@ InputSource::InputSource(const QString &source, QObject *parent) : QObject(parent) { m_url = source; + m_offset = -1; } -const QString InputSource::url() +const QString InputSource::url() const { return m_url; } +qint64 InputSource::offset() const +{ + return m_offset; +} +void InputSource::setOffset(qint64 offset) +{ + m_offset = offset; +} + // static methods QList<InputSourceFactory*> *InputSource::m_factories = 0; QStringList InputSource::m_files; diff --git a/src/qmmp/inputsource.h b/src/qmmp/inputsource.h index 7eb38a9f3..06a33b55b 100644 --- a/src/qmmp/inputsource.h +++ b/src/qmmp/inputsource.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2009 by Ilya Kotov * + * Copyright (C) 2009-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -38,7 +38,9 @@ public: virtual QIODevice *ioDevice() = 0; virtual bool initialize() = 0; virtual bool isReady() = 0; - const QString url(); + const QString url() const; + qint64 offset() const; + void setOffset(qint64 offset); static InputSource *create(const QString &url, QObject *parent = 0); /*! @@ -55,6 +57,7 @@ signals: private: QString m_url; + qint64 m_offset; static void checkFactories(); static QList<InputSourceFactory*> *m_factories; static QStringList m_files; diff --git a/src/qmmp/qmmpaudioengine.cpp b/src/qmmp/qmmpaudioengine.cpp index 79fc9cbd5..b26170b6f 100644 --- a/src/qmmp/qmmpaudioengine.cpp +++ b/src/qmmp/qmmpaudioengine.cpp @@ -101,6 +101,7 @@ bool QmmpAudioEngine::enqueue(InputSource *source) mutex()->lock(); if(m_decoder && m_decoder->nextURL() == source->url()) { + m_inputs.value(m_decoder)->setOffset(source->offset()); delete source; m_next = TRUE; mutex()->unlock(); @@ -134,6 +135,8 @@ bool QmmpAudioEngine::enqueue(InputSource *source) } m_decoders.enqueue(decoder); m_inputs.insert(decoder, source); + if(!decoder->totalTime()) + source->setOffset(-1); source->setParent(this); return TRUE; } @@ -362,8 +365,8 @@ void QmmpAudioEngine::run() mutex()->unlock (); return; } - m_decoder = m_decoders.dequeue(); + addOffset(); //offset m_replayGain->setReplayGainInfo(m_decoder->replayGainInfo()); mutex()->unlock(); m_output->start(); @@ -406,6 +409,7 @@ void QmmpAudioEngine::run() StateHandler::instance()->dispatch(Qmmp::Playing); m_decoder->next(); m_output->seek(0); //reset counter + addOffset(); //offset mutex()->unlock(); continue; } @@ -414,6 +418,7 @@ void QmmpAudioEngine::run() m_inputs.take(m_decoder)->deleteLater (); delete m_decoder; m_decoder = m_decoders.dequeue(); + //m_seekTime = m_inputs.value(m_decoder)->offset(); m_replayGain->setReplayGainInfo(m_decoder->replayGainInfo()); //use current output if possible if(m_decoder->audioParameters() == m_ap) @@ -425,6 +430,7 @@ void QmmpAudioEngine::run() m_output->seek(0); //reset counter mutex()->unlock(); sendMetaData(); + addOffset(); //offset continue; } else @@ -445,6 +451,7 @@ void QmmpAudioEngine::run() { m_output->start(); sendMetaData(); + addOffset(); //offset continue; } } @@ -525,6 +532,16 @@ void QmmpAudioEngine::flush(bool final) } } +void QmmpAudioEngine::addOffset() +{ + qint64 pos = m_inputs.value(m_decoder)->offset(); + if(pos > 0) + { + m_seekTime = pos; + m_output->seek(pos); + } +} + void QmmpAudioEngine::sendMetaData() { if(!m_decoder || m_inputs.isEmpty()) diff --git a/src/qmmp/qmmpaudioengine.h b/src/qmmp/qmmpaudioengine.h index 019088d93..9394732f3 100644 --- a/src/qmmp/qmmpaudioengine.h +++ b/src/qmmp/qmmpaudioengine.h @@ -65,6 +65,7 @@ private: void run(); void reset(); void flush(bool = FALSE); + void addOffset(); qint64 produceSound(char *data, qint64 size, quint32 brate, int chan); void sendMetaData(); Output *createOutput(Decoder *d); diff --git a/src/qmmp/soundcore.cpp b/src/qmmp/soundcore.cpp index 86fb7c0db..4dad3b0e4 100644 --- a/src/qmmp/soundcore.cpp +++ b/src/qmmp/soundcore.cpp @@ -75,7 +75,7 @@ SoundCore::~SoundCore() MetaDataManager::destroy(); } -bool SoundCore::play(const QString &source, bool queue) +bool SoundCore::play(const QString &source, bool queue, qint64 offset) { if(!queue) { @@ -85,6 +85,7 @@ bool SoundCore::play(const QString &source, bool queue) MetaDataManager::instance(); //create metadata manager InputSource *s = InputSource::create(source, this); + s->setOffset(offset); m_pendingSources.append(s); if(state() == Qmmp::Stopped) m_handler->dispatch(Qmmp::Buffering); diff --git a/src/qmmp/soundcore.h b/src/qmmp/soundcore.h index 14ba2bc30..2c0ae5a62 100644 --- a/src/qmmp/soundcore.h +++ b/src/qmmp/soundcore.h @@ -124,7 +124,7 @@ public slots: * Returns \b true if playback has been started successful or source is not a local file, * otherwise returns \b false. Useful for invalid files skipping. */ - bool play(const QString &source, bool queue = FALSE); + bool play(const QString &source, bool queue = FALSE, qint64 offset = -1); /*! * Stops playback */ diff --git a/src/qmmpui/mediaplayer.cpp b/src/qmmpui/mediaplayer.cpp index 35f52e6e0..bf6648470 100644 --- a/src/qmmpui/mediaplayer.cpp +++ b/src/qmmpui/mediaplayer.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2009 by Ilya Kotov * + * Copyright (C) 2008-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -72,7 +72,7 @@ bool MediaPlayer::isRepeatable() const return m_repeat; } -void MediaPlayer::play() +void MediaPlayer::play(qint64 offset) { m_pl_manager->currentPlayList()->doCurrentVisibleRequest(); if (m_core->state() == Qmmp::Paused) @@ -96,7 +96,7 @@ void MediaPlayer::play() return; } - if (!m_core->play(s)) + if (!m_core->play(s, FALSE, offset)) { //find out the reason why playback failed switch ((int) m_core->state()) diff --git a/src/qmmpui/mediaplayer.h b/src/qmmpui/mediaplayer.h index afecfac1c..b345b6df4 100644 --- a/src/qmmpui/mediaplayer.h +++ b/src/qmmpui/mediaplayer.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2009 by Ilya Kotov * + * Copyright (C) 2008-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -64,7 +64,7 @@ public slots: /*! * Starts playback. */ - void play(); + void play(qint64 offset = -1); /*! * Stops playback. */ diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 1224fbebc..4fad52ce8 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -616,10 +616,7 @@ void MainWindow::resume() settings.beginGroup("General"); if(settings.value("resume_playback", FALSE).toBool()) { - play(); qint64 pos = settings.value("resume_playback_time").toLongLong(); - qApp->processEvents(); - if(pos) - m_core->seek(pos); + m_player->play(pos); } } |
