|
8 | 8 | #include "CNFA_sf.h" |
9 | 9 |
|
10 | 10 | #include "device.h" |
11 | | -#include "utils.h" |
12 | 11 | #include "riscv.h" |
13 | 12 | #include "riscv_private.h" |
| 13 | +#include "utils.h" |
14 | 14 | #include "virtio.h" |
15 | 15 |
|
16 | 16 | #define VSND_DEV_CNT_MAX 1 |
@@ -622,29 +622,23 @@ static void virtio_snd_cb(struct CNFADriver *dev, |
622 | 622 | { |
623 | 623 | (void) in; /* reversed for future recording use */ |
624 | 624 | 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; |
625 | 627 |
|
626 | 628 | pthread_mutex_lock(&virtio_snd_ctrl_mutex); |
627 | 629 |
|
628 | | - while (v_ptr->guest_playing <= 0) { |
| 630 | + while (v_ptr->guest_playing == 0) { |
629 | 631 | fprintf(stderr, "wait ctrl cond\n"); |
| 632 | + memset(out, 0, sizeof(*out) * out_buf_sz); |
630 | 633 | pthread_cond_wait(&virtio_snd_ctrl_cond, &virtio_snd_ctrl_mutex); |
631 | 634 | } |
632 | 635 |
|
633 | | - v_ptr->guest_playing--; |
634 | | - |
635 | 636 | totalframesr += framesr; |
636 | 637 | totalframesp += framesp; |
637 | 638 |
|
638 | | - int channels = dev->channelsPlay; |
639 | 639 | uint32_t id = v_ptr->stream_id; |
640 | | - uint32_t out_buf_sz = framesp * channels; |
641 | 640 | fprintf(stderr, "start to play with out_buf_sz %" PRIu32 "\n", out_buf_sz); |
642 | 641 |
|
643 | | - /*if (!(playing)) { |
644 | | - memset(out, 0, sizeof(short) * out_buf_sz); |
645 | | - return; |
646 | | - }*/ |
647 | | - |
648 | 642 | /* TODO: add single consumer */ |
649 | 643 | __virtio_snd_frame_dequeue(out, out_buf_sz, id); |
650 | 644 | #if 0 |
|
0 commit comments