diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2012-01-17 08:51:39 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2012-01-17 08:51:39 +0000 |
| commit | acb3d9b6c3df6dd3eaedefde0f6d82f51681158a (patch) | |
| tree | 28e76c1e8db5baddeb75ae97075ecf76977455e7 /src/plugins/Output | |
| parent | 49cdf460a519565b113892095c874c15ef755bc5 (diff) | |
| download | qmmp-acb3d9b6c3df6dd3eaedefde0f6d82f51681158a.tar.gz qmmp-acb3d9b6c3df6dd3eaedefde0f6d82f51681158a.tar.bz2 qmmp-acb3d9b6c3df6dd3eaedefde0f6d82f51681158a.zip | |
added win32 patches
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2537 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Output')
| -rw-r--r-- | src/plugins/Output/Output.pro | 3 | ||||
| -rw-r--r-- | src/plugins/Output/null/null.pro | 20 | ||||
| -rw-r--r-- | src/plugins/Output/waveout/outputwaveout.cpp | 107 | ||||
| -rw-r--r-- | src/plugins/Output/waveout/outputwaveout.h | 10 | ||||
| -rw-r--r-- | src/plugins/Output/waveout/outputwaveoutfactory.cpp | 2 | ||||
| -rw-r--r-- | src/plugins/Output/waveout/outputwaveoutfactory.h | 10 |
6 files changed, 86 insertions, 66 deletions
diff --git a/src/plugins/Output/Output.pro b/src/plugins/Output/Output.pro index 4dde76900..8ded62f9f 100644 --- a/src/plugins/Output/Output.pro +++ b/src/plugins/Output/Output.pro @@ -3,10 +3,11 @@ include(../../../qmmp.pri) CONFIG += release warn_on TEMPLATE = subdirs win32:SUBDIRS += waveout -unix{ SUBDIRS += null +unix{ + contains(CONFIG, JACK_PLUGIN){ SUBDIRS += jack } diff --git a/src/plugins/Output/null/null.pro b/src/plugins/Output/null/null.pro index cf03c38bb..bf787c850 100644 --- a/src/plugins/Output/null/null.pro +++ b/src/plugins/Output/null/null.pro @@ -8,7 +8,6 @@ SOURCES += outputnullfactory.cpp \ TARGET=$$PLUGINS_PREFIX/Output/null -QMAKE_CLEAN =$$PLUGINS_PREFIX/Output/libnull.so INCLUDEPATH += ../../../ QMAKE_LIBDIR += ../../../../lib @@ -19,8 +18,6 @@ thread \ plugin TEMPLATE = lib -LIBS += -lqmmp - TRANSLATIONS = translations/null_plugin_cs.ts \ translations/null_plugin_de.ts \ @@ -38,9 +35,18 @@ TRANSLATIONS = translations/null_plugin_cs.ts \ RESOURCES = translations/translations.qrc -isEmpty (LIB_DIR){ -LIB_DIR = /lib +unix { + isEmpty (LIB_DIR){ + LIB_DIR = /lib + } + + target.path = $$LIB_DIR/qmmp/Output + INSTALLS += target + LIBS += -lqmmp + QMAKE_CLEAN =$$PLUGINS_PREFIX/Output/libnull.so } -target.path = $$LIB_DIR/qmmp/Output -INSTALLS += target +win32 { + LIBS += -lqmmp0 + QMAKE_LIBDIR += ../../../../bin +} diff --git a/src/plugins/Output/waveout/outputwaveout.cpp b/src/plugins/Output/waveout/outputwaveout.cpp index f95100aac..57b70b7e3 100644 --- a/src/plugins/Output/waveout/outputwaveout.cpp +++ b/src/plugins/Output/waveout/outputwaveout.cpp @@ -1,5 +1,5 @@ /***************************************************************************
- * Copyright (C) 2009 by Ilya Kotov *
+ * Copyright (C) 2009-2012 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -31,19 +31,19 @@ #include <qmmp/visual.h>
#include "outputwaveout.h"
-#define MAX_WAVEBLOCKS 32
+#define MAX_WAVEBLOCKS 256
static CRITICAL_SECTION cs;
static HWAVEOUT dev = NULL;
-static int ScheduledBlocks = 0;
+static unsigned int ScheduledBlocks = 0;
static int PlayedWaveHeadersCount = 0; // free index
static WAVEHDR* PlayedWaveHeaders [MAX_WAVEBLOCKS];
-static void CALLBACK wave_callback (HWAVE hWave, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 )
+static void CALLBACK wave_callback (HWAVE hWave, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
{
- if ( uMsg == WOM_DONE )
+ if (uMsg == WOM_DONE)
{
EnterCriticalSection (&cs);
PlayedWaveHeaders [PlayedWaveHeadersCount++] = (WAVEHDR*) dwParam1;
@@ -52,38 +52,28 @@ static void CALLBACK wave_callback (HWAVE hWave, UINT uMsg, DWORD dwInstance, DW }
static void
-free_memory ( void )
+free_memory (void)
{
WAVEHDR* wh;
HGLOBAL hg;
- EnterCriticalSection ( &cs );
+ EnterCriticalSection (&cs);
wh = PlayedWaveHeaders [--PlayedWaveHeadersCount];
ScheduledBlocks--; // decrease the number of USED blocks
- LeaveCriticalSection ( &cs );
+ LeaveCriticalSection (&cs);
- waveOutUnprepareHeader ( dev, wh, sizeof (WAVEHDR) );
+ waveOutUnprepareHeader (dev, wh, sizeof (WAVEHDR));
- hg = GlobalHandle ( wh -> lpData ); // Deallocate the buffer memory
+ hg = GlobalHandle (wh -> lpData); // Deallocate the buffer memory
GlobalUnlock (hg);
GlobalFree (hg);
- hg = GlobalHandle ( wh ); // Deallocate the header memory
+ hg = GlobalHandle (wh); // Deallocate the header memory
GlobalUnlock (hg);
GlobalFree (hg);
}
-static int
-Box ( const char* msg )
-{
- //MessageBox ( NULL, ms"Error Message . . .", MB_OK | MB_ICONEXCLAMATION );
- return -1;
-}
-
-
-
-OutputWaveOut::OutputWaveOut(QObject * parent)
- : Output(parent)
+OutputWaveOut::OutputWaveOut(QObject * parent) : Output(parent)
{
//m_connection = 0;
//m_dev = 0;
@@ -139,7 +129,7 @@ bool OutputWaveOut::initialize(quint32 freq, int chan, Qmmp::AudioFormat format) }
waveOutReset (dev);
- InitializeCriticalSection ( &cs );
+ InitializeCriticalSection (&cs);
configure(freq, chan, format);
return true;
@@ -159,60 +149,88 @@ qint64 OutputWaveOut::writeAudio(unsigned char *data, qint64 len) void* allocptr;
len = qMin(len, (qint64)1024);
- do
- {
- while ( PlayedWaveHeadersCount > 0 ) // free used blocks ...
- free_memory ();
-
- if ( ScheduledBlocks < sizeof(PlayedWaveHeaders)/sizeof(*PlayedWaveHeaders) ) // wait for a free block ...
- break;
- usleep (500);
+
+ while (PlayedWaveHeadersCount > 0) // free used blocks ...
+ free_memory ();
+ if (ScheduledBlocks >= sizeof(PlayedWaveHeaders)/sizeof(*PlayedWaveHeaders)) // wait for a free block ...
+ {
+ usleep(500);
+ return 0;
+ }
+
+ if ((hg2 = GlobalAlloc (GMEM_MOVEABLE, len)) == NULL) // allocate some memory for a copy of the buffer
+ {
+ qWarning("OutputWaveOut: GlobalAlloc failed");
+ return 0;
}
- while (1);
-
- if ( (hg2 = GlobalAlloc ( GMEM_MOVEABLE, len )) == NULL ) // allocate some memory for a copy of the buffer
- return Box ( "GlobalAlloc failed." );
allocptr = GlobalLock (hg2);
- CopyMemory ( allocptr, data, len ); // Here we can call any modification output functions we want....
+ CopyMemory (allocptr, data, len); // Here we can call any modification output functions we want....
- if ( (hg = GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof (WAVEHDR))) == NULL ) // now make a header and WRITE IT!
+ if ((hg = GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, sizeof (WAVEHDR))) == NULL) // now make a header and WRITE IT!
return -1;
wh = (wavehdr_tag*)GlobalLock (hg);
wh->dwBufferLength = len;
wh->lpData = (CHAR *)allocptr;
- if ( waveOutPrepareHeader ( dev, wh, sizeof (WAVEHDR)) != MMSYSERR_NOERROR )
+ if (waveOutPrepareHeader (dev, wh, sizeof (WAVEHDR)) != MMSYSERR_NOERROR)
{
GlobalUnlock (hg);
GlobalFree (hg);
return -1;
}
- if ( waveOutWrite ( dev, wh, sizeof (WAVEHDR)) != MMSYSERR_NOERROR )
+ if (waveOutWrite (dev, wh, sizeof (WAVEHDR)) != MMSYSERR_NOERROR)
{
GlobalUnlock (hg);
GlobalFree (hg);
return -1;
}
- EnterCriticalSection ( &cs );
+ EnterCriticalSection (&cs);
ScheduledBlocks++;
- LeaveCriticalSection ( &cs );
+ LeaveCriticalSection (&cs);
return len;
}
+void OutputWaveOut::drain()
+{
+ while (ScheduledBlocks > 0)
+ {
+ Sleep(ScheduledBlocks);
+ while (PlayedWaveHeadersCount > 0) // free used blocks ...
+ free_memory();
+ }
+}
+
+void OutputWaveOut::suspend()
+{
+ waveOutPause(dev);
+}
+
+void OutputWaveOut::resume()
+{
+ waveOutRestart(dev);
+}
+
+void OutputWaveOut::reset()
+{
+ while (PlayedWaveHeadersCount > 0) // free used blocks ...
+ free_memory ();
+ waveOutReset (dev);
+}
+
void OutputWaveOut::uninitialize()
{
if (dev)
{
- while ( ScheduledBlocks > 0 )
+ while (ScheduledBlocks > 0)
{
Sleep (ScheduledBlocks);
- while ( PlayedWaveHeadersCount > 0 ) // free used blocks ...
+ while (PlayedWaveHeadersCount > 0) // free used blocks ...
free_memory ();
}
@@ -221,8 +239,7 @@ void OutputWaveOut::uninitialize() dev = 0;
}
- DeleteCriticalSection ( &cs );
+ DeleteCriticalSection (&cs);
ScheduledBlocks = 0;
return;
}
-
diff --git a/src/plugins/Output/waveout/outputwaveout.h b/src/plugins/Output/waveout/outputwaveout.h index 2d019ef6e..0fc5746b1 100644 --- a/src/plugins/Output/waveout/outputwaveout.h +++ b/src/plugins/Output/waveout/outputwaveout.h @@ -1,5 +1,5 @@ /***************************************************************************
- * Copyright (C) 2009 by Ilya Kotov *
+ * Copyright (C) 2009-2012 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -42,10 +42,10 @@ public: private:
//output api
qint64 writeAudio(unsigned char *data, qint64 size);
- void drain(){};
- void suspend(){};
- void resume(){};
- void reset(){};
+ void drain();
+ void suspend();
+ void resume();
+ void reset();
// helper functions
void status();
diff --git a/src/plugins/Output/waveout/outputwaveoutfactory.cpp b/src/plugins/Output/waveout/outputwaveoutfactory.cpp index d3d1776f9..38c7a0a67 100644 --- a/src/plugins/Output/waveout/outputwaveoutfactory.cpp +++ b/src/plugins/Output/waveout/outputwaveoutfactory.cpp @@ -1,5 +1,5 @@ /***************************************************************************
- * Copyright (C) 2009 by Ilya Kotov *
+ * Copyright (C) 2009-2012 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
diff --git a/src/plugins/Output/waveout/outputwaveoutfactory.h b/src/plugins/Output/waveout/outputwaveoutfactory.h index 6a59edbf4..ac43dfcbf 100644 --- a/src/plugins/Output/waveout/outputwaveoutfactory.h +++ b/src/plugins/Output/waveout/outputwaveoutfactory.h @@ -1,5 +1,5 @@ /***************************************************************************
- * Copyright (C) 2009 by Ilya Kotov *
+ * Copyright (C) 2009-2012 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -20,21 +20,18 @@ #ifndef OUTPUTPULSEAUDIOFACTORY_H
#define OUTPUTPULSEAUDIOFACTORY_H
-
#include <QObject>
#include <QString>
#include <QIODevice>
#include <QWidget>
-
#include <qmmp/output.h>
#include <qmmp/outputfactory.h>
-class OutputWaveOutFactory : public QObject,
- OutputFactory
+class OutputWaveOutFactory : public QObject, OutputFactory
{
Q_OBJECT
-Q_INTERFACES(OutputFactory);
+Q_INTERFACES(OutputFactory)
public:
const OutputProperties properties() const;
@@ -43,7 +40,6 @@ public: void showSettings(QWidget* parent);
void showAbout(QWidget *parent);
QTranslator *createTranslator(QObject *parent);
-
};
#endif
|
