2008-06-02 17:41:35 -04:00
|
|
|
/*
|
2009-10-14 12:10:01 -04:00
|
|
|
Copyright (C) 2000-2006 Paul Davis
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
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;
|
|
|
|
|
2009-12-19 15:26:31 -05:00
|
|
|
PBD::Signal2<void,boost::shared_ptr<Playlist>, bool> PlaylistFactory::PlaylistCreated;
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
boost::shared_ptr<Playlist>
|
2008-09-26 04:29:30 -04:00
|
|
|
PlaylistFactory::create (Session& s, const XMLNode& node, bool hidden, bool unused)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
const XMLProperty* type = node.property("type");
|
|
|
|
|
|
|
|
boost::shared_ptr<Playlist> pl;
|
|
|
|
|
2011-06-22 16:06:10 -04:00
|
|
|
try {
|
|
|
|
if (!type || type->value() == "audio") {
|
|
|
|
pl = boost::shared_ptr<Playlist> (new AudioPlaylist (s, node, hidden));
|
|
|
|
} else if (type->value() == "midi") {
|
|
|
|
pl = boost::shared_ptr<Playlist> (new MidiPlaylist (s, node, hidden));
|
|
|
|
}
|
|
|
|
|
|
|
|
pl->set_region_ownership ();
|
|
|
|
|
|
|
|
if (pl && !hidden) {
|
|
|
|
PlaylistCreated (pl, unused);
|
|
|
|
}
|
|
|
|
return pl;
|
|
|
|
|
|
|
|
} catch (...) {
|
|
|
|
return boost::shared_ptr<Playlist> ();
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
boost::shared_ptr<Playlist>
|
|
|
|
PlaylistFactory::create (DataType type, Session& s, string name, bool hidden)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
boost::shared_ptr<Playlist> pl;
|
|
|
|
|
2011-06-22 16:06:10 -04:00
|
|
|
try {
|
|
|
|
if (type == DataType::AUDIO)
|
|
|
|
pl = boost::shared_ptr<Playlist> (new AudioPlaylist (s, name, hidden));
|
|
|
|
else if (type == DataType::MIDI)
|
|
|
|
pl = boost::shared_ptr<Playlist> (new MidiPlaylist (s, name, hidden));
|
|
|
|
|
|
|
|
if (pl && !hidden) {
|
|
|
|
PlaylistCreated (pl, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return pl;
|
|
|
|
} catch (...) {
|
|
|
|
return boost::shared_ptr<Playlist> ();
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
boost::shared_ptr<Playlist>
|
|
|
|
PlaylistFactory::create (boost::shared_ptr<const Playlist> old, string name, bool hidden)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
boost::shared_ptr<Playlist> pl;
|
|
|
|
boost::shared_ptr<const AudioPlaylist> apl;
|
|
|
|
boost::shared_ptr<const MidiPlaylist> mpl;
|
2011-06-22 16:06:10 -04:00
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if ((apl = boost::dynamic_pointer_cast<const AudioPlaylist> (old)) != 0) {
|
|
|
|
pl = boost::shared_ptr<Playlist> (new AudioPlaylist (apl, name, hidden));
|
|
|
|
pl->set_region_ownership ();
|
|
|
|
} else if ((mpl = boost::dynamic_pointer_cast<const MidiPlaylist> (old)) != 0) {
|
|
|
|
pl = boost::shared_ptr<Playlist> (new MidiPlaylist (mpl, name, hidden));
|
|
|
|
pl->set_region_ownership ();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pl && !hidden) {
|
|
|
|
PlaylistCreated (pl, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return pl;
|
|
|
|
} catch (...) {
|
|
|
|
return boost::shared_ptr<Playlist> ();
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
2011-06-22 16:06:10 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
boost::shared_ptr<Playlist>
|
2010-12-03 17:26:29 -05:00
|
|
|
PlaylistFactory::create (boost::shared_ptr<const Playlist> old, framepos_t start, framecnt_t cnt, string name, bool hidden)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
boost::shared_ptr<Playlist> pl;
|
|
|
|
boost::shared_ptr<const AudioPlaylist> apl;
|
|
|
|
boost::shared_ptr<const MidiPlaylist> mpl;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2011-06-22 16:06:10 -04:00
|
|
|
try {
|
|
|
|
if ((apl = boost::dynamic_pointer_cast<const AudioPlaylist> (old)) != 0) {
|
|
|
|
pl = boost::shared_ptr<Playlist> (new AudioPlaylist (apl, start, cnt, name, hidden));
|
|
|
|
pl->set_region_ownership ();
|
|
|
|
} else if ((mpl = boost::dynamic_pointer_cast<const MidiPlaylist> (old)) != 0) {
|
|
|
|
pl = boost::shared_ptr<Playlist> (new MidiPlaylist (mpl, start, cnt, name, hidden));
|
|
|
|
pl->set_region_ownership ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this factory method does NOT notify others */
|
|
|
|
|
|
|
|
return pl;
|
|
|
|
} catch (...) {
|
|
|
|
return boost::shared_ptr<Playlist> ();
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
}
|