summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaarten Bosmans <mkbosmans@gmail.com>2011-07-02 12:12:43 +0200
committerColin Guthrie <colin@mageia.org>2011-07-03 13:54:56 +0100
commited0e879cd999750d06e189953319786e5178cf27 (patch)
treedf5aaef1cdf1efeae54653bc2b8c999f09586169 /src
parent6addadc57494f30efd608ef6bb7980033bd0f0db (diff)
module-waveout: Correctly handle mono volume controls on waveout device
Diffstat (limited to 'src')
-rw-r--r--src/modules/module-waveout.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/modules/module-waveout.c b/src/modules/module-waveout.c
index cb02723c..f0710b7e 100644
--- a/src/modules/module-waveout.c
+++ b/src/modules/module-waveout.c
@@ -400,14 +400,23 @@ static int process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa
static void sink_get_volume_cb(pa_sink *s) {
struct userdata *u = s->userdata;
+ WAVEOUTCAPS caps;
DWORD vol;
pa_volume_t left, right;
+ if (waveOutGetDevCaps(u->hwo, &caps, sizeof(caps)) != MMSYSERR_NOERROR)
+ return;
+ if (!(caps.dwSupport & WAVECAPS_VOLUME))
+ return;
+
if (waveOutGetVolume(u->hwo, &vol) != MMSYSERR_NOERROR)
return;
left = PA_CLAMP_VOLUME((vol & 0xFFFF) * PA_VOLUME_NORM / WAVEOUT_MAX_VOLUME);
- right = PA_CLAMP_VOLUME(((vol >> 16) & 0xFFFF) * PA_VOLUME_NORM / WAVEOUT_MAX_VOLUME);
+ if (caps.dwSupport & WAVECAPS_LRVOLUME)
+ right = PA_CLAMP_VOLUME(((vol >> 16) & 0xFFFF) * PA_VOLUME_NORM / WAVEOUT_MAX_VOLUME);
+ else
+ right = left;
/* Windows supports > 2 channels, except for volume control */
if (s->real_volume.channels > 2)
@@ -420,11 +429,21 @@ static void sink_get_volume_cb(pa_sink *s) {
static void sink_set_volume_cb(pa_sink *s) {
struct userdata *u = s->userdata;
+ WAVEOUTCAPS caps;
DWORD vol;
- vol = s->real_volume.values[0] * WAVEOUT_MAX_VOLUME / PA_VOLUME_NORM;
- if (s->real_volume.channels > 1)
- vol |= (s->real_volume.values[1] * WAVEOUT_MAX_VOLUME / PA_VOLUME_NORM) << 16;
+ if (waveOutGetDevCaps(u->hwo, &caps, sizeof(caps)) != MMSYSERR_NOERROR)
+ return;
+ if (!(caps.dwSupport & WAVECAPS_VOLUME))
+ return;
+
+ if (s->real_volume.channels == 2 && caps.dwSupport & WAVECAPS_LRVOLUME) {
+ vol = (s->real_volume.values[0] * WAVEOUT_MAX_VOLUME / PA_VOLUME_NORM)
+ | (s->real_volume.values[1] * WAVEOUT_MAX_VOLUME / PA_VOLUME_NORM) << 16;
+ } else {
+ vol = (pa_cvolume_avg(&(s->real_volume)) * WAVEOUT_MAX_VOLUME / PA_VOLUME_NORM)
+ | (pa_cvolume_avg(&(s->real_volume)) * WAVEOUT_MAX_VOLUME / PA_VOLUME_NORM) << 16;
+ }
if (waveOutSetVolume(u->hwo, vol) != MMSYSERR_NOERROR)
return;