Skip to contentSkip to conversation

qemu support for S32 and U32 alsa output

PATCH In review Lonnie Mendez 2 participants 3 messages Feb 6, 2007 – Feb 10, 2007 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemu support for S32 and U32 alsa output

Forwarding this for a user who is not subscribed.
---

Hi,

My M-Audio soundcard (ice1712) did not play nice with qemu's alsa output since it only accepted S32_LE. I asked some weirdo who has nothing better to do at 6:50 AM in the #qemu channel on freenode for help, and he wrote the attached patch.

I've patched this against CVS and also against 0.8.2 with some manual code hacking (different line offsets), and hereby kindly request that someone knowledgeable takes a look at it so it can be committed.

Thanks in advance; the patch is attached.

Regards,

infernix

? .gdb_history
Index: Makefile.target
===================================================================
RCS file: /cvsroot/qemu/qemu/Makefile.target,v
retrieving revision 1.144

Makefile.target +2 -2
diff -u -r1.144 Makefile.target
@@ -583,8 +583,8 @@
 include .depend
 endif
 
-ifeq (1, 0)
+ifeq (1, 1)
 audio.o sdlaudio.o dsoundaudio.o ossaudio.o wavaudio.o noaudio.o \
 fmodaudio.o alsaaudio.o mixeng.o sb16.o es1370.o gus.o adlib.o: \
-CFLAGS := $(CFLAGS) -Wall -Werror -W -Wsign-compare
+CFLAGS := $(CFLAGS) -O0 -g # -Wall -Werror -W -Wsign-compare -O0 -g
 endif

Index: audio/alsaaudio.c
===================================================================
RCS file: /cvsroot/qemu/qemu/audio/alsaaudio.c,v
retrieving revision 1.7

alsaaudio.c +26 -0
diff -u -r1.7 alsaaudio.c
@@ -157,6 +157,12 @@
     case AUD_FMT_U16:
         return SND_PCM_FORMAT_U16_LE;
 
+    case AUD_FMT_S32:
+        return SND_PCM_FORMAT_S32_LE;
+
+    case AUD_FMT_U32:
+        return SND_PCM_FORMAT_U32_LE;
+
     default:
         dolog ("Internal logic error: Bad audio format %d\n", fmt);
 #ifdef DEBUG_AUDIO
@@ -199,6 +205,26 @@
         *fmt = AUD_FMT_U16;
         break;
 
+    case SND_PCM_FORMAT_S32_LE:
+        *endianness = 0;
+        *fmt = AUD_FMT_S32;
+        break;
+
+    case SND_PCM_FORMAT_U32_LE:
+        *endianness = 0;
+        *fmt = AUD_FMT_U32;
+        break;
+
+    case SND_PCM_FORMAT_S32_BE:
+        *endianness = 1;
+        *fmt = AUD_FMT_S32;
+        break;
+
+    case SND_PCM_FORMAT_U32_BE:
+        *endianness = 1;
+        *fmt = AUD_FMT_U32;
+        break;
+
     default:
         dolog ("Unrecognized audio format %d\n", alsafmt);
         return -1;

Index: audio/audio.c
===================================================================
RCS file: /cvsroot/qemu/qemu/audio/audio.c,v
retrieving revision 1.15

audio.c +90 -14

175 lines not on this page · raw message

Index: audio/audio.h
===================================================================
RCS file: /cvsroot/qemu/qemu/audio/audio.h,v
retrieving revision 1.8

audio.h +3 -1
diff -u -r1.8 audio.h
@@ -33,7 +33,9 @@
     AUD_FMT_U8,
     AUD_FMT_S8,
     AUD_FMT_U16,
-    AUD_FMT_S16
+    AUD_FMT_S16,
+    AUD_FMT_U32,
+    AUD_FMT_S32
 } audfmt_e;
 
 #ifdef WORDS_BIGENDIAN

Index: audio/audio_template.h
===================================================================
RCS file: /cvsroot/qemu/qemu/audio/audio_template.h,v retrieving revision 1.8

audio_template.h +2 -2
diff -u -r1.8 audio_template.h
@@ -164,7 +164,7 @@
         [sw->info.nchannels == 2]
         [sw->info.sign]
         [sw->info.swap_endianness]
-        [sw->info.bits == 16];
+        [audio_bits_to_index (sw->info.bits)];
 
     sw->name = qemu_strdup (name);
     err = glue (audio_pcm_sw_alloc_resources_, TYPE) (sw);
@@ -288,7 +288,7 @@
         [hw->info.nchannels == 2]
         [hw->info.sign]
         [hw->info.swap_endianness]
-        [hw->info.bits == 16];
+        [audio_bits_to_index (hw->info.bits)];
 
     if (glue (audio_pcm_hw_alloc_resources_, TYPE) (hw)) {
         goto err1;

Index: audio/coreaudio.c
===================================================================
RCS file: /cvsroot/qemu/qemu/audio/coreaudio.c,v
retrieving revision 1.7

coreaudio.c +0 -5
diff -u -r1.7 coreaudio.c
@@ -294,7 +294,6 @@
     coreaudioVoiceOut *core = (coreaudioVoiceOut *) hw;
     UInt32 propertySize;
     int err;
-    int bits = 8;
     const char *typ = "playback";
     AudioValueRange frameRange;
 
@@ -305,10 +304,6 @@
         return -1;
     }
 
-    if (as->fmt == AUD_FMT_S16 || as->fmt == AUD_FMT_U16) {
-        bits = 16;
-    }
-
     audio_pcm_init_info (&hw->info, as);
 
     /* open default output device */

Index: audio/mixeng.c
===================================================================
RCS file: /cvsroot/qemu/qemu/audio/mixeng.c,v
retrieving revision 1.4

mixeng.c +77 -18

176 lines not on this page · raw message

Index: audio/mixeng.h
===================================================================
RCS file: /cvsroot/qemu/qemu/audio/mixeng.h,v
retrieving revision 1.2

mixeng.h +2 -2
diff -u -r1.2 mixeng.h
@@ -37,8 +37,8 @@
                          int samples, volume_t *vol);
 typedef void (f_sample) (void *dst, const st_sample_t *src, int samples);
 
-extern t_sample *mixeng_conv[2][2][2][2];
-extern f_sample *mixeng_clip[2][2][2][2];
+extern t_sample *mixeng_conv[2][2][2][3];
+extern f_sample *mixeng_clip[2][2][2][3];
 
 void *st_rate_start (int inrate, int outrate);
 void st_rate_flow (void *opaque, st_sample_t *ibuf, st_sample_t *obuf,

Index: audio/wavaudio.c
===================================================================
RCS file: /cvsroot/qemu/qemu/audio/wavaudio.c,v
retrieving revision 1.9

wavaudio.c +5 -0
diff -u -r1.9 wavaudio.c
@@ -131,6 +131,11 @@
     case AUD_FMT_U16:
         bits16 = 1;
         break;
+
+    case AUD_FMT_S32:
+    case AUD_FMT_U32:
+        dolog ("WAVE files can not handle 32bit formats\n");
+        return -1;
     }
 
     hdr[34] = bits16 ? 0x10 : 0x08;

Index: audio/wavcapture.c
===================================================================
RCS file: /cvsroot/qemu/qemu/audio/wavcapture.c,v
retrieving revision 1.7

wavcapture.c +3 -3
diff -u -r1.7 wavcapture.c
@@ -37,15 +37,15 @@
     if (wav->f) {
         le_store (rlen, rifflen, 4);
         le_store (dlen, datalen, 4);
-        
+
         qemu_fseek (wav->f, 4, SEEK_SET);
         qemu_put_buffer (wav->f, rlen, 4);
-        
+
         qemu_fseek (wav->f, 32, SEEK_CUR);
         qemu_put_buffer (wav->f, dlen, 4);
         qemu_fclose (wav->f);
     }
-    
+
     qemu_free (wav->path);
 }
 
#1 lore raw
Quoted 5 lines · Lonnie Mendez

Forwarding this for a user who is not subscribed.
---

Hi,

Quoted 8 lines

My M-Audio soundcard (ice1712) did not play nice with qemu's alsa output since it only accepted S32_LE. I asked some weirdo who has nothing better to do at 6:50 AM in the #qemu channel on freenode for help, and he wrote the attached patch.

I've patched this against CVS and also against 0.8.2 with some manual code hacking (different line offsets), and hereby kindly request that someone knowledgeable takes a look at it so it can be committed.

So ... who is the person to blam^Wcredit for authorship? The patch looks good elsewise.

Thiemo

#2 lore raw
Quoted 2 lines · Thiemo Seufer

So ... who is the person to blam^Wcredit for authorship? The patch looks good elsewise.

I believe the author is Vassili Karpov.