Supporters update.
[dcpomatic.git] / src / lib / audio_filter_graph.cc
index fc43b5a344a972a9ef20d69e1257441024616412..4e3052d57c519eccc3f390e01d5f3e4c3ad6da5f 100644 (file)
 
 */
 
-#include "audio_filter_graph.h"
+
 #include "audio_buffers.h"
+#include "audio_filter_graph.h"
 #include "compose.hpp"
+#include "dcpomatic_assert.h"
+#include "exceptions.h"
 extern "C" {
 #include <libavfilter/buffersink.h>
 #include <libavfilter/buffersrc.h>
@@ -31,9 +34,12 @@ extern "C" {
 
 #include "i18n.h"
 
-using std::string;
+
 using std::cout;
+using std::make_shared;
 using std::shared_ptr;
+using std::string;
+
 
 AudioFilterGraph::AudioFilterGraph (int sample_rate, int channels)
        : _sample_rate (sample_rate)
@@ -49,6 +55,9 @@ AudioFilterGraph::AudioFilterGraph (int sample_rate, int channels)
        }
 
        _in_frame = av_frame_alloc ();
+       if (_in_frame == nullptr) {
+               throw std::bad_alloc();
+       }
 }
 
 AudioFilterGraph::~AudioFilterGraph()
@@ -102,7 +111,7 @@ AudioFilterGraph::sink_name () const
 }
 
 void
-AudioFilterGraph::process (shared_ptr<const AudioBuffers> buffers)
+AudioFilterGraph::process (shared_ptr<AudioBuffers> buffers)
 {
        DCPOMATIC_ASSERT (buffers->frames() > 0);
        int const process_channels = av_get_channel_layout_nb_channels (_channel_layout);
@@ -113,7 +122,7 @@ AudioFilterGraph::process (shared_ptr<const AudioBuffers> buffers)
                   the constructor) so we need to create new buffers with some extra
                   silent channels.
                */
-               shared_ptr<AudioBuffers> extended_buffers (new AudioBuffers (process_channels, buffers->frames()));
+               auto extended_buffers = make_shared<AudioBuffers>(process_channels, buffers->frames());
                for (int i = 0; i < buffers->channels(); ++i) {
                        extended_buffers->copy_channel_from (buffers.get(), i, i);
                }