projects
/
ardour.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Allow naming of new tracks/busses in the add route dialogue (#3376).
[ardour.git]
/
libs
/
ardour
/
session.cc
diff --git
a/libs/ardour/session.cc
b/libs/ardour/session.cc
index 4c25989c0ae8acbb7360244b685a6d4c3b44edd7..b7d04c379fefd477897fdfb9c8e3575c87226568 100644
(file)
--- a/
libs/ardour/session.cc
+++ b/
libs/ardour/session.cc
@@
-323,7
+323,6
@@
Session::destroy ()
playlists.reset ();
delete _locations;
playlists.reset ();
delete _locations;
- delete _speakers;
DEBUG_TRACE (DEBUG::Destruction, "Session::destroy() done\n");
DEBUG_TRACE (DEBUG::Destruction, "Session::destroy() done\n");
@@
-672,7
+671,6
@@
Session::hookup_io ()
_state_of_the_state = StateOfTheState (_state_of_the_state | InitialConnecting);
_state_of_the_state = StateOfTheState (_state_of_the_state | InitialConnecting);
-
if (!auditioner) {
/* we delay creating the auditioner till now because
if (!auditioner) {
/* we delay creating the auditioner till now because
@@
-680,13
+678,12
@@
Session::hookup_io ()
*/
try {
*/
try {
-
Auditioner* a = new Auditioner (*this
);
+
boost::shared_ptr<Auditioner> a (new Auditioner (*this)
);
if (a->init()) {
if (a->init()) {
- delete a;
- throw failed_constructor();
+ throw failed_constructor ();
}
a->use_new_diskstream ();
}
a->use_new_diskstream ();
- auditioner
.reset (a)
;
+ auditioner
= a
;
}
catch (failed_constructor& err) {
}
catch (failed_constructor& err) {
@@
-728,10
+725,8
@@
Session::hookup_io ()
/* relax */
} else {
/* relax */
} else {
-
- (*x)->listen_via (_monitor_out,
- (Config->get_listen_position() == AfterFaderListen ? PostFader : PreFader),
- false, false);
+
+ (*x)->listen_via_monitor ();
}
}
}
}
}
}
@@
-1422,20
+1417,29
@@
Session::resort_routes_using (boost::shared_ptr<RouteList> r)
}
}
-/** Find the route name starting with \a base with the lowest \a id.
+/** Find a route name starting with \a base, maybe followed by the
+ * lowest \a id. \a id will always be added if \a definitely_add_number
+ * is true on entry; otherwise it will only be added if required
+ * to make the name unique.
*
*
- * Names are constructed like e.g. "Audio 3" for base="Audio" and id=3.
- * The available route name with the lowest ID will be used, and \a id
- * will be set to the ID.
+ *
Names are constructed like e.g. "Audio 3" for base="Audio" and id=3.
+ *
The available route name with the lowest ID will be used, and \a id
+ *
will be set to the ID.
*
*
- * \return false if a route name could not be found, and \a track_name
- * and \a id do not reflect a free route name.
+ *
\return false if a route name could not be found, and \a track_name
+ *
and \a id do not reflect a free route name.
*/
bool
*/
bool
-Session::find_route_name (
const char* base, uint32_t& id, char* name, size_t name_len
)
+Session::find_route_name (
string const & base, uint32_t& id, char* name, size_t name_len, bool definitely_add_number
)
{
{
+ if (!definitely_add_number && route_by_name (base) == 0) {
+ /* juse use the base */
+ snprintf (name, name_len, "%s", base.c_str());
+ return true;
+ }
+
do {
do {
- snprintf (name, name_len, "%s %" PRIu32, base, id);
+ snprintf (name, name_len, "%s %" PRIu32, base
.c_str()
, id);
if (route_by_name (name) == 0) {
return true;
if (route_by_name (name) == 0) {
return true;
@@
-1463,9
+1467,11
@@
Session::count_existing_route_channels (ChanCount& in, ChanCount& out)
}
}
}
}
-/** Caller must not hold process lock */
+/** Caller must not hold process lock
+ * @param name_template string to use for the start of the name, or "" to use "Midi".
+ */
list<boost::shared_ptr<MidiTrack> >
list<boost::shared_ptr<MidiTrack> >
-Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_many)
+Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_many
, string name_template
)
{
char track_name[32];
uint32_t track_id = 0;
{
char track_name[32];
uint32_t track_id = 0;
@@
-1481,7
+1487,7
@@
Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_m
control_id = ntracks() + nbusses();
while (how_many) {
control_id = ntracks() + nbusses();
while (how_many) {
- if (!find_route_name (
"Midi", ++track_id, track_name, sizeof(track_name)
)) {
+ if (!find_route_name (
name_template.empty() ? _("Midi") : name_template, ++track_id, track_name, sizeof(track_name), false
)) {
error << "cannot find name for new midi track" << endmsg;
goto failed;
}
error << "cannot find name for new midi track" << endmsg;
goto failed;
}
@@
-1489,20
+1495,17
@@
Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_m
boost::shared_ptr<MidiTrack> track;
try {
boost::shared_ptr<MidiTrack> track;
try {
-
MidiTrack* mt = new MidiTrack (*this, track_name, Route::Flag (0), mode
);
+
track.reset (new MidiTrack (*this, track_name, Route::Flag (0), mode)
);
- if (mt->init ()) {
- delete mt;
+ if (track->init ()) {
goto failed;
}
goto failed;
}
-
mt
->use_new_diskstream();
+
track
->use_new_diskstream();
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
- boost_debug_shared_ptr_mark_interesting (
mt
, "Track");
+ boost_debug_shared_ptr_mark_interesting (
track.get()
, "Track");
#endif
#endif
- track = boost::shared_ptr<MidiTrack>(mt);
-
{
Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
if (track->input()->ensure_io (ChanCount(DataType::MIDI, 1), false, this)) {
{
Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
if (track->input()->ensure_io (ChanCount(DataType::MIDI, 1), false, this)) {
@@
-1634,9
+1637,13
@@
Session::auto_connect_route (
existing_outputs += route->n_outputs();
}
existing_outputs += route->n_outputs();
}
-/** Caller must not hold process lock */
+/** Caller must not hold process lock
+ * @param name_template string to use for the start of the name, or "" to use "Audio".
+ */
list< boost::shared_ptr<AudioTrack> >
list< boost::shared_ptr<AudioTrack> >
-Session::new_audio_track (int input_channels, int output_channels, TrackMode mode, RouteGroup* route_group, uint32_t how_many)
+Session::new_audio_track (
+ int input_channels, int output_channels, TrackMode mode, RouteGroup* route_group, uint32_t how_many, string name_template
+ )
{
char track_name[32];
uint32_t track_id = 0;
{
char track_name[32];
uint32_t track_id = 0;
@@
-1652,7
+1659,7
@@
Session::new_audio_track (int input_channels, int output_channels, TrackMode mod
control_id = ntracks() + nbusses() + 1;
while (how_many) {
control_id = ntracks() + nbusses() + 1;
while (how_many) {
- if (!find_route_name (
"Audio", ++track_id, track_name, sizeof(track_name)
)) {
+ if (!find_route_name (
name_template.empty() ? _("Audio") : name_template, ++track_id, track_name, sizeof(track_name), false
)) {
error << "cannot find name for new audio track" << endmsg;
goto failed;
}
error << "cannot find name for new audio track" << endmsg;
goto failed;
}
@@
-1660,20
+1667,17
@@
Session::new_audio_track (int input_channels, int output_channels, TrackMode mod
boost::shared_ptr<AudioTrack> track;
try {
boost::shared_ptr<AudioTrack> track;
try {
-
AudioTrack* at = new AudioTrack (*this, track_name, Route::Flag (0), mode
);
+
track.reset (new AudioTrack (*this, track_name, Route::Flag (0), mode)
);
- if (at->init ()) {
- delete at;
+ if (track->init ()) {
goto failed;
}
goto failed;
}
-
at
->use_new_diskstream();
+
track
->use_new_diskstream();
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
- boost_debug_shared_ptr_mark_interesting (
at
, "Track");
+ boost_debug_shared_ptr_mark_interesting (
track.get()
, "Track");
#endif
#endif
- track = boost::shared_ptr<AudioTrack>(at);
-
{
Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
{
Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
@@
-1759,9
+1763,11
@@
Session::set_remote_control_ids ()
}
}
}
}
-/** Caller must not hold process lock */
+/** Caller must not hold process lock.
+ * @param name_template string to use for the start of the name, or "" to use "Bus".
+ */
RouteList
RouteList
-Session::new_audio_route (int input_channels, int output_channels, RouteGroup* route_group, uint32_t how_many)
+Session::new_audio_route (int input_channels, int output_channels, RouteGroup* route_group, uint32_t how_many
, string name_template
)
{
char bus_name[32];
uint32_t bus_id = 0;
{
char bus_name[32];
uint32_t bus_id = 0;
@@
-1776,24
+1782,21
@@
Session::new_audio_route (int input_channels, int output_channels, RouteGroup* r
control_id = ntracks() + nbusses() + 1;
while (how_many) {
control_id = ntracks() + nbusses() + 1;
while (how_many) {
- if (!find_route_name (
"Bus", ++bus_id, bus_name, sizeof(bus_name)
)) {
+ if (!find_route_name (
name_template.empty () ? _("Bus") : name_template, ++bus_id, bus_name, sizeof(bus_name), false
)) {
error << "cannot find name for new audio bus" << endmsg;
goto failure;
}
try {
error << "cannot find name for new audio bus" << endmsg;
goto failure;
}
try {
-
Route* rt = new Route (*this, bus_name, Route::Flag(0), DataType::AUDIO
);
+
boost::shared_ptr<Route> bus (new Route (*this, bus_name, Route::Flag(0), DataType::AUDIO)
);
- if (rt->init ()) {
- delete rt;
+ if (bus->init ()) {
goto failure;
}
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
goto failure;
}
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
- boost_debug_shared_ptr_mark_interesting (
rt
, "Route");
+ boost_debug_shared_ptr_mark_interesting (
bus.get()
, "Route");
#endif
#endif
- boost::shared_ptr<Route> bus (rt);
-
{
Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
{
Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
@@
-1874,7
+1877,7
@@
Session::new_route_from_template (uint32_t how_many, const std::string& template
std::string node_name = IO::name_from_state (*node_copy.children().front());
/* generate a new name by adding a number to the end of the template name */
std::string node_name = IO::name_from_state (*node_copy.children().front());
/* generate a new name by adding a number to the end of the template name */
- if (!find_route_name (node_name.c_str(), ++number, name, sizeof(name))) {
+ if (!find_route_name (node_name.c_str(), ++number, name, sizeof(name)
, true
)) {
fatal << _("Session: UINT_MAX routes? impossible!") << endmsg;
/*NOTREACHED*/
}
fatal << _("Session: UINT_MAX routes? impossible!") << endmsg;
/*NOTREACHED*/
}
@@
-2001,9
+2004,7
@@
Session::add_routes (RouteList& new_routes, bool save)
} else if ((*x)->is_master()) {
/* relax */
} else {
} else if ((*x)->is_master()) {
/* relax */
} else {
- (*x)->listen_via (_monitor_out,
- (Config->get_listen_position() == AfterFaderListen ? PostFader : PreFader),
- false, false);
+ (*x)->listen_via_monitor ();
}
}
}
}
@@
-2092,7
+2093,7
@@
Session::add_internal_sends (boost::shared_ptr<Route> dest, Placement p, boost::
continue;
}
continue;
}
- (*i)->listen_via (dest, p
, true, true
);
+ (*i)->listen_via (dest, p);
}
graph_reordered ();
}
graph_reordered ();
@@
-2208,7
+2209,7
@@
Session::route_listen_changed (void* /*src*/, boost::weak_ptr<Route> wpr)
return;
}
return;
}
- if (route->listening()) {
+ if (route->listening
_via_monitor
()) {
if (Config->get_exclusive_solo()) {
/* new listen: disable all other listen */
if (Config->get_exclusive_solo()) {
/* new listen: disable all other listen */
@@
-2227,6
+2228,8
@@
Session::route_listen_changed (void* /*src*/, boost::weak_ptr<Route> wpr)
_listen_cnt--;
}
_listen_cnt--;
}
+
+ update_route_solo_state ();
}
void
Session::route_solo_isolated_changed (void* /*src*/, boost::weak_ptr<Route> wpr)
}
void
Session::route_solo_isolated_changed (void* /*src*/, boost::weak_ptr<Route> wpr)
@@
-2364,7
+2367,7
@@
Session::update_route_solo_state (boost::shared_ptr<RouteList> r)
something_soloed = true;
}
something_soloed = true;
}
- if (!(*i)->is_hidden() && (*i)->listening()) {
+ if (!(*i)->is_hidden() && (*i)->listening
_via_monitor
()) {
if (Config->get_solo_control_is_listen_control()) {
listeners++;
} else {
if (Config->get_solo_control_is_listen_control()) {
listeners++;
} else {
@@
-3893,22
+3896,10
@@
Session::update_have_rec_enabled_track ()
void
Session::listen_position_changed ()
{
void
Session::listen_position_changed ()
{
- Placement p;
-
- switch (Config->get_listen_position()) {
- case AfterFaderListen:
- p = PostFader;
- break;
-
- case PreFaderListen:
- p = PreFader;
- break;
- }
-
boost::shared_ptr<RouteList> r = routes.reader ();
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
boost::shared_ptr<RouteList> r = routes.reader ();
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
- (*i)->
put_monitor_send_at (p
);
+ (*i)->
listen_position_changed (
);
}
}
}
}
@@
-4175,10
+4166,10
@@
Session::ensure_search_path_includes (const string& path, DataType type)
}
}
}
}
-Speakers&
+boost::shared_ptr<Speakers>
Session::get_speakers()
{
Session::get_speakers()
{
- return
*
_speakers;
+ return _speakers;
}
list<string>
}
list<string>