aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Output/oss
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2010-07-24 07:54:13 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2010-07-24 07:54:13 +0000
commitd2d062fa716a79ccf161fc302e73723f3eb1bb8d (patch)
tree19e594eec9635939305c1084b2ed380d4ed786c0 /src/plugins/Output/oss
parent04f1cf7bd526a9e906131ad35f950aa701f5b4f5 (diff)
downloadqmmp-d2d062fa716a79ccf161fc302e73723f3eb1bb8d.tar.gz
qmmp-d2d062fa716a79ccf161fc302e73723f3eb1bb8d.tar.bz2
qmmp-d2d062fa716a79ccf161fc302e73723f3eb1bb8d.zip
added fast seeking patches (Closes issue 338)
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1804 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Output/oss')
-rw-r--r--src/plugins/Output/oss/outputoss.cpp140
-rw-r--r--src/plugins/Output/oss/outputoss.h10
2 files changed, 56 insertions, 94 deletions
diff --git a/src/plugins/Output/oss/outputoss.cpp b/src/plugins/Output/oss/outputoss.cpp
index 7125dc981..eea53584d 100644
--- a/src/plugins/Output/oss/outputoss.cpp
+++ b/src/plugins/Output/oss/outputoss.cpp
@@ -81,22 +81,13 @@ int OutputOSS::audio_fd()
OutputOSS::~OutputOSS()
{
- m_instance = 0;
- if (m_audio_fd > 0)
- {
- close(m_audio_fd);
- m_audio_fd = -1;
- }
+ uninitialize();
+ m_instance = 0;
}
void OutputOSS::configure(quint32 freq, int chan, Qmmp::AudioFormat format)
{
- // we need to configure
- if (freq != m_frequency || chan != m_channels)
- {
- // we have already configured, but are changing settings...
- // reset the device
- resetDSP();
+
#if SOUND_VERSION >= 0x040000
if (VolumeControlOSS::instance())
{
@@ -108,75 +99,36 @@ void OutputOSS::configure(quint32 freq, int chan, Qmmp::AudioFormat format)
ioctl(m_audio_fd, cmd, &v);
}
#endif
- m_frequency = freq;
- m_channels = chan;
+ m_frequency = freq;
+ m_channels = chan;
- //m_bps = freq * chan * (prec / 8);
+ //m_bps = freq * chan * (prec / 8);
- int p;
- switch (format)
- {
- default:
- case Qmmp::PCM_S16LE:
+ int p;
+ switch (format)
+ {
+ default:
+ case Qmmp::PCM_S16LE:
#if defined(AFMT_S16_NE)
- p = AFMT_S16_NE;
+ p = AFMT_S16_NE;
#else
- p = AFMT_S16_LE;
+ p = AFMT_S16_LE;
#endif
- break;
+ break;
- case Qmmp::PCM_S8:
- p = AFMT_S8;
- break;
+ case Qmmp::PCM_S8:
+ p = AFMT_S8;
+ break;
- }
-
- if (ioctl(m_audio_fd, SNDCTL_DSP_SETFMT, &p) == -1)
- qWarning("OutputOSS: can't set audio format");
- /*if(ioctl(m_audio_fd, SNDCTL_DSP_SAMPLESIZE, &prec) == -1)
- qDebug("OutputOSS: can't set audio format");*/
- int stereo = (chan > 1) ? 1 : 0;
- ioctl(m_audio_fd, SNDCTL_DSP_STEREO, &stereo);
- /*if (ioctl(m_audio_fd, SNDCTL_DSP_SPEED, &m_channels) == -1)
- qWarning("OutputOSS: can't set number of channels");*/
- /*if (chan != m_channels)
- qWarning("OutputOSS: can't set number of channels, using %d instead", m_channels);*/
- if (ioctl(m_audio_fd, SNDCTL_DSP_SPEED, &freq) == -1)
- qWarning("OutputOSS: can't set audio format");
}
- Output::configure(freq, chan, format);
-}
-void OutputOSS::reset()
-{
- if (m_audio_fd > 0)
- {
- close(m_audio_fd);
- m_audio_fd = -1;
- }
-
- m_audio_fd = open(m_audio_device.toAscii(), O_WRONLY, 0);
-
- if (m_audio_fd < 0)
- {
- qWarning("OSSOutput: failed to open output device '%s'", qPrintable(m_audio_device));
- return;
- }
-
- 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;
- do_select = (select(m_audio_fd + 1, 0, &afd, 0, &tv) > 0);
+ if (ioctl(m_audio_fd, SNDCTL_DSP_SETFMT, &p) == -1)
+ qWarning("OutputOSS: can't set audio format");
+ int stereo = (chan > 1) ? 1 : 0;
+ ioctl(m_audio_fd, SNDCTL_DSP_STEREO, &stereo);
+ if (ioctl(m_audio_fd, SNDCTL_DSP_SPEED, &freq) == -1)
+ qWarning("OutputOSS: can't set audio format");
+ Output::configure(freq, chan, format);
}
void OutputOSS::post()
@@ -197,22 +149,29 @@ void OutputOSS::sync()
ioctl(m_audio_fd, SNDCTL_DSP_SYNC, &unused);
}
-
-void OutputOSS::resetDSP()
-{
- if (m_audio_fd < 1)
- return;
-
- int unused;
- ioctl(m_audio_fd, SNDCTL_DSP_RESET, &unused);
-}
-
-
bool OutputOSS::initialize()
{
- reset();
+ m_audio_fd = open(m_audio_device.toAscii(), O_WRONLY, 0);
+
if (m_audio_fd < 0)
+ {
+ qWarning("OSSOutput: failed to open output device '%s'", qPrintable(m_audio_device));
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;
+ do_select = (select(m_audio_fd + 1, 0, &afd, 0, &tv) > 0);
m_inited = true;
return true;
}
@@ -224,9 +183,9 @@ void OutputOSS::uninitialize()
m_inited = false;
m_frequency = -1;
m_channels = -1;
- resetDSP();
if (m_audio_fd > 0)
{
+ ioctl(m_audio_fd, SNDCTL_DSP_RESET, 0);
close(m_audio_fd);
m_audio_fd = -1;
}
@@ -265,8 +224,17 @@ qint64 OutputOSS::writeAudio(unsigned char *data, qint64 maxSize)
return m;
}
-/***** MIXER *****/
+void OutputOSS::drain()
+{
+ ioctl(m_audio_fd, SNDCTL_DSP_SYNC, 0);
+}
+void OutputOSS::reset()
+{
+ ioctl(m_audio_fd, SNDCTL_DSP_RESET, 0);
+}
+
+/***** MIXER *****/
VolumeControlOSS *VolumeControlOSS::instance()
{
return m_instance;
diff --git a/src/plugins/Output/oss/outputoss.h b/src/plugins/Output/oss/outputoss.h
index 7fb0e4c94..5046b1bc3 100644
--- a/src/plugins/Output/oss/outputoss.h
+++ b/src/plugins/Output/oss/outputoss.h
@@ -44,18 +44,12 @@ public:
private:
//output api
qint64 writeAudio(unsigned char *data, qint64 maxSize);
- void flush(){};
+ void drain();
+ void reset();
private:
- // thread run function
- //void run();
-
- // helper functions
- void reset();
- void resetDSP();
void post();
void sync();
- //void openMixer();
void uninitialize();
QString m_audio_device, m_mixer_device;