Skip to content

Commit

Permalink
Let sound playing continuously in pcm_start state
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuda-Chen committed Dec 17, 2024
1 parent 77027c8 commit 2e9b605
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions virtio-snd.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#include "CNFA_sf.h"

#include "device.h"
#include "utils.h"
#include "riscv.h"
#include "riscv_private.h"
#include "utils.h"
#include "virtio.h"

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

pthread_mutex_lock(&virtio_snd_ctrl_mutex);

while (v_ptr->guest_playing <= 0) {
while (v_ptr->guest_playing == 0) {
fprintf(stderr, "wait ctrl cond\n");
memset(out, 0, sizeof(*out) * out_buf_sz);
pthread_cond_wait(&virtio_snd_ctrl_cond, &virtio_snd_ctrl_mutex);
}

v_ptr->guest_playing--;

totalframesr += framesr;
totalframesp += framesp;

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

/*if (!(playing)) {
memset(out, 0, sizeof(short) * out_buf_sz);
return;
}*/

/* TODO: add single consumer */
__virtio_snd_frame_dequeue(out, out_buf_sz, id);
#if 0
Expand Down

0 comments on commit 2e9b605

Please sign in to comment.