summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-12-30 10:31:57 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-12-30 10:31:57 +0100
commit5d4ae976c65b7baef5657def60d2afefcbf45af4 (patch)
treeeb9860b03822b6de1e2cce1c1b18b1645f130045 /src
parentf9601ec858a4a715422e7bc38ea6c3e720e44a7b (diff)
downloadODR-AudioEnc-5d4ae976c65b7baef5657def60d2afefcbf45af4.tar.gz
ODR-AudioEnc-5d4ae976c65b7baef5657def60d2afefcbf45af4.tar.bz2
ODR-AudioEnc-5d4ae976c65b7baef5657def60d2afefcbf45af4.zip
Fix initialisation of VLC arguments
Diffstat (limited to 'src')
-rw-r--r--src/VLCInput.cpp41
1 files changed, 32 insertions, 9 deletions
diff --git a/src/VLCInput.cpp b/src/VLCInput.cpp
index dde9a7b..d6c996a 100644
--- a/src/VLCInput.cpp
+++ b/src/VLCInput.cpp
@@ -151,18 +151,41 @@ int VLCInput::prepare()
prepareRender_address,
(long long int)(intptr_t)this);
- char verb_options[512];
- snprintf(verb_options, sizeof(verb_options),
- "--verbose=%d --network-caching %s --compressor-makeup-gain=%s ",
- m_verbosity,(char *)m_cache.c_str(),(char *)m_gain.c_str());
- const char * const vlc_args[] = {
- verb_options,
- "--sout", smem_options // Stream to memory
- };
+ const char* vlc_args[6];
+ size_t arg_ix = 0;
+ std::stringstream arg_verbose;
+ arg_verbose << "--verbose=" << m_verbosity;
+ vlc_args[arg_ix++] = arg_verbose.str().c_str();
+
+ std::string arg_network_caching;
+ if (not m_cache.empty()) {
+ stringstream ss;
+ ss << "--network-caching=" << m_cache;
+ arg_network_caching = ss.str();
+ vlc_args[arg_ix++] = arg_network_caching.c_str();
+ }
+
+ std::string arg_gain;
+ if (not m_gain.empty()) {
+ stringstream ss;
+ ss << "--compressor-makeup=" << m_gain;
+ arg_gain = ss.str();
+ vlc_args[arg_ix++] = arg_gain.c_str();
+ }
+
+ vlc_args[arg_ix++] = "--sout";
+ vlc_args[arg_ix++] = smem_options; // Stream to memory
+
+ fprintf(stderr, "VLC opt:\n");
+ for (size_t i = 0; i < arg_ix; i++) {
+ fprintf(stderr, " %s\n", vlc_args[i]);
+ }
+
+ fprintf(stderr, "End of VLC opt\n");
// Launch VLC
- m_vlc = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
+ m_vlc = libvlc_new(arg_ix, vlc_args);
libvlc_set_exit_handler(m_vlc, handleVLCExit, this);