pcm_convert: add method _reset()

Resets the libsamplerate state.  Not being used yet.
This commit is contained in:
Max Kellermann 2012-03-01 00:59:53 +01:00
parent 0742976138
commit 3b565b5f97
6 changed files with 39 additions and 0 deletions

View File

@ -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,

View File

@ -66,6 +66,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.
*

View File

@ -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,

View File

@ -68,6 +68,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.
*

View File

@ -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,

View File

@ -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,