@@ -297,8 +297,6 @@ typedef struct {
297297 // PCM frame doubly-ended queue
298298 vsnd_buf_queue_node_t buf ;
299299 struct list_head buf_queue_head ;
300- // PCM frame intermediate buffer;
301- void * intermediate ;
302300
303301 // playback control
304302 vsnd_stream_sel_t v ;
@@ -652,8 +650,6 @@ static void virtio_snd_read_pcm_prepare(const virtio_snd_pcm_hdr_t *query,
652650 uint32_t cnfa_period_frames = cnfa_period_bytes / VSND_CNFA_FRAME_SZ ;
653651
654652 INIT_LIST_HEAD (& props -> buf_queue_head );
655- props -> intermediate =
656- (void * ) malloc (sizeof (* props -> intermediate ) * cnfa_period_bytes );
657653 PaStreamParameters params = {
658654 .device = Pa_GetDefaultOutputDevice (),
659655 .channelCount = props -> pp .channels ,
@@ -746,7 +742,6 @@ static void virtio_snd_read_pcm_release(const virtio_snd_pcm_hdr_t *query,
746742 props -> pp .hdr .hdr .code = VIRTIO_SND_R_PCM_RELEASE ;
747743
748744 /* Tear down PCM buffer related locking attributes. */
749- free (props -> intermediate );
750745 /* Explicitly unlock the CVs and mutex. */
751746 pthread_cond_broadcast (& props -> lock .readable );
752747 pthread_cond_broadcast (& props -> lock .writable );
@@ -761,9 +756,6 @@ static void virtio_snd_read_pcm_release(const virtio_snd_pcm_hdr_t *query,
761756 }
762757 }
763758
764- /* avoid dangling pointers */
765- props -> intermediate = NULL ;
766-
767759 PaError err = Pa_CloseStream (props -> pa_stream );
768760 if (err != paNoError ) {
769761 fprintf (stderr , "get error in pcm_release\n" );
@@ -795,7 +787,6 @@ static void __virtio_snd_frame_dequeue(void *out,
795787
796788 /* Get the PCM frames from queue */
797789 uint32_t written_bytes = 0 ;
798- memset (props -> intermediate , 0 , sizeof (* props -> intermediate ) * n );
799790 while (!list_empty (& props -> buf_queue_head ) && written_bytes < n ) {
800791 vsnd_buf_queue_node_t * node =
801792 list_first_entry (& props -> buf_queue_head , vsnd_buf_queue_node_t , q );
@@ -804,15 +795,13 @@ static void __virtio_snd_frame_dequeue(void *out,
804795 uint32_t len =
805796 left < actual ? left : actual ; /* Naive min implementation */
806797
807- memcpy (props -> intermediate + written_bytes , node -> addr + node -> pos ,
808- len );
798+ memcpy (out + written_bytes , node -> addr + node -> pos , len );
809799
810800 written_bytes += len ;
811801 node -> pos += len ;
812802 if (node -> pos >= node -> len )
813803 list_del (& node -> q );
814804 }
815- memcpy (out , props -> intermediate , written_bytes );
816805
817806 props -> lock .buf_ev_notity -- ;
818807 pthread_cond_signal (& props -> lock .writable );
0 commit comments