X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Faudio_playlist_source.cc;h=7cc00a855f90e2c7030f1eca451341c58f48f5b1;hb=dfbda9e0f6d5003ba2ba05b21c6045f4ad1109fa;hp=141a8495f9eb75b326e1244615ed03e3db37ca2f;hpb=0938a42440cc82ce8d0cb064840c258c863714ab;p=ardour.git diff --git a/libs/ardour/audio_playlist_source.cc b/libs/ardour/audio_playlist_source.cc index 141a8495f9..7cc00a855f 100644 --- a/libs/ardour/audio_playlist_source.cc +++ b/libs/ardour/audio_playlist_source.cc @@ -27,34 +27,29 @@ #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" +#include "pbd/i18n.h" using namespace std; using namespace ARDOUR; using namespace PBD; 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) + uint32_t chn, sampleoffset_t begin, samplecnt_t len, Source::Flag flags) : Source (s, DataType::AUDIO, name) , PlaylistSource (s, orig, name, p, DataType::AUDIO, begin, len, flags) , AudioSource (s, name) , _playlist_channel (chn) { AudioSource::_length = len; - ensure_buffers_for_level (_level, _session.frame_rate()); + ensure_buffers_for_level (_level, _session.sample_rate()); } AudioPlaylistSource::AudioPlaylistSource (Session& s, const XMLNode& node) @@ -84,14 +79,12 @@ XMLNode& AudioPlaylistSource::get_state () { XMLNode& node (AudioSource::get_state ()); - char buf[64]; /* merge PlaylistSource state */ PlaylistSource::add_state (node); - snprintf (buf, sizeof (buf), "%" PRIu32, _playlist_channel); - node.add_property ("channel", buf); + node.set_property ("channel", _playlist_channel); return node; } @@ -113,29 +106,26 @@ AudioPlaylistSource::set_state (const XMLNode& node, int version, bool with_desc } } - const XMLProperty* prop; - pair extent = _playlist->get_extent(); + pair extent = _playlist->get_extent(); AudioSource::_length = extent.second - extent.first; - if ((prop = node.property (X_("channel"))) == 0) { + if (!node.get_property (X_("channel"), _playlist_channel)) { throw failed_constructor (); } - sscanf (prop->value().c_str(), "%" PRIu32, &_playlist_channel); - - ensure_buffers_for_level (_level, _session.frame_rate()); + ensure_buffers_for_level (_level, _session.sample_rate()); return 0; } -framecnt_t -AudioPlaylistSource::read_unlocked (Sample* dst, framepos_t start, framecnt_t cnt) const +samplecnt_t +AudioPlaylistSource::read_unlocked (Sample* dst, samplepos_t start, samplecnt_t cnt) const { - boost::shared_ptr sbuf; - boost::shared_ptr gbuf; - framecnt_t to_read; - framecnt_t to_zero; + boost::shared_array sbuf; + boost::shared_array gbuf; + samplecnt_t to_read; + samplecnt_t to_zero; /* 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 @@ -156,7 +146,7 @@ AudioPlaylistSource::read_unlocked (Sample* dst, framepos_t start, framecnt_t cn 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]; } @@ -170,11 +160,11 @@ AudioPlaylistSource::read_unlocked (Sample* dst, framepos_t start, framecnt_t cn return cnt; } -framecnt_t -AudioPlaylistSource::write_unlocked (Sample *, framecnt_t) +samplecnt_t +AudioPlaylistSource::write_unlocked (Sample *, samplecnt_t) { fatal << string_compose (_("programming error: %1"), "AudioPlaylistSource::write() called - should be impossible") << endmsg; - /*NOTREACHED*/ + abort(); /*NOTREACHED*/ return 0; } @@ -193,7 +183,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 (); @@ -205,10 +195,10 @@ AudioPlaylistSource::sample_rate () const /* use just the first region to decide */ if (empty()) { - _session.frame_rate (); + _session.sample_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 (); @@ -217,12 +207,12 @@ 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; }