]> code.delx.au - pulseaudio/commitdiff
resampler: Add a choose_auto_resampler function
authorpoljar (Damir Jelić) <poljarinho@gmail.com>
Wed, 7 Aug 2013 17:55:44 +0000 (19:55 +0200)
committerpoljar (Damir Jelić) <poljarinho@gmail.com>
Tue, 27 Aug 2013 10:33:10 +0000 (12:33 +0200)
This function returns our preferred resampler if the user choose the
auto (or if he has chosen an unsupported) resampler.

src/pulsecore/resampler.c

index b2238ff65311f80a6a7e0be60f30290a8dc2a11a..5599035f6ddd54c4bd0d1b4e876b4a9902f91173 100644 (file)
@@ -176,6 +176,19 @@ static int (* const init_table[])(pa_resampler*r) = {
     [PA_RESAMPLER_PEAKS]                   = peaks_init,
 };
 
+static pa_resample_method_t choose_auto_resampler(pa_resample_flags_t flags) {
+    pa_resample_method_t method;
+
+    if (pa_resample_method_supported(PA_RESAMPLER_SPEEX_FLOAT_BASE + 1))
+        method = PA_RESAMPLER_SPEEX_FLOAT_BASE + 1;
+    else if (flags & PA_RESAMPLER_VARIABLE_RATE)
+        method = PA_RESAMPLER_TRIVIAL;
+    else
+        method = PA_RESAMPLER_FFMPEG;
+
+    return method;
+}
+
 static pa_resample_method_t pa_resampler_fix_method(
                 pa_resample_flags_t flags,
                 pa_resample_method_t method,
@@ -224,16 +237,8 @@ static pa_resample_method_t pa_resampler_fix_method(
             break;
     }
 
-    if (method == PA_RESAMPLER_AUTO) {
-#ifdef HAVE_SPEEX
-        method = PA_RESAMPLER_SPEEX_FLOAT_BASE + 1;
-#else
-        if (flags & PA_RESAMPLER_VARIABLE_RATE)
-            method = PA_RESAMPLER_TRIVIAL;
-        else
-            method = PA_RESAMPLER_FFMPEG;
-#endif
-    }
+    if (method == PA_RESAMPLER_AUTO)
+        method = choose_auto_resampler(flags);
 
     return method;
 }