Skip to content

Commit

Permalink
Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuda-Chen committed Dec 29, 2024
1 parent edf559c commit 8658fcf
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions virtio-snd.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ static void __virtio_snd_frame_dequeue(short *out,

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

Expand All @@ -647,9 +647,9 @@ static void __virtio_snd_frame_dequeue(short *out,
uint32_t size = props->ring.cons.size;
uint32_t idx = cons_head % size;
fprintf(stderr,
"cons_head %" PRIu32 " cons_next %" PRIu32 " mask %" PRIu32
" idx %" PRIu32 "\n",
cons_head, cons_next, mask, idx);
"cons_head %" PRIu32 " cons_next %" PRIu32 " prod_tail %" PRIu32
" mask %" PRIu32 " idx %" PRIu32 "\n",
cons_head, cons_next, prod_tail, mask, idx);
if (idx + n < size) {
memcpy(out, props->ring.buffer + idx, n);
} else {
Expand Down Expand Up @@ -857,8 +857,13 @@ static void __virtio_snd_frame_enqueue(void *payload,
/* Update prod_tail */
props->ring.prod.tail = prod_next;

props->ring.buf_ev_notity++;
pthread_cond_signal(&props->ring.readable);
uint32_t buffer_bytes = props->pp.buffer_bytes;
if (mask + cons_tail - prod_next >= buffer_bytes) {
fprintf(stderr, "buffer ready for %" PRIu32 "\n",
mask + cons_tail - prod_next);
props->ring.buf_ev_notity++;
pthread_cond_signal(&props->ring.readable);
}
pthread_mutex_unlock(&props->ring.lock);
}

Expand Down

0 comments on commit 8658fcf

Please sign in to comment.