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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/18/2013 09:22 AM, Peter Meerwald wrote:
> From: Peter Meerwald <p.meerwald at bct-electronic.com>
> 
> useful for testing resampling
> 
> Signed-off-by: Peter Meerwald <p.meerwald at bct-electronic.com>
> ---
>  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;
> +    }

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)?




-- 
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic


[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux