Another macOS std::list boost::thread SNAFU.
[dcpomatic.git] / src / lib / audio_filter_graph.cc
index a43f1881ea515755ed34176bc43784d82807867e..0eeeb3c4ae5858b094ffd4f5da58ab659f9d3b75 100644 (file)
@@ -1,19 +1,20 @@
 /*
     Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
 
-    This program is free software; you can redistribute it and/or modify
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
-    This program is distributed in the hope that it will be useful,
+    DCP-o-matic is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 
@@ -23,7 +24,9 @@
 extern "C" {
 #include <libavfilter/buffersink.h>
 #include <libavfilter/buffersrc.h>
+#include <libavutil/channel_layout.h>
 }
+#include <iostream>
 
 #include "i18n.h"
 
@@ -55,16 +58,16 @@ AudioFilterGraph::~AudioFilterGraph()
 string
 AudioFilterGraph::src_parameters () const
 {
-       SafeStringStream a;
-
-       char buffer[64];
-       av_get_channel_layout_string (buffer, sizeof(buffer), 0, _channel_layout);
+       char layout[64];
+       av_get_channel_layout_string (layout, sizeof(layout), 0, _channel_layout);
 
-       a << "time_base=1/1:sample_rate=" << _sample_rate << ":"
-         << "sample_fmt=" << av_get_sample_fmt_name(AV_SAMPLE_FMT_FLTP) << ":"
-         << "channel_layout=" << buffer;
+       char buffer[256];
+       snprintf (
+               buffer, sizeof(buffer), "time_base=1/1:sample_rate=%d:sample_fmt=%s:channel_layout=%s",
+               _sample_rate, av_get_sample_fmt_name(AV_SAMPLE_FMT_FLTP), layout
+               );
 
-       return a.str ();
+       return buffer;
 }
 
 void *
@@ -104,6 +107,7 @@ AudioFilterGraph::sink_name () const
 void
 AudioFilterGraph::process (shared_ptr<const AudioBuffers> buffers)
 {
+       DCPOMATIC_ASSERT (buffers->frames() > 0);
        int const process_channels = av_get_channel_layout_nb_channels (_channel_layout);
        DCPOMATIC_ASSERT (process_channels >= buffers->channels());
 
@@ -148,7 +152,7 @@ AudioFilterGraph::process (shared_ptr<const AudioBuffers> buffers)
        if (r < 0) {
                char buffer[256];
                av_strerror (r, buffer, sizeof(buffer));
-               throw DecodeError (String::compose (N_("could not push buffer into filter chain (%1)"), buffer));
+               throw DecodeError (String::compose (N_("could not push buffer into filter chain (%1)"), &buffer[0]));
        }
 
        while (true) {