[pulseaudio-commits] r1757 - in /branches/lennart/src/pulsecore: resampler.c resampler.h

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Mon Sep 3 13:50:04 PDT 2007


Author: lennart
Date: Mon Sep  3 22:50:03 2007
New Revision: 1757

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1757&root=pulseaudio&view=rev
Log:
add new API function pa_resample_method_supported() which tests whether a resampling method is supported. Fix building with libsamplerate enabled

Modified:
    branches/lennart/src/pulsecore/resampler.c
    branches/lennart/src/pulsecore/resampler.h

Modified: branches/lennart/src/pulsecore/resampler.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/resampler.c?rev=1757&root=pulseaudio&r1=1756&r2=1757&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/resampler.c (original)
+++ branches/lennart/src/pulsecore/resampler.c Mon Sep  3 22:50:03 2007
@@ -91,6 +91,9 @@
 static int trivial_init(pa_resampler*r);
 static int speex_init(pa_resampler*r);
 static int ffmpeg_init(pa_resampler*r);
+#ifdef HAVE_LIBSAMPLERATE
+static int libsamplerate_init(pa_resampler*r);
+#endif
 
 static void calc_map_table(pa_resampler *r);
 
@@ -166,6 +169,11 @@
 
     /* Fix method */
 
+    if (!pa_resample_method_supported(resample_method)) {
+        pa_log_warn("Support for resampler '%s' not compiled in, reverting to 'auto'.", pa_resample_method_to_string(resample_method));
+        resample_method = PA_RESAMPLER_AUTO;
+    }
+    
     if (resample_method == PA_RESAMPLER_FFMPEG && variable_rate) {
         pa_log_info("Resampler 'ffmpeg' cannot do variable rate, reverting to resampler 'auto'." );
         resample_method = PA_RESAMPLER_AUTO;
@@ -360,6 +368,19 @@
     return resample_methods[m];
 }
 
+int pa_resample_method_supported(pa_resample_method_t m) {
+
+    if (m < 0 || m >= PA_RESAMPLER_MAX)
+        return 0;
+
+#ifndef HAVE_LIBSAMPLERATE
+    if (m <= PA_RESAMPLER_SRC_LINEAR)
+        return 0;
+#endif
+        
+    return 1;
+}
+
 pa_resample_method_t pa_parse_resample_method(const char *string) {
     pa_resample_method_t m;
 

Modified: branches/lennart/src/pulsecore/resampler.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/resampler.h?rev=1757&root=pulseaudio&r1=1756&r2=1757&view=diff
==============================================================================
--- branches/lennart/src/pulsecore/resampler.h (original)
+++ branches/lennart/src/pulsecore/resampler.h Mon Sep  3 22:50:03 2007
@@ -80,4 +80,7 @@
 /* return a human readable string for the specified resampling method. Inverse of pa_parse_resample_method() */
 const char *pa_resample_method_to_string(pa_resample_method_t m);
 
+/* Return 1 when the specified resampling method is supported */
+int pa_resample_method_supported(pa_resample_method_t m);
+
 #endif




More information about the pulseaudio-commits mailing list