]> git.alsa-project.org Git - alsa-plugins.git/commitdiff
Add PCM rates query support for PCM rate plugins
authorTakashi Iwai <tiwai@suse.de>
Tue, 2 Jun 2009 14:30:06 +0000 (16:30 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 2 Jun 2009 14:30:06 +0000 (16:30 +0200)
Follow the new PCM rate-plugin protocol to support the rate range
queries, etc.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
pph/rate_speexrate.c
rate-lavc/rate_lavcrate.c
rate/rate_samplerate.c

index 38244b6d11b53d2f28996e3cf5b81be83289d533..0a1325c323687d1df67134c0b0db4cebbc190621 100644 (file)
@@ -116,6 +116,26 @@ static void pcm_src_close(void *obj)
    free(obj);
 }
 
+#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
+static int get_supported_rates(void *obj, unsigned int *rate_min,
+                              unsigned int *rate_max)
+{
+       *rate_min = *rate_max = 0; /* both unlimited */
+       return 0;
+}
+
+static void dump(void *obj, snd_output_t *out)
+{
+       snd_output_printf(out, "Converter: libspeex "
+#ifdef USE_LIBSPEEX
+                         "(external)"
+#else
+                         "(builtin)"
+#endif
+                         "\n");
+}
+#endif
+
 static snd_pcm_rate_ops_t pcm_src_ops = {
        .close = pcm_src_close,
        .init = pcm_src_init,
@@ -125,6 +145,11 @@ static snd_pcm_rate_ops_t pcm_src_ops = {
        .convert_s16 = pcm_src_convert_s16,
        .input_frames = input_frames,
        .output_frames = output_frames,
+#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
+       .version = SND_PCM_RATE_PLUGIN_VERSION,
+       .get_supported_rates = get_supported_rates,
+       .dump = dump,
+#endif
 };
 
 static int pcm_src_open(unsigned int version, void **objp,
@@ -132,18 +157,24 @@ static int pcm_src_open(unsigned int version, void **objp,
 {
        struct rate_src *rate;
 
+#if SND_PCM_RATE_PLUGIN_VERSION < 0x010002
        if (version != SND_PCM_RATE_PLUGIN_VERSION) {
                fprintf(stderr, "Invalid rate plugin version %x\n", version);
                return -EINVAL;
        }
-
+#endif
        rate = calloc(1, sizeof(*rate));
        if (! rate)
                return -ENOMEM;
        rate->quality = quality;
 
        *objp = rate;
-       *ops = pcm_src_ops;
+#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
+       if (version == 0x010001)
+               memcpy(ops, &pcm_src_ops, sizeof(snd_pcm_rate_old_ops_t));
+       else
+#endif
+               *ops = pcm_src_ops;
        return 0;
 }
 
index ea2e2f54e8a8da0e255d7c734231bf3ff7edda8a..14a219840300f9cc4023d05d66e1d708f9358dc2 100644 (file)
@@ -202,6 +202,20 @@ static void pcm_src_close(void *obj)
        pcm_src_free(obj);
 }
 
+#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
+static int get_supported_rates(void *obj, unsigned int *rate_min,
+                              unsigned int *rate_max)
+{
+       *rate_min = *rate_max = 0; /* both unlimited */
+       return 0;
+}
+
+static void dump(void *obj, snd_output_t *out)
+{
+       snd_output_printf(out, "Converter: liblavc\n");
+}
+#endif
+
 static snd_pcm_rate_ops_t pcm_src_ops = {
        .close = pcm_src_close,
        .init = pcm_src_init,
@@ -211,6 +225,11 @@ static snd_pcm_rate_ops_t pcm_src_ops = {
        .convert_s16 = pcm_src_convert_s16,
        .input_frames = input_frames,
        .output_frames = output_frames,
+#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
+       .version = SND_PCM_RATE_PLUGIN_VERSION,
+       .get_supported_rates = get_supported_rates,
+       .dump = dump,
+#endif
 };
 
 int pcm_src_open(unsigned int version, void **objp, snd_pcm_rate_ops_t *ops)
@@ -218,18 +237,24 @@ int pcm_src_open(unsigned int version, void **objp, snd_pcm_rate_ops_t *ops)
 {
        struct rate_src *rate;
 
+#if SND_PCM_RATE_PLUGIN_VERSION < 0x010002
        if (version != SND_PCM_RATE_PLUGIN_VERSION) {
                fprintf(stderr, "Invalid rate plugin version %x\n", version);
                return -EINVAL;
        }
-
+#endif
        rate = calloc(1, sizeof(*rate));
        if (!rate)
                return -ENOMEM;
 
        *objp = rate;
        rate->context = NULL;
-       *ops = pcm_src_ops;
+#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
+       if (version == 0x010001)
+               memcpy(ops, &pcm_src_ops, sizeof(snd_pcm_rate_old_ops_t));
+       else
+#endif
+               *ops = pcm_src_ops;
        return 0;
 }
 
index e366db06af3e2cf40281106dd59aa113e038ef8c..53a0627b21dc080b31c3c8697fe54b3afeaabab3 100644 (file)
@@ -137,6 +137,20 @@ static void pcm_src_close(void *obj)
        free(obj);
 }
 
+#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
+static int get_supported_rates(void *obj, unsigned int *rate_min,
+                              unsigned int *rate_max)
+{
+       *rate_min = *rate_max = 0; /* both unlimited */
+       return 0;
+}
+
+static void dump(void *obj, snd_output_t *out)
+{
+       snd_output_printf(out, "Converter: libsamplerate\n");
+}
+#endif
+
 static snd_pcm_rate_ops_t pcm_src_ops = {
        .close = pcm_src_close,
        .init = pcm_src_init,
@@ -146,6 +160,11 @@ static snd_pcm_rate_ops_t pcm_src_ops = {
        .convert_s16 = pcm_src_convert_s16,
        .input_frames = input_frames,
        .output_frames = output_frames,
+#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
+       .version = SND_PCM_RATE_PLUGIN_VERSION,
+       .get_supported_rates = get_supported_rates,
+       .dump = dump,
+#endif
 };
 
 static int pcm_src_open(unsigned int version, void **objp,
@@ -153,18 +172,24 @@ static int pcm_src_open(unsigned int version, void **objp,
 {
        struct rate_src *rate;
 
+#if SND_PCM_RATE_PLUGIN_VERSION < 0x010002
        if (version != SND_PCM_RATE_PLUGIN_VERSION) {
                fprintf(stderr, "Invalid rate plugin version %x\n", version);
                return -EINVAL;
        }
-
+#endif
        rate = calloc(1, sizeof(*rate));
        if (! rate)
                return -ENOMEM;
        rate->converter = type;
 
        *objp = rate;
-       *ops = pcm_src_ops;
+#if SND_PCM_RATE_PLUGIN_VERSION >= 0x010002
+       if (version == 0x010001)
+               memcpy(ops, &pcm_src_ops, sizeof(snd_pcm_rate_old_ops_t));
+       else
+#endif
+               *ops = pcm_src_ops;
        return 0;
 }