aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cubeb_resampler_internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/cubeb_resampler_internal.h')
-rw-r--r--src/cubeb_resampler_internal.h21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/cubeb_resampler_internal.h b/src/cubeb_resampler_internal.h
index c845d91..eed16c4 100644
--- a/src/cubeb_resampler_internal.h
+++ b/src/cubeb_resampler_internal.h
@@ -1,5 +1,5 @@
/*
- * Copyright � 2016 Mozilla Foundation
+ * Copyright © 2016 Mozilla Foundation
*
* This program is made available under an ISC-style license. See the
* accompanying file LICENSE for details.
@@ -32,9 +32,6 @@ namespace std
int to_speex_quality(cubeb_resampler_quality q);
-template<typename T>
-class cubeb_resampler_speex_one_way;
-
struct cubeb_resampler {
virtual long fill(void * input_buffer, long * input_frames_count,
void * output_buffer, long frames_needed) = 0;
@@ -155,10 +152,22 @@ public:
cubeb_resampler_speex_one_way(uint32_t channels,
uint32_t source_rate,
uint32_t target_rate,
- int quality);
+ int quality)
+ : processor(channels)
+ , resampling_ratio(static_cast<float>(source_rate) / target_rate)
+ , additional_latency(0)
+ {
+ int r;
+ speex_resampler = speex_resampler_init(channels, source_rate,
+ target_rate, quality, &r);
+ assert(r == RESAMPLER_ERR_SUCCESS && "resampler allocation failure");
+ }
/** Destructor, deallocate the resampler */
- virtual ~cubeb_resampler_speex_one_way();
+ virtual ~cubeb_resampler_speex_one_way()
+ {
+ speex_resampler_destroy(speex_resampler);
+ }
/** Sometimes, it is necessary to add latency on one way of a two-way
* resampler so that the stream are synchronized. This must be called only on