diff options
-rw-r--r-- | plugins/dsp_libsrc/src.c | 27 | ||||
-rw-r--r-- | plugins/dsp_libsrc/src.h | 11 | ||||
-rw-r--r-- | streamer.c | 1 |
3 files changed, 14 insertions, 25 deletions
diff --git a/plugins/dsp_libsrc/src.c b/plugins/dsp_libsrc/src.c index 11f80e5d..77e26ed8 100644 --- a/plugins/dsp_libsrc/src.c +++ b/plugins/dsp_libsrc/src.c @@ -38,12 +38,12 @@ ddb_dsp_src_t plugin; typedef struct { DB_dsp_instance_t inst; + int channels; int quality; SRC_STATE *src; SRC_DATA srcdata; int remaining; // number of input samples in SRC buffer __attribute__((__aligned__(16))) char in_fbuffer[sizeof(float)*SRC_BUFFER*SRC_MAX_CHANNELS]; -// __attribute__((__aligned__(16))) float out_fbuffer[SRC_BUFFER*SRC_MAX_CHANNELS]; uintptr_t mutex; } ddb_src_libsamplerate_t; @@ -55,11 +55,7 @@ DB_dsp_instance_t* ddb_src_open (const char *id) { char var[20]; snprintf (var, sizeof (var), "%s.quality", src->inst.id); src->quality = deadbeef->conf_get_int (var, 2); - src->src = src_new (src->quality, 2, NULL); - if (!src->src) { - plugin.dsp.close ((DB_dsp_instance_t *)src); - return NULL; - } + src->channels = -1; return (DB_dsp_instance_t *)src; } @@ -101,12 +97,8 @@ ddb_src_reset (DB_dsp_instance_t *_src, int full) { ddb_src_lock (_src); trace ("changing src->quality from %d to %d\n", src->quality, q); src->quality = q; - if (src) { - src_delete (src->src); - src->src = NULL; - } memset (&src->srcdata, 0, sizeof (src->srcdata)); - src->src = src_new (src->quality, 2, NULL); + src->channels = -1; ddb_src_unlock (_src); } else { @@ -123,14 +115,23 @@ ddb_src_set_ratio (DB_dsp_instance_t *_src, float ratio) { } int -//ddb_src_process (DB_dsp_instance_t *_src, const char * restrict input, int nframes, char * restrict output, int buffersize, float ratio, int nchannels) { ddb_src_process (DB_dsp_instance_t *_src, float *samples, int nframes, int nchannels) { ddb_src_libsamplerate_t *src = (ddb_src_libsamplerate_t*)_src; + if (src->channels != nchannels) { + if (src->src) { + src_delete (src->src); + src->src = NULL; + } + src->channels = nchannels; + src->src = src_new (src->quality, src->channels, NULL); + } + + int numoutframes = nframes * src->srcdata.src_ratio; float outbuf[numoutframes*nchannels]; int buffersize = sizeof (outbuf); - char *output = outbuf; + char *output = (char *)outbuf; float *input = samples; int inputsize = numoutframes; diff --git a/plugins/dsp_libsrc/src.h b/plugins/dsp_libsrc/src.h index 09f6a27f..8ede3e1c 100644 --- a/plugins/dsp_libsrc/src.h +++ b/plugins/dsp_libsrc/src.h @@ -25,15 +25,4 @@ typedef struct { void (*set_ratio) (DB_dsp_instance_t *inst, float ratio); } ddb_dsp_src_t; -#if 0 -void -ddb_src_reset (ddb_src_t *src, int full); - -void -ddb_src_confchanged (ddb_src_t *src); - -int -ddb_src_process (ddb_src_t *_src, const char * restrict input, int nframes, char * restrict output, int buffersize, float ratio, int nchannels); -#endif - #endif @@ -848,7 +848,6 @@ streamer_thread (void *ctx) { #ifdef __linux__ prctl (PR_SET_NAME, "deadbeef-stream", 0, 0, 0, 0); #endif -// srcplug->reset (src, 0); while (!streaming_terminate) { struct timeval tm1; |