diff options
Diffstat (limited to 'src/plugins/Output/oss')
| -rw-r--r-- | src/plugins/Output/oss/outputoss.cpp | 93 | ||||
| -rw-r--r-- | src/plugins/Output/oss/outputoss.h | 3 |
2 files changed, 48 insertions, 48 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; } diff --git a/src/plugins/Output/oss/outputoss.h b/src/plugins/Output/oss/outputoss.h index c712e83fc..8864339c4 100644 --- a/src/plugins/Output/oss/outputoss.h +++ b/src/plugins/Output/oss/outputoss.h @@ -35,8 +35,7 @@ public: OutputOSS(QObject * parent = 0); virtual ~OutputOSS(); - bool initialize(); - void configure(quint32, int, Qmmp::AudioFormat format); + bool initialize(quint32, int, Qmmp::AudioFormat format); qint64 latency(); private: |
