-void
-ExportHandler::start_timespan ()
-{
- export_status->timespan++;
-
- if (config_map.empty()) {
- export_status->finish ();
- return;
- }
-
- current_timespan = config_map.begin()->first;
-
- /* Register channel configs with timespan */
-
- timespan_bounds = config_map.equal_range (current_timespan);
-
- for (ConfigMap::iterator it = timespan_bounds.first; it != timespan_bounds.second; ++it) {
- it->second.channel_config->register_with_timespan (current_timespan);
- }
-
- /* connect stuff and start export */
-
- session.ProcessExport.connect_same_thread (current_timespan->process_connection, boost::bind (&ExportTimespan::process, current_timespan, _1));
- session.start_audio_export (current_timespan->get_start(), realtime);
-}
-
-void
-ExportHandler::finish_timespan ()
-{
- current_timespan->process_connection.disconnect ();
-
- /* Register formats and filenames to relevant channel configs */
-
- export_status->total_formats = 0;
- export_status->format = 0;
-
- for (ConfigMap::iterator it = timespan_bounds.first; it != timespan_bounds.second; ++it) {
-
- export_status->total_formats++;
-
- /* Setup filename */
-
- it->second.filename->set_timespan (current_timespan);
- it->second.filename->set_channel_config (it->second.channel_config);
-
- /* Do actual registration */
-
- ChannelConfigPtr chan_config = it->second.channel_config;
- chan_config->register_file_config (it->second.format, it->second.filename);
- }
-
- /* Start writing files by doing a manual call to timespan_thread_finished */
-
- current_map_it = timespan_bounds.first;
- timespan_thread_finished ();
-}
-
-void
-ExportHandler::timespan_thread_finished ()
-{
- channel_config_connection.disconnect();
- export_read_finished_connection.disconnect ();
-
- if (current_map_it != timespan_bounds.second) {
-
- /* Get next configuration as long as no new export process is started */
-
- ChannelConfigPtr cc = current_map_it->second.channel_config;
- while (!cc->write_files(processor)) {
-
- ++current_map_it;
-
- if (current_map_it == timespan_bounds.second) {
-
- /* reached end of bounds, this call will end up in the else block below */
-
- timespan_thread_finished ();
- return;
- }
-
- cc = current_map_it->second.channel_config;
- }
-
- cc->FilesWritten.connect_same_thread (channel_config_connection, boost::bind (&ExportHandler::timespan_thread_finished, this));
- ++current_map_it;
-
- } else { /* All files are written from current timespan, reset timespan and start new */
-
- /* Unregister configs and remove configs with this timespan */
-
- for (ConfigMap::iterator it = timespan_bounds.first; it != timespan_bounds.second;) {
- it->second.channel_config->unregister_all ();
-
- ConfigMap::iterator to_erase = it;
- ++it;
- config_map.erase (to_erase);
- }
-
- /* Start new timespan */
-
- start_timespan ();
-
- }
-}
-