X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Faudio_playlist_source.cc;h=98df5c1835316cdab9ec0f885d6b9d23c71d9d83;hb=225a8a47a419e5e67a27b604bfd912498e3ad2cc;hp=09b30ff87a628434b3d752673b0c9fd70159add0;hpb=43495d7f2b4ee4189e7b5497539ebe8eb126a3aa;p=ardour.git diff --git a/libs/ardour/audio_playlist_source.cc b/libs/ardour/audio_playlist_source.cc index 09b30ff87a..98df5c1835 100644 --- a/libs/ardour/audio_playlist_source.cc +++ b/libs/ardour/audio_playlist_source.cc @@ -27,18 +27,13 @@ #include #include "pbd/error.h" -#include "pbd/convert.h" -#include "pbd/enumwriter.h" #include "ardour/audioplaylist.h" #include "ardour/audio_playlist_source.h" #include "ardour/audioregion.h" -#include "ardour/debug.h" #include "ardour/filename_extensions.h" #include "ardour/session.h" #include "ardour/session_directory.h" -#include "ardour/session_playlists.h" -#include "ardour/source_factory.h" #include "i18n.h" @@ -46,11 +41,11 @@ using namespace std; using namespace ARDOUR; using namespace PBD; -AudioPlaylistSource::AudioPlaylistSource (Session& s, const ID& orig, const std::string& name, boost::shared_ptr p, +AudioPlaylistSource::AudioPlaylistSource (Session& s, const ID& orig, const std::string& name, boost::shared_ptr p, uint32_t chn, frameoffset_t begin, framecnt_t len, Source::Flag flags) : Source (s, DataType::AUDIO, name) - , AudioSource (s, name) , PlaylistSource (s, orig, name, p, DataType::AUDIO, begin, len, flags) + , AudioSource (s, name) , _playlist_channel (chn) { AudioSource::_length = len; @@ -59,8 +54,8 @@ AudioPlaylistSource::AudioPlaylistSource (Session& s, const ID& orig, const std: AudioPlaylistSource::AudioPlaylistSource (Session& s, const XMLNode& node) : Source (s, node) - , AudioSource (s, node) , PlaylistSource (s, node) + , AudioSource (s, node) { /* PlaylistSources are never writable, renameable, removable or destructive */ _flags = Flag (_flags & ~(Writable|CanRename|Removable|RemovableIfEmpty|RemoveAtDestroy|Destructive)); @@ -68,10 +63,12 @@ AudioPlaylistSource::AudioPlaylistSource (Session& s, const XMLNode& node) /* ancestors have already called ::set_state() in their XML-based constructors. */ - + if (set_state (node, Stateful::loading_state_version, false)) { throw failed_constructor (); } + + AudioSource::_length = _playlist_length; } AudioPlaylistSource::~AudioPlaylistSource () @@ -94,26 +91,26 @@ AudioPlaylistSource::get_state () return node; } - int -AudioPlaylistSource::set_state (const XMLNode& node, int version) +AudioPlaylistSource::set_state (const XMLNode& node, int version) { return set_state (node, version, true); } int -AudioPlaylistSource::set_state (const XMLNode& node, int version, bool with_descendants) +AudioPlaylistSource::set_state (const XMLNode& node, int version, bool with_descendants) { if (with_descendants) { - if (Source::set_state (node, version) || - AudioSource::set_state (node, version) || - PlaylistSource::set_state (node, version)) { + if (Source::set_state (node, version) || + PlaylistSource::set_state (node, version) || + AudioSource::set_state (node, version)) { return -1; } } - const XMLProperty* prop; + XMLProperty const * prop; pair extent = _playlist->get_extent(); + AudioSource::_length = extent.second - extent.first; if ((prop = node.property (X_("channel"))) == 0) { @@ -127,14 +124,13 @@ AudioPlaylistSource::set_state (const XMLNode& node, int version, bool with_desc return 0; } -framecnt_t +framecnt_t AudioPlaylistSource::read_unlocked (Sample* dst, framepos_t start, framecnt_t cnt) const { - Sample* sbuf; - gain_t* gbuf; + boost::shared_array sbuf; + boost::shared_array gbuf; framecnt_t to_read; framecnt_t to_zero; - pair extent = _playlist->get_extent(); /* we must be careful not to read beyond the end of our "section" of * the playlist, because otherwise we may read data that exists, but @@ -149,18 +145,18 @@ AudioPlaylistSource::read_unlocked (Sample* dst, framepos_t start, framecnt_t cn to_zero = 0; } - { + { /* Don't need to hold the lock for the actual read, and actually, we cannot, but we do want to interlock with any changes to the list of buffers caused by creating new nested playlists/sources */ - Glib::Mutex::Lock lm (_level_buffer_lock); + Glib::Threads::Mutex::Lock lm (_level_buffer_lock); sbuf = _mixdown_buffers[_level-1]; gbuf = _gain_buffers[_level-1]; } - boost::dynamic_pointer_cast(_playlist)->read (dst, sbuf, gbuf, start+_playlist_offset, to_read, _playlist_channel); + boost::dynamic_pointer_cast(_playlist)->read (dst, sbuf.get(), gbuf.get(), start+_playlist_offset, to_read, _playlist_channel); if (to_zero) { memset (dst+to_read, 0, sizeof (Sample) * to_zero); @@ -169,11 +165,11 @@ AudioPlaylistSource::read_unlocked (Sample* dst, framepos_t start, framecnt_t cn return cnt; } -framecnt_t -AudioPlaylistSource::write_unlocked (Sample *src, framecnt_t cnt) +framecnt_t +AudioPlaylistSource::write_unlocked (Sample *, framecnt_t) { fatal << string_compose (_("programming error: %1"), "AudioPlaylistSource::write() called - should be impossible") << endmsg; - /*NOTREACHED*/ + abort(); /*NOTREACHED*/ return 0; } @@ -192,7 +188,7 @@ AudioPlaylistSource::n_channels () const return 1; } - boost::shared_ptr r = _playlist->region_list().front (); + boost::shared_ptr r = _playlist->region_list_property().front (); boost::shared_ptr ar = boost::dynamic_pointer_cast (r); return ar->audio_source()->n_channels (); @@ -207,7 +203,7 @@ AudioPlaylistSource::sample_rate () const _session.frame_rate (); } - boost::shared_ptr r = _playlist->region_list().front (); + boost::shared_ptr r = _playlist->region_list_property().front (); boost::shared_ptr ar = boost::dynamic_pointer_cast (r); return ar->audio_source()->sample_rate (); @@ -216,13 +212,14 @@ AudioPlaylistSource::sample_rate () const int AudioPlaylistSource::setup_peakfile () { - _peak_path = Glib::build_filename (_session.session_directory().peak_path().to_string(), name() + ARDOUR::peakfile_suffix); - return initialize_peakfile (false, string()); + _peak_path = Glib::build_filename (_session.session_directory().peak_path(), name() + ARDOUR::peakfile_suffix); + return initialize_peakfile (string()); } string -AudioPlaylistSource::peak_path (string /*audio_path_IGNORED*/) +AudioPlaylistSource::construct_peak_filepath (const string& /*audio_path_*/, const bool /* in_session */, const bool /* old_peak_name */) const { return _peak_path; } +