1 #ifndef fooresamplerhfoo
2 #define fooresamplerhfoo
5 This file is part of PulseAudio.
7 Copyright 2004-2006 Lennart Poettering
9 PulseAudio is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published
11 by the Free Software Foundation; either version 2 of the License,
12 or (at your option) any later version.
14 PulseAudio is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public License
20 along with PulseAudio; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 #include <pulse/sample.h>
26 #include <pulse/channelmap.h>
27 #include <pulsecore/memblock.h>
28 #include <pulsecore/memchunk.h>
30 typedef struct pa_resampler pa_resampler
;
32 typedef enum pa_resample_method
{
33 PA_RESAMPLER_INVALID
= -1,
34 PA_RESAMPLER_SRC_SINC_BEST_QUALITY
= 0, /* = SRC_SINC_BEST_QUALITY */
35 PA_RESAMPLER_SRC_SINC_MEDIUM_QUALITY
= 1, /* = SRC_SINC_MEDIUM_QUALITY */
36 PA_RESAMPLER_SRC_SINC_FASTEST
= 2, /* = SRC_SINC_FASTEST */
37 PA_RESAMPLER_SRC_ZERO_ORDER_HOLD
= 3, /* = SRC_ZERO_ORDER_HOLD */
38 PA_RESAMPLER_SRC_LINEAR
= 4, /* = SRC_LINEAR */
40 PA_RESAMPLER_SPEEX_FLOAT_BASE
,
41 PA_RESAMPLER_SPEEX_FLOAT_MAX
= PA_RESAMPLER_SPEEX_FLOAT_BASE
+ 10,
42 PA_RESAMPLER_SPEEX_FIXED_BASE
,
43 PA_RESAMPLER_SPEEX_FIXED_MAX
= PA_RESAMPLER_SPEEX_FIXED_BASE
+ 10,
45 PA_RESAMPLER_AUTO
, /* automatic select based on sample format */
49 } pa_resample_method_t
;
51 typedef enum pa_resample_flags
{
52 PA_RESAMPLER_VARIABLE_RATE
= 1,
53 PA_RESAMPLER_NO_REMAP
= 2, /* implies NO_REMIX */
54 PA_RESAMPLER_NO_REMIX
= 4
55 } pa_resample_flags_t
;
57 pa_resampler
* pa_resampler_new(
59 const pa_sample_spec
*a
,
60 const pa_channel_map
*am
,
61 const pa_sample_spec
*b
,
62 const pa_channel_map
*bm
,
63 pa_resample_method_t resample_method
,
64 pa_resample_flags_t flags
);
66 void pa_resampler_free(pa_resampler
*r
);
68 /* Returns the size of an input memory block which is required to return the specified amount of output data */
69 size_t pa_resampler_request(pa_resampler
*r
, size_t out_length
);
71 /* Inverse of pa_resampler_request() */
72 size_t pa_resampler_result(pa_resampler
*r
, size_t in_length
);
74 /* Returns the maximum size of input blocks we can process without needing bounce buffers larger than the mempool tile size. */
75 size_t pa_resampler_max_block_size(pa_resampler
*r
);
77 /* Pass the specified memory chunk to the resampler and return the newly resampled data */
78 void pa_resampler_run(pa_resampler
*r
, const pa_memchunk
*in
, pa_memchunk
*out
);
80 /* Change the input rate of the resampler object */
81 void pa_resampler_set_input_rate(pa_resampler
*r
, uint32_t rate
);
83 /* Change the output rate of the resampler object */
84 void pa_resampler_set_output_rate(pa_resampler
*r
, uint32_t rate
);
86 /* Reinitialize state of the resampler, possibly due to seeking or other discontinuities */
87 void pa_resampler_reset(pa_resampler
*r
);
89 /* Return the resampling method of the resampler object */
90 pa_resample_method_t
pa_resampler_get_method(pa_resampler
*r
);
92 /* Try to parse the resampler method */
93 pa_resample_method_t
pa_parse_resample_method(const char *string
);
95 /* return a human readable string for the specified resampling method. Inverse of pa_parse_resample_method() */
96 const char *pa_resample_method_to_string(pa_resample_method_t m
);
98 /* Return 1 when the specified resampling method is supported */
99 int pa_resample_method_supported(pa_resample_method_t m
);