diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-06-26 13:51:05 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-06-26 13:51:05 +0000 |
| commit | 051dbde759f82a7e9498ec6d7b04969c1411e9a7 (patch) | |
| tree | 45683a7714191c1785c7d8b2a6229ef30dd8e650 /src/plugins/Output/jack | |
| parent | 2a332a2fdefbac806f54b7842e77fccbd53ad19b (diff) | |
| download | qmmp-051dbde759f82a7e9498ec6d7b04969c1411e9a7.tar.gz qmmp-051dbde759f82a7e9498ec6d7b04969c1411e9a7.tar.bz2 qmmp-051dbde759f82a7e9498ec6d7b04969c1411e9a7.zip | |
ported jack plugin
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@980 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Output/jack')
| -rw-r--r-- | src/plugins/Output/jack/outputjack.cpp | 157 | ||||
| -rw-r--r-- | src/plugins/Output/jack/outputjack.h | 33 | ||||
| -rw-r--r-- | src/plugins/Output/jack/outputjackfactory.cpp | 11 | ||||
| -rw-r--r-- | src/plugins/Output/jack/outputjackfactory.h | 3 |
4 files changed, 36 insertions, 168 deletions
diff --git a/src/plugins/Output/jack/outputjack.cpp b/src/plugins/Output/jack/outputjack.cpp index 2555e5b1e..2819941d4 100644 --- a/src/plugins/Output/jack/outputjack.cpp +++ b/src/plugins/Output/jack/outputjack.cpp @@ -32,45 +32,8 @@ #include <stdio.h> #include <string.h> -void OutputJACK::stop() -{ - m_userStop = TRUE; -} - -void OutputJACK::status() -{ - long ct = (m_totalWritten - latency()) / m_bps; - - if (ct < 0) - ct = 0; - - if (ct > m_currentSeconds) - { - m_currentSeconds = ct; - dispatch(m_currentSeconds, m_totalWritten, m_rate, - m_frequency, m_precision, m_channels); - } -} - -long OutputJACK::written() -{ - return m_totalWritten; -} - -void OutputJACK::seek(long pos) -{ - /*recycler()->mutex()->lock (); - recycler()->clear(); - recycler()->mutex()->unlock();*/ - - m_totalWritten = (pos * m_bps); - m_currentSeconds = -1; -} - OutputJACK::OutputJACK(QObject *parent) - : Output(parent), m_inited(FALSE), m_pause(FALSE), m_play(FALSE), - m_userStop(FALSE), m_totalWritten(0), m_currentSeconds(-1), - m_bps(-1), m_frequency(-1), m_channels(-1), m_precision(-1) + : Output(parent), m_inited(FALSE), m_configure(FALSE) { JACK_Init(); } @@ -80,42 +43,23 @@ OutputJACK::~OutputJACK() uninitialize(); } -void OutputJACK::configure(long freq, int chan, int prec, int) +void OutputJACK::configure(quint32 freq, int chan, int prec) { qDebug("OutputJACK: configure"); - m_precision = prec; - m_channels = chan; - m_frequency = freq; - m_bps = freq * chan * (prec / 8); if(JACK_Open(&jack_device, prec, (unsigned long *)&freq, chan)) - { + { m_configure = FALSE; - return; - } + return; + } else m_configure = TRUE; - + Output::configure(freq, chan, prec); qDebug("OutputJACK: configure end"); } -void OutputJACK::pause() -{ - m_pause = (m_pause) ? FALSE : TRUE; - { - int state = m_pause ? OutputState::Paused: OutputState::Playing; - dispatch(OutputState((OutputState::Type) state)); - } - -} - bool OutputJACK::initialize() { - m_inited = m_pause = m_play = m_userStop = FALSE; - m_currentSeconds = -1; - m_totalWritten = 0; - if (m_inited) - m_inited = TRUE; - m_inited = TRUE; + m_inited = FALSE; m_configure = FALSE; jack_options_t options = JackNoStartServer; jack_status_t status; @@ -133,96 +77,25 @@ bool OutputJACK::initialize() return TRUE; } -long OutputJACK::latency() +qint64 OutputJACK::latency() { - ulong used = 0; - return used; + return 0; } -void OutputJACK::run() +qint64 OutputJACK::writeAudio(unsigned char *data, qint64 maxSize) { - mutex()->lock (); - if (! m_inited) - { - mutex()->unlock(); - return; - } - - m_play = TRUE; - Buffer *b = 0; - bool done = FALSE; - long m = 0; - unsigned long l; - - dispatch(OutputState::Playing); - - mutex()->unlock(); - while (!done&&m_configure) - { - mutex()->lock (); - recycler()->mutex()->lock (); - done = m_userStop; - - while (! done && (recycler()->empty() || m_pause)) - { - mutex()->unlock(); - recycler()->cond()->wakeOne(); - recycler()->cond()->wait(recycler()->mutex()); - mutex()->lock (); - done = m_userStop; - status(); - } - - if (! b) - { - b = recycler()->next(); - if (b->rate) - m_rate = b->rate; - } - - recycler()->cond()->wakeOne(); - recycler()->mutex()->unlock(); - - if (b) - { - l = int(b->nbytes); - unsigned char *buf = b->data; - m_totalWritten += l; - while (l > 0) - { - m = JACK_Write(jack_device, (unsigned char*)buf, l); - if (!m) - usleep(2000); - usleep(((m/m_channels)*100000)/m_frequency); - l-=m; - buf+=m; - } - - status(); - dispatchVisual(b, m_totalWritten, m_channels, m_precision); - } - recycler()->mutex()->lock (); - recycler()->done(); - recycler()->mutex()->unlock(); - b = 0; - mutex()->unlock(); - } - mutex()->lock (); - m_play = FALSE; - dispatch(OutputState::Stopped); - mutex()->unlock(); + m = JACK_Write(jack_device, (unsigned char*)data, maxSize); + if (!m) + usleep(2000); + return m; } void OutputJACK::uninitialize() { if (!m_inited) return; - m_inited = FALSE; - m_inited = m_pause = m_play = m_userStop = FALSE; - m_currentSeconds = -1; - m_totalWritten = 0; + if (m_configure) JACK_Close(jack_device); - dispatch(OutputState::Stopped); } diff --git a/src/plugins/Output/jack/outputjack.h b/src/plugins/Output/jack/outputjack.h index 0f0c7ea5f..8a340002d 100644 --- a/src/plugins/Output/jack/outputjack.h +++ b/src/plugins/Output/jack/outputjack.h @@ -38,32 +38,21 @@ class OutputJACK : public Output public: OutputJACK(QObject * parent = 0); ~OutputJACK(); + bool initialize(); - bool isInitialized() const - { - return m_inited; - } - void uninitialize(); - void configure(long, int, int, int); - void stop(); - void pause(); - long written(); - long latency(); - void seek(long); + void configure(quint32, int, int); + qint64 latency(); private: - // thread run function - void run(); + //output api + qint64 writeAudio(unsigned char *data, qint64 maxSize); + void flush(){}; + // helper functions - void status(); - QString audio_device; - bool m_inited, m_configure, m_pause, m_play, m_userStop; - long m_totalWritten, m_currentSeconds, m_bps; - int m_rate, m_frequency, m_channels, m_precision, jack_device; - bool do_select; - int audio_fd; + void uninitialize(); + qint64 m; + bool m_inited, m_configure; + int jack_device; }; - #endif - diff --git a/src/plugins/Output/jack/outputjackfactory.cpp b/src/plugins/Output/jack/outputjackfactory.cpp index 2a9709e5e..997330d5c 100644 --- a/src/plugins/Output/jack/outputjackfactory.cpp +++ b/src/plugins/Output/jack/outputjackfactory.cpp @@ -19,7 +19,7 @@ ***************************************************************************/ #include <QtGui> - +#include <qmmp/qmmp.h> #include "outputjack.h" #include "outputjackfactory.h" @@ -30,15 +30,20 @@ const OutputProperties OutputJACKFactory::properties() const properties.name = tr("JACK Plugin"); properties.hasAbout = TRUE; properties.hasSettings = FALSE; + properties.shortName = "jack"; return properties; } -Output* OutputJACKFactory::create(QObject* parent, bool volume) +Output* OutputJACKFactory::create(QObject* parent) { - Q_UNUSED(volume); return new OutputJACK(parent); } +VolumeControl *OutputJACKFactory::createVolumeControl(QObject *) +{ + return 0; +} + void OutputJACKFactory::showSettings(QWidget*) { } diff --git a/src/plugins/Output/jack/outputjackfactory.h b/src/plugins/Output/jack/outputjackfactory.h index 6b99805e4..0847b8a0b 100644 --- a/src/plugins/Output/jack/outputjackfactory.h +++ b/src/plugins/Output/jack/outputjackfactory.h @@ -38,7 +38,8 @@ Q_INTERFACES(OutputFactory); public: const OutputProperties properties() const; - Output* create(QObject* parent, bool volume); + Output* create(QObject* parent); + VolumeControl *createVolumeControl(QObject *parent); void showSettings(QWidget* parent); void showAbout(QWidget *parent); QTranslator *createTranslator(QObject *parent); |
