Typedef all globally used export smart pointer types in one file.

Some of them need to be ordered in STL containers, and thus need
a special comparable wrapper for boost::shared_ptr, defined in
comparable_shared_ptr.h. This also alleviates the typedef hell
present earlier in some export classes :)

Making the timespan pointer comparable should fix bug #4093


git-svn-id: svn://localhost/ardour2/branches/3.0@9702 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Sakari Bergen 2011-06-11 14:14:24 +00:00
parent 47e2b9db77
commit 7468fdb9ca
21 changed files with 299 additions and 201 deletions

View File

@ -493,7 +493,7 @@ ExportFormatDialog::update_compatibility_selection (std::string const & path)
{
Gtk::TreeModel::iterator iter = compatibility_view.get_model ()->get_iter (path);
ExportFormatManager::CompatPtr ptr = iter->get_value (compatibility_cols.ptr);
ExportFormatCompatibilityPtr ptr = iter->get_value (compatibility_cols.ptr);
bool state = iter->get_value (compatibility_cols.selected);
iter->set_value (compatibility_cols.selected, state);
@ -553,7 +553,7 @@ ExportFormatDialog::change_compatibility_selection (bool select, WeakCompatPtr c
{
++applying_changes_from_engine;
ExportFormatManager::CompatPtr ptr = compat.lock();
ExportFormatCompatibilityPtr ptr = compat.lock();
for (Gtk::ListStore::Children::iterator it = compatibility_list->children().begin(); it != compatibility_list->children().end(); ++it) {
if (it->get_value (compatibility_cols.ptr) == ptr) {
@ -576,7 +576,7 @@ ExportFormatDialog::change_format_selection (bool select, WeakFormatPtr format)
{
change_selection<ExportFormat, FormatCols> (select, format, format_list, format_view, format_cols);
ExportFormatManager::FormatPtr ptr = format.lock();
ExportFormatPtr ptr = format.lock();
if (select && ptr) {
change_encoding_options (ptr);
@ -798,7 +798,7 @@ ExportFormatDialog::update_tagging_selection ()
}
void
ExportFormatDialog::change_encoding_options (ExportFormatManager::FormatPtr ptr)
ExportFormatDialog::change_encoding_options (ExportFormatPtr ptr)
{
empty_encoding_option_table ();

View File

@ -37,9 +37,9 @@
class ExportFormatDialog : public ArdourDialog, public PBD::ScopedConnectionList {
private:
typedef ARDOUR::ExportFormatManager::WeakCompatPtr WeakCompatPtr;
typedef ARDOUR::WeakExportFormatCompatibilityPtr WeakCompatPtr;
typedef ARDOUR::WeakExportFormatPtr WeakFormatPtr;
typedef ARDOUR::ExportFormatManager::WeakQualityPtr WeakQualityPtr;
typedef ARDOUR::ExportFormatManager::WeakFormatPtr WeakFormatPtr;
typedef ARDOUR::ExportFormatManager::WeakSampleRatePtr WeakSampleRatePtr;
typedef ARDOUR::ExportFormatManager::WeakSampleFormatPtr WeakSampleFormatPtr;
typedef ARDOUR::ExportFormatManager::WeakDitherTypePtr WeakDitherTypePtr;
@ -131,7 +131,7 @@ class ExportFormatDialog : public ArdourDialog, public PBD::ScopedConnectionList
/*** Encoding options */
void change_encoding_options (ARDOUR::ExportFormatManager::FormatPtr ptr);
void change_encoding_options (ARDOUR::ExportFormatPtr ptr);
void empty_encoding_option_table ();
void remove_widget (Gtk::Widget & to_remove, Gtk::Container * remove_from);
@ -177,8 +177,8 @@ class ExportFormatDialog : public ArdourDialog, public PBD::ScopedConnectionList
struct CompatibilityCols : public Gtk::TreeModelColumnRecord
{
public:
Gtk::TreeModelColumn<ARDOUR::ExportFormatManager::CompatPtr> ptr;
Gtk::TreeModelColumn<bool> selected;
Gtk::TreeModelColumn<ARDOUR::ExportFormatCompatibilityPtr> ptr;
Gtk::TreeModelColumn<bool> selected;
Gtk::TreeModelColumn<std::string> label;
CompatibilityCols () { add(ptr); add(selected); add(label); }
@ -205,9 +205,9 @@ class ExportFormatDialog : public ArdourDialog, public PBD::ScopedConnectionList
struct FormatCols : public Gtk::TreeModelColumnRecord
{
public:
Gtk::TreeModelColumn<ARDOUR::ExportFormatManager::FormatPtr> ptr;
Gtk::TreeModelColumn<std::string> color;
Gtk::TreeModelColumn<std::string> label;
Gtk::TreeModelColumn<ARDOUR::ExportFormatPtr> ptr;
Gtk::TreeModelColumn<std::string> color;
Gtk::TreeModelColumn<std::string> label;
FormatCols () { add(ptr); add(color); add(label); }
};

View File

@ -40,7 +40,7 @@ class ExportPresetSelector : public Gtk::HBox
private:
typedef boost::shared_ptr<ARDOUR::ExportProfileManager> ManagerPtr;
typedef ARDOUR::ExportProfileManager::PresetPtr PresetPtr;
typedef ARDOUR::ExportPresetPtr PresetPtr;
typedef ARDOUR::ExportProfileManager::PresetList PresetList;
ManagerPtr profile_manager;

View File

@ -102,7 +102,7 @@ ExportTimespanSelector::~ExportTimespanSelector ()
void
ExportTimespanSelector::add_range_to_selection (ARDOUR::Location const * loc)
{
TimespanPtr span = _session->get_export_handler()->add_timespan();
ExportTimespanPtr span = _session->get_export_handler()->add_timespan();
std::string id;
if (loc == state->session_range.get()) {

View File

@ -49,8 +49,7 @@ class ExportTimespanSelector : public Gtk::VBox, public ARDOUR::SessionHandlePtr
typedef boost::shared_ptr<ARDOUR::ExportHandler> HandlerPtr;
typedef boost::shared_ptr<ARDOUR::ExportProfileManager> ProfileManagerPtr;
typedef boost::shared_ptr<ARDOUR::ExportTimespan> TimespanPtr;
typedef std::list<TimespanPtr> TimespanList;
typedef std::list<ARDOUR::ExportTimespanPtr> TimespanList;
typedef boost::shared_ptr<TimespanList> TimespanListPtr;
typedef ARDOUR::ExportProfileManager::TimespanStatePtr TimespanStatePtr;

View File

@ -0,0 +1,56 @@
/*
Copyright (C) 2011 Paul Davis
Author: Sakari Bergen
This program 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,
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.
*/
#ifndef __ardour_comparable_shared_ptr_h__
#define __ardour_comparable_shared_ptr_h__
namespace ARDOUR {
template<typename T>
class ComparableSharedPtr : public boost::shared_ptr<T>
, public boost::less_than_comparable<ComparableSharedPtr<T> >
{
public:
ComparableSharedPtr () {}
template<class Y>
explicit ComparableSharedPtr (Y * p) : boost::shared_ptr<T> (p) {}
template<class Y, class D>
ComparableSharedPtr (Y * p, D d) : boost::shared_ptr<T> (p, d) {}
template<class Y, class D, class A>
ComparableSharedPtr (Y * p, D d, A a) : boost::shared_ptr<T> (p, d, a) {}
ComparableSharedPtr (ComparableSharedPtr const & r) : boost::shared_ptr<T> (r) {}
template<class Y>
ComparableSharedPtr(ComparableSharedPtr<Y> const & r) : boost::shared_ptr<T> (r) {}
template<class Y>
ComparableSharedPtr(ComparableSharedPtr<Y> const & r, T * p) : boost::shared_ptr<T> (r, p) {}
template<class Y>
bool operator< (ComparableSharedPtr<Y> const & other) const { return **this < *other; }
};
} // namespace ARDOUR
#endif // __ardour_comparable_shared_ptr_h__

View File

@ -26,11 +26,11 @@
#include <boost/signals2.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/scoped_array.hpp>
#include <boost/operators.hpp>
#include "pbd/signals.h"
#include "ardour/buffer_set.h"
#include "ardour/export_pointers.h"
namespace ARDOUR {
@ -62,17 +62,6 @@ class ExportChannel : public boost::less_than_comparable<ExportChannel>
virtual bool operator< (ExportChannel const & other) const = 0;
};
/// Safe pointer for storing ExportChannels in ordered STL containers
class ExportChannelPtr : public boost::shared_ptr<ExportChannel>
, public boost::less_than_comparable<ExportChannel>
{
public:
ExportChannelPtr () {}
template<typename Y> explicit ExportChannelPtr (Y * ptr) : boost::shared_ptr<ExportChannel> (ptr) {}
bool operator< (ExportChannelPtr const & other) const { return **this < *other; }
};
/// Basic export channel that reads from AudioPorts
class PortExportChannel : public ExportChannel
{
@ -99,6 +88,7 @@ class PortExportChannel : public ExportChannel
framecnt_t buffer_size;
};
/// Handles RegionExportChannels and does actual reading from region
class RegionExportChannelFactory
{

View File

@ -22,24 +22,19 @@
#define __ardour_export_filename_h__
#include <boost/shared_ptr.hpp>
#include <string>
#include <ardour/export_pointers.h>
#include "pbd/statefuldestructible.h"
namespace ARDOUR
{
class Session;
class ExportTimespan;
class ExportChannelConfiguration;
class ExportFormatSpecification;
class ExportFilename {
private:
typedef boost::shared_ptr<ExportTimespan> TimespanPtr;
typedef boost::shared_ptr<ExportChannelConfiguration> ChannelConfigPtr;
typedef boost::shared_ptr<ExportFormatSpecification const> FormatPtr;
public:
enum DateFormat {
@ -68,7 +63,7 @@ class ExportFilename {
/* data access */
std::string get_path (FormatPtr format) const;
std::string get_path (ExportFormatSpecPtr format) const;
std::string get_folder () const { return folder; }
TimeFormat get_time_format () const { return time_format; }
@ -88,8 +83,8 @@ class ExportFilename {
void set_channel (uint32_t value) { channel = value; }
bool set_folder (std::string path);
void set_timespan (TimespanPtr ts) { timespan = ts; }
void set_channel_config (ChannelConfigPtr cc) { channel_config = cc; }
void set_timespan (ExportTimespanPtr ts) { timespan = ts; }
void set_channel_config (ExportChannelConfigPtr cc) { channel_config = cc; }
/* public members */
@ -119,8 +114,8 @@ class ExportFilename {
// Due to the static allocation used in strftime(), no destructor or copy-ctor is needed for this
struct tm * time_struct;
TimespanPtr timespan;
ChannelConfigPtr channel_config;
ExportTimespanPtr timespan;
ExportChannelConfigPtr channel_config;
/* Serialization helpers */

View File

@ -25,11 +25,11 @@
#include <string>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include "pbd/signals.h"
#include "ardour/export_formats.h"
#include "ardour/export_pointers.h"
namespace ARDOUR
{
@ -43,13 +43,8 @@ class ExportFormatManager : public PBD::ScopedConnectionList
{
public:
typedef boost::shared_ptr<ExportFormatCompatibility> CompatPtr;
typedef boost::weak_ptr<ExportFormatCompatibility> WeakCompatPtr;
typedef std::list<CompatPtr> CompatList;
typedef boost::shared_ptr<ExportFormat> FormatPtr;
typedef boost::weak_ptr<ExportFormat> WeakFormatPtr;
typedef std::list<FormatPtr> FormatList;
typedef std::list<ExportFormatCompatibilityPtr> CompatList;
typedef std::list<ExportFormatPtr> FormatList;
typedef HasSampleFormat::SampleFormatPtr SampleFormatPtr;
typedef HasSampleFormat::SampleFormatList SampleFormatList;
@ -58,9 +53,6 @@ class ExportFormatManager : public PBD::ScopedConnectionList
typedef HasSampleFormat::DitherTypePtr DitherTypePtr;
typedef HasSampleFormat::WeakDitherTypePtr WeakDitherTypePtr;
typedef boost::shared_ptr<ExportFormatSpecification> SpecPtr;
typedef boost::shared_ptr<ExportFormatBase> FormatBasePtr;
/* Quality states */
class QualityState : public ExportFormatBase::SelectableCompatible {
@ -87,7 +79,7 @@ class ExportFormatManager : public PBD::ScopedConnectionList
public:
explicit ExportFormatManager (SpecPtr specification);
explicit ExportFormatManager (ExportFormatSpecPtr specification);
~ExportFormatManager ();
/* Signals */
@ -121,16 +113,16 @@ class ExportFormatManager : public PBD::ScopedConnectionList
void init_formats ();
void init_sample_rates ();
void add_compatibility (CompatPtr ptr);
void add_compatibility (ExportFormatCompatibilityPtr ptr);
void add_quality (QualityPtr ptr);
void add_format (FormatPtr ptr);
void add_format (ExportFormatPtr ptr);
void add_sample_rate (SampleRatePtr ptr);
/* Connected to signals */
void change_compatibility_selection (bool select, WeakCompatPtr const & compat);
void change_compatibility_selection (bool select, WeakExportFormatCompatibilityPtr const & compat);
void change_quality_selection (bool select, WeakQualityPtr const & quality);
void change_format_selection (bool select, WeakFormatPtr const & format);
void change_format_selection (bool select, WeakExportFormatPtr const & format);
void change_sample_rate_selection (bool select, WeakSampleRatePtr const & rate);
void change_sample_format_selection (bool select, WeakSampleFormatPtr const & format);
@ -138,9 +130,9 @@ class ExportFormatManager : public PBD::ScopedConnectionList
/* Do actual selection */
void select_compatibility (WeakCompatPtr const & compat);
void select_compatibility (WeakExportFormatCompatibilityPtr const & compat);
void select_quality (QualityPtr const & quality);
void select_format (FormatPtr const & format);
void select_format (ExportFormatPtr const & format);
void select_sample_rate (SampleRatePtr const & rate);
void select_sample_format (SampleFormatPtr const & format);
@ -152,15 +144,15 @@ class ExportFormatManager : public PBD::ScopedConnectionList
/* Formats and compatibilities */
QualityPtr get_selected_quality ();
FormatPtr get_selected_format ();
ExportFormatPtr get_selected_format ();
SampleRatePtr get_selected_sample_rate ();
SampleFormatPtr get_selected_sample_format ();
FormatBasePtr get_compatibility_intersection ();
ExportFormatBasePtr get_compatibility_intersection ();
FormatBasePtr universal_set;
SpecPtr current_selection;
ExportFormatBasePtr universal_set;
ExportFormatSpecPtr current_selection;
CompatList compatibilities;
QualityList qualities;

View File

@ -51,7 +51,6 @@ class ExportGraphBuilder
{
private:
typedef ExportHandler::FileSpec FileSpec;
typedef ExportElementFactory::FilenamePtr FilenamePtr;
typedef boost::shared_ptr<AudioGrapher::Sink<Sample> > FloatSinkPtr;
typedef boost::shared_ptr<AudioGrapher::IdentityVertex<Sample> > IdentityVertexPtr;
@ -90,7 +89,7 @@ class ExportGraphBuilder
void copy_files (std::string orig_path);
FileSpec config;
std::list<FilenamePtr> filenames;
std::list<ExportFilenamePtr> filenames;
PBD::ScopedConnection copy_files_connection;
// Only one of these should be available at a time

View File

@ -25,9 +25,11 @@
#include <list>
#include <fstream>
#include <boost/operators.hpp>
#include <boost/shared_ptr.hpp>
#include "ardour/ardour.h"
#include "ardour/export_pointers.h"
#include "ardour/session.h"
#include "ardour/types.h"
@ -47,27 +49,21 @@ class ExportGraphBuilder;
class ExportElementFactory
{
public:
typedef boost::shared_ptr<ExportTimespan> TimespanPtr;
typedef boost::shared_ptr<ExportChannelConfiguration> ChannelConfigPtr;
typedef boost::shared_ptr<ExportFormatSpecification> FormatPtr;
typedef boost::shared_ptr<ExportFilename> FilenamePtr;
public:
ExportElementFactory (Session & session);
~ExportElementFactory ();
TimespanPtr add_timespan ();
ExportTimespanPtr add_timespan ();
ChannelConfigPtr add_channel_config ();
ExportChannelConfigPtr add_channel_config ();
FormatPtr add_format ();
FormatPtr add_format (XMLNode const & state);
FormatPtr add_format_copy (FormatPtr other);
ExportFormatSpecPtr add_format ();
ExportFormatSpecPtr add_format (XMLNode const & state);
ExportFormatSpecPtr add_format_copy (ExportFormatSpecPtr other);
FilenamePtr add_filename ();
FilenamePtr add_filename_copy (FilenamePtr other);
ExportFilenamePtr add_filename ();
ExportFilenamePtr add_filename_copy (ExportFilenamePtr other);
private:
Session & session;
@ -78,17 +74,18 @@ class ExportHandler : public ExportElementFactory
public:
struct FileSpec {
FileSpec() {}
FileSpec (ChannelConfigPtr channel_config, FormatPtr format, FilenamePtr filename, boost::shared_ptr<AudioGrapher::BroadcastInfo> broadcast_info)
FileSpec (ExportChannelConfigPtr channel_config, ExportFormatSpecPtr format,
ExportFilenamePtr filename, BroadcastInfoPtr broadcast_info)
: channel_config (channel_config)
, format (format)
, filename (filename)
, broadcast_info (broadcast_info)
{}
ChannelConfigPtr channel_config;
FormatPtr format;
FilenamePtr filename;
boost::shared_ptr<AudioGrapher::BroadcastInfo> broadcast_info;
ExportChannelConfigPtr channel_config;
ExportFormatSpecPtr format;
ExportFilenamePtr filename;
BroadcastInfoPtr broadcast_info;
};
private:
@ -97,11 +94,10 @@ class ExportHandler : public ExportElementFactory
* The multimap maps timespans to file specifications
*/
typedef std::pair<TimespanPtr, FileSpec> ConfigPair;
typedef std::multimap<TimespanPtr, FileSpec> ConfigMap;
typedef std::pair<ExportTimespanPtr, FileSpec> ConfigPair;
typedef std::multimap<ExportTimespanPtr, FileSpec> ConfigMap;
typedef boost::shared_ptr<ExportGraphBuilder> GraphBuilderPtr;
typedef boost::shared_ptr<ExportStatus> StatusPtr;
private:
/* Session::get_export_handler() should be used to obtain an export handler
@ -114,7 +110,9 @@ class ExportHandler : public ExportElementFactory
public:
~ExportHandler ();
bool add_export_config (TimespanPtr timespan, ChannelConfigPtr channel_config, FormatPtr format, FilenamePtr filename, boost::shared_ptr<AudioGrapher::BroadcastInfo> broadcast_info);
bool add_export_config (ExportTimespanPtr timespan, ExportChannelConfigPtr channel_config,
ExportFormatSpecPtr format, ExportFilenamePtr filename,
BroadcastInfoPtr broadcast_info);
void do_export (bool rt = false);
private:
@ -123,7 +121,7 @@ class ExportHandler : public ExportElementFactory
Session & session;
GraphBuilderPtr graph_builder;
StatusPtr export_status;
ExportStatusPtr export_status;
ConfigMap config_map;
bool realtime;
@ -137,7 +135,7 @@ class ExportHandler : public ExportElementFactory
void finish_timespan ();
typedef std::pair<ConfigMap::iterator, ConfigMap::iterator> TimespanBounds;
TimespanPtr current_timespan;
ExportTimespanPtr current_timespan;
TimespanBounds timespan_bounds;
PBD::ScopedConnection process_connection;
@ -146,21 +144,22 @@ class ExportHandler : public ExportElementFactory
/* CD Marker stuff */
struct CDMarkerStatus {
CDMarkerStatus (std::string out_file, TimespanPtr timespan, FormatPtr format, std::string filename) :
out (out_file.c_str()), timespan (timespan), format (format), filename (filename), marker(0),
track_number (1), track_position (0), track_duration (0), track_start_frame (0),
index_number (1), index_position (0)
CDMarkerStatus (std::string out_file, ExportTimespanPtr timespan,
ExportFormatSpecPtr format, std::string filename)
: out (out_file.c_str()), timespan (timespan), format (format), filename (filename), marker(0)
, track_number (1), track_position (0), track_duration (0), track_start_frame (0)
, index_number (1), index_position (0)
{}
/* General info */
std::ofstream out;
TimespanPtr timespan;
FormatPtr format;
std::string filename;
Location * marker;
ExportTimespanPtr timespan;
ExportFormatSpecPtr format;
std::string filename;
Location * marker;
/* Track info */
uint32_t track_number;
uint32_t track_number;
framepos_t track_position;
framepos_t track_duration;
framepos_t track_start_frame;
@ -171,7 +170,8 @@ class ExportHandler : public ExportElementFactory
};
void export_cd_marker_file (TimespanPtr timespan, FormatPtr file_format, std::string filename, CDMarkerFormat format);
void export_cd_marker_file (ExportTimespanPtr timespan, ExportFormatSpecPtr file_format,
std::string filename, CDMarkerFormat format);
void write_cue_header (CDMarkerStatus & status);
void write_toc_header (CDMarkerStatus & status);

View File

@ -0,0 +1,66 @@
/*
Copyright (C) 2011 Paul Davis
Author: Sakari Bergen
This program 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,
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.
*/
#ifndef __ardour_export_pointers_h__
#define __ardour_export_pointers_h__
#include <boost/operators.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include "ardour/comparable_shared_ptr.h"
namespace AudioGrapher {
class BroadcastInfo;
}
namespace ARDOUR {
class ExportTimespan;
class ExportChannel;
class ExportChannelConfiguration;
class ExportFormat;
class ExportFormatBase;
class ExportFormatSpecification;
class ExportFormatCompatibility;
class ExportFilename;
class ExportStatus;
class ExportPreset;
typedef ComparableSharedPtr<ExportChannel> ExportChannelPtr;
typedef ComparableSharedPtr<ExportTimespan> ExportTimespanPtr;
typedef boost::shared_ptr<ExportChannelConfiguration> ExportChannelConfigPtr;
typedef boost::shared_ptr<ExportFormatBase> ExportFormatBasePtr;
typedef boost::shared_ptr<ExportFormat> ExportFormatPtr;
typedef boost::shared_ptr<ExportFormatSpecification> ExportFormatSpecPtr;
typedef boost::shared_ptr<ExportFormatCompatibility> ExportFormatCompatibilityPtr;
typedef boost::shared_ptr<ExportFilename> ExportFilenamePtr;
typedef boost::shared_ptr<ExportStatus> ExportStatusPtr;
typedef boost::shared_ptr<ExportPreset> ExportPresetPtr;
typedef boost::weak_ptr<ExportFormatCompatibility> WeakExportFormatCompatibilityPtr;
typedef boost::weak_ptr<ExportFormat> WeakExportFormatPtr;
typedef boost::shared_ptr<AudioGrapher::BroadcastInfo> BroadcastInfoPtr;
} // namespace ARDOUR
#endif // __ardour_export_pointers_h__

View File

@ -28,7 +28,6 @@
#include <string>
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include "pbd/uuid.h"
#include "pbd/file_utils.h"
@ -37,16 +36,12 @@
#include "ardour/filesystem_paths.h"
#include "ardour/location.h"
#include "ardour/types.h"
#include "ardour/export_handler.h"
namespace ARDOUR
{
class ExportHandler;
class ExportTimespan;
class ExportChannelConfiguration;
class ExportFormatSpecification;
class ExportFilename;
class ExportPreset;
class Location;
class Session;
@ -61,13 +56,12 @@ class ExportProfileManager
void load_profile ();
void prepare_for_export ();
typedef boost::shared_ptr<ExportPreset> PresetPtr;
typedef std::list<PresetPtr> PresetList;
typedef std::list<ExportPresetPtr> PresetList;
PresetList const & get_presets () { return preset_list; }
bool load_preset (PresetPtr preset);
PresetPtr new_preset (std::string const & name);
PresetPtr save_preset (std::string const & name);
bool load_preset (ExportPresetPtr preset);
ExportPresetPtr new_preset (std::string const & name);
ExportPresetPtr save_preset (std::string const & name);
void remove_preset ();
private:
@ -92,9 +86,9 @@ class ExportProfileManager
void serialize_global_profile (XMLNode & root);
void serialize_local_profile (XMLNode & root);
PresetList preset_list;
PresetPtr current_preset;
FileMap preset_file_map;
PresetList preset_list;
ExportPresetPtr current_preset;
FileMap preset_file_map;
std::vector<PBD::sys::path> find_file (std::string const & pattern);
@ -104,8 +98,7 @@ class ExportProfileManager
/* Timespans */
public:
typedef boost::shared_ptr<ExportTimespan> TimespanPtr;
typedef std::list<TimespanPtr> TimespanList;
typedef std::list<ExportTimespanPtr> TimespanList;
typedef boost::shared_ptr<TimespanList> TimespanListPtr;
typedef std::list<Location *> LocationList;
@ -165,12 +158,10 @@ class ExportProfileManager
/* Channel Configs */
public:
typedef boost::shared_ptr<ExportChannelConfiguration> ChannelConfigPtr;
struct ChannelConfigState {
ChannelConfigPtr config;
ExportChannelConfigPtr config;
ChannelConfigState (ChannelConfigPtr ptr) : config (ptr) {}
ChannelConfigState (ExportChannelConfigPtr ptr) : config (ptr) {}
};
typedef boost::shared_ptr<ChannelConfigState> ChannelConfigStatePtr;
typedef std::list<ChannelConfigStatePtr> ChannelConfigStateList;
@ -188,14 +179,13 @@ class ExportProfileManager
/* Formats */
public:
typedef boost::shared_ptr<ExportFormatSpecification> FormatPtr;
typedef std::list<FormatPtr> FormatList;
typedef std::list<ExportFormatSpecPtr> FormatList;
struct FormatState {
boost::shared_ptr<FormatList const> list;
FormatPtr format;
ExportFormatSpecPtr format;
FormatState (boost::shared_ptr<FormatList const> list, FormatPtr format) :
FormatState (boost::shared_ptr<FormatList const> list, ExportFormatSpecPtr format) :
list (list), format (format) {}
};
typedef boost::shared_ptr<FormatState> FormatStatePtr;
@ -205,9 +195,9 @@ class ExportProfileManager
FormatStatePtr duplicate_format_state (FormatStatePtr state);
void remove_format_state (FormatStatePtr state);
PBD::sys::path save_format_to_disk (FormatPtr format);
void remove_format_profile (FormatPtr format);
FormatPtr get_new_format (FormatPtr original);
PBD::sys::path save_format_to_disk (ExportFormatSpecPtr format);
void remove_format_profile (ExportFormatSpecPtr format);
ExportFormatSpecPtr get_new_format (ExportFormatSpecPtr original);
PBD::Signal0<void> FormatListChanged;
@ -221,7 +211,7 @@ class ExportProfileManager
void load_formats ();
FormatPtr load_format (XMLNode & node);
ExportFormatSpecPtr load_format (XMLNode & node);
void load_format_from_disk (PBD::sys::path const & path);
boost::shared_ptr<FormatList> format_list;
@ -230,12 +220,10 @@ class ExportProfileManager
/* Filenames */
public:
typedef boost::shared_ptr<ExportFilename> FilenamePtr;
struct FilenameState {
FilenamePtr filename;
ExportFilenamePtr filename;
FilenameState (FilenamePtr ptr) : filename (ptr) {}
FilenameState (ExportFilenamePtr ptr) : filename (ptr) {}
};
typedef boost::shared_ptr<FilenameState> FilenameStatePtr;
typedef std::list<FilenameStatePtr> FilenameStateList;
@ -249,7 +237,7 @@ class ExportProfileManager
FilenameStateList filenames;
bool init_filenames (XMLNodeList nodes);
FilenamePtr load_filename (XMLNode & node);
ExportFilenamePtr load_filename (XMLNode & node);
/* Warnings */
public:
@ -268,8 +256,8 @@ class ExportProfileManager
FormatStatePtr format_state,
FilenameStatePtr filename_state);
bool check_format (FormatPtr format, uint32_t channels);
bool check_sndfile_format (FormatPtr format, unsigned int channels);
bool check_format (ExportFormatSpecPtr format, uint32_t channels);
bool check_sndfile_format (ExportFormatSpecPtr format, unsigned int channels);
/* Utilities */

View File

@ -58,6 +58,13 @@ class ExportTimespan
framepos_t get_start () const { return start_frame; }
framepos_t get_end () const { return end_frame; }
/// Primarily compare start time, then end time
bool operator< (ExportTimespan const & other) {
if (start_frame < other.start_frame) { return true; }
if (start_frame > other.start_frame) { return false; }
return end_frame < other.end_frame;
}
private:
ExportStatusPtr status;

View File

@ -251,6 +251,7 @@ namespace ARDOUR {
case Seconds:
return seconds == other.seconds;
}
return false; // get rid of warning
}
bool not_zero() const

View File

@ -139,7 +139,7 @@ ExportFilename::set_state (const XMLNode & node)
}
string
ExportFilename::get_path (FormatPtr format) const
ExportFilename::get_path (ExportFormatSpecPtr format) const
{
string path = folder;
bool filename_empty = true;

View File

@ -31,7 +31,7 @@ using std::string;
namespace ARDOUR
{
ExportFormatManager::ExportFormatManager (SpecPtr specification) :
ExportFormatManager::ExportFormatManager (ExportFormatSpecPtr specification) :
pending_selection_change (false),
universal_set (new ExportFormatBase ())
{
@ -51,7 +51,7 @@ ExportFormatManager::~ExportFormatManager ()
void
ExportFormatManager::init_compatibilities ()
{
CompatPtr c_ptr;
ExportFormatCompatibilityPtr c_ptr;
c_ptr.reset (new ExportFormatCompatibility (_("CD")));
c_ptr->add_sample_rate (ExportFormatBase::SR_44_1);
@ -115,7 +115,7 @@ ExportFormatManager::init_qualities ()
void
ExportFormatManager::init_formats ()
{
FormatPtr f_ptr;
ExportFormatPtr f_ptr;
ExportFormatLinear * fl_ptr;
f_ptr.reset (fl_ptr = new ExportFormatLinear ("AIFF", ExportFormatBase::F_AIFF));
@ -213,10 +213,12 @@ ExportFormatManager::init_sample_rates ()
}
void
ExportFormatManager::add_compatibility (CompatPtr ptr)
ExportFormatManager::add_compatibility (ExportFormatCompatibilityPtr ptr)
{
compatibilities.push_back (ptr);
ptr->SelectChanged.connect_same_thread (*this, boost::bind (&ExportFormatManager::change_compatibility_selection, this, _1, WeakCompatPtr (ptr)));
ptr->SelectChanged.connect_same_thread (*this,
boost::bind (&ExportFormatManager::change_compatibility_selection,
this, _1, WeakExportFormatCompatibilityPtr (ptr)));
}
void
@ -227,10 +229,10 @@ ExportFormatManager::add_quality (QualityPtr ptr)
}
void
ExportFormatManager::add_format (FormatPtr ptr)
ExportFormatManager::add_format (ExportFormatPtr ptr)
{
formats.push_back (ptr);
ptr->SelectChanged.connect_same_thread (*this, boost::bind (&ExportFormatManager::change_format_selection, this, _1, WeakFormatPtr (ptr)));
ptr->SelectChanged.connect_same_thread (*this, boost::bind (&ExportFormatManager::change_format_selection, this, _1, WeakExportFormatPtr (ptr)));
universal_set = universal_set->get_union (*ptr);
/* Encoding options */
@ -305,14 +307,14 @@ ExportFormatManager::select_tagging (bool tag)
}
void
ExportFormatManager::change_compatibility_selection (bool select, WeakCompatPtr const & compat)
ExportFormatManager::change_compatibility_selection (bool select, WeakExportFormatCompatibilityPtr const & compat)
{
bool do_selection_changed = !pending_selection_change;
if (!pending_selection_change) {
pending_selection_change = true;
}
CompatPtr ptr = compat.lock();
ExportFormatCompatibilityPtr ptr = compat.lock();
if (ptr && select) {
select_compatibility (ptr);
@ -341,9 +343,9 @@ ExportFormatManager::change_quality_selection (bool select, WeakQualityPtr const
}
void
ExportFormatManager::change_format_selection (bool select, WeakFormatPtr const & format)
ExportFormatManager::change_format_selection (bool select, WeakExportFormatPtr const & format)
{
FormatPtr ptr = format.lock();
ExportFormatPtr ptr = format.lock();
if (!ptr) {
return;
@ -409,11 +411,11 @@ ExportFormatManager::change_dither_type_selection (bool select, WeakDitherTypePt
}
void
ExportFormatManager::select_compatibility (WeakCompatPtr const & /*compat*/)
ExportFormatManager::select_compatibility (WeakExportFormatCompatibilityPtr const & /*compat*/)
{
/* Calculate compatibility intersection for the selection */
FormatBasePtr compat_intersect = get_compatibility_intersection ();
ExportFormatBasePtr compat_intersect = get_compatibility_intersection ();
/* Unselect incompatible items */
@ -426,7 +428,7 @@ ExportFormatManager::select_compatibility (WeakCompatPtr const & /*compat*/)
select_intersect = compat_intersect->get_intersection (*current_selection);
if (select_intersect->formats_empty()) {
select_format (FormatPtr());
select_format (ExportFormatPtr());
}
select_intersect = compat_intersect->get_intersection (*current_selection);
@ -453,7 +455,7 @@ ExportFormatManager::select_quality (QualityPtr const & quality)
/* Deselect format if it is incompatible */
FormatPtr format = get_selected_format();
ExportFormatPtr format = get_selected_format();
if (format && !format->has_quality (quality->quality)) {
format->set_selected (false);
}
@ -479,7 +481,7 @@ ExportFormatManager::select_quality (QualityPtr const & quality)
}
void
ExportFormatManager::select_format (FormatPtr const & format)
ExportFormatManager::select_format (ExportFormatPtr const & format)
{
bool do_selection_changed = !pending_selection_change;
if (!pending_selection_change) {
@ -525,7 +527,7 @@ ExportFormatManager::select_format (FormatPtr const & format)
current_selection->set_sample_format (format_to_select);
} else {
FormatPtr current_format = get_selected_format ();
ExportFormatPtr current_format = get_selected_format ();
if (current_format) {
current_format->set_selected (false);
}
@ -627,7 +629,7 @@ ExportFormatManager::selection_changed ()
/* Mark compatibility for everything necessary */
std::set<ExportFormatBase::Quality> compatible_qualities;
FormatBasePtr compat_intersect = get_compatibility_intersection ();
ExportFormatBasePtr compat_intersect = get_compatibility_intersection ();
ExportFormatCompatibility global_compat (*compat_intersect);
for (FormatList::iterator it = formats.begin(); it != formats.end(); ++it) {
@ -702,10 +704,10 @@ ExportFormatManager::get_selected_quality ()
return QualityPtr();
}
ExportFormatManager::FormatPtr
ExportFormatPtr
ExportFormatManager::get_selected_format ()
{
FormatPtr format;
ExportFormatPtr format;
for (FormatList::iterator it = formats.begin(); it != formats.end(); ++it) {
if ((*it)->selected()) {
@ -741,10 +743,10 @@ ExportFormatManager::get_selected_sample_format ()
}
ExportFormatManager::FormatBasePtr
ExportFormatBasePtr
ExportFormatManager::get_compatibility_intersection ()
{
FormatBasePtr compat_intersect = universal_set;
ExportFormatBasePtr compat_intersect = universal_set;
for (CompatList::iterator it = compatibilities.begin(); it != compatibilities.end(); ++it) {
if ((*it)->selected ()) {

View File

@ -519,7 +519,7 @@ ExportFormatSpecification::description ()
} else if (_trim_beginning) {
desc += _("trim start, ");
} else if (_trim_end) {
desc += "trim end, ";
desc += _("trim end, ");
}
desc += _format_name + ", ";

View File

@ -206,7 +206,7 @@ void
ExportGraphBuilder::Encoder::copy_files (std::string orig_path)
{
while (filenames.size()) {
FilenamePtr & filename = filenames.front();
ExportFilenamePtr & filename = filenames.front();
PBD::sys::copy_file (orig_path, filename->get_path (config.format).c_str());
filenames.pop_front();
}

View File

@ -56,46 +56,46 @@ ExportElementFactory::~ExportElementFactory ()
}
ExportElementFactory::TimespanPtr
ExportTimespanPtr
ExportElementFactory::add_timespan ()
{
return TimespanPtr (new ExportTimespan (session.get_export_status(), session.frame_rate()));
return ExportTimespanPtr (new ExportTimespan (session.get_export_status(), session.frame_rate()));
}
ExportElementFactory::ChannelConfigPtr
ExportChannelConfigPtr
ExportElementFactory::add_channel_config ()
{
return ChannelConfigPtr (new ExportChannelConfiguration (session));
return ExportChannelConfigPtr (new ExportChannelConfiguration (session));
}
ExportElementFactory::FormatPtr
ExportFormatSpecPtr
ExportElementFactory::add_format ()
{
return FormatPtr (new ExportFormatSpecification (session));
return ExportFormatSpecPtr (new ExportFormatSpecification (session));
}
ExportElementFactory::FormatPtr
ExportFormatSpecPtr
ExportElementFactory::add_format (XMLNode const & state)
{
return FormatPtr (new ExportFormatSpecification (session, state));
return ExportFormatSpecPtr (new ExportFormatSpecification (session, state));
}
ExportElementFactory::FormatPtr
ExportElementFactory::add_format_copy (FormatPtr other)
ExportFormatSpecPtr
ExportElementFactory::add_format_copy (ExportFormatSpecPtr other)
{
return FormatPtr (new ExportFormatSpecification (*other));
return ExportFormatSpecPtr (new ExportFormatSpecification (*other));
}
ExportElementFactory::FilenamePtr
ExportFilenamePtr
ExportElementFactory::add_filename ()
{
return FilenamePtr (new ExportFilename (session));
return ExportFilenamePtr (new ExportFilename (session));
}
ExportElementFactory::FilenamePtr
ExportElementFactory::add_filename_copy (FilenamePtr other)
ExportFilenamePtr
ExportElementFactory::add_filename_copy (ExportFilenamePtr other)
{
return FilenamePtr (new ExportFilename (*other));
return ExportFilenamePtr (new ExportFilename (*other));
}
/*** ExportHandler ***/
@ -118,7 +118,9 @@ ExportHandler::~ExportHandler ()
}
bool
ExportHandler::add_export_config (TimespanPtr timespan, ChannelConfigPtr channel_config, FormatPtr format, FilenamePtr filename, boost::shared_ptr<AudioGrapher::BroadcastInfo> broadcast_info)
ExportHandler::add_export_config (ExportTimespanPtr timespan, ExportChannelConfigPtr channel_config,
ExportFormatSpecPtr format, ExportFilenamePtr filename,
BroadcastInfoPtr broadcast_info)
{
FileSpec spec (channel_config, format, filename, broadcast_info);
ConfigPair pair (timespan, spec);
@ -133,7 +135,7 @@ ExportHandler::do_export (bool rt)
/* Count timespans */
export_status->init();
std::set<TimespanPtr> timespan_set;
std::set<ExportTimespanPtr> timespan_set;
for (ConfigMap::iterator it = config_map.begin(); it != config_map.end(); ++it) {
timespan_set.insert (it->first);
}
@ -246,7 +248,8 @@ struct LocationSortByStart {
};
void
ExportHandler::export_cd_marker_file (TimespanPtr timespan, FormatPtr file_format, std::string filename, CDMarkerFormat format)
ExportHandler::export_cd_marker_file (ExportTimespanPtr timespan, ExportFormatSpecPtr file_format,
std::string filename, CDMarkerFormat format)
{
string filepath;
string basename = Glib::path_get_basename(filename);

View File

@ -124,7 +124,7 @@ ExportProfileManager::prepare_for_export ()
format_it != formats.end() && filename_it != filenames.end();
++format_it, ++filename_it) {
FilenamePtr filename = (*filename_it)->filename;
ExportFilenamePtr filename = (*filename_it)->filename;
// filename->include_timespan = (ts_list->size() > 1); Disabled for now...
boost::shared_ptr<BroadcastInfo> b;
@ -143,7 +143,7 @@ ExportProfileManager::prepare_for_export ()
}
bool
ExportProfileManager::load_preset (PresetPtr preset)
ExportProfileManager::load_preset (ExportPresetPtr preset)
{
bool ok = true;
@ -181,7 +181,7 @@ ExportProfileManager::preset_filename (std::string const & preset_name)
return export_config_dir.to_string() + "/" + safe_name + export_preset_suffix;
}
ExportProfileManager::PresetPtr
ExportPresetPtr
ExportProfileManager::new_preset (string const & name)
{
// Generate new ID and do regular save
@ -191,7 +191,7 @@ ExportProfileManager::new_preset (string const & name)
return save_preset (name);
}
ExportProfileManager::PresetPtr
ExportPresetPtr
ExportProfileManager::save_preset (string const & name)
{
string filename = preset_filename (name);
@ -241,7 +241,7 @@ ExportProfileManager::remove_preset ()
void
ExportProfileManager::load_preset_from_disk (PBD::sys::path const & path)
{
PresetPtr preset (new ExportPreset (path.to_string(), session));
ExportPresetPtr preset (new ExportPreset (path.to_string(), session));
/* Handle id to filename mapping and don't add duplicates to list */
@ -363,7 +363,7 @@ ExportProfileManager::init_timespans (XMLNodeList nodes)
timespans.push_back (state);
// Add session as default selection
TimespanPtr timespan = handler->add_timespan();
ExportTimespanPtr timespan = handler->add_timespan();
timespan->set_name (session_range->name());
timespan->set_range_id ("session");
timespan->set_range (session_range->start(), session_range->end());
@ -391,7 +391,7 @@ ExportProfileManager::deserialize_timespan (XMLNode & root)
if ((!id.compare ("session") && *it == session_range.get()) ||
(!id.compare ("selection") && *it == selection_range.get()) ||
(!id.compare ((*it)->id().to_s()))) {
TimespanPtr timespan = handler->add_timespan();
ExportTimespanPtr timespan = handler->add_timespan();
timespan->set_name ((*it)->name());
timespan->set_range_id (id);
timespan->set_range ((*it)->start(), (*it)->end());
@ -520,7 +520,7 @@ ExportProfileManager::remove_format_state (FormatStatePtr state)
}
sys::path
ExportProfileManager::save_format_to_disk (FormatPtr format)
ExportProfileManager::save_format_to_disk (ExportFormatSpecPtr format)
{
// TODO filename character stripping
@ -577,7 +577,7 @@ ExportProfileManager::save_format_to_disk (FormatPtr format)
}
void
ExportProfileManager::remove_format_profile (FormatPtr format)
ExportProfileManager::remove_format_profile (ExportFormatSpecPtr format)
{
for (FormatList::iterator it = format_list->begin(); it != format_list->end(); ++it) {
if (*it == format) {
@ -595,10 +595,10 @@ ExportProfileManager::remove_format_profile (FormatPtr format)
FormatListChanged ();
}
ExportProfileManager::FormatPtr
ExportProfileManager::get_new_format (FormatPtr original)
ExportFormatSpecPtr
ExportProfileManager::get_new_format (ExportFormatSpecPtr original)
{
FormatPtr format;
ExportFormatSpecPtr format;
if (original) {
format.reset (new ExportFormatSpecification (*original));
} else {
@ -630,7 +630,7 @@ ExportProfileManager::init_formats (XMLNodeList nodes)
}
if (formats.empty ()) {
FormatStatePtr format (new FormatState (format_list, FormatPtr ()));
FormatStatePtr format (new FormatState (format_list, ExportFormatSpecPtr ()));
formats.push_back (format);
return false;
}
@ -682,7 +682,7 @@ void
ExportProfileManager::load_format_from_disk (PBD::sys::path const & path)
{
XMLTree const tree (path.to_string());
FormatPtr format = handler->add_format (*tree.root());
ExportFormatSpecPtr format = handler->add_format (*tree.root());
/* Handle id to filename mapping and don't add duplicates to list */
@ -719,7 +719,7 @@ ExportProfileManager::init_filenames (XMLNodeList nodes)
filenames.clear ();
for (XMLNodeList::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
FilenamePtr filename = handler->add_filename();
ExportFilenamePtr filename = handler->add_filename();
filename->set_state (**it);
filenames.push_back (FilenameStatePtr (new FilenameState (filename)));
}
@ -746,7 +746,7 @@ ExportProfileManager::get_warnings ()
/*** Check "global" config ***/
TimespanListPtr timespans = timespan_state->timespans;
ChannelConfigPtr channel_config = channel_config_state->config;
ExportChannelConfigPtr channel_config = channel_config_state->config;
/* Check Timespans are not empty */
@ -781,9 +781,9 @@ ExportProfileManager::check_config (boost::shared_ptr<Warnings> warnings,
FilenameStatePtr filename_state)
{
TimespanListPtr timespans = timespan_state->timespans;
ChannelConfigPtr channel_config = channel_config_state->config;
FormatPtr format = format_state->format;
FilenamePtr filename = filename_state->filename;
ExportChannelConfigPtr channel_config = channel_config_state->config;
ExportFormatSpecPtr format = format_state->format;
ExportFilenamePtr filename = filename_state->filename;
/* Check format and maximum channel count */
if (!format || !format->type()) {
@ -806,7 +806,7 @@ ExportProfileManager::check_config (boost::shared_ptr<Warnings> warnings,
// filename->include_timespan = (timespans->size() > 1); Disabled for now...
for (std::list<TimespanPtr>::iterator timespan_it = timespans->begin(); timespan_it != timespans->end(); ++timespan_it) {
for (std::list<ExportTimespanPtr>::iterator timespan_it = timespans->begin(); timespan_it != timespans->end(); ++timespan_it) {
filename->set_timespan (*timespan_it);
if (channel_config->get_split()) {
@ -833,7 +833,7 @@ ExportProfileManager::check_config (boost::shared_ptr<Warnings> warnings,
}
bool
ExportProfileManager::check_format (FormatPtr format, uint32_t channels)
ExportProfileManager::check_format (ExportFormatSpecPtr format, uint32_t channels)
{
switch (format->type()) {
case ExportFormatBase::T_Sndfile:
@ -845,7 +845,7 @@ ExportProfileManager::check_format (FormatPtr format, uint32_t channels)
}
bool
ExportProfileManager::check_sndfile_format (FormatPtr format, unsigned int channels)
ExportProfileManager::check_sndfile_format (ExportFormatSpecPtr format, unsigned int channels)
{
SF_INFO sf_info;
sf_info.channels = channels;