Ticket #125: 0001-pulsecore-Make-libsamplerate-optional.patch

File 0001-pulsecore-Make-libsamplerate-optional.patch, 6.2 kB (added by elmarco, 1 year ago)

an attempt, ..

  • a/configure.ac

    old new  
    323323 
    324324PKG_PROG_PKG_CONFIG 
    325325 
    326 #### Sample rate conversion #### 
    327  
    328 PKG_CHECK_MODULES(LIBSAMPLERATE, [ samplerate >= 0.1.0 ]) 
    329 AC_SUBST(LIBSAMPLERATE_CFLAGS) 
    330 AC_SUBST(LIBSAMPLERATE_LIBS) 
    331  
    332326#### Sound file #### 
    333327 
    334328PKG_CHECK_MODULES(LIBSNDFILE, [ sndfile >= 1.0.10 ]) 
     
    346340    LIBS="$LIBS -latomic_ops" 
    347341fi 
    348342 
     343#### Libsample support (optional) #### 
     344 
     345AC_ARG_ENABLE([samplerate],  
     346    AC_HELP_STRING([--disable-samplerate], [Disable optional libsamplerate support]),  
     347        [ 
     348            case "${enableval}" in 
     349                yes) samplerate=yes ;; 
     350                no) samplerate=no ;; 
     351                *) AC_MSG_ERROR(bad value ${enableval} for --disable-samplerate) ;; 
     352            esac 
     353        ], 
     354        [samplerate=auto]) 
     355 
     356if test "x${samplerate}" != xno ; then 
     357    PKG_CHECK_MODULES(LIBSAMPLERATE, [ samplerate >= 0.1.0 ], 
     358        HAVE_LIBSAMPLERATE=1, 
     359        [ 
     360            HAVE_LIBSAMPLERATE=0 
     361            if test "x$samplerate" = xyes ; then 
     362                AC_MSG_ERROR([*** Libsamplerate not found]) 
     363            fi 
     364        ]) 
     365else 
     366    HAVE_LIBSAMPLERATE=0 
     367fi 
     368 
     369AC_SUBST(LIBSAMPLERATE_CFLAGS) 
     370AC_SUBST(LIBSAMPLERATE_LIBS) 
     371AC_SUBST(HAVE_LIBSAMPLERATE) 
     372AM_CONDITIONAL([HAVE_LIBSAMPLERATE], [test "x$HAVE_LIBSAMPLERATE" = x1]) 
     373 
    349374#### OSS support (optional) #### 
    350375 
    351376AC_ARG_ENABLE([oss],  
     
    869894    System Group:           ${PA_SYSTEM_GROUP} 
    870895    Realtime Group:         ${PA_REALTIME_GROUP} 
    871896    Access Group:           ${PA_ACCESS_GROUP} 
    872 " 
     897" | tee configure.summary-$(date +%T-%s) 
  • a/src/pulsecore/core-util.c

    old new  
    7474#include <grp.h> 
    7575#endif 
    7676 
     77#ifdef HAVE_LIBSAMPLERATE 
    7778#include <samplerate.h> 
     79#endif 
    7880 
    7981#include <pulse/xmalloc.h> 
    8082#include <pulse/util.h> 
  • a/src/pulsecore/resampler.c

    old new  
    2727 
    2828#include <string.h> 
    2929 
     30#if HAVE_LIBSAMPLERATE 
    3031#include <samplerate.h> 
     32#endif  
    3133 
    3234#include <liboil/liboilfuncs.h> 
    3335#include <liboil/liboil.h> 
     
    7072        unsigned i_counter; 
    7173    } trivial; 
    7274 
     75#ifdef HAVE_LIBSAMPLERATE 
    7376    struct { /* data specific to libsamplerate */ 
    7477        SRC_STATE *state; 
    7578    } src; 
     79#endif 
    7680 
    7781    struct { /* data specific to speex */ 
    7882        SpeexResamplerState* state; 
     
    8488    } ffmpeg; 
    8589}; 
    8690 
     91#ifdef HAVE_LIBSAMPLERATE 
    8792static int libsamplerate_init(pa_resampler*r); 
     93#define LIBSAMPLERATE_INIT libsamplerate_init 
     94#else 
     95#define LIBSAMPLERATE_INIT NULL 
     96#endif 
     97 
    8898static int trivial_init(pa_resampler*r); 
    8999static int speex_init(pa_resampler*r); 
    90100static int ffmpeg_init(pa_resampler*r); 
     
    92102static void calc_map_table(pa_resampler *r); 
    93103 
    94104static int (* const init_table[])(pa_resampler*r) = { 
    95     [PA_RESAMPLER_SRC_SINC_BEST_QUALITY]   = libsamplerate_init
    96     [PA_RESAMPLER_SRC_SINC_MEDIUM_QUALITY] = libsamplerate_init
    97     [PA_RESAMPLER_SRC_SINC_FASTEST]        = libsamplerate_init
    98     [PA_RESAMPLER_SRC_ZERO_ORDER_HOLD]     = libsamplerate_init
    99     [PA_RESAMPLER_SRC_LINEAR]              = libsamplerate_init
     105    [PA_RESAMPLER_SRC_SINC_BEST_QUALITY]   = LIBSAMPLERATE_INIT
     106    [PA_RESAMPLER_SRC_SINC_MEDIUM_QUALITY] = LIBSAMPLERATE_INIT
     107    [PA_RESAMPLER_SRC_SINC_FASTEST]        = LIBSAMPLERATE_INIT
     108    [PA_RESAMPLER_SRC_ZERO_ORDER_HOLD]     = LIBSAMPLERATE_INIT
     109    [PA_RESAMPLER_SRC_LINEAR]              = LIBSAMPLERATE_INIT
    100110    [PA_RESAMPLER_TRIVIAL]                 = trivial_init, 
    101111    [PA_RESAMPLER_SPEEX_FLOAT_BASE+0]      = speex_init, 
    102112    [PA_RESAMPLER_SPEEX_FLOAT_BASE+1]      = speex_init, 
     
    622632 
    623633/*** libsamplerate based implementation ***/ 
    624634 
     635#ifdef HAVE_LIBSAMPLERATE 
    625636static void libsamplerate_resample(pa_resampler *r, const pa_memchunk *input, unsigned in_n_frames, pa_memchunk *output, unsigned *out_n_frames) { 
    626637    SRC_DATA data; 
    627638     
     
    677688 
    678689    return 0; 
    679690} 
     691#endif 
    680692 
    681693/*** speex based implementation ***/ 
    682694 
  • a/src/pulsecore/resampler.h

    old new  
    2424  USA. 
    2525***/ 
    2626 
    27 #include <samplerate.h> 
    28  
    2927#include <pulse/sample.h> 
    3028#include <pulse/channelmap.h> 
    3129#include <pulsecore/memblock.h> 
     
    3533 
    3634typedef enum pa_resample_method { 
    3735    PA_RESAMPLER_INVALID                 = -1, 
    38     PA_RESAMPLER_SRC_SINC_BEST_QUALITY   = SRC_SINC_BEST_QUALITY, 
    39     PA_RESAMPLER_SRC_SINC_MEDIUM_QUALITY = SRC_SINC_MEDIUM_QUALITY, 
    40     PA_RESAMPLER_SRC_SINC_FASTEST        = SRC_SINC_FASTEST, 
    41     PA_RESAMPLER_SRC_ZERO_ORDER_HOLD     = SRC_ZERO_ORDER_HOLD, 
    42     PA_RESAMPLER_SRC_LINEAR              = SRC_LINEAR, 
     36    PA_RESAMPLER_SRC_SINC_BEST_QUALITY   = 0, /* = SRC_SINC_BEST_QUALITY */ 
     37    PA_RESAMPLER_SRC_SINC_MEDIUM_QUALITY = 1, /* = SRC_SINC_MEDIUM_QUALITY */ 
     38    PA_RESAMPLER_SRC_SINC_FASTEST        = 2, /* = SRC_SINC_FASTEST */ 
     39    PA_RESAMPLER_SRC_ZERO_ORDER_HOLD     = 3, /* = SRC_ZERO_ORDER_HOLD */ 
     40    PA_RESAMPLER_SRC_LINEAR              = 4, /* = SRC_LINEAR */ 
    4341    PA_RESAMPLER_TRIVIAL, 
    4442    PA_RESAMPLER_SPEEX_FLOAT_BASE, 
    4543    PA_RESAMPLER_SPEEX_FLOAT_MAX = PA_RESAMPLER_SPEEX_FLOAT_BASE + 10,