aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/pcm_convert.c6
-rw-r--r--src/pcm_convert.h7
-rw-r--r--src/pcm_resample.c10
-rw-r--r--src/pcm_resample.h6
-rw-r--r--src/pcm_resample_internal.h3
-rw-r--r--src/pcm_resample_libsamplerate.c7
6 files changed, 39 insertions, 0 deletions
diff --git a/src/pcm_convert.c b/src/pcm_convert.c
index daf1cd234..a3b3bb446 100644
--- a/src/pcm_convert.c
+++ b/src/pcm_convert.c
@@ -57,6 +57,12 @@ void pcm_convert_deinit(struct pcm_convert_state *state)
pcm_buffer_deinit(&state->byteswap_buffer);
}
+void
+pcm_convert_reset(struct pcm_convert_state *state)
+{
+ pcm_resample_reset(&state->resample);
+}
+
static const void *
pcm_convert_channels(struct pcm_buffer *buffer, enum sample_format format,
uint8_t dest_channels,
diff --git a/src/pcm_convert.h b/src/pcm_convert.h
index 6dbd7541b..41a9f9380 100644
--- a/src/pcm_convert.h
+++ b/src/pcm_convert.h
@@ -67,6 +67,13 @@ void pcm_convert_init(struct pcm_convert_state *state);
void pcm_convert_deinit(struct pcm_convert_state *state);
/**
+ * Reset the pcm_convert_state object. Use this at the boundary
+ * between two distinct songs and each time the format changes.
+ */
+void
+pcm_convert_reset(struct pcm_convert_state *state);
+
+/**
* Converts PCM data between two audio formats.
*
* @param state an initialized pcm_convert_state object
diff --git a/src/pcm_resample.c b/src/pcm_resample.c
index 892d1c633..4bc057a7e 100644
--- a/src/pcm_resample.c
+++ b/src/pcm_resample.c
@@ -76,6 +76,16 @@ void pcm_resample_deinit(struct pcm_resample_state *state)
pcm_resample_fallback_deinit(state);
}
+void
+pcm_resample_reset(struct pcm_resample_state *state)
+{
+#ifdef HAVE_LIBSAMPLERATE
+ pcm_resample_lsr_reset(state);
+#else
+ (void)state;
+#endif
+}
+
const float *
pcm_resample_float(struct pcm_resample_state *state,
unsigned channels,
diff --git a/src/pcm_resample.h b/src/pcm_resample.h
index 24fa1d044..a49a24142 100644
--- a/src/pcm_resample.h
+++ b/src/pcm_resample.h
@@ -69,6 +69,12 @@ void pcm_resample_init(struct pcm_resample_state *state);
void pcm_resample_deinit(struct pcm_resample_state *state);
/**
+ * @see pcm_convert_reset()
+ */
+void
+pcm_resample_reset(struct pcm_resample_state *state);
+
+/**
* Resamples 32 bit float data.
*
* @param state an initialized pcm_resample_state object
diff --git a/src/pcm_resample_internal.h b/src/pcm_resample_internal.h
index 0b0a05006..a0e108d4b 100644
--- a/src/pcm_resample_internal.h
+++ b/src/pcm_resample_internal.h
@@ -41,6 +41,9 @@ pcm_resample_lsr_init(struct pcm_resample_state *state);
void
pcm_resample_lsr_deinit(struct pcm_resample_state *state);
+void
+pcm_resample_lsr_reset(struct pcm_resample_state *state);
+
const float *
pcm_resample_lsr_float(struct pcm_resample_state *state,
unsigned channels,
diff --git a/src/pcm_resample_libsamplerate.c b/src/pcm_resample_libsamplerate.c
index c1b1760a9..f957e5155 100644
--- a/src/pcm_resample_libsamplerate.c
+++ b/src/pcm_resample_libsamplerate.c
@@ -104,6 +104,13 @@ pcm_resample_lsr_deinit(struct pcm_resample_state *state)
pcm_buffer_deinit(&state->buffer);
}
+void
+pcm_resample_lsr_reset(struct pcm_resample_state *state)
+{
+ if (state->state != NULL)
+ src_reset(state->state);
+}
+
static bool
pcm_resample_set(struct pcm_resample_state *state,
unsigned channels, unsigned src_rate, unsigned dest_rate,