aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Output/oss/outputoss.cpp44
-rw-r--r--src/plugins/Output/oss4/outputoss4.cpp43
2 files changed, 27 insertions, 60 deletions
diff --git a/src/plugins/Output/oss/outputoss.cpp b/src/plugins/Output/oss/outputoss.cpp
index 51031116a..4e0f9e1d1 100644
--- a/src/plugins/Output/oss/outputoss.cpp
+++ b/src/plugins/Output/oss/outputoss.cpp
@@ -111,40 +111,26 @@ bool OutputOSS::initialize(quint32 freq, int chan, Qmmp::AudioFormat format)
qWarning("OutputOSS: unsupported audio format");
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;
- }
- /*if(param != p)
- {
- qWarning("OutputOSS: unsupported audio format");
- return;
- }*/
- param = chan;
- if(ioctl(m_audio_fd, SNDCTL_DSP_CHANNELS, &chan) < 0)
- {
+
+ ioctl(m_audio_fd, SNDCTL_DSP_SYNC, 0);
+
+ if(ioctl(m_audio_fd, SNDCTL_DSP_CHANNELS, &chan) == -1)
qWarning("OutputOSS: ioctl SNDCTL_DSP_CHANNELS failed: %s", strerror(errno));
- return false;
- }
- if(param != chan)
+
+ if(chan <= 2)
{
- qWarning("OutputOSS: unsupported %d-channel mode", param);
- return false;
+ int param = chan - 1;
+ if(ioctl(m_audio_fd, SNDCTL_DSP_STEREO, &param) == -1)
+ qWarning("OutputOSS: ioctl SNDCTL_DSP_STEREO failed: %s", strerror(errno));
+ chan = param + 1;
}
- uint param2 = freq;
+
+ if (ioctl(m_audio_fd, SNDCTL_DSP_SETFMT, &p) == -1)
+ qWarning("OutputOSS: ioctl SNDCTL_DSP_SETFMT failed: %s",strerror(errno));
+
if (ioctl(m_audio_fd, SNDCTL_DSP_SPEED, &freq) < 0)
- {
qWarning("OutputOSS: ioctl SNDCTL_DSP_SPEED failed: %s", strerror(errno));
- return false;
- }
- if(param2 != freq)
- {
- qWarning("OutputOSS: unsupported sample rate");
- return false;
- }
- ioctl(m_audio_fd, SNDCTL_DSP_RESET, 0);
+
configure(freq, chan, format);
return true;
}
diff --git a/src/plugins/Output/oss4/outputoss4.cpp b/src/plugins/Output/oss4/outputoss4.cpp
index ecd37c504..39cb5347c 100644
--- a/src/plugins/Output/oss4/outputoss4.cpp
+++ b/src/plugins/Output/oss4/outputoss4.cpp
@@ -129,40 +129,21 @@ bool OutputOSS4::initialize(quint32 freq, int chan, Qmmp::AudioFormat format)
qWarning("OutputOSS4: unsupported audio format");
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 false;
- }
- if(param != p)
- {
- qWarning("OutputOSS4: unsupported audio format");
- return false;
- }
- param = chan;
- if(ioctl(m_audio_fd, SNDCTL_DSP_CHANNELS, &chan) < 0)
- {
+ 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_CHANNELS, &chan) == -1)
qWarning("OutputOSS4: ioctl SNDCTL_DSP_CHANNELS failed: %s", strerror(errno));
- return false;
- }
- if(param != chan)
- {
- qWarning("OutputOSS4: unsupported %d-channel mode", param);
- return false;
- }
- uint param2 = freq;
+
+ 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));
- return false;
- }
- if(param2 != freq)
- {
- qWarning("OutputOSS4: unsupported sample rate");
- return false;
- }
- ioctl(m_audio_fd, SNDCTL_DSP_RESET, 0);
+
configure(freq, chan, format);
return true;
}