Patchwork [1/2] ossaudio: add endianness support for VoiceIn

login
register
mail settings
Submitter Michael Walle
Date Jan. 8, 2011, 4:53 p.m.
Message ID <1294505610-20187-1-git-send-email-michael@walle.cc>
Download mbox | patch
Permalink /patch/77968/
State New
Headers show

Comments

Michael Walle - Jan. 8, 2011, 4:53 p.m.
Signed-off-by: Michael Walle <michael@walle.cc>
---
 audio/ossaudio.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
malc - Jan. 9, 2011, 12:07 a.m.
On Sat, 8 Jan 2011, Michael Walle wrote:

> Signed-off-by: Michael Walle <michael@walle.cc>
> ---
>  audio/ossaudio.c |   18 +++++++++++++-----
>  1 files changed, 13 insertions(+), 5 deletions(-)

Thanks, applied with minor stylistic changes. (ditto alsaaudio.c)

[..snip..]

Patch

diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index 42bffae..cfa8f99 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -161,7 +161,7 @@  static int oss_write (SWVoiceOut *sw, void *buf, int len)
     return audio_pcm_sw_write (sw, buf, len);
 }
 
-static int aud_to_ossfmt (audfmt_e fmt)
+static int aud_to_ossfmt (audfmt_e fmt, int endianness)
 {
     switch (fmt) {
     case AUD_FMT_S8:
@@ -171,10 +171,18 @@  static int aud_to_ossfmt (audfmt_e fmt)
         return AFMT_U8;
 
     case AUD_FMT_S16:
-        return AFMT_S16_LE;
+        if (endianness) {
+            return AFMT_S16_BE;
+        } else {
+            return AFMT_S16_LE;
+        }
 
     case AUD_FMT_U16:
-        return AFMT_U16_LE;
+        if (endianness) {
+            return AFMT_U16_BE;
+        } else {
+            return AFMT_U16_LE;
+        }
 
     default:
         dolog ("Internal logic error: Bad audio format %d\n", fmt);
@@ -516,7 +524,7 @@  static int oss_init_out (HWVoiceOut *hw, struct audsettings *as)
 
     oss->fd = -1;
 
-    req.fmt = aud_to_ossfmt (as->fmt);
+    req.fmt = aud_to_ossfmt (as->fmt, as->endianness);
     req.freq = as->freq;
     req.nchannels = as->nchannels;
     req.fragsize = conf.fragsize;
@@ -682,7 +690,7 @@  static int oss_init_in (HWVoiceIn *hw, struct audsettings *as)
 
     oss->fd = -1;
 
-    req.fmt = aud_to_ossfmt (as->fmt);
+    req.fmt = aud_to_ossfmt (as->fmt, as->endianness);
     req.freq = as->freq;
     req.nchannels = as->nchannels;
     req.fragsize = conf.fragsize;