diff options
author | Lennart Poettering <lennart@poettering.net> | 2007-09-03 20:50:03 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2007-09-03 20:50:03 +0000 |
commit | c9a0df361794750cc075c3f0bf7835028db64ead (patch) | |
tree | c7b2c815ec7cbd7d2d8e453756f1d4b847a5c7f0 | |
parent | 5bc1221d40553f4c0e19cc7dfd606ff164d49cef (diff) |
add new API function pa_resample_method_supported() which tests whether a resampling method is supported. Fix building with libsamplerate enabled
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1757 fefdeb5f-60dc-0310-8127-8f9354f1896f
-rw-r--r-- | src/pulsecore/resampler.c | 21 | ||||
-rw-r--r-- | src/pulsecore/resampler.h | 3 |
2 files changed, 24 insertions, 0 deletions
diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c index 3e14c0e7..7493eef0 100644 --- a/src/pulsecore/resampler.c +++ b/src/pulsecore/resampler.c @@ -91,6 +91,9 @@ struct pa_resampler { 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 @@ pa_resampler* pa_resampler_new( /* 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 @@ const char *pa_resample_method_to_string(pa_resample_method_t m) { 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; diff --git a/src/pulsecore/resampler.h b/src/pulsecore/resampler.h index 711f9c62..fed4d897 100644 --- a/src/pulsecore/resampler.h +++ b/src/pulsecore/resampler.h @@ -80,4 +80,7 @@ pa_resample_method_t pa_parse_resample_method(const char *string); /* 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 |