From 3dd71bd5abeae01d55a06a97ec6f4a69f12e05b1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 14 May 2007 11:03:37 +0000 Subject: also downgrade channel map when downgrading channel number git-svn-id: file:///home/lennart/svn/public/libsydney/trunk@15 9ba3c220-e4d3-45a2-8aa3-73fcc9aff6ce --- common.c | 4 ++-- malloc.h | 2 +- oss.c | 11 ++++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/common.c b/common.c index 7ace728..774d4cf 100644 --- a/common.c +++ b/common.c @@ -291,7 +291,7 @@ int sa_stream_change_read_volume(sa_stream_t *s, const int32_t vol[], unsigned n sa_return_val_if_fail((!s->codec && n == s->pcm_attrs.nchannels) || s->pcm_attrs.nchannels == 1, SA_ERROR_INVALID); if (s->codec || s->pcm_attrs.nchannels == n) { - if (!(v = sa_newdup(vol, int32_t, n))) + if (!(v = sa_newdup(int32_t, vol, n))) return SA_ERROR_OOM; } else { unsigned i; @@ -323,7 +323,7 @@ int sa_stream_change_write_volume(sa_stream_t *s, const int32_t vol[], unsigned sa_return_val_if_fail((!s->codec && n == s->pcm_attrs.nchannels) || s->pcm_attrs.nchannels == 1, SA_ERROR_INVALID); if (s->codec || s->pcm_attrs.nchannels == n) { - if (!(v = sa_newdup(vol, int32_t, n))) + if (!(v = sa_newdup(int32_t, vol, n))) return SA_ERROR_OOM; } else { unsigned i; diff --git a/malloc.h b/malloc.h index d9dcee9..bcaf53e 100644 --- a/malloc.h +++ b/malloc.h @@ -14,6 +14,6 @@ void* sa_memdup(const void* p, size_t size); #define sa_new(t, n) ((t*) sa_malloc(sizeof(t)*(n))) #define sa_new0(t, n) ((t*) sa_malloc0(sizeof(t)*(n))) -#define sa_newdup(p, t, n) ((t*) sa_memdup(p, sizeof(t)*(n))) +#define sa_newdup(t, p, n) ((t*) sa_memdup(p, sizeof(t)*(n))) #endif diff --git a/oss.c b/oss.c index 8c46884..50063bd 100644 --- a/oss.c +++ b/oss.c @@ -340,8 +340,17 @@ int driver_open(sa_stream_t *s) { printf("Chosen: %u channels, %uHz, format=%u\n", oss->real_pcm_attrs.nchannels, oss->real_pcm_attrs.rate, oss->real_pcm_attrs.format); - if (s->adjust_nchannels != 0) + if (s->adjust_nchannels != 0) { + sa_channel_t *cm; + + if (!(cm = sa_newdup(sa_channel_t, oss->real_pcm_attrs.channel_map, oss->real_pcm_attrs.nchannels))) + return SA_ERROR_OOM; + + sa_free(s->pcm_attrs.channel_map); + s->pcm_attrs.channel_map = cm; + s->pcm_attrs.nchannels = oss->real_pcm_attrs.nchannels; + } if (s->adjust_rate != 0) s->pcm_attrs.rate = oss->real_pcm_attrs.rate; if (s->adjust_pcm_format != 0) -- cgit