Rename SafeStringStream -> locked_stringstream. Bump deps for removal of stringstream.
[dcpomatic.git] / src / lib / resampler.cc
index 4476d9f1f9b2220cab1160ae876246e301a49661..ff93d1609ae5e68590c3dcb76f8e2a337be216bf 100644 (file)
@@ -24,7 +24,6 @@
 #include "compose.hpp"
 #include "dcpomatic_assert.h"
 #include <samplerate.h>
-#include <boost/make_shared.hpp>
 #include <iostream>
 
 #include "i18n.h"
@@ -34,20 +33,18 @@ using std::pair;
 using std::make_pair;
 using std::runtime_error;
 using boost::shared_ptr;
-using boost::make_shared;
 
 /** @param in Input sampling rate (Hz)
  *  @param out Output sampling rate (Hz)
  *  @param channels Number of channels.
- *  @param fast true to be fast rather than good.
  */
-Resampler::Resampler (int in, int out, int channels, bool fast)
+Resampler::Resampler (int in, int out, int channels)
        : _in_rate (in)
        , _out_rate (out)
        , _channels (channels)
 {
        int error;
-       _src = src_new (fast ? SRC_LINEAR : SRC_SINC_BEST_QUALITY, _channels, &error);
+       _src = src_new (SRC_SINC_BEST_QUALITY, _channels, &error);
        if (!_src) {
                throw runtime_error (String::compose (N_("could not create sample-rate converter (%1)"), error));
        }
@@ -58,13 +55,24 @@ Resampler::~Resampler ()
        src_delete (_src);
 }
 
+void
+Resampler::set_fast ()
+{
+       src_delete (_src);
+       int error;
+       _src = src_new (SRC_LINEAR, _channels, &error);
+       if (!_src) {
+               throw runtime_error (String::compose (N_("could not create sample-rate converter (%1)"), error));
+       }
+}
+
 shared_ptr<const AudioBuffers>
 Resampler::run (shared_ptr<const AudioBuffers> in)
 {
        int in_frames = in->frames ();
        int in_offset = 0;
        int out_offset = 0;
-       shared_ptr<AudioBuffers> resampled = make_shared<AudioBuffers> (_channels, 0);
+       shared_ptr<AudioBuffers> resampled (new AudioBuffers (_channels, 0));
 
        while (in_frames > 0) {
 
@@ -138,7 +146,7 @@ Resampler::run (shared_ptr<const AudioBuffers> in)
 shared_ptr<const AudioBuffers>
 Resampler::flush ()
 {
-       shared_ptr<AudioBuffers> out = make_shared<AudioBuffers> (_channels, 0);
+       shared_ptr<AudioBuffers> out (new AudioBuffers (_channels, 0));
        int out_offset = 0;
        int64_t const output_size = 65536;