[pulseaudio-discuss] [PATCH v4 8/9] native: Add a proplist to the sink and source info.

Tanu Kaskinen tanuk at iki.fi
Thu Apr 12 06:47:26 PDT 2012


On Thu, 2012-04-12 at 15:42 +0200, David Henningsson wrote:
> On 04/12/2012 01:59 PM, Tanu Kaskinen wrote:
> > diff --git a/src/pulse/introspect.c b/src/pulse/introspect.c
> > index 38a9d1c..be65fdd 100644
> > --- a/src/pulse/introspect.c
> > +++ b/src/pulse/introspect.c
> > @@ -200,29 +200,33 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, u
> >
> >               if (o->context->version>= 16) {
> >                   if (i.n_ports>  0) {
> > -                    i.ports = pa_xnew(pa_sink_port_info*, i.n_ports+1);
> > -                    i.ports[0] = pa_xnew(pa_sink_port_info, i.n_ports);
> > +                    i.ports = pa_xnew0(pa_sink_port_info*, i.n_ports+1);
> > +                    i.ports[0] = pa_xnew0(pa_sink_port_info, i.n_ports);
> >
> >                       for (j = 0; j<  i.n_ports; j++) {
> > -                        if (pa_tagstruct_gets(t,&i.ports[0][j].name)<  0 ||
> > -                            pa_tagstruct_gets(t,&i.ports[0][j].description)<  0 ||
> > -                            pa_tagstruct_getu32(t,&i.ports[0][j].priority)<  0) {
> > +                        i.ports[j] =&i.ports[0][j];
> > +
> > +                        if (pa_tagstruct_gets(t,&i.ports[j]->name)<  0 ||
> > +                            pa_tagstruct_gets(t,&i.ports[j]->description)<  0 ||
> > +                            pa_tagstruct_getu32(t,&i.ports[j]->priority)<  0) {
> >
> >                               goto fail;
> >                           }
> >
> > -                        i.ports[0][j].available = PA_PORT_AVAILABLE_UNKNOWN;
> > +                        i.ports[j]->available = PA_PORT_AVAILABLE_UNKNOWN;
> >                           if (o->context->version>= 24) {
> >                               uint32_t av;
> >                               if (pa_tagstruct_getu32(t,&av)<  0 || av>  PA_PORT_AVAILABLE_YES)
> >                                   goto fail;
> > -                            i.ports[0][j].available = av;
> > +                            i.ports[j]->available = av;
> >                           }
> >
> > -                        i.ports[j] =&i.ports[0][j];
> > +                        i.ports[j]->proplist = pa_proplist_new();
> > +                        if (o->context->version>= 27) {
> > +                            if (pa_tagstruct_get_proplist(t, i.ports[j]->proplist)<  0)
> > +                                goto fail;
> > +                        }
> >                       }
> > -
> > -                    i.ports[j] = NULL;
> >                   }
> >
> >                   if (pa_tagstruct_gets(t,&ap)<  0)
> > @@ -268,6 +272,9 @@ static void context_get_sink_info_callback(pa_pdispatch *pd, uint32_t command, u
> >                   pa_xfree(i.formats);
> >               }
> >               if (i.ports) {
> > +                for (j = 0; i.ports[j]; j++)
> > +                    pa_proplist_free(i.ports[j]->proplist);
> > +
> >                   pa_xfree(i.ports[0]);
> >                   pa_xfree(i.ports);
> >               }
> > @@ -296,6 +303,11 @@ fail:
> >           pa_xfree(i.formats);
> >       }
> >       if (i.ports) {
> > +        for (j = 0; i.ports[j]; j++) {
> > +            if (i.ports[j]->proplist)
> > +                pa_proplist_free(i.ports[j]->proplist);
> 
> Just a random dive-in here: is it possible that the pa_proplist_new has 
> not been called for the last port, therefore pa_proplist_free will raise 
> an assertion failure?

It's possible that pa_proplist_new() hasn't been called, but in that
case the pointer is NULL, and the if condition on the previous line is
false, so pa_proplist_free() won't be called.

-- 
Tanu



More information about the pulseaudio-discuss mailing list