Skip to content

Commit f08721d

Browse files
committed
Disable PCM output debug
1 parent 038b347 commit f08721d

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

virtio-snd.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#include <math.h>
33
#include <pthread.h>
44
#include <stdio.h>
5-
#include <string.h>
65
#include <stdlib.h>
6+
#include <string.h>
77
#define CNFA_IMPLEMENTATION
88
#include "CNFA_sf.h"
99

@@ -13,6 +13,8 @@
1313
#include "utils.h"
1414
#include "virtio.h"
1515

16+
#define WRITEOUT 0
17+
1618
#define VSND_DEV_CNT_MAX 1
1719

1820
#define VSND_QUEUE_NUM_MAX 1024
@@ -21,7 +23,9 @@
2123
#define PRIV(x) ((virtio_snd_config_t *) x->priv)
2224

2325
#define VSND_CNFA_FRAME_SZ 2
26+
#if WRITEOUT
2427
FILE *outfile;
28+
#endif
2529
enum {
2630
VSND_QUEUE_CTRL = 0,
2731
VSND_QUEUE_EVT = 1,
@@ -562,7 +566,9 @@ static void virtio_snd_read_pcm_prepare(const virtio_snd_pcm_hdr_t *query,
562566
pthread_cond_init(&props->ring.readable, NULL);
563567
pthread_cond_init(&props->ring.writable, NULL);
564568
INIT_LIST_HEAD(&props->buf_queue_head);
569+
#if WRITEOUT
565570
outfile = fopen("out_enque.bin", "wb");
571+
#endif
566572

567573
*plen = 0;
568574
fprintf(stderr, "virtio_snd_read_pcm_prepare\n");
@@ -636,7 +642,9 @@ static void virtio_snd_read_pcm_release(const virtio_snd_pcm_hdr_t *query,
636642
}
637643

638644
props->pp.hdr.hdr.code = VIRTIO_SND_R_PCM_RELEASE;
645+
#if WRITEOUT
639646
fclose(outfile);
647+
#endif
640648
/* Tear down the PCM ring buffer. */
641649
free(props->ring.buffer);
642650
pthread_mutex_destroy(&props->ring.lock);
@@ -714,17 +722,14 @@ static void __virtio_snd_frame_dequeue(short *out,
714722
props->ring.cons.tail = cons_next;
715723

716724
uint32_t len = 0;
717-
while (
718-
!list_empty(&props->buf_queue_head) &&
719-
len < n) {
720-
vsnd_buf_queue_node_t *node =
721-
list_first_entry(&props->buf_queue_head, vsnd_buf_queue_node_t, q);
722-
list_del(&node->q);
723-
memcpy(out, node->addr, node->len);
724-
len += node->len;
725+
while (!list_empty(&props->buf_queue_head) && len < n) {
726+
vsnd_buf_queue_node_t *node =
727+
list_first_entry(&props->buf_queue_head, vsnd_buf_queue_node_t, q);
728+
list_del(&node->q);
729+
memcpy(out, node->addr, node->len);
730+
len += node->len;
725731
}
726732

727-
finally:
728733
props->ring.buf_ev_notity--;
729734
pthread_cond_signal(&props->ring.writable);
730735
pthread_mutex_unlock(&props->ring.lock);
@@ -925,7 +930,9 @@ static void __virtio_snd_frame_enqueue(void *payload,
925930
node->addr = payload;
926931
node->len = n;
927932
list_push(&node->q, &props->buf_queue_head);
933+
#if WRITEOUT
928934
fwrite(node->addr, sizeof(void), node->len, outfile);
935+
#endif
929936

930937
uint32_t period_bytes = props->pp.period_bytes;
931938
if (prod_next - cons_tail >= period_bytes) {

0 commit comments

Comments
 (0)