Skip to content

Commit d312e6f

Browse files
committed
Set playback setting in pcm_set_param
1 parent bbe3c06 commit d312e6f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

virtio-snd.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,11 @@ static void virtio_snd_read_pcm_set_params(struct virtq_desc *vq_desc,
349349
{
350350
#if 0
351351
/* TODO: detect current state of stream */
352-
virtio_snd_pcm_set_params_t *info =
353-
(virtio_snd_pcm_set_params_t *) ((uintptr_t) vq_desc[1].addr);
354-
355352
/* TODO: let application to set each value at will */
356353
/* TODO: check the valiability of buffer_bytes, period_bytes, channel_min,
357354
* and channel_max */
358355
info->hdr.hdr.code = VIRTIO_SND_R_PCM_SET_PARAMS;
359-
info->hdr.stream_id = VIRTIO_SND_PCM_F_SHMEM_HOST;
356+
info->hdr.stream_id = 0;
360357
info->buffer_bytes = 2048;
361358
info->period_bytes = 1024;
362359
info->features = 0;
@@ -365,6 +362,17 @@ static void virtio_snd_read_pcm_set_params(struct virtq_desc *vq_desc,
365362
info->rate = (1 << VIRTIO_SND_PCM_RATE_44100);
366363
info->padding = 0;
367364
#endif
365+
virtio_snd_pcm_set_params_t *request = query;
366+
uint32_t id = request->hdr.stream_id;
367+
vsnd_props[id].pp.hdr.hdr.code = VIRTIO_SND_R_PCM_SET_PARAMS;
368+
vsnd_props[id].pp.buffer_bytes = request->buffer_bytes;
369+
vsnd_props[id].pp.period_bytes = request->period_bytes;
370+
vsnd_props[id].pp.features = request->features;
371+
vsnd_props[id].pp.channels = request->channels;
372+
vsnd_props[id].pp.format = request->format;
373+
vsnd_props[id].pp.rate = request->rate;
374+
vsnd_props[id].pp.padding = request->padding;
375+
368376
fprintf(stderr, "virtio_snd_read_pcm_set_params\n");
369377
}
370378

@@ -377,6 +385,7 @@ static void virtio_snd_read_pcm_prepare(struct virtq_desc *vq_desc,
377385
/* TODO: add lock to avoid race condition */
378386
guest_playing = false;
379387

388+
380389
fprintf(stderr, "virtio_snd_read_pcm_prepare\n");
381390
}
382391

0 commit comments

Comments
 (0)