media/libcubeb/src/cubeb_resampler.h
author Nick Alexander <nalexander@mozilla.com>
Mon, 09 Nov 2015 10:18:45 -0800
changeset 307655 4ed20ca285932773e617e1f477119d598118d6bc
parent 189121 68427e971ad648fa3b8df97aae4e764f03d9cb7c
child 320053 bcae2f19634d9b2b9fbd8456e7e90df8e9f513e7
permissions -rw-r--r--
Bug 938994 - Post: Update Gradle configurations. r?sebastian I moved the JAR out of the root directory because I didn't want multiple copies of things in robocop/ appearing in IntelliJ, although this turns out to not be strictly necessary. Keeping it as part of a general push to move things out of the root dumping ground.

/*
 * Copyright © 2014 Mozilla Foundation
 *
 * This program is made available under an ISC-style license.  See the
 * accompanying file LICENSE for details.
 */
#ifndef CUBEB_RESAMPLER_H
#define CUBEB_RESAMPLER_H

#include "cubeb/cubeb.h"

#if defined(__cplusplus)
extern "C" {
#endif

typedef struct cubeb_resampler cubeb_resampler;

typedef enum {
  CUBEB_RESAMPLER_QUALITY_VOIP,
  CUBEB_RESAMPLER_QUALITY_DEFAULT,
  CUBEB_RESAMPLER_QUALITY_DESKTOP
} cubeb_resampler_quality;

/**
 * Create a resampler to adapt the requested sample rate into something that
 * is accepted by the audio backend.
 * @param stream A cubeb_stream instance supplied to the data callback.
 * @param params Used to calculate bytes per frame and buffer size for resampling.
 * @param out_rate The sampling rate after resampling.
 * @param callback A callback to request data for resampling.
 * @param buffer_frame_count Maximum number of frames passed to cubeb_resampler_fill
 *                           as |frames_needed|. This is also used to calculate
 *                           the size of buffer allocated for resampling.
 * @param user_ptr User data supplied to the data callback.
 * @param quality Quality of the resampler.
 * @retval A non-null pointer if success.
 */
cubeb_resampler * cubeb_resampler_create(cubeb_stream * stream,
                                         cubeb_stream_params params,
                                         unsigned int out_rate,
                                         cubeb_data_callback callback,
                                         long buffer_frame_count,
                                         void * user_ptr,
                                         cubeb_resampler_quality quality);

/**
 * Fill the buffer with frames acquired using the data callback. Resampling will
 * happen if necessary.
 * @param resampler A cubeb_resampler instance.
 * @param buffer The buffer to be filled.
 * @param frames_needed Number of frames that should be produced.
 * @retval Number of frames that are actually produced.
 * @retval CUBEB_ERROR on error.
 */
long cubeb_resampler_fill(cubeb_resampler * resampler,
                          void * buffer, long frames_needed);

/**
 * Destroy a cubeb_resampler.
 * @param resampler A cubeb_resampler instance.
 */
void cubeb_resampler_destroy(cubeb_resampler * resampler);

#if defined(__cplusplus)
}
#endif

#endif /* CUBEB_RESAMPLER_H */