Skip to content

Commit 2e9b605

Browse files
committed
Let sound playing continuously in pcm_start state
1 parent 77027c8 commit 2e9b605

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

virtio-snd.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#include "CNFA_sf.h"
99

1010
#include "device.h"
11-
#include "utils.h"
1211
#include "riscv.h"
1312
#include "riscv_private.h"
13+
#include "utils.h"
1414
#include "virtio.h"
1515

1616
#define VSND_DEV_CNT_MAX 1
@@ -622,29 +622,23 @@ static void virtio_snd_cb(struct CNFADriver *dev,
622622
{
623623
(void) in; /* reversed for future recording use */
624624
vsnd_stream_sel_t *v_ptr = (vsnd_stream_sel_t *) dev->opaque;
625+
int channels = dev->channelsPlay;
626+
uint32_t out_buf_sz = framesp * channels;
625627

626628
pthread_mutex_lock(&virtio_snd_ctrl_mutex);
627629

628-
while (v_ptr->guest_playing <= 0) {
630+
while (v_ptr->guest_playing == 0) {
629631
fprintf(stderr, "wait ctrl cond\n");
632+
memset(out, 0, sizeof(*out) * out_buf_sz);
630633
pthread_cond_wait(&virtio_snd_ctrl_cond, &virtio_snd_ctrl_mutex);
631634
}
632635

633-
v_ptr->guest_playing--;
634-
635636
totalframesr += framesr;
636637
totalframesp += framesp;
637638

638-
int channels = dev->channelsPlay;
639639
uint32_t id = v_ptr->stream_id;
640-
uint32_t out_buf_sz = framesp * channels;
641640
fprintf(stderr, "start to play with out_buf_sz %" PRIu32 "\n", out_buf_sz);
642641

643-
/*if (!(playing)) {
644-
memset(out, 0, sizeof(short) * out_buf_sz);
645-
return;
646-
}*/
647-
648642
/* TODO: add single consumer */
649643
__virtio_snd_frame_dequeue(out, out_buf_sz, id);
650644
#if 0

0 commit comments

Comments
 (0)