diff options
author | David Robillard <d@drobilla.net> | 2006-07-30 03:25:38 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-07-30 03:25:38 +0000 |
commit | 9d5d82b4df5b3510177fd31557ac765f46778fe8 (patch) | |
tree | b0b786f4f8fcee4e76c7c3ab1a66f603c08de070 /libs/ardour/diskstream.cc | |
parent | 8277d134b9733aee344782891c99f07114384d9e (diff) |
Abstraction cleanups/polish, towards merging with trunk
git-svn-id: svn://localhost/ardour2/branches/midi@720 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/diskstream.cc')
-rw-r--r-- | libs/ardour/diskstream.cc | 112 |
1 files changed, 89 insertions, 23 deletions
diff --git a/libs/ardour/diskstream.cc b/libs/ardour/diskstream.cc index 4e2bec9850..9fc2ded0ce 100644 --- a/libs/ardour/diskstream.cc +++ b/libs/ardour/diskstream.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2003 Paul Davis + Copyright (C) 2000-2006 Paul Davis 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 @@ -55,7 +55,7 @@ using namespace std; using namespace ARDOUR; using namespace PBD; -jack_nframes_t Diskstream::disk_io_chunk_frames; +jack_nframes_t Diskstream::disk_io_chunk_frames = 0; sigc::signal<void,Diskstream*> Diskstream::DiskstreamCreated; //sigc::signal<void,list<AudioFileSource*>*> Diskstream::DeleteSources; @@ -65,13 +65,14 @@ sigc::signal<void> Diskstream::DiskUnderrun; Diskstream::Diskstream (Session &sess, const string &name, Flag flag) : _name (name) , _session (sess) + , _playlist(NULL) { init (flag); } Diskstream::Diskstream (Session& sess, const XMLNode& node) : _session (sess) - + , _playlist(NULL) { init (Recordable); } @@ -113,37 +114,28 @@ Diskstream::init (Flag f) _read_data_count = 0; _write_data_count = 0; - /* there are no channels at this point, so these - two calls just get speed_buffer_size and wrap_buffer - size setup without duplicating their code. - */ - - //set_block_size (_session.get_block_size()); - //allocate_temporary_buffers (); - pending_overwrite = false; overwrite_frame = 0; overwrite_queued = false; input_change_pending = NoChange; - //add_channel (); - _n_channels = 0;//1; + _n_channels = 0; } Diskstream::~Diskstream () { - // Taken by child.. assure lock? + // Taken by derived class destrctors.. assure lock? //Glib::Mutex::Lock lm (state_lock); - //if (_playlist) { - // _playlist->unref (); - //} + if (_playlist) + _playlist->unref (); +} - //for (ChannelList::iterator chan = channels.begin(); chan != channels.end(); ++chan) { - // destroy_channel((*chan)); - //} - - //channels.clear(); +void +Diskstream::set_io (IO& io) +{ + _io = &io; + set_align_style_from_io (); } void @@ -157,6 +149,29 @@ Diskstream::handle_input_change (IOChange change, void *src) } } +void +Diskstream::non_realtime_set_speed () +{ + if (_buffer_reallocation_required) + { + Glib::Mutex::Lock lm (state_lock); + allocate_temporary_buffers (); + + _buffer_reallocation_required = false; + } + + if (_seek_required) { + if (speed() != 1.0f || speed() != -1.0f) { + seek ((jack_nframes_t) (_session.transport_frame() * (double) speed()), true); + } + else { + seek (_session.transport_frame(), true); + } + + _seek_required = false; + } +} + bool Diskstream::realtime_set_speed (double sp, bool global) { @@ -223,7 +238,6 @@ Diskstream::set_align_style (AlignStyle a) return; } - if (a != _alignment_style) { _alignment_style = a; AlignmentStyleChanged (); @@ -287,6 +301,47 @@ Diskstream::set_speed (double sp) playlist_modified(); } +int +Diskstream::use_playlist (Playlist* playlist) +{ + { + Glib::Mutex::Lock lm (state_lock); + + if (playlist == _playlist) { + return 0; + } + + plstate_connection.disconnect(); + plmod_connection.disconnect (); + plgone_connection.disconnect (); + + if (_playlist) { + _playlist->unref(); + } + + _playlist = playlist; + _playlist->ref(); + + if (!in_set_state && recordable()) { + reset_write_sources (false); + } + + plstate_connection = _playlist->StateChanged.connect (mem_fun (*this, &Diskstream::playlist_changed)); + plmod_connection = _playlist->Modified.connect (mem_fun (*this, &Diskstream::playlist_modified)); + plgone_connection = _playlist->GoingAway.connect (mem_fun (*this, &Diskstream::playlist_deleted)); + } + + if (!overwrite_queued) { + _session.request_overwrite_buffer (this); + overwrite_queued = true; + } + + PlaylistChanged (); /* EMIT SIGNAL */ + _session.set_dirty (); + + return 0; +} + void Diskstream::playlist_changed (Change ignored) { @@ -302,6 +357,17 @@ Diskstream::playlist_modified () } } +void +Diskstream::playlist_deleted (Playlist* pl) +{ + /* this catches an ordering issue with session destruction. playlists + are destroyed before diskstreams. we have to invalidate any handles + we have to the playlist. + */ + + _playlist = 0; +} + int Diskstream::set_name (string str, void *src) { |