Skip to content

Commit

Permalink
Code tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
Cuda-Chen committed Jan 2, 2025
1 parent 9e06b1d commit 982fbca
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions virtio-snd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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");
Expand Down

0 comments on commit 982fbca

Please sign in to comment.