Fix invalid assertion from previous commit, and possibly fix having random garbage...
[ardour.git] / libs / ardour / export_graph_builder.cc
index ab77252e0513aeaea5defc9adcfdb57da68ca6b6..1cd3118eae85e822fce42a45a6c4876e90aa1bc8 100644 (file)
@@ -20,6 +20,7 @@
 #include "pbd/filesystem.h"
 
 using namespace AudioGrapher;
+using std::string;
 
 namespace ARDOUR {
 
@@ -37,11 +38,13 @@ ExportGraphBuilder::~ExportGraphBuilder ()
 }
 
 int
-ExportGraphBuilder::process (nframes_t /* frames */, bool last_cycle)
+ExportGraphBuilder::process (nframes_t frames, bool last_cycle)
 {
+       assert(frames <= process_buffer_frames);
+       
        for (ChannelMap::iterator it = channels.begin(); it != channels.end(); ++it) {
-               it->first->read (process_buffer, process_buffer_frames);
-               ProcessContext<Sample> context(process_buffer, process_buffer_frames, 1);
+               it->first->read (process_buffer, frames);
+               ProcessContext<Sample> context(process_buffer, frames, 1);
                if (last_cycle) { context.set_flag (ProcessContext<Sample>::EndOfInput); }
                it->second->process (context);
        }
@@ -166,9 +169,9 @@ ExportGraphBuilder::Encoder::init_writer (boost::shared_ptr<AudioGrapher::Sndfil
 {
        unsigned channels = config.channel_config->get_n_chans();
        int format = get_real_format (config);
-       Glib::ustring filename = config.filename->get_path (config.format);
+       string filename = config.filename->get_path (config.format);
        
-       writer.reset (new AudioGrapher::SndfileWriter<T> (filename, format, channels, config.format->sample_rate()));
+       writer.reset (new AudioGrapher::SndfileWriter<T> (filename, format, channels, config.format->sample_rate(), config.broadcast_info));
        writer->FileWritten.connect_same_thread (copy_files_connection, boost::bind (&ExportGraphBuilder::Encoder::copy_files, this, _1));
 }
 
@@ -200,8 +203,9 @@ ExportGraphBuilder::SFC::SFC (ExportGraphBuilder &, FileSpec const & new_config,
                int_converter->init (max_frames, config.format->dither_type(), data_width);
                add_child (config);
        } else {
+               int actual_data_width = 8 * sizeof(Sample);
                float_converter = FloatConverterPtr (new SampleFormatConverter<Sample> (channels));
-               float_converter->init (max_frames, config.format->dither_type(), data_width);
+               float_converter->init (max_frames, config.format->dither_type(), actual_data_width);
                add_child (config);
        }
 }