Commit 3b565b5f authored by Max Kellermann's avatar Max Kellermann

pcm_convert: add method _reset()

Resets the libsamplerate state. Not being used yet.
parent 07429761
......@@ -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,
......
......@@ -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
......
......@@ -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,
......
......@@ -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
......
......@@ -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,
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment