e->write (_opt, (*i)->frame ());
frame_done ((*i)->frame ());
} catch (std::exception& e) {
- stringstream s;
- s << "Local encode failed " << e.what() << ".";
- _log->log (s.str ());
+ _log->log (String::compose ("Local encode failed (%1)", e.what ()));
}
}
+
+ #if HAVE_SWRESAMPLE
+ if (_swr_context) {
+
+ while (1) {
+ uint8_t buffer[256 * _fs->bytes_per_sample() * _fs->audio_channels];
+ uint8_t* out[2] = {
+ buffer,
+ 0
+ };
+
+ int const frames = swr_convert (_swr_context, out, 256, 0, 0);
+
+ if (frames < 0) {
+ throw EncodeError ("could not run sample-rate converter");
+ }
+
+ if (frames == 0) {
+ break;
+ }
+
+ write_audio (buffer, frames * _fs->bytes_per_sample() * _fs->audio_channels);
+ }
+
+ swr_free (&_swr_context);
+ }
+ #endif
close_sound_files ();