Skip to content

Commit c4083a5

Browse files
committed
Add ring buffer prototype
1 parent 966086f commit c4083a5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

virtio-snd.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ typedef struct {
254254

255255
// PCM frame ring buffer
256256
void *buffer;
257-
int sz;
258257
} virtio_snd_prop_t;
259258

260259
static virtio_snd_config_t vsnd_configs[VSND_DEV_CNT_MAX];
@@ -449,9 +448,11 @@ static void virtio_snd_read_pcm_prepare(const virtio_snd_pcm_hdr_t *query,
449448
v.stream_id = stream_id;
450449
// pthread_mutex_unlock(&virtio_snd_mutex);
451450
vsnd_props[stream_id].pp.hdr.hdr.code = VIRTIO_SND_R_PCM_PREPARE;
451+
uint32_t buffer_bytes = vsnd_props[stream_id].pp.buffer_bytes;
452452
vsnd_props[stream_id].audio_host =
453453
CNFAInit(NULL, "semu-virtio-snd", virtio_snd_cb, 44100, 0, 1, 0,
454-
vsnd_props[stream_id].pp.buffer_bytes, NULL, NULL, &v);
454+
buffer_bytes, NULL, NULL, &v);
455+
vsnd_props[stream_id].buffer = (void *)malloc(sizeof(void) * buffer_bytes);
455456

456457
*plen = 0;
457458
fprintf(stderr, "virtio_snd_read_pcm_prepare\n");
@@ -526,6 +527,7 @@ static void virtio_snd_read_pcm_release(const virtio_snd_pcm_hdr_t *query,
526527
fprintf(stderr, "pass CNFAclose\n");
527528

528529
/* Tear down the PCM frames. */
530+
free(vsnd_props[stream_id].buffer);
529531

530532
*plen = 0;
531533
fprintf(stderr, "virtio_snd_read_pcm_release\n");

0 commit comments

Comments
 (0)