[Spice-devel] [spice-gtk PATCH v9 2/4] audio: spice-pulse implement async volume-info

Christophe Fergeau cfergeau at redhat.com
Tue Apr 21 09:02:02 PDT 2015


On Tue, Apr 21, 2015 at 05:57:12PM +0200, Victor Toso wrote:
> > > +static void source_output_info_cb(pa_context *context,
> > > +                                  const pa_source_output_info *info,
> > > +                                  int eol,
> > > +                                  void *userdata)
> > > +{
> > > +    struct async_task *task = userdata;
> > > +    SpicePulsePrivate *p = task->pulse->priv;
> > > +    struct stream *pstream = &p->record;
> > > +
> > > +    if (eol) {
> > > +        spice_pulse_complete_async_task(task, NULL);
> > > +        return;
> > > +    }
> > > +
> > > +    pstream->info_updated = TRUE;
> > > +    pstream->info.name = pstream->name;
> > > +    pstream->info.mute = info->mute;
> > > +    pstream->info.channel_map = info->channel_map;
> > > +    pstream->info.volume = info->volume;
> > > +}
> > > +
> > > +static void sink_input_info_cb(pa_context *context,
> > > +                               const pa_sink_input_info *info,
> > > +                               int eol,
> > > +                               void *userdata)
> > > +{
> > > +    struct async_task *task = userdata;
> > > +    SpicePulsePrivate *p = task->pulse->priv;
> > > +    struct stream *pstream = &p->playback;
> > > +
> > > +    if (eol) {
> > > +        spice_pulse_complete_async_task(task, NULL);
> > > +        return;
> > > +    }
> > > +
> > > +    pstream->info_updated = TRUE;
> > > +    pstream->info.name = pstream->name;
> > > +    pstream->info.mute = info->mute;
> > > +    pstream->info.channel_map = info->channel_map;
> > > +    pstream->info.volume = info->volume;
> > > +}
> > 
> > It seems source_output_info_cb/source_output_info_cb could be combined
> > with just
> > struct stream *pstream = (is_playback) ? &p->playback : &p->record;
> > as the difference as is down elsewhere in that patch.
> > 
> 
> Indeed but as they are callbacks I thought it would be better to have
> each function with your callback; also, pa_sink_input_info not equal to
> pa_source_output_info.
> I can have a function to avoid duplication code as I did in the other
> part of the patch as well, do you think it is better?

Ah right, different prototypes. Well, I'd say don't bother. Or add a
small helper to fill pstream->info which could be used 3 times, but I
don't really think that's that useful, the code is fine as it is.

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20150421/96e85d3f/attachment.sig>


More information about the Spice-devel mailing list