diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2011-08-06 10:07:36 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2011-08-06 10:07:36 +0000 |
| commit | 9d35f2ce0e9e2816022b06819551312c182b4713 (patch) | |
| tree | 86d4b6e56665902a423095bf96727c926c4bad55 /src/plugins/Output/oss/outputoss.cpp | |
| parent | 7e107ff8feb4b4f1c8c4e79a364503bbfed118f8 (diff) | |
| download | qmmp-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/oss/outputoss.cpp')
| -rw-r--r-- | src/plugins/Output/oss/outputoss.cpp | 93 |
1 files changed, 47 insertions, 46 deletions
diff --git a/src/plugins/Output/oss/outputoss.cpp b/src/plugins/Output/oss/outputoss.cpp index 6722f18ad..51031116a 100644 --- a/src/plugins/Output/oss/outputoss.cpp +++ b/src/plugins/Output/oss/outputoss.cpp @@ -60,91 +60,92 @@ OutputOSS::~OutputOSS() } } -void OutputOSS::configure(quint32 freq, int chan, Qmmp::AudioFormat format) +void OutputOSS::post() +{ + ioctl(m_audio_fd, SNDCTL_DSP_POST, 0); +} + +void OutputOSS::sync() +{ + ioctl(m_audio_fd, SNDCTL_DSP_SYNC, 0); +} + +bool OutputOSS::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("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); + int p; switch (format) { case Qmmp::PCM_S16LE: - p = AFMT_S16_LE; +#ifdef AFMT_S16_NE + p = AFMT_S16_NE; +#else + p = AFMT_S16_LE; +#endif break; case Qmmp::PCM_S8: p = AFMT_S8; break; default: qWarning("OutputOSS: unsupported audio format"); - return; + return false; } int param = p; if (ioctl(m_audio_fd, SNDCTL_DSP_SETFMT, &p) < 0) { qWarning("OutputOSS: ioctl SNDCTL_DSP_SETFMT failed: %s",strerror(errno)); - return; + //return; } - if(param != p) + /*if(param != p) { qWarning("OutputOSS: unsupported audio format"); return; - } + }*/ param = chan; if(ioctl(m_audio_fd, SNDCTL_DSP_CHANNELS, &chan) < 0) { qWarning("OutputOSS: ioctl SNDCTL_DSP_CHANNELS failed: %s", strerror(errno)); - return; + return false; } if(param != chan) { qWarning("OutputOSS: unsupported %d-channel mode", param); - return; + return false; } uint param2 = freq; if (ioctl(m_audio_fd, SNDCTL_DSP_SPEED, &freq) < 0) { qWarning("OutputOSS: ioctl SNDCTL_DSP_SPEED failed: %s", strerror(errno)); - return; + return false; } if(param2 != freq) { qWarning("OutputOSS: unsupported sample rate"); - return; - } - ioctl(m_audio_fd, SNDCTL_DSP_RESET, 0); - Output::configure(freq, chan, format); -} - -void OutputOSS::post() -{ - ioctl(m_audio_fd, SNDCTL_DSP_POST, 0); -} - -void OutputOSS::sync() -{ - ioctl(m_audio_fd, SNDCTL_DSP_SYNC, 0); -} - -bool OutputOSS::initialize() -{ - 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); + ioctl(m_audio_fd, SNDCTL_DSP_RESET, 0); + configure(freq, chan, format); return true; } |
