2008-06-02 17:41:35 -04:00
|
|
|
/*
|
2019-08-02 22:01:25 -04:00
|
|
|
* Copyright (C) 2006-2009 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/error.h"
|
2009-05-13 20:13:27 -04:00
|
|
|
#include "pbd/xml++.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/playlist.h"
|
|
|
|
#include "ardour/audioplaylist.h"
|
|
|
|
#include "ardour/midi_playlist.h"
|
|
|
|
#include "ardour/playlist_factory.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-05-12 13:03:42 -04:00
|
|
|
using namespace std;
|
2008-06-02 17:41:35 -04:00
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
|
|
|
|
2023-06-09 21:09:41 -04:00
|
|
|
PBD::Signal1<void,std::shared_ptr<Playlist>> PlaylistFactory::PlaylistCreated;
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Playlist>
|
2023-06-09 21:09:41 -04:00
|
|
|
PlaylistFactory::create (Session& s, const XMLNode& node, bool hidden)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
2016-05-04 23:09:37 -04:00
|
|
|
XMLProperty const * type = node.property("type");
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Playlist> pl;
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2011-06-22 16:06:10 -04:00
|
|
|
try {
|
|
|
|
if (!type || type->value() == "audio") {
|
2023-02-16 18:33:28 -05:00
|
|
|
pl = std::shared_ptr<Playlist> (new AudioPlaylist (s, node, hidden));
|
2011-06-22 16:06:10 -04:00
|
|
|
} else if (type->value() == "midi") {
|
2023-02-16 18:33:28 -05:00
|
|
|
pl = std::shared_ptr<Playlist> (new MidiPlaylist (s, node, hidden));
|
2011-06-22 16:06:10 -04:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2011-06-22 16:06:10 -04:00
|
|
|
pl->set_region_ownership ();
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2011-06-22 16:06:10 -04:00
|
|
|
if (pl && !hidden) {
|
2023-06-09 21:09:41 -04:00
|
|
|
PlaylistCreated (pl);
|
2011-06-22 16:06:10 -04:00
|
|
|
}
|
|
|
|
return pl;
|
|
|
|
|
|
|
|
} catch (...) {
|
2023-02-16 18:33:28 -05:00
|
|
|
return std::shared_ptr<Playlist> ();
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Playlist>
|
2009-10-14 12:10:01 -04:00
|
|
|
PlaylistFactory::create (DataType type, Session& s, string name, bool hidden)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Playlist> pl;
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2011-06-22 16:06:10 -04:00
|
|
|
try {
|
|
|
|
if (type == DataType::AUDIO)
|
2023-02-16 18:33:28 -05:00
|
|
|
pl = std::shared_ptr<Playlist> (new AudioPlaylist (s, name, hidden));
|
2011-06-22 16:06:10 -04:00
|
|
|
else if (type == DataType::MIDI)
|
2023-02-16 18:33:28 -05:00
|
|
|
pl = std::shared_ptr<Playlist> (new MidiPlaylist (s, name, hidden));
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2011-06-22 16:06:10 -04:00
|
|
|
if (pl && !hidden) {
|
2023-06-09 21:09:41 -04:00
|
|
|
PlaylistCreated (pl);
|
2011-06-22 16:06:10 -04:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2011-06-22 16:06:10 -04:00
|
|
|
return pl;
|
|
|
|
} catch (...) {
|
2023-02-16 18:33:28 -05:00
|
|
|
return std::shared_ptr<Playlist> ();
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Playlist>
|
|
|
|
PlaylistFactory::create (std::shared_ptr<const Playlist> old, string name, bool hidden)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Playlist> pl;
|
|
|
|
std::shared_ptr<const AudioPlaylist> apl;
|
|
|
|
std::shared_ptr<const MidiPlaylist> mpl;
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2011-06-22 16:06:10 -04:00
|
|
|
try {
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
if ((apl = std::dynamic_pointer_cast<const AudioPlaylist> (old)) != 0) {
|
|
|
|
pl = std::shared_ptr<Playlist> (new AudioPlaylist (apl, name, hidden));
|
2011-06-22 16:06:10 -04:00
|
|
|
pl->set_region_ownership ();
|
2023-02-16 18:33:28 -05:00
|
|
|
} else if ((mpl = std::dynamic_pointer_cast<const MidiPlaylist> (old)) != 0) {
|
|
|
|
pl = std::shared_ptr<Playlist> (new MidiPlaylist (mpl, name, hidden));
|
2011-06-22 16:06:10 -04:00
|
|
|
pl->set_region_ownership ();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pl && !hidden) {
|
2023-06-09 21:09:41 -04:00
|
|
|
PlaylistCreated (pl);
|
2011-06-22 16:06:10 -04:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2011-06-22 16:06:10 -04:00
|
|
|
return pl;
|
|
|
|
} catch (...) {
|
2023-02-16 18:33:28 -05:00
|
|
|
return std::shared_ptr<Playlist> ();
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Playlist>
|
|
|
|
PlaylistFactory::create (std::shared_ptr<const Playlist> old, timepos_t const & start, timepos_t const & cnt, string name, bool hidden)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Playlist> pl;
|
|
|
|
std::shared_ptr<const AudioPlaylist> apl;
|
|
|
|
std::shared_ptr<const MidiPlaylist> mpl;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-06-22 16:06:10 -04:00
|
|
|
try {
|
2023-02-16 18:33:28 -05:00
|
|
|
if ((apl = std::dynamic_pointer_cast<const AudioPlaylist> (old)) != 0) {
|
|
|
|
pl = std::shared_ptr<Playlist> (new AudioPlaylist (apl, start, cnt, name, hidden));
|
2011-06-22 16:06:10 -04:00
|
|
|
pl->set_region_ownership ();
|
2023-02-16 18:33:28 -05:00
|
|
|
} else if ((mpl = std::dynamic_pointer_cast<const MidiPlaylist> (old)) != 0) {
|
|
|
|
pl = std::shared_ptr<Playlist> (new MidiPlaylist (mpl, start, cnt, name, hidden));
|
2011-06-22 16:06:10 -04:00
|
|
|
pl->set_region_ownership ();
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2011-06-22 16:06:10 -04:00
|
|
|
/* this factory method does NOT notify others */
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2011-06-22 16:06:10 -04:00
|
|
|
return pl;
|
|
|
|
} catch (...) {
|
2023-02-16 18:33:28 -05:00
|
|
|
return std::shared_ptr<Playlist> ();
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
}
|