diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2015-09-30 12:58:36 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-09-30 13:02:58 -0400 |
commit | 2cf779fd0c6f581df1a258696e83255cf7cd65ac (patch) | |
tree | 2ce038f96a550be2325423634d0f35065f0329b3 /libs/ardour | |
parent | 48b904fceef1ac593d272c7588efa39facc786c8 (diff) |
split Butler::flush_tracks_to_disk() into two distinct versions with clear names and make one of them private
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/butler.h | 4 | ||||
-rw-r--r-- | libs/ardour/butler.cc | 64 |
2 files changed, 58 insertions, 10 deletions
diff --git a/libs/ardour/ardour/butler.h b/libs/ardour/ardour/butler.h index 3a2d8090d5..7a74fef6d1 100644 --- a/libs/ardour/ardour/butler.h +++ b/libs/ardour/ardour/butler.h @@ -67,7 +67,7 @@ class LIBARDOUR_API Butler : public SessionHandleRef framecnt_t audio_diskstream_playback_buffer_size() const { return audio_dstream_playback_buffer_size; } uint32_t midi_diskstream_buffer_size() const { return midi_dstream_buffer_size; } - bool flush_tracks_to_disk (boost::shared_ptr<RouteList>, uint32_t& errors, bool force_flush); + bool flush_tracks_to_disk_after_locate (boost::shared_ptr<RouteList>, uint32_t& errors); static void* _thread_work(void *arg); void* thread_work(); @@ -95,6 +95,8 @@ private: void empty_pool_trash (); void config_changed (std::string); + bool flush_tracks_to_disk_normal (boost::shared_ptr<RouteList>, uint32_t& errors); + /** * Add request to butler thread request queue */ diff --git a/libs/ardour/butler.cc b/libs/ardour/butler.cc index 8542f5e0cb..f97a99fed2 100644 --- a/libs/ardour/butler.cc +++ b/libs/ardour/butler.cc @@ -268,7 +268,7 @@ Butler::thread_work () goto restart; } - disk_work_outstanding = flush_tracks_to_disk (rl, err, false); + disk_work_outstanding = flush_tracks_to_disk_normal (rl, err); if (err && _session.actively_recording()) { /* stop the transport and try to catch as much possible @@ -308,11 +308,60 @@ Butler::thread_work () } bool -Butler::flush_tracks_to_disk (boost::shared_ptr<RouteList> rl, uint32_t& errors, bool force) +Butler::flush_tracks_to_disk_normal (boost::shared_ptr<RouteList> rl, uint32_t& errors) { bool disk_work_outstanding = false; - for (RouteList::iterator i = rl->begin(); (force || !transport_work_requested()) && should_run && i != rl->end(); ++i) { + for (RouteList::iterator i = rl->begin(); !transport_work_requested() && should_run && i != rl->end(); ++i) { + + // cerr << "write behind for " << (*i)->name () << endl; + + boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i); + + if (!tr) { + continue; + } + + /* note that we still try to flush diskstreams attached to inactive routes + */ + + int ret; + + DEBUG_TRACE (DEBUG::Butler, string_compose ("butler flushes track %1 capture load %2\n", tr->name(), tr->capture_buffer_load())); + ret = tr->do_flush (ButlerContext, false); + switch (ret) { + case 0: + DEBUG_TRACE (DEBUG::Butler, string_compose ("\tflush complete for %1\n", tr->name())); + break; + + case 1: + DEBUG_TRACE (DEBUG::Butler, string_compose ("\tflush not finished for %1\n", tr->name())); + disk_work_outstanding = true; + break; + + default: + errors++; + error << string_compose(_("Butler write-behind failure on dstream %1"), (*i)->name()) << endmsg; + std::cerr << string_compose(_("Butler write-behind failure on dstream %1"), (*i)->name()) << std::endl; + /* don't break - try to flush all streams in case they + are split across disks. + */ + } + } + + return disk_work_outstanding; +} + +bool +Butler::flush_tracks_to_disk_after_locate (boost::shared_ptr<RouteList> rl, uint32_t& errors) +{ + bool disk_work_outstanding = false; + + /* almost the same as the "normal" version except that we do not test + * for transport_work_requested() and we force flushes. + */ + + for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) { // cerr << "write behind for " << (*i)->name () << endl; @@ -325,20 +374,17 @@ Butler::flush_tracks_to_disk (boost::shared_ptr<RouteList> rl, uint32_t& errors, /* note that we still try to flush diskstreams attached to inactive routes */ - gint64 before, after; int ret; DEBUG_TRACE (DEBUG::Butler, string_compose ("butler flushes track %1 capture load %2\n", tr->name(), tr->capture_buffer_load())); - before = g_get_monotonic_time (); - ret = tr->do_flush (ButlerContext, force); - after = g_get_monotonic_time (); + ret = tr->do_flush (ButlerContext, true); switch (ret) { case 0: - DEBUG_TRACE (DEBUG::Butler, string_compose ("\tflush complete for %1, %2 usecs\n", tr->name(), after - before)); + DEBUG_TRACE (DEBUG::Butler, string_compose ("\tflush complete for %1\n", tr->name())); break; case 1: - DEBUG_TRACE (DEBUG::Butler, string_compose ("\tflush not finished for %1, %2 usecs\n", tr->name(), after - before)); + DEBUG_TRACE (DEBUG::Butler, string_compose ("\tflush not finished for %1\n", tr->name())); disk_work_outstanding = true; break; |