356{
357 enum { RESAMPLER_DEFAULT, RESAMPLER_SPEEX, RESAMPLER_SOXR } resampler_type = RESAMPLER_DEFAULT;
359 std::string_view sv = cfg_c ? cfg_c : "";
361 while (!sv.empty()) {
362 const auto &tok =
tokenize(sv,
':');
363 if (tok == "speex") {
364 resampler_type = RESAMPLER_SPEEX;
365 } else if (tok == "soxr") {
366 resampler_type = RESAMPLER_SOXR;
367 } else if (tok.compare(0, "quality="sv.length(), "quality=") == 0) {
368 quality = stoi(string(tok.substr("quality="sv.length())));
369 if (quality < 0 || quality > 10) {
370 throw ug_runtime_error(
"Quality " + to_string(quality) +
" out of range 0-10"s);
371 }
372 } else {
374 }
375 }
376 switch (resampler_type) {
377 case RESAMPLER_DEFAULT:
378#ifdef HAVE_SPEEXDSP
379 m_impl = unique_ptr<audio_frame2_resampler::impl>(
new speex_resampler(quality));
380#elif defined HAVE_SOXR
381 m_impl = unique_ptr<audio_frame2_resampler::impl>(
new soxr_resampler());
382#endif
383 break;
384 case RESAMPLER_SPEEX:
385#ifdef HAVE_SPEEXDSP
386 m_impl = unique_ptr<audio_frame2_resampler::impl>(
new speex_resampler(quality));
387#else
389#endif
390 break;
391 case RESAMPLER_SOXR:
392#if defined HAVE_SOXR
393 m_impl = unique_ptr<audio_frame2_resampler::impl>(
new soxr_resampler());
394 break;
395#else
397#endif
398 }
399}
std::unique_ptr< impl > m_impl
const char * get_commandline_param(const char *key)
#define DEFAULT_SPEEX_RESAMPLE_QUALITY
std::string_view tokenize(std::string_view &str, char delim, char quot)
Tokenizer for string_view.