@@ -523,6 +523,18 @@ static void virtio_snd_read_pcm_release(const virtio_snd_pcm_hdr_t *query,
523523 vsnd_props [stream_id ].pp .hdr .hdr .code = VIRTIO_SND_R_PCM_RELEASE ;
524524 CNFAClose (vsnd_props [stream_id ].audio_host );
525525
526+ /* Tear down the PCM frames. */
527+ virtio_snd_pcm_frame_t * t = NULL ;
528+ struct queue_head frame_q = vsnd_props [stream_id ].pcm_frames_q ;
529+ virtio_snd_pcm_frame_t * frame = vsnd_props [stream_id ].pcm_frames ;
530+ queue_for_each_entry_safe (frame , t , & frame_q , q )
531+ {
532+ free (frame -> buf );
533+ queue_del (& frame -> q );
534+ free (frame );
535+ }
536+ assert (queue_empty (& frame_q ));
537+
526538 * plen = 0 ;
527539 fprintf (stderr , "virtio_snd_read_pcm_release\n" );
528540}
@@ -671,7 +683,7 @@ static int virtio_snd_tx_desc_handler(virtio_snd_state_t *vsnd,
671683 uint32_t desc_idx ,
672684 uint32_t * plen )
673685{
674- /* TODO: clarify the usage of last descriptor. */
686+ /* TODO: clarify the usage of the last descriptor. */
675687 /* virtio-snd TX uses arbitrary number of virtqueue descriptors.
676688 * The first descritor descriptor contains:
677689 * struct virtio_snd_hdr hdr (for request)
@@ -692,11 +704,6 @@ static int virtio_snd_tx_desc_handler(virtio_snd_state_t *vsnd,
692704 const uint32_t * desc = & vsnd -> ram [queue -> QueueDesc + desc_idx * 4 ];
693705
694706 /* Retrieve the fields of current descriptor */
695- /*if (i < VSND_DESC_CNT) {
696- vq_desc[i].addr = desc[0];
697- vq_desc[i].len = desc[2];
698- vq_desc[i].flags = desc[3];
699- }*/
700707 node = (virtq_desc_queue_node_t * ) malloc (sizeof (* node ));
701708 node -> vq_desc .addr = desc [0 ];
702709 node -> vq_desc .len = desc [2 ];
@@ -787,6 +794,7 @@ static int virtio_snd_tx_desc_handler(virtio_snd_state_t *vsnd,
787794 assert (idx == cnt );
788795 assert (queue_empty (& q ));
789796
797+ #if 0
790798 /* Tear down the PCM frames. (should use in pcm_release) */
791799 idx = 0 ;
792800 virtio_snd_pcm_frame_t * t = NULL ;
@@ -799,6 +807,7 @@ static int virtio_snd_tx_desc_handler(virtio_snd_state_t *vsnd,
799807 }
800808 assert (idx == cnt - 2 );
801809 assert (queue_empty (& frame_q ));
810+ #endif
802811
803812 return 0 ;
804813}
@@ -1068,13 +1077,6 @@ bool virtio_snd_init(virtio_snd_state_t *vsnd)
10681077 /* Allocate the memory of private member. */
10691078 vsnd -> priv = & vsnd_configs [vsnd_dev_cnt ++ ];
10701079
1071- /*audio_host = CNFAInit(NULL, "semu-virtio-snd", virtio_snd_cb, 44100, 0, 1,
1072- 0, 1024, NULL, NULL, &guest_playing);
1073- if (!audio_host) {
1074- fprintf(stderr, "virtio-snd driver initialization failed.\n");
1075- return false;
1076- }*/
1077-
10781080 PRIV (vsnd )-> jacks = 1 ;
10791081 PRIV (vsnd )-> streams = 1 ;
10801082 PRIV (vsnd )-> chmaps = 1 ;
0 commit comments