|
3 | 3 | #include <pthread.h> |
4 | 4 | #include <stdio.h> |
5 | 5 | #include <string.h> |
6 | | - |
| 6 | +#include <stdlib.h> |
7 | 7 | #define CNFA_IMPLEMENTATION |
8 | 8 | #include "CNFA_sf.h" |
9 | 9 |
|
|
21 | 21 | #define PRIV(x) ((virtio_snd_config_t *) x->priv) |
22 | 22 |
|
23 | 23 | #define VSND_CNFA_FRAME_SZ 2 |
24 | | - |
| 24 | +FILE *outfile; |
25 | 25 | enum { |
26 | 26 | VSND_QUEUE_CTRL = 0, |
27 | 27 | VSND_QUEUE_EVT = 1, |
@@ -562,6 +562,7 @@ static void virtio_snd_read_pcm_prepare(const virtio_snd_pcm_hdr_t *query, |
562 | 562 | pthread_cond_init(&props->ring.readable, NULL); |
563 | 563 | pthread_cond_init(&props->ring.writable, NULL); |
564 | 564 | INIT_LIST_HEAD(&props->buf_queue_head); |
| 565 | + outfile = fopen("out_enque.bin", "wb"); |
565 | 566 |
|
566 | 567 | *plen = 0; |
567 | 568 | fprintf(stderr, "virtio_snd_read_pcm_prepare\n"); |
@@ -635,7 +636,7 @@ static void virtio_snd_read_pcm_release(const virtio_snd_pcm_hdr_t *query, |
635 | 636 | } |
636 | 637 |
|
637 | 638 | props->pp.hdr.hdr.code = VIRTIO_SND_R_PCM_RELEASE; |
638 | | - |
| 639 | + fclose(outfile); |
639 | 640 | /* Tear down the PCM ring buffer. */ |
640 | 641 | free(props->ring.buffer); |
641 | 642 | pthread_mutex_destroy(&props->ring.lock); |
@@ -712,12 +713,16 @@ static void __virtio_snd_frame_dequeue(short *out, |
712 | 713 |
|
713 | 714 | props->ring.cons.tail = cons_next; |
714 | 715 |
|
715 | | - if (list_empty(&props->buf_queue_head)) |
716 | | - goto finally; |
| 716 | + uint32_t len = 0; |
| 717 | + while ( |
| 718 | + !list_empty(&props->buf_queue_head) && |
| 719 | + len < n) { |
717 | 720 | vsnd_buf_queue_node_t *node = |
718 | 721 | list_first_entry(&props->buf_queue_head, vsnd_buf_queue_node_t, q); |
719 | 722 | list_del(&node->q); |
720 | 723 | memcpy(out, node->addr, node->len); |
| 724 | + len += node->len; |
| 725 | + } |
721 | 726 |
|
722 | 727 | finally: |
723 | 728 | props->ring.buf_ev_notity--; |
@@ -920,6 +925,7 @@ static void __virtio_snd_frame_enqueue(void *payload, |
920 | 925 | node->addr = payload; |
921 | 926 | node->len = n; |
922 | 927 | list_push(&node->q, &props->buf_queue_head); |
| 928 | + fwrite(node->addr, sizeof(void), node->len, outfile); |
923 | 929 |
|
924 | 930 | uint32_t period_bytes = props->pp.period_bytes; |
925 | 931 | if (prod_next - cons_tail >= period_bytes) { |
|
0 commit comments