aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Output/oss4
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2011-08-06 10:07:36 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2011-08-06 10:07:36 +0000
commit9d35f2ce0e9e2816022b06819551312c182b4713 (patch)
tree86d4b6e56665902a423095bf96727c926c4bad55 /src/plugins/Output/oss4
parent7e107ff8feb4b4f1c8c4e79a364503bbfed118f8 (diff)
downloadqmmp-9d35f2ce0e9e2816022b06819551312c182b4713.tar.gz
qmmp-9d35f2ce0e9e2816022b06819551312c182b4713.tar.bz2
qmmp-9d35f2ce0e9e2816022b06819551312c182b4713.zip
some output plugin api changes
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2292 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Output/oss4')
-rw-r--r--src/plugins/Output/oss4/outputoss4.cpp107
-rw-r--r--src/plugins/Output/oss4/outputoss4.h1
2 files changed, 51 insertions, 57 deletions
diff --git a/src/plugins/Output/oss4/outputoss4.cpp b/src/plugins/Output/oss4/outputoss4.cpp
index d9c46f2b6..ecd37c504 100644
--- a/src/plugins/Output/oss4/outputoss4.cpp
+++ b/src/plugins/Output/oss4/outputoss4.cpp
@@ -44,7 +44,6 @@ extern "C"
#include <qmmp/visual.h>
#include "outputoss4.h"
-
OutputOSS4 *OutputOSS4::m_instance = 0;
OutputOSS4::OutputOSS4(QObject *parent) : Output(parent)
@@ -67,8 +66,50 @@ OutputOSS4::~OutputOSS4()
m_instance = 0;
}
-void OutputOSS4::configure(quint32 freq, int chan, Qmmp::AudioFormat format)
+int OutputOSS4::fd()
+{
+ return m_audio_fd;
+}
+
+OutputOSS4 *OutputOSS4::instance()
+{
+ return m_instance;
+}
+
+void OutputOSS4::post()
+{
+ ioctl(m_audio_fd, SNDCTL_DSP_POST, 0);
+}
+
+void OutputOSS4::sync()
+{
+ ioctl(m_audio_fd, SNDCTL_DSP_SYNC, 0);
+}
+
+bool OutputOSS4::initialize(quint32 freq, int chan, Qmmp::AudioFormat format)
{
+ m_audio_fd = open(m_audio_device.toAscii(), O_WRONLY, 0);
+
+ if (m_audio_fd < 0)
+ {
+ qWarning("OSS4Output: unable to open output device '%s'; error: %s",
+ qPrintable(m_audio_device), strerror(errno));
+ return false;
+ }
+
+ int flags;
+ if ((flags = fcntl(m_audio_fd, F_GETFL, 0)) > 0)
+ {
+ flags &= O_NDELAY;
+ fcntl(m_audio_fd, F_SETFL, flags);
+ }
+ fd_set afd;
+ FD_ZERO(&afd);
+ FD_SET(m_audio_fd, &afd);
+ struct timeval tv;
+ tv.tv_sec = 0l;
+ tv.tv_usec = 50000l;
+ m_do_select = (select(m_audio_fd + 1, 0, &afd, 0, &tv) > 0);
int p;
switch (format)
{
@@ -86,89 +127,43 @@ void OutputOSS4::configure(quint32 freq, int chan, Qmmp::AudioFormat format)
break;
default:
qWarning("OutputOSS4: unsupported audio format");
- return;
+ return false;
}
int param = p;
if (ioctl(m_audio_fd, SNDCTL_DSP_SETFMT, &p) < 0)
{
qWarning("OutputOSS4: ioctl SNDCTL_DSP_SETFMT failed: %s",strerror(errno));
- return;
+ return false;
}
if(param != p)
{
qWarning("OutputOSS4: unsupported audio format");
- return;
+ return false;
}
param = chan;
if(ioctl(m_audio_fd, SNDCTL_DSP_CHANNELS, &chan) < 0)
{
qWarning("OutputOSS4: ioctl SNDCTL_DSP_CHANNELS failed: %s", strerror(errno));
- return;
+ return false;
}
if(param != chan)
{
qWarning("OutputOSS4: unsupported %d-channel mode", param);
- return;
+ return false;
}
uint param2 = freq;
if (ioctl(m_audio_fd, SNDCTL_DSP_SPEED, &freq) < 0)
{
qWarning("OutputOSS4: ioctl SNDCTL_DSP_SPEED failed: %s", strerror(errno));
- return;
+ return false;
}
if(param2 != freq)
{
qWarning("OutputOSS4: unsupported sample rate");
- return;
- }
- ioctl(m_audio_fd, SNDCTL_DSP_RESET, 0);
- Output::configure(freq, chan, format);
-}
-
-int OutputOSS4::fd()
-{
- return m_audio_fd;
-}
-
-OutputOSS4 *OutputOSS4::instance()
-{
- return m_instance;
-}
-
-void OutputOSS4::post()
-{
- ioctl(m_audio_fd, SNDCTL_DSP_POST, 0);
-}
-
-void OutputOSS4::sync()
-{
- ioctl(m_audio_fd, SNDCTL_DSP_SYNC, 0);
-}
-
-bool OutputOSS4::initialize()
-{
- m_audio_fd = open(m_audio_device.toAscii(), O_WRONLY, 0);
-
- if (m_audio_fd < 0)
- {
- qWarning("OSS4Output: unable to open output device '%s'; error: %s",
- qPrintable(m_audio_device), strerror(errno));
return false;
}
-
- int flags;
- if ((flags = fcntl(m_audio_fd, F_GETFL, 0)) > 0)
- {
- flags &= O_NDELAY;
- fcntl(m_audio_fd, F_SETFL, flags);
- }
- fd_set afd;
- FD_ZERO(&afd);
- FD_SET(m_audio_fd, &afd);
- struct timeval tv;
- tv.tv_sec = 0l;
- tv.tv_usec = 50000l;
- m_do_select = (select(m_audio_fd + 1, 0, &afd, 0, &tv) > 0);
+ ioctl(m_audio_fd, SNDCTL_DSP_RESET, 0);
+ configure(freq, chan, format);
return true;
}
diff --git a/src/plugins/Output/oss4/outputoss4.h b/src/plugins/Output/oss4/outputoss4.h
index a9d1bd608..fecd396c6 100644
--- a/src/plugins/Output/oss4/outputoss4.h
+++ b/src/plugins/Output/oss4/outputoss4.h
@@ -39,7 +39,6 @@ public:
bool initialize();
void configure(quint32, int, Qmmp::AudioFormat format);
- qint64 latency();
int fd();
static OutputOSS4 *instance();