+void
+Source::mark_for_remove ()
+{
+ // This operation is not allowed for sources for destructive tracks or out-of-session files.
+
+ /* XXX need a way to detect _within_session() condition here - move it from FileSource?
+ */
+
+ if ((_flags & Destructive)) {
+ return;
+ }
+
+ _flags = Flag (_flags | Removable | RemoveAtDestroy);
+}
+
+void
+Source::set_timeline_position (int64_t pos)
+{
+ _timeline_position = pos;
+}
+
+void
+Source::set_allow_remove_if_empty (bool yn)
+{
+ if (!writable()) {
+ return;
+ }
+
+ if (yn) {
+ _flags = Flag (_flags | RemovableIfEmpty);
+ } else {
+ _flags = Flag (_flags & ~RemovableIfEmpty);
+ }
+}
+
+void
+Source::inc_use_count ()
+{
+ g_atomic_int_inc (&_use_count);
+}
+
+void
+Source::dec_use_count ()
+{
+#ifndef NDEBUG
+ gint oldval = g_atomic_int_exchange_and_add (&_use_count, -1);
+ if (oldval <= 0) {
+ cerr << "Bad use dec for " << name() << endl;
+ abort ();
+ }
+ assert (oldval > 0);
+#else
+ g_atomic_int_exchange_and_add (&_use_count, -1);
+#endif
+}
+
+bool
+Source::writable () const
+{
+ return (_flags & Writable) && _session.writable();
+}
+