qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2] ossaudio: add endianness support for VoiceIn
@ 2011-01-08 15:28 Michael Walle
  2011-01-08 15:28 ` [Qemu-devel] [PATCH 2/2] alsaaudio: " Michael Walle
  2011-01-08 16:42 ` [Qemu-devel] Re: [PATCH 1/2] ossaudio: " malc
  0 siblings, 2 replies; 6+ messages in thread
From: Michael Walle @ 2011-01-08 15:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael Walle

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

diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index 42bffae..5a56aa8 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,16 @@ 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 +522,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 +688,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;
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH 2/2] alsaaudio: add endianness support for VoiceIn
  2011-01-08 15:28 [Qemu-devel] [PATCH 1/2] ossaudio: add endianness support for VoiceIn Michael Walle
@ 2011-01-08 15:28 ` Michael Walle
  2011-01-08 16:42 ` [Qemu-devel] Re: [PATCH 1/2] ossaudio: " malc
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Walle @ 2011-01-08 15:28 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael Walle

Signed-off-by: Michael Walle <michael@walle.cc>
---
 audio/alsaaudio.c |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
index 0741203..a86aa08 100644
--- a/audio/alsaaudio.c
+++ b/audio/alsaaudio.c
@@ -318,7 +318,7 @@ static int alsa_write (SWVoiceOut *sw, void *buf, int len)
     return audio_pcm_sw_write (sw, buf, len);
 }
 
-static snd_pcm_format_t aud_to_alsafmt (audfmt_e fmt)
+static snd_pcm_format_t aud_to_alsafmt (audfmt_e fmt, int endianness)
 {
     switch (fmt) {
     case AUD_FMT_S8:
@@ -328,16 +328,28 @@ static snd_pcm_format_t aud_to_alsafmt (audfmt_e fmt)
         return SND_PCM_FORMAT_U8;
 
     case AUD_FMT_S16:
-        return SND_PCM_FORMAT_S16_LE;
+        if (endianness)
+            return SND_PCM_FORMAT_S16_BE;
+        else
+            return SND_PCM_FORMAT_S16_LE;
 
     case AUD_FMT_U16:
-        return SND_PCM_FORMAT_U16_LE;
+        if (endianness)
+            return SND_PCM_FORMAT_U16_BE;
+        else
+            return SND_PCM_FORMAT_U16_LE;
 
     case AUD_FMT_S32:
-        return SND_PCM_FORMAT_S32_LE;
+        if (endianness)
+            return SND_PCM_FORMAT_S32_BE;
+        else
+            return SND_PCM_FORMAT_S32_LE;
 
     case AUD_FMT_U32:
-        return SND_PCM_FORMAT_U32_LE;
+        if (endianness)
+            return SND_PCM_FORMAT_U32_BE;
+        else
+            return SND_PCM_FORMAT_U32_LE;
 
     default:
         dolog ("Internal logic error: Bad audio format %d\n", fmt);
@@ -809,7 +821,7 @@ static int alsa_init_out (HWVoiceOut *hw, struct audsettings *as)
     snd_pcm_t *handle;
     struct audsettings obt_as;
 
-    req.fmt = aud_to_alsafmt (as->fmt);
+    req.fmt = aud_to_alsafmt (as->fmt, as->endianness);
     req.freq = as->freq;
     req.nchannels = as->nchannels;
     req.period_size = conf.period_size_out;
@@ -918,7 +930,7 @@ static int alsa_init_in (HWVoiceIn *hw, struct audsettings *as)
     snd_pcm_t *handle;
     struct audsettings obt_as;
 
-    req.fmt = aud_to_alsafmt (as->fmt);
+    req.fmt = aud_to_alsafmt (as->fmt, as->endianness);
     req.freq = as->freq;
     req.nchannels = as->nchannels;
     req.period_size = conf.period_size_in;
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] Re: [PATCH 1/2] ossaudio: add endianness support for VoiceIn
  2011-01-08 15:28 [Qemu-devel] [PATCH 1/2] ossaudio: add endianness support for VoiceIn Michael Walle
  2011-01-08 15:28 ` [Qemu-devel] [PATCH 2/2] alsaaudio: " Michael Walle
@ 2011-01-08 16:42 ` malc
  2011-01-08 16:53   ` [Qemu-devel] " Michael Walle
  2011-01-08 16:53   ` [Qemu-devel] [PATCH 2/2] alsaaudio: " Michael Walle
  1 sibling, 2 replies; 6+ messages in thread
From: malc @ 2011-01-08 16:42 UTC (permalink / raw)
  To: Michael Walle; +Cc: qemu-devel

On Sat, 8 Jan 2011, Michael Walle wrote:

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

This misses braces around if statements. (Ditto for alsa)

[..snip..]

-- 
mailto:av1474@comtv.ru

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH 1/2] ossaudio: add endianness support for VoiceIn
  2011-01-08 16:42 ` [Qemu-devel] Re: [PATCH 1/2] ossaudio: " malc
@ 2011-01-08 16:53   ` Michael Walle
  2011-01-09  0:07     ` [Qemu-devel] " malc
  2011-01-08 16:53   ` [Qemu-devel] [PATCH 2/2] alsaaudio: " Michael Walle
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Walle @ 2011-01-08 16:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael Walle

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

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;
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] [PATCH 2/2] alsaaudio: add endianness support for VoiceIn
  2011-01-08 16:42 ` [Qemu-devel] Re: [PATCH 1/2] ossaudio: " malc
  2011-01-08 16:53   ` [Qemu-devel] " Michael Walle
@ 2011-01-08 16:53   ` Michael Walle
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Walle @ 2011-01-08 16:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: Michael Walle

Signed-off-by: Michael Walle <michael@walle.cc>
---
 audio/alsaaudio.c |   30 +++++++++++++++++++++++-------
 1 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
index 0741203..8d77646 100644
--- a/audio/alsaaudio.c
+++ b/audio/alsaaudio.c
@@ -318,7 +318,7 @@ static int alsa_write (SWVoiceOut *sw, void *buf, int len)
     return audio_pcm_sw_write (sw, buf, len);
 }
 
-static snd_pcm_format_t aud_to_alsafmt (audfmt_e fmt)
+static snd_pcm_format_t aud_to_alsafmt (audfmt_e fmt, int endianness)
 {
     switch (fmt) {
     case AUD_FMT_S8:
@@ -328,16 +328,32 @@ static snd_pcm_format_t aud_to_alsafmt (audfmt_e fmt)
         return SND_PCM_FORMAT_U8;
 
     case AUD_FMT_S16:
-        return SND_PCM_FORMAT_S16_LE;
+        if (endianness) {
+            return SND_PCM_FORMAT_S16_BE;
+        } else {
+            return SND_PCM_FORMAT_S16_LE;
+        }
 
     case AUD_FMT_U16:
-        return SND_PCM_FORMAT_U16_LE;
+        if (endianness) {
+            return SND_PCM_FORMAT_U16_BE;
+        } else {
+            return SND_PCM_FORMAT_U16_LE;
+        }
 
     case AUD_FMT_S32:
-        return SND_PCM_FORMAT_S32_LE;
+        if (endianness) {
+            return SND_PCM_FORMAT_S32_BE;
+        } else {
+            return SND_PCM_FORMAT_S32_LE;
+        }
 
     case AUD_FMT_U32:
-        return SND_PCM_FORMAT_U32_LE;
+        if (endianness) {
+            return SND_PCM_FORMAT_U32_BE;
+        } else {
+            return SND_PCM_FORMAT_U32_LE;
+        }
 
     default:
         dolog ("Internal logic error: Bad audio format %d\n", fmt);
@@ -809,7 +825,7 @@ static int alsa_init_out (HWVoiceOut *hw, struct audsettings *as)
     snd_pcm_t *handle;
     struct audsettings obt_as;
 
-    req.fmt = aud_to_alsafmt (as->fmt);
+    req.fmt = aud_to_alsafmt (as->fmt, as->endianness);
     req.freq = as->freq;
     req.nchannels = as->nchannels;
     req.period_size = conf.period_size_out;
@@ -918,7 +934,7 @@ static int alsa_init_in (HWVoiceIn *hw, struct audsettings *as)
     snd_pcm_t *handle;
     struct audsettings obt_as;
 
-    req.fmt = aud_to_alsafmt (as->fmt);
+    req.fmt = aud_to_alsafmt (as->fmt, as->endianness);
     req.freq = as->freq;
     req.nchannels = as->nchannels;
     req.period_size = conf.period_size_in;
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Qemu-devel] Re: [PATCH 1/2] ossaudio: add endianness support for VoiceIn
  2011-01-08 16:53   ` [Qemu-devel] " Michael Walle
@ 2011-01-09  0:07     ` malc
  0 siblings, 0 replies; 6+ messages in thread
From: malc @ 2011-01-09  0:07 UTC (permalink / raw)
  To: Michael Walle; +Cc: qemu-devel

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..]

-- 
mailto:av1474@comtv.ru

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-01-09  0:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-08 15:28 [Qemu-devel] [PATCH 1/2] ossaudio: add endianness support for VoiceIn Michael Walle
2011-01-08 15:28 ` [Qemu-devel] [PATCH 2/2] alsaaudio: " Michael Walle
2011-01-08 16:42 ` [Qemu-devel] Re: [PATCH 1/2] ossaudio: " malc
2011-01-08 16:53   ` [Qemu-devel] " Michael Walle
2011-01-09  0:07     ` [Qemu-devel] " malc
2011-01-08 16:53   ` [Qemu-devel] [PATCH 2/2] alsaaudio: " Michael Walle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).