From ba1a738c05e187fefbc7cd7f7a499f4b14b95d98 Mon Sep 17 00:00:00 2001 From: Cuda-Chen Date: Sun, 29 Dec 2024 17:52:13 +0800 Subject: [PATCH] Debug The playing beginning artifact appears again. --- virtio-snd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/virtio-snd.c b/virtio-snd.c index 489b5e7..5662061 100644 --- a/virtio-snd.c +++ b/virtio-snd.c @@ -842,10 +842,10 @@ static void __virtio_snd_frame_enqueue(void *payload, /* Write payload to ring buffer. */ uint32_t size = props->ring.prod.size; uint32_t idx = prod_head % size; - /*fprintf(stderr, - "prod_head %" PRIu32 " prod_next %" PRIu32 " mask %" PRIu32 - " idx %" PRIu32 "\n", - prod_head, prod_next, mask, idx);*/ + fprintf(stderr, + "prod_head %" PRIu32 " prod_next %" PRIu32 " cons_tail %" PRIu32 + " mask %" PRIu32 " idx %" PRIu32 "\n", + prod_head, prod_next, cons_tail, mask, idx); if (idx + n < size) { memcpy(props->ring.buffer + idx, payload, n); } else { @@ -858,9 +858,9 @@ static void __virtio_snd_frame_enqueue(void *payload, props->ring.prod.tail = prod_next; uint32_t buffer_bytes = props->pp.buffer_bytes; - if (mask + cons_tail - prod_next >= buffer_bytes) { + if (prod_next - cons_tail >= buffer_bytes) { fprintf(stderr, "buffer ready for %" PRIu32 "\n", - mask + cons_tail - prod_next); + prod_next - cons_tail); props->ring.buf_ev_notity++; pthread_cond_signal(&props->ring.readable); }