@@ -551,7 +551,7 @@ static void virtio_snd_read_pcm_prepare(const virtio_snd_pcm_hdr_t *query,
551551 /* CNFA only accept frame with signed 16-bit data in little-endian. */
552552 props -> audio_host =
553553 CNFAInit (NULL , "semu-virtio-snd" , virtio_snd_cb , rate , 0 , channels , 0 ,
554- cnfa_period_frames , NULL , NULL , & props -> v );
554+ period_bytes / VSND_CNFA_FRAME_SZ , NULL , NULL , & props -> v );
555555 uint32_t sz = props -> pp .buffer_bytes ;
556556 props -> ring .buffer = (void * ) malloc (sizeof (void ) * sz );
557557 props -> ring .prod .head = 0 ;
@@ -709,26 +709,26 @@ static void __virtio_snd_frame_dequeue(short *out,
709709 "cons_head %" PRIu32 " cons_next %" PRIu32 " prod_tail %" PRIu32
710710 " mask %" PRIu32 " idx %" PRIu32 "\n" ,
711711 cons_head , cons_next , prod_tail , mask , idx );
712- /* if (idx + n < size) {
712+ if (idx + n < size ) {
713713 memcpy (out , props -> ring .buffer + idx , n );
714714 } else {
715715 memcpy (out , props -> ring .buffer + idx , size - idx );
716716 memcpy (out + (size - idx ), props -> ring .buffer , n - (size - idx ));
717717 fprintf (stderr , "=== start %" PRIu32 " end %" PRIu32 "\n" , size - idx ,
718718 n - (size - idx ));
719- }*/
719+ }
720720 VSND_COMPILER_BARRIER ;
721721
722722 props -> ring .cons .tail = cons_next ;
723723
724- uint32_t len = 0 ;
724+ /* uint32_t len = 0;
725725 while (!list_empty(&props->buf_queue_head) && len < n) {
726726 vsnd_buf_queue_node_t *node =
727727 list_first_entry(&props->buf_queue_head, vsnd_buf_queue_node_t, q);
728728 list_del(&node->q);
729729 memcpy(out, node->addr, node->len);
730730 len += node->len;
731- }
731+ }*/
732732
733733 props -> ring .buf_ev_notity -- ;
734734 pthread_cond_signal (& props -> ring .writable );
@@ -934,15 +934,15 @@ static void __virtio_snd_frame_enqueue(void *payload,
934934 fwrite (node -> addr , sizeof (void ), node -> len , outfile );
935935#endif
936936
937- uint32_t period_bytes = props -> pp .period_bytes ;
937+ /* uint32_t period_bytes = props->pp.period_bytes;
938938 if (prod_next - cons_tail >= period_bytes) {
939939 fprintf(stderr,
940940 "buffer ready for %" PRIu32 " cons_tail %" PRIu32
941941 " prod_next %" PRIu32 "\n",
942942 prod_next - cons_tail, cons_tail, prod_next);
943943 props->ring.buf_ev_notity++;
944944 pthread_cond_signal(&props->ring.readable);
945- }
945+ }*/
946946 pthread_mutex_unlock (& props -> ring .lock );
947947}
948948
@@ -1006,6 +1006,7 @@ static int virtio_snd_tx_desc_handler(virtio_snd_state_t *vsnd,
10061006 (virtio_snd_pcm_status_t * ) (base + addr );
10071007 response -> status = VIRTIO_SND_S_OK ;
10081008 response -> latency_bytes = ret_len ;
1009+ printf ("=== TX queue get %" PRIu32 " bytes ===\n" , ret_len );
10091010 * plen = sizeof (* response );
10101011 goto early_continue ;
10111012 }
@@ -1018,6 +1019,10 @@ static int virtio_snd_tx_desc_handler(virtio_snd_state_t *vsnd,
10181019 idx ++ ;
10191020 }
10201021
1022+ virtio_snd_prop_t * props = & vsnd_props [stream_id ];
1023+ props -> ring .buf_ev_notity ++ ;
1024+ pthread_cond_signal (& props -> ring .readable );
1025+
10211026 /* Tear down the descriptor list and free space. */
10221027 virtq_desc_queue_node_t * tmp = NULL ;
10231028 list_for_each_entry_safe (node , tmp , & q , q ) {
0 commit comments