#include "ardour/export_filename.h"
#include "ardour/export_failed.h"
+#include "i18n.h"
+
using namespace std;
using namespace PBD;
, graph_builder (new ExportGraphBuilder (session))
, export_status (session.get_export_status ())
, realtime (false)
-
+ , normalizing (false)
+ , cue_tracknum (0)
+ , cue_indexnum (0)
{
}
}
bool
-ExportHandler::add_export_config (TimespanPtr timespan, ChannelConfigPtr channel_config, FormatPtr format, FilenamePtr filename)
+ExportHandler::add_export_config (TimespanPtr timespan, ChannelConfigPtr channel_config, FormatPtr format, FilenamePtr filename, boost::shared_ptr<AudioGrapher::BroadcastInfo> broadcast_info)
{
- FileSpec spec (channel_config, format, filename);
+ FileSpec spec (channel_config, format, filename, broadcast_info);
ConfigPair pair (timespan, spec);
config_map.insert (pair);
-
+
return true;
}
/* Start export */
realtime = rt;
-
- session.ExportReadFinished.connect_same_thread (export_read_finished_connection, boost::bind (&ExportHandler::finish_timespan, this));
start_timespan ();
}
export_status->timespan++;
if (config_map.empty()) {
+ // freewheeling has to be stopped from outside the process cycle
export_status->running = false;
return;
}
timespan_bounds = config_map.equal_range (current_timespan);
graph_builder->reset ();
for (ConfigMap::iterator it = timespan_bounds.first; it != timespan_bounds.second; ++it) {
- graph_builder->add_config (it->second);
+ // Filenames can be shared across timespans
+ FileSpec & spec = it->second;
+ spec.filename->set_timespan (it->first);
+ graph_builder->add_config (spec);
}
/* start export */
- session.ProcessExport.connect_same_thread (process_connection, boost::bind (&ExportHandler::process_timespan, this, _1));
+ normalizing = false;
+ session.ProcessExport.connect_same_thread (process_connection, boost::bind (&ExportHandler::process, this, _1));
process_position = current_timespan->get_start();
session.start_audio_export (process_position, realtime);
}
+int
+ExportHandler::process (nframes_t frames)
+{
+ if (!export_status->running) {
+ return 0;
+ } else if (normalizing) {
+ return process_normalize ();
+ } else {
+ return process_timespan (frames);
+ }
+}
+
int
ExportHandler::process_timespan (nframes_t frames)
{
/* update position */
nframes_t frames_to_read = 0;
- sframes_t const start = current_timespan->get_start();
- sframes_t const end = current_timespan->get_end();
+ framepos_t const start = current_timespan->get_start();
+ framepos_t const end = current_timespan->get_end();
bool const last_cycle = (process_position + frames >= end);
if (last_cycle) {
frames_to_read = end - process_position;
export_status->stop = true;
+ normalizing = true;
} else {
frames_to_read = frames;
}
return graph_builder->process (frames_to_read, last_cycle);
}
+int
+ExportHandler::process_normalize ()
+{
+ if (graph_builder->process_normalize ()) {
+ finish_timespan ();
+ }
+
+ return 0;
+}
+
void
ExportHandler::finish_timespan ()
{
- process_connection.disconnect ();
-
while (config_map.begin() != timespan_bounds.second) {
config_map.erase (config_map.begin());
}
Locations::LocationList temp;
for (i = locations.begin(); i != locations.end(); ++i) {
- if ((*i)->start() >= timespan->get_start() && (*i)->end() <= timespan->get_end() && (*i)->is_cd_marker() && !(*i)->is_end()) {
+ if ((*i)->start() >= timespan->get_start() && (*i)->end() <= timespan->get_end() && (*i)->is_cd_marker() && !(*i)->is_session_range()) {
temp.push_back (*i);
}
}
/* Start actual marker stuff */
- sframes_t last_end_time = timespan->get_start(), last_start_time = timespan->get_start();
+ framepos_t last_end_time = timespan->get_start(), last_start_time = timespan->get_start();
status.track_position = last_start_time - timespan->get_start();
for (i = temp.begin(); i != temp.end(); ++i) {
void
ExportHandler::write_cue_header (CDMarkerStatus & status)
{
- Glib::ustring title = status.timespan->name().compare ("Session") ? status.timespan->name() : (Glib::ustring) session.name();
+ string title = status.timespan->name().compare ("Session") ? status.timespan->name() : (string) session.name();
status.out << "REM Cue file generated by Ardour" << endl;
status.out << "TITLE \"" << title << "\"" << endl;
status.out << "FILE \"" << Glib::path_get_basename(status.filename) << "\" ";
if (!status.format->format_name().compare ("WAV")) {
status.out << "WAVE";
- } else if (status.format->format_name() == ExportFormatBase::F_RAW &&
+ } else if (status.format->format_id() == ExportFormatBase::F_RAW &&
status.format->sample_format() == ExportFormatBase::SF_16 &&
status.format->sample_rate() == ExportFormatBase::SR_44_1) {
// Format is RAW 16bit 44.1kHz
void
ExportHandler::write_toc_header (CDMarkerStatus & status)
{
- Glib::ustring title = status.timespan->name().compare ("Session") ? status.timespan->name() : (Glib::ustring) session.name();
+ string title = status.timespan->name().compare ("Session") ? status.timespan->name() : (string) session.name();
status.out << "CD_DA" << endl;
status.out << "CD_TEXT {" << endl << " LANGUAGE_MAP {" << endl << " 0 : EN" << endl << " }" << endl;
}
void
-ExportHandler::frames_to_cd_frames_string (char* buf, sframes_t when)
+ExportHandler::frames_to_cd_frames_string (char* buf, framepos_t when)
{
- sframes_t remainder;
+ framecnt_t remainder;
nframes_t fr = session.nominal_frame_rate();
int mins, secs, frames;