Skip to content

Commit 8658fcf

Browse files
committed
Debug
1 parent edf559c commit 8658fcf

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

virtio-snd.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ static void __virtio_snd_frame_dequeue(short *out,
622622

623623
pthread_mutex_lock(&props->ring.lock);
624624
while (props->ring.buf_ev_notity < 1) {
625-
fprintf(stderr, "---wair in deque---\n");
625+
fprintf(stderr, "---wait in deque---\n");
626626
pthread_cond_wait(&props->ring.readable, &props->ring.lock);
627627
}
628628

@@ -647,9 +647,9 @@ static void __virtio_snd_frame_dequeue(short *out,
647647
uint32_t size = props->ring.cons.size;
648648
uint32_t idx = cons_head % size;
649649
fprintf(stderr,
650-
"cons_head %" PRIu32 " cons_next %" PRIu32 " mask %" PRIu32
651-
" idx %" PRIu32 "\n",
652-
cons_head, cons_next, mask, idx);
650+
"cons_head %" PRIu32 " cons_next %" PRIu32 " prod_tail %" PRIu32
651+
" mask %" PRIu32 " idx %" PRIu32 "\n",
652+
cons_head, cons_next, prod_tail, mask, idx);
653653
if (idx + n < size) {
654654
memcpy(out, props->ring.buffer + idx, n);
655655
} else {
@@ -857,8 +857,13 @@ static void __virtio_snd_frame_enqueue(void *payload,
857857
/* Update prod_tail */
858858
props->ring.prod.tail = prod_next;
859859

860-
props->ring.buf_ev_notity++;
861-
pthread_cond_signal(&props->ring.readable);
860+
uint32_t buffer_bytes = props->pp.buffer_bytes;
861+
if (mask + cons_tail - prod_next >= buffer_bytes) {
862+
fprintf(stderr, "buffer ready for %" PRIu32 "\n",
863+
mask + cons_tail - prod_next);
864+
props->ring.buf_ev_notity++;
865+
pthread_cond_signal(&props->ring.readable);
866+
}
862867
pthread_mutex_unlock(&props->ring.lock);
863868
}
864869

0 commit comments

Comments
 (0)