qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrzej Zaborowski <balrogg@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [4254] Let WM8750 users write to audio buffer directly.
Date: Sat, 26 Apr 2008 12:00:20 +0000	[thread overview]
Message-ID: <E1Jpj4m-0005NG-5O@cvs.savannah.gnu.org> (raw)

Revision: 4254
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=4254
Author:   balrog
Date:     2008-04-26 12:00:18 +0000 (Sat, 26 Apr 2008)

Log Message:
-----------
Let WM8750 users write to audio buffer directly.

Modified Paths:
--------------
    trunk/hw/i2c.h
    trunk/hw/musicpal.c
    trunk/hw/wm8750.c

Modified: trunk/hw/i2c.h
===================================================================
--- trunk/hw/i2c.h	2008-04-26 01:43:07 UTC (rev 4253)
+++ trunk/hw/i2c.h	2008-04-26 12:00:18 UTC (rev 4254)
@@ -67,6 +67,8 @@
                 void (*data_req)(void *, int, int), void *opaque);
 void wm8750_dac_dat(void *opaque, uint32_t sample);
 uint32_t wm8750_adc_dat(void *opaque);
+void *wm8750_dac_buffer(void *opaque, int samples);
+void wm8750_dac_commit(void *opaque);
 
 /* ssd0303.c */
 void ssd0303_init(DisplayState *ds, i2c_bus *bus, int address);

Modified: trunk/hw/musicpal.c
===================================================================
--- trunk/hw/musicpal.c	2008-04-26 01:43:07 UTC (rev 4253)
+++ trunk/hw/musicpal.c	2008-04-26 12:00:18 UTC (rev 4254)
@@ -254,7 +254,7 @@
 static void audio_callback(void *opaque, int free_out, int free_in)
 {
     musicpal_audio_state *s = opaque;
-    int16_t channel[2];
+    int16_t *codec_buffer;
     int pos, block_size;
 
     if (!(s->playback_mode & MP_AUDIO_PLAYBACK_EN))
@@ -270,17 +270,19 @@
         return;
 
     if (s->playback_mode & MP_AUDIO_16BIT_SAMPLE)
-        for (pos = 0; pos < block_size; pos += 4)
-            wm8750_dac_dat(s->wm,
-                    *(uint32_t *)(s->target_buffer + s->play_pos + pos));
-    else
+        memcpy(wm8750_dac_buffer(s->wm, block_size >> 2), 
+               (uint32_t *)(s->target_buffer + s->play_pos),
+               block_size);
+    else {
+        codec_buffer = wm8750_dac_buffer(s->wm, block_size >> 1);
         for (pos = 0; pos < block_size; pos += 2) {
-            channel[0] = cpu_to_le16(2 *
+            *codec_buffer++ = cpu_to_le16(2 *
                     *(int8_t *)(s->target_buffer + s->play_pos + pos));
-            channel[1] = cpu_to_le16(2 *
+            *codec_buffer++ = cpu_to_le16(2 *
                     *(int8_t *)(s->target_buffer + s->play_pos + pos + 1));
-            wm8750_dac_dat(s->wm, channel[0] | (channel[1] << 16));
         }
+    }
+    wm8750_dac_commit(s->wm);
 
     s->last_free = free_out - block_size;
 

Modified: trunk/hw/wm8750.c
===================================================================
--- trunk/hw/wm8750.c	2008-04-26 01:43:07 UTC (rev 4253)
+++ trunk/hw/wm8750.c	2008-04-26 12:00:18 UTC (rev 4254)
@@ -627,6 +627,24 @@
         wm8750_out_flush(s);
 }
 
+void *wm8750_dac_buffer(void *opaque, int samples)
+{
+    struct wm8750_s *s = (struct wm8750_s *) opaque;
+    /* XXX: Should check if there are <i>samples</i> free samples available */
+    void *ret = s->data_out + s->idx_out;
+
+    s->idx_out += samples << 2;
+    s->req_out -= samples << 2;
+    return ret;
+}
+
+void wm8750_dac_commit(void *opaque)
+{
+    struct wm8750_s *s = (struct wm8750_s *) opaque;
+
+    return wm8750_out_flush(s);
+}
+
 uint32_t wm8750_adc_dat(void *opaque)
 {
     struct wm8750_s *s = (struct wm8750_s *) opaque;

             reply	other threads:[~2008-04-26 12:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-26 12:00 Andrzej Zaborowski [this message]
2008-04-26 13:29 ` [Qemu-devel] [4254] Let WM8750 users write to audio buffer directly Jan Kiszka
2008-04-26 13:50   ` andrzej zaborowski
2008-04-26 14:11     ` Jan Kiszka
2008-04-26 20:10       ` andrzej zaborowski
2008-04-26 23:31         ` Jan Kiszka
2008-04-27 23:29           ` andrzej zaborowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1Jpj4m-0005NG-5O@cvs.savannah.gnu.org \
    --to=balrogg@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).