summaryrefslogtreecommitdiff
path: root/libs/ardour/audio_diskstream.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-06-26 16:01:34 +0000
committerDavid Robillard <d@drobilla.net>2006-06-26 16:01:34 +0000
commitfe13d08874f08b723df53116e5655c3d229a657e (patch)
tree21dcf9d03415864b685c1e23cb553dcf18a3ab07 /libs/ardour/audio_diskstream.cc
parent13532c8500dce5f7a4525bcdfc3b44936fbaa5e6 (diff)
Large nasty commit in the form of a 5000 line patch chock-full of completely
unecessary changes. (Sorry, doing a "sprint" based thing, this is the end of the first one) Achieved MIDI track and bus creation, associated Jack port and diskstream creation, and minimal GUI stuff for creating them. Should be set to start work on actually recording and playing midi to/from disk now. Relevant (significant) changes: - Creation of a Buffer class. Base class is type agnostic so things can point to a buffer but not care what kind it is (otherwise it'd be a template). Derived into AudioBuffer and MidiBuffer, with a type tag because checking type is necessary in parts of the code where dynamic_cast wouldn't be wise. Originally I considered this a hack, but passing around a type proved to be a very good solution to all the other problems (below). There is a 1:1 mapping between jack port data types and ardour Buffer types (with a conversion function), but that's easily removed if it ever becomes necessary. Having the type scoped in the Buffer class is maybe not the best spot for it, but whatever (this is proof of concept kinda stuff right now...) - IO now has a "default" port type (passed to the constructor and stored as a member), used by ensure_io (and similar) to create n ports. IO::register_***_port has a type argument that defaults to the default type if not passed. Rationale: previous IO API is identical, no changes needed to existing code, but path is paved for multiple port types in one IO, which we will need for eg synth plugin inserts, among other things. This is not quite ideal (best would be to only have the two port register functions and have them take a type), but the alternative is a lot of work (namely destroying the 'ensure' functions and everything that uses them) for very little gain. (I am convinced after quite a few tries at the whiteboard that subclassing IO in any way is not a feasible option, look at it's inheritance diagram in Doxygen and you can see why) - AudioEngine::register_audio_input_port is now register_input_port and takes a type argument. Ditto for output. - (Most significant change) AudioDiskstream abstracted into Distream, and sibling MidiDiskstream created. Very much still a work in progress, but Diskstream is there to switch references over to (most already are), which is the important part. It is still unclear what the MIDI diskstream's relation to channels is, but I'm pretty sure they will be single channel only (so SMF Type 0) since noone can come up with a reason otherwise. - MidiTrack creation. Same thing as AudioTrack but with a different default type basically. No big deal here. - Random cleanups and variable renamings etc. because I have OCD and can't help myself. :) Known broken: Loading of sessions containing MIDI tracks. git-svn-id: svn://localhost/ardour2/branches/midi@641 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/audio_diskstream.cc')
-rw-r--r--libs/ardour/audio_diskstream.cc298
1 files changed, 37 insertions, 261 deletions
diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc
index 043b2a1c97..277fad0ae8 100644
--- a/libs/ardour/audio_diskstream.cc
+++ b/libs/ardour/audio_diskstream.cc
@@ -53,17 +53,16 @@
using namespace std;
using namespace ARDOUR;
+using namespace PBD;
-jack_nframes_t AudioDiskstream::disk_io_chunk_frames;
-
-sigc::signal<void,AudioDiskstream*> AudioDiskstream::AudioDiskstreamCreated;
+//sigc::signal<void,AudioDiskstream*> AudioDiskstream::AudioDiskstreamCreated;
sigc::signal<void,list<AudioFileSource*>*> AudioDiskstream::DeleteSources;
-sigc::signal<void> AudioDiskstream::DiskOverrun;
-sigc::signal<void> AudioDiskstream::DiskUnderrun;
+//sigc::signal<void> AudioDiskstream::DiskOverrun;
+//sigc::signal<void> AudioDiskstream::DiskUnderrun;
-AudioDiskstream::AudioDiskstream (Session &sess, const string &name, Flag flag)
- : _name (name),
- _session (sess)
+AudioDiskstream::AudioDiskstream (Session &sess, const string &name, Diskstream::Flag flag)
+ : Diskstream(sess, name, flag)
+ , _playlist(NULL)
{
/* prevent any write sources from being created */
@@ -74,12 +73,12 @@ AudioDiskstream::AudioDiskstream (Session &sess, const string &name, Flag flag)
in_set_state = false;
- AudioDiskstreamCreated (this); /* EMIT SIGNAL */
+ DiskstreamCreated (this); /* EMIT SIGNAL */
}
AudioDiskstream::AudioDiskstream (Session& sess, const XMLNode& node)
- : _session (sess)
-
+ : Diskstream(sess, node)
+ , _playlist(NULL)
{
in_set_state = true;
init (Recordable);
@@ -95,7 +94,7 @@ AudioDiskstream::AudioDiskstream (Session& sess, const XMLNode& node)
use_destructive_playlist ();
}
- AudioDiskstreamCreated (this); /* EMIT SIGNAL */
+ DiskstreamCreated (this); /* EMIT SIGNAL */
}
void
@@ -128,44 +127,9 @@ AudioDiskstream::init_channel (ChannelInfo &chan)
void
-AudioDiskstream::init (Flag f)
+AudioDiskstream::init (Diskstream::Flag f)
{
- _id = new_id();
- _refcnt = 0;
- _flags = f;
- _io = 0;
- _alignment_style = ExistingMaterial;
- _persistent_alignment_style = ExistingMaterial;
- first_input_change = true;
- _playlist = 0;
- i_am_the_modifier = 0;
- g_atomic_int_set (&_record_enabled, 0);
- was_recording = false;
- capture_start_frame = 0;
- capture_captured = 0;
- _visible_speed = 1.0f;
- _actual_speed = 1.0f;
- _buffer_reallocation_required = false;
- _seek_required = false;
- first_recordable_frame = max_frames;
- last_recordable_frame = max_frames;
- _roll_delay = 0;
- _capture_offset = 0;
- _processed = false;
- _slaved = false;
- adjust_capture_position = 0;
- last_possibly_recording = 0;
- loop_location = 0;
- wrap_buffer_size = 0;
- speed_buffer_size = 0;
- last_phase = 0;
- phi = (uint64_t) (0x1000000);
- file_frame = 0;
- playback_sample = 0;
- playback_distance = 0;
- _read_data_count = 0;
- _write_data_count = 0;
- deprecated_io_node = 0;
+ Diskstream::init(f);
/* there are no channels at this point, so these
two calls just get speed_buffer_size and wrap_buffer
@@ -215,9 +179,8 @@ AudioDiskstream::~AudioDiskstream ()
{
Glib::Mutex::Lock lm (state_lock);
- if (_playlist) {
+ if (_playlist)
_playlist->unref ();
- }
for (ChannelList::iterator chan = channels.begin(); chan != channels.end(); ++chan) {
destroy_channel((*chan));
@@ -225,7 +188,7 @@ AudioDiskstream::~AudioDiskstream ()
channels.clear();
}
-
+/*
void
AudioDiskstream::handle_input_change (IOChange change, void *src)
{
@@ -236,7 +199,7 @@ AudioDiskstream::handle_input_change (IOChange change, void *src)
_session.request_input_change_handling ();
}
}
-
+*/
void
AudioDiskstream::non_realtime_input_change ()
{
@@ -346,8 +309,10 @@ AudioDiskstream::find_and_use_playlist (const string& name)
}
int
-AudioDiskstream::use_playlist (AudioPlaylist* playlist)
+AudioDiskstream::use_playlist (Playlist* playlist)
{
+ assert(dynamic_cast<AudioPlaylist*>(playlist));
+
{
Glib::Mutex::Lock lm (state_lock);
@@ -363,7 +328,7 @@ AudioDiskstream::use_playlist (AudioPlaylist* playlist)
_playlist->unref();
}
- _playlist = playlist;
+ _playlist = dynamic_cast<AudioPlaylist*>(playlist);
_playlist->ref();
if (!in_set_state && recordable()) {
@@ -386,17 +351,6 @@ AudioDiskstream::use_playlist (AudioPlaylist* playlist)
return 0;
}
-void
-AudioDiskstream::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
AudioDiskstream::use_new_playlist ()
{
@@ -446,6 +400,19 @@ AudioDiskstream::use_copy_playlist ()
}
}
+
+void
+AudioDiskstream::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;
+}
+
+
void
AudioDiskstream::setup_destructive_playlist ()
{
@@ -499,67 +466,6 @@ AudioDiskstream::set_io (IO& io)
set_align_style_from_io ();
}
-int
-AudioDiskstream::set_name (string str, void *src)
-{
- if (str != _name) {
- _playlist->set_name (str);
- _name = str;
-
- if (!in_set_state && recordable()) {
- /* rename existing capture files so that they have the correct name */
- return rename_write_sources ();
- } else {
- return -1;
- }
- }
-
- return 0;
-}
-
-void
-AudioDiskstream::set_speed (double sp)
-{
- _session.request_diskstream_speed (*this, sp);
-
- /* to force a rebuffering at the right place */
- playlist_modified();
-}
-
-bool
-AudioDiskstream::realtime_set_speed (double sp, bool global)
-{
- bool changed = false;
- double new_speed = sp * _session.transport_speed();
-
- if (_visible_speed != sp) {
- _visible_speed = sp;
- changed = true;
- }
-
- if (new_speed != _actual_speed) {
-
- jack_nframes_t required_wrap_size = (jack_nframes_t) floor (_session.get_block_size() *
- fabs (new_speed)) + 1;
-
- if (required_wrap_size > wrap_buffer_size) {
- _buffer_reallocation_required = true;
- }
-
- _actual_speed = new_speed;
- phi = (uint64_t) (0x1000000 * fabs(_actual_speed));
- }
-
- if (changed) {
- if (!global) {
- _seek_required = true;
- }
- speed_changed (); /* EMIT SIGNAL */
- }
-
- return _buffer_reallocation_required || _seek_required;
-}
-
void
AudioDiskstream::non_realtime_set_speed ()
{
@@ -584,13 +490,6 @@ AudioDiskstream::non_realtime_set_speed ()
}
void
-AudioDiskstream::prepare ()
-{
- _processed = false;
- playback_distance = 0;
-}
-
-void
AudioDiskstream::check_record_status (jack_nframes_t transport_frame, jack_nframes_t nframes, bool can_record)
{
int possibly_recording;
@@ -1009,13 +908,6 @@ AudioDiskstream::process (jack_nframes_t transport_frame, jack_nframes_t nframes
return ret;
}
-void
-AudioDiskstream::recover ()
-{
- state_lock.unlock();
- _processed = false;
-}
-
bool
AudioDiskstream::commit (jack_nframes_t nframes)
{
@@ -1155,9 +1047,9 @@ AudioDiskstream::seek (jack_nframes_t frame, bool complete_refill)
file_frame = frame;
if (complete_refill) {
- while ((ret = do_refill (0, 0, 0)) > 0);
+ while ((ret = non_realtime_do_refill ()) > 0);
} else {
- ret = do_refill (0, 0, 0);
+ ret = non_realtime_do_refill ();
}
return ret;
@@ -1650,21 +1542,6 @@ AudioDiskstream::do_flush (char * workbuf, bool force_flush)
}
void
-AudioDiskstream::playlist_changed (Change ignored)
-{
- playlist_modified ();
-}
-
-void
-AudioDiskstream::playlist_modified ()
-{
- if (!i_am_the_modifier && !overwrite_queued) {
- _session.request_overwrite_buffer (this);
- overwrite_queued = true;
- }
-}
-
-void
AudioDiskstream::transport_stopped (struct tm& when, time_t twhen, bool abort_capture)
{
uint32_t buffer_position;
@@ -1898,7 +1775,7 @@ AudioDiskstream::finish_capture (bool rec_monitors_input)
void
AudioDiskstream::set_record_enabled (bool yn, void* src)
{
- bool rolling = _session.transport_speed() != 0.0f;
+ bool rolling = _session.transport_speed() != 0.0f;
if (!recordable() || !_session.record_enabling_legal()) {
return;
@@ -1958,7 +1835,7 @@ XMLNode&
AudioDiskstream::get_state ()
{
XMLNode* node = new XMLNode ("AudioDiskstream");
- char buf[64];
+ char buf[64] = "";
LocaleGuard lg (X_("POSIX"));
snprintf (buf, sizeof(buf), "0x%x", _flags);
@@ -2289,23 +2166,6 @@ AudioDiskstream::monitor_input (bool yn)
}
void
-AudioDiskstream::set_capture_offset ()
-{
- if (_io == 0) {
- /* can't capture, so forget it */
- return;
- }
-
- _capture_offset = _io->input_latency();
-}
-
-void
-AudioDiskstream::set_persistent_align_style (AlignStyle a)
-{
- _persistent_alignment_style = a;
-}
-
-void
AudioDiskstream::set_align_style_from_io ()
{
bool have_physical = false;
@@ -2330,20 +2190,6 @@ AudioDiskstream::set_align_style_from_io ()
}
}
-void
-AudioDiskstream::set_align_style (AlignStyle a)
-{
- if (record_enabled() && _session.actively_recording()) {
- return;
- }
-
-
- if (a != _alignment_style) {
- _alignment_style = a;
- AlignmentStyleChanged ();
- }
-}
-
int
AudioDiskstream::add_channel ()
{
@@ -2394,57 +2240,6 @@ AudioDiskstream::capture_buffer_load () const
(double) channels.front().capture_buf->bufsize());
}
-int
-AudioDiskstream::set_loop (Location *location)
-{
- if (location) {
- if (location->start() >= location->end()) {
- error << string_compose(_("Location \"%1\" not valid for track loop (start >= end)"), location->name()) << endl;
- return -1;
- }
- }
-
- loop_location = location;
-
- LoopSet (location); /* EMIT SIGNAL */
- return 0;
-}
-
-jack_nframes_t
-AudioDiskstream::get_capture_start_frame (uint32_t n)
-{
- Glib::Mutex::Lock lm (capture_info_lock);
-
- if (capture_info.size() > n) {
- return capture_info[n]->start;
- }
- else {
- return capture_start_frame;
- }
-}
-
-jack_nframes_t
-AudioDiskstream::get_captured_frames (uint32_t n)
-{
- Glib::Mutex::Lock lm (capture_info_lock);
-
- if (capture_info.size() > n) {
- return capture_info[n]->frames;
- }
- else {
- return capture_captured;
- }
-}
-
-void
-AudioDiskstream::punch_in ()
-{
-}
-
-void
-AudioDiskstream::punch_out ()
-{
-}
int
AudioDiskstream::use_pending_capture_data (XMLNode& node)
@@ -2541,22 +2336,3 @@ AudioDiskstream::use_pending_capture_data (XMLNode& node)
return 0;
}
-
-void
-AudioDiskstream::set_roll_delay (jack_nframes_t nframes)
-{
- _roll_delay = nframes;
-}
-
-void
-AudioDiskstream::set_destructive (bool yn)
-{
- if (yn != destructive()) {
- reset_write_sources (true, true);
- if (yn) {
- _flags |= Destructive;
- } else {
- _flags &= ~Destructive;
- }
- }
-}