[pulseaudio-discuss] [PATCH 1/4] module-sine: Add rate argument

Peter Meerwald pmeerw at pmeerw.net
Tue Aug 6 13:53:33 PDT 2013


Hello,

regards, p.

> >  src/modules/module-sine.c |    7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/src/modules/module-sine.c b/src/modules/module-sine.c
> > index 573a7c0..3d97025 100644
> > --- a/src/modules/module-sine.c
> > +++ b/src/modules/module-sine.c
> > @@ -41,6 +41,7 @@ PA_MODULE_VERSION(PACKAGE_VERSION);
> >  PA_MODULE_LOAD_ONCE(false);
> >  PA_MODULE_USAGE(
> >          "sink=<sink to connect to> "
> > +        "rate=<sample rate> "
> >          "frequency=<frequency in Hz>");
> >  
> >  struct userdata {
> > @@ -53,6 +54,7 @@ struct userdata {
> >  
> >  static const char* const valid_modargs[] = {
> >      "sink",
> > +    "rate",
> >      "frequency",
> >      NULL,
> >  };
> > @@ -138,6 +140,11 @@ int pa__init(pa_module*m) {
> >      ss.rate = sink->sample_spec.rate;
> >      ss.channels = 1;
> >  
> > +    if (pa_modargs_get_value_u32(ma, "rate", &ss.rate) < 0 || ss.rate <= 1) {
> > +        pa_log("Invalid rate specification");
> > +        goto fail;
> > +    }

the code is 'inspired' (aka copied) from module-sine-source.c:

    if (pa_modargs_get_value_u32(ma, "rate", &ss.rate) < 0 || ss.rate <= 1) {
        pa_log("Invalid rate specification");
        goto fail;
    }

> Here's the same code from pa_modargs_get_sample_spec:

>     if ((pa_modargs_get_value_u32(ma, "rate", &ss.rate)) < 0 ||
>         ss.rate <= 0 ||
>         ss.rate > PA_RATE_MAX)
>         return -1;
> 
> They should probably look the same or even be refactored into a common
> function (pa_modargs_get_rate)?

yes; another potential use is in module-bluetooth-device.c

will do for v2

regards, p.

-- 

Peter Meerwald
+43-664-2444418 (mobile)


More information about the pulseaudio-discuss mailing list