/*1* Copyright © 2014 Mozilla Foundation2*3* This program is made available under an ISC-style license. See the4* accompanying file LICENSE for details.5*/6#ifndef CUBEB_RESAMPLER_H7#define CUBEB_RESAMPLER_H89#include "cubeb/cubeb.h"1011#if defined(__cplusplus)12extern "C" {13#endif1415typedef struct cubeb_resampler cubeb_resampler;1617typedef enum {18CUBEB_RESAMPLER_QUALITY_VOIP,19CUBEB_RESAMPLER_QUALITY_DEFAULT,20CUBEB_RESAMPLER_QUALITY_DESKTOP21} cubeb_resampler_quality;2223typedef enum {24CUBEB_RESAMPLER_RECLOCK_NONE,25CUBEB_RESAMPLER_RECLOCK_INPUT26} cubeb_resampler_reclock;2728/**29* Create a resampler to adapt the requested sample rate into something that30* is accepted by the audio backend.31* @param stream A cubeb_stream instance supplied to the data callback.32* @param input_params Used to calculate bytes per frame and buffer size for33* resampling of the input side of the stream. NULL if input should not be34* resampled.35* @param output_params Used to calculate bytes per frame and buffer size for36* resampling of the output side of the stream. NULL if output should not be37* resampled.38* @param target_rate The sampling rate after resampling for the input side of39* the stream, and/or the sampling rate prior to resampling of the output side40* of the stream.41* @param callback A callback to request data for resampling.42* @param user_ptr User data supplied to the data callback.43* @param quality Quality of the resampler.44* @retval A non-null pointer if success.45*/46cubeb_resampler *47cubeb_resampler_create(cubeb_stream * stream,48cubeb_stream_params * input_params,49cubeb_stream_params * output_params,50unsigned int target_rate, cubeb_data_callback callback,51void * user_ptr, cubeb_resampler_quality quality,52cubeb_resampler_reclock reclock);5354/**55* Fill the buffer with frames acquired using the data callback. Resampling will56* happen if necessary.57* @param resampler A cubeb_resampler instance.58* @param input_buffer A buffer of input samples59* @param input_frame_count The size of the buffer. Returns the number of frames60* consumed.61* @param output_buffer The buffer to be filled.62* @param output_frames_needed Number of frames that should be produced.63* @retval Number of frames that are actually produced.64* @retval CUBEB_ERROR on error.65*/66long67cubeb_resampler_fill(cubeb_resampler * resampler, void * input_buffer,68long * input_frame_count, void * output_buffer,69long output_frames_needed);7071/**72* Destroy a cubeb_resampler.73* @param resampler A cubeb_resampler instance.74*/75void76cubeb_resampler_destroy(cubeb_resampler * resampler);7778/**79* Returns the latency, in frames, of the resampler.80* @param resampler A cubeb resampler instance.81* @retval The latency, in frames, induced by the resampler.82*/83long84cubeb_resampler_latency(cubeb_resampler * resampler);8586#if defined(__cplusplus)87}88#endif8990#endif /* CUBEB_RESAMPLER_H */919293