Message ID | cover.1690626150.git.manos.pitsidianakis@linaro.org (mailing list archive) |
---|---|
Headers | show |
Series | Add VIRTIO sound card | expand |
Hi On Sat, Jul 29, 2023 at 2:39 PM Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org> wrote: > + > +/* > + * Prepares a VirtIOSound card stream. > + * Returns the response status code. (VIRTIO_SND_S_*). > + * > + * @s: VirtIOSound device > + * @stream_id: stream id > + */ > +static uint32_t virtio_snd_pcm_prepare_impl(VirtIOSound *s, uint32_t stream_id) > +{ > + audsettings as; > + VirtIOSoundPCMParams *params; > + VirtIOSoundPCMStream *stream; > + > + if (!s->pcm->streams || > + !s->pcm->pcm_params || > + !s->pcm->pcm_params[stream_id]) { > + return VIRTIO_SND_S_BAD_MSG; > + } > + > + params = virtio_snd_pcm_get_params(s, stream_id); > + if (!params) { > + return VIRTIO_SND_S_BAD_MSG; > + } > + > + virtio_snd_get_qemu_audsettings(&as, params); > + > + stream = g_new0(VirtIOSoundPCMStream, 1); > + > + stream->id = stream_id; > + stream->pcm = s->pcm; > + stream->direction = stream_id < s->snd_conf.streams / 2 + > + (s->snd_conf.streams & 1) ? VIRTIO_SND_D_OUTPUT : VIRTIO_SND_D_INPUT; > + stream->info.hdr.hda_fn_nid = VIRTIO_SOUND_HDA_FN_NID; > + stream->features = 0; > + stream->channels_min = 1; > + stream->channels_max = as.nchannels; > + stream->formats = supported_formats; > + stream->rates = supported_rates; > + stream->s = s; > + > + stream->buffer_bytes = params->buffer_bytes; > + stream->period_bytes = params->period_bytes; > + > + stream->positions[0] = VIRTIO_SND_CHMAP_FL; > + stream->positions[1] = VIRTIO_SND_CHMAP_FR; > + > + stream->as = as; > + stream->desired_as = stream->as; > + qemu_mutex_init(&stream->queue_mutex); > + QSIMPLEQ_INIT(&stream->queue); > + > + s->pcm->streams[stream_id] = stream; Same remark as v4: Shouldn't it close & free the existing stream? Or return an error?
On Sat, 29 Jul 2023 14:00, Marc-André Lureau <marcandre.lureau@redhat.com> wrote: >> + >> + s->pcm->streams[stream_id] = stream; > >Same remark as v4: >Shouldn't it close & free the existing stream? Or return an error? > Hello, yes you are correct. I missed that comment on the v4 reviews :) Will send a v6 with a fix, I will wait a bit in case any other patch gets a Reviewed-By this time.