diff options
Diffstat (limited to 'src/plugins/Output/oss4/outputoss4.cpp')
| -rw-r--r-- | src/plugins/Output/oss4/outputoss4.cpp | 58 |
1 files changed, 15 insertions, 43 deletions
diff --git a/src/plugins/Output/oss4/outputoss4.cpp b/src/plugins/Output/oss4/outputoss4.cpp index 6d3bad527..84cd6c17b 100644 --- a/src/plugins/Output/oss4/outputoss4.cpp +++ b/src/plugins/Output/oss4/outputoss4.cpp @@ -49,7 +49,6 @@ VolumeOSS4 *OutputOSS4::m_vc = 0; OutputOSS4::OutputOSS4(QObject *parent) : Output(parent) { - m_do_select = true; m_audio_fd = -1; QSettings settings(Qmmp::configFile(), QSettings::IniFormat); m_audio_device = settings.value("OSS4/device", DEFAULT_DEV).toString(); @@ -89,7 +88,7 @@ void OutputOSS4::sync() bool OutputOSS4::initialize(quint32 freq, int chan, Qmmp::AudioFormat format) { - m_audio_fd = open(m_audio_device.toAscii(), O_WRONLY, 0); + m_audio_fd = open(m_audio_device.toAscii(), O_WRONLY); if (m_audio_fd < 0) { @@ -98,19 +97,8 @@ bool OutputOSS4::initialize(quint32 freq, int chan, Qmmp::AudioFormat format) 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); + int p; switch (format) { @@ -130,22 +118,21 @@ bool OutputOSS4::initialize(quint32 freq, int chan, Qmmp::AudioFormat format) qWarning("OutputOSS4: unsupported audio format"); return false; } - ioctl(m_audio_fd, SNDCTL_DSP_SYNC, 0); - - int enabled = 1; - if(ioctl(m_audio_fd, SNDCTL_DSP_COOKEDMODE, &enabled) == -1) - qWarning("OutputOSS4: ioctl SNDCTL_DSP_COOKEDMODE: %s", strerror(errno)); + + if (ioctl(m_audio_fd, SNDCTL_DSP_SETFMT, &p) == -1) + qWarning("OutputOSS4: ioctl SNDCTL_DSP_SETFMT failed: %s",strerror(errno)); if(ioctl(m_audio_fd, SNDCTL_DSP_CHANNELS, &chan) == -1) qWarning("OutputOSS4: ioctl SNDCTL_DSP_CHANNELS failed: %s", strerror(errno)); - if (ioctl(m_audio_fd, SNDCTL_DSP_SETFMT, &p) == -1) - qWarning("OutputOSS4: ioctl SNDCTL_DSP_SETFMT failed: %s",strerror(errno)); - if (ioctl(m_audio_fd, SNDCTL_DSP_SPEED, &freq) < 0) qWarning("OutputOSS4: ioctl SNDCTL_DSP_SPEED failed: %s", strerror(errno)); - ioctl(m_audio_fd, SNDCTL_DSP_HALT, 0); + int enabled = 1; + if(ioctl(m_audio_fd, SNDCTL_DSP_COOKEDMODE, &enabled) == -1) + qWarning("OutputOSS4: ioctl SNDCTL_DSP_COOKEDMODE: %s", strerror(errno)); + + ioctl(m_audio_fd, SNDCTL_DSP_RESET, 0); configure(freq, chan, format); @@ -161,23 +148,7 @@ qint64 OutputOSS4::latency() qint64 OutputOSS4::writeAudio(unsigned char *data, qint64 maxSize) { - fd_set afd; - struct timeval tv; - qint64 m = -1, l; - FD_ZERO(&afd); - FD_SET(m_audio_fd, &afd); - // nice long poll timeout - tv.tv_sec = 5l; - tv.tv_usec = 0l; - if ((!m_do_select || (select(m_audio_fd + 1, 0, &afd, 0, &tv) > 0 && - FD_ISSET(m_audio_fd, &afd)))) - { - l = qMin(int(2048), int(maxSize)); - if (l > 0) - { - m = write(m_audio_fd, data, l); - } - } + qint64 m = write(m_audio_fd, data, maxSize); post(); return m; } @@ -199,7 +170,6 @@ VolumeOSS4::VolumeOSS4() QSettings settings(Qmmp::configFile(), QSettings::IniFormat); m_volume = settings.value("OSS4/volume", 0x3232).toInt(); OutputOSS4::m_vc = this; - restore(); } VolumeOSS4::~VolumeOSS4() @@ -242,5 +212,7 @@ int VolumeOSS4::volume(int channel) void VolumeOSS4::restore() { - setVolume((m_volume & 0x00FF), (m_volume & 0xFF00) >> 8); + int v = m_volume; + setVolume(Volume::LEFT_CHANNEL, (v & 0x00FF)); + setVolume(Volume::RIGHT_CHANNEL, (v & 0xFF00) >> 8); } |
