Skip to contentSkip to conversation

wm8750: Fix rate init and output fifo flushing

PATCH New Jan Kiszka 1 participant 1 message Apr 19, 2008

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 wm8750: Fix rate init and output fifo flushing

Two in one, but trivial to split up if preferred:

1. wm8750_s.rate remained uninitialized and caused segfaults here if the guest took different init paths than probably tested to far.

2. Flushing the output fifo at the beginning of the related callback caused severe jitters and sound clicks to the musicpal emulation which builds its audio IRQ timing on top of the periodically reported "free". Moving the flush after the data_req callback fixes this - and makes more sense given that most users will have written new data from within that callback. :)

---
 hw/wm8750.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/wm8750.c +2 -1
Index: b/hw/wm8750.c
===================================================================
@@ -76,10 +76,10 @@ static void wm8750_audio_in_cb(void *opa
 static void wm8750_audio_out_cb(void *opaque, int free_b)
 {
     struct wm8750_s *s = (struct wm8750_s *) opaque;
-    wm8750_out_flush(s);
 
     s->req_out = free_b;
     s->data_req(s->opaque, free_b >> 2, s->req_in >> 2);
+    wm8750_out_flush(s);
 }
 
 struct wm_rate_s {
@@ -213,6 +213,7 @@ static void inline wm8750_mask_update(st
 void wm8750_reset(i2c_slave *i2c)
 {
     struct wm8750_s *s = (struct wm8750_s *) i2c;
+    s->rate = &wm_rate_table[0];
     s->enable = 0;
     wm8750_set_format(s);
     s->diff[0] = 0;