From 982fbca0f753d6cebd57d6638bfb24b674e2dba9 Mon Sep 17 00:00:00 2001 From: Cuda-Chen Date: Thu, 2 Jan 2025 17:19:26 +0800 Subject: [PATCH] Code tidy --- virtio-snd.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/virtio-snd.c b/virtio-snd.c index 4f3d39e..d7f35f8 100644 --- a/virtio-snd.c +++ b/virtio-snd.c @@ -450,8 +450,8 @@ static void virtio_snd_read_pcm_set_params( { const virtio_snd_pcm_set_params_t *request = query; uint32_t id = request->hdr.stream_id; - /* TODO: detect current state of stream */ - uint32_t code = vsnd_props[id].pp.hdr.hdr.code; + virtio_snd_prop_t *props = &vsnd_props[id]; + uint32_t code = props->pp.hdr.hdr.code; if (code != VIRTIO_SND_R_PCM_RELEASE && code != VIRTIO_SND_R_PCM_SET_PARAMS && code != VIRTIO_SND_R_PCM_PREPARE) { @@ -462,22 +462,21 @@ static void virtio_snd_read_pcm_set_params( } /* TODO: check the valiability of buffer_bytes, period_bytes, channel_min, * and channel_max */ - vsnd_props[id].pp.hdr.hdr.code = VIRTIO_SND_R_PCM_SET_PARAMS; - vsnd_props[id].pp.buffer_bytes = request->buffer_bytes; - vsnd_props[id].pp.period_bytes = request->period_bytes; - vsnd_props[id].pp.features = request->features; - vsnd_props[id].pp.channels = request->channels; - vsnd_props[id].pp.format = request->format; - vsnd_props[id].pp.rate = request->rate; - vsnd_props[id].pp.padding = request->padding; + props->pp.hdr.hdr.code = VIRTIO_SND_R_PCM_SET_PARAMS; + props->pp.buffer_bytes = request->buffer_bytes; + props->pp.period_bytes = request->period_bytes; + props->pp.features = request->features; + props->pp.channels = request->channels; + props->pp.format = request->format; + props->pp.rate = request->rate; + props->pp.padding = request->padding; fprintf(stderr, "pcm_set_params rate %d" " period_bytes %" PRIu32 " buffer_bytes %" PRIu32 " channels %" PRIu32 "\n", - pcm_rate_tbl[vsnd_props[id].pp.rate], - vsnd_props[id].pp.period_bytes, vsnd_props[id].pp.buffer_bytes, - vsnd_props[id].pp.channels); + pcm_rate_tbl[props->pp.rate], props->pp.period_bytes, + props->pp.buffer_bytes, props->pp.channels); *plen = 0; fprintf(stderr, "virtio_snd_read_pcm_set_params\n");