diff options
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/session.h | 7 | ||||
-rw-r--r-- | libs/ardour/audioengine.cc | 10 | ||||
-rw-r--r-- | libs/ardour/audiosource.cc | 53 | ||||
-rw-r--r-- | libs/ardour/control_protocol_manager.cc | 2 | ||||
-rw-r--r-- | libs/ardour/session.cc | 6 | ||||
-rw-r--r-- | libs/ardour/session_command.cc | 10 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 22 |
7 files changed, 85 insertions, 25 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 253cd28b7f..3ea443d9ef 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -242,6 +242,7 @@ class Session : public PBD::StatefulDestructible void set_dirty (); void set_clean (); bool dirty() const { return _state_of_the_state & Dirty; } + void set_deletion_in_progress (); bool deletion_in_progress() const { return _state_of_the_state & Deletion; } sigc::signal<void> DirtyChanged; @@ -762,8 +763,10 @@ class Session : public PBD::StatefulDestructible std::map<PBD::ID, PBD::StatefulThingWithGoingAway*> registry; // these commands are implemented in libs/ardour/session_command.cc - Command *memento_command_factory(XMLNode *n); - void register_with_memento_command_factory(PBD::ID, PBD::StatefulThingWithGoingAway *); + Command* memento_command_factory(XMLNode* n); + void register_with_memento_command_factory(PBD::ID, PBD::StatefulThingWithGoingAway*); + + Command* global_state_command_factory (XMLNode* n); class GlobalSoloStateCommand : public Command { diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index e68dc718d9..b68235171f 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -156,6 +156,7 @@ AudioEngine::stop (bool forever) jack_client_t* foo = _jack; _jack = 0; jack_client_close (foo); + stop_metering_thread (); } else { jack_deactivate (_jack); } @@ -379,9 +380,9 @@ AudioEngine::stop_metering_thread () { if (m_meter_thread) { g_atomic_int_set (&m_meter_exit, 1); + m_meter_thread->join (); + m_meter_thread = 0; } - m_meter_thread->join (); - m_meter_thread = 0; } void @@ -395,8 +396,11 @@ AudioEngine::start_metering_thread () void AudioEngine::meter_thread () { - while (g_atomic_int_get(&m_meter_exit) != true) { + while (true) { Glib::usleep (10000); /* 1/100th sec interval */ + if (g_atomic_int_get(&m_meter_exit)) { + break; + } IO::update_meters (); } } diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index a8d8929812..cc6d156c9c 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -35,6 +35,7 @@ #include <pbd/pthread_utils.h> #include <ardour/audiosource.h> +#include <ardour/cycle_timer.h> #include "i18n.h" @@ -431,7 +432,8 @@ AudioSource::read_peaks (PeakData *peaks, nframes_t npeaks, nframes_t start, nfr expected_peaks = (cnt / (double) frames_per_peak); scale = npeaks/expected_peaks; -#if 0 +#undef DEBUG_READ_PEAKS +#ifdef DEBUG_READ_PEAKS cerr << "======>RP: npeaks = " << npeaks << " start = " << start << " cnt = " << cnt @@ -457,8 +459,9 @@ AudioSource::read_peaks (PeakData *peaks, nframes_t npeaks, nframes_t start, nfr if (npeaks == cnt) { +#ifdef DEBUG_READ_PEAKS cerr << "RAW DATA\n"; - +#endif /* no scaling at all, just get the sample data and duplicate it for both max and min peak values. */ @@ -490,7 +493,9 @@ AudioSource::read_peaks (PeakData *peaks, nframes_t npeaks, nframes_t start, nfr return -1; } - // cerr << "DIRECT PEAKS\n"; +#ifdef DEBUG_READ_PEAKS + cerr << "DIRECT PEAKS\n"; +#endif nread = ::pread (peakfile, peaks, sizeof (PeakData)* npeaks, first_peak_byte); close (peakfile); @@ -523,8 +528,9 @@ AudioSource::read_peaks (PeakData *peaks, nframes_t npeaks, nframes_t start, nfr if (scale < 1.0) { - // cerr << "DOWNSAMPLE\n"; - +#ifdef DEBUG_READ_PEAKS + cerr << "DOWNSAMPLE\n"; +#endif /* the caller wants: - more frames-per-peak (lower resolution) than the peakfile, or to put it another way, @@ -535,7 +541,7 @@ AudioSource::read_peaks (PeakData *peaks, nframes_t npeaks, nframes_t start, nfr to avoid confusion, I'll refer to the requested peaks as visual_peaks and the peakfile peaks as stored_peaks */ - const uint32_t chunksize = (uint32_t) min (expected_peaks, 4096.0); + const uint32_t chunksize = (uint32_t) min (expected_peaks, 65536.0); staging = new PeakData[chunksize]; @@ -569,10 +575,15 @@ AudioSource::read_peaks (PeakData *peaks, nframes_t npeaks, nframes_t start, nfr tnp = min ((_length/frames_per_peak - current_stored_peak), (nframes_t) expected_peaks); to_read = min (chunksize, tnp); - off_t fend = lseek (peakfile, 0, SEEK_END); +#ifdef DEBUG_READ_PEAKS + cerr << "read " << sizeof (PeakData) * to_read << " from peakfile @ " << start_byte << endl; +#endif if ((nread = ::pread (peakfile, staging, sizeof (PeakData) * to_read, start_byte)) != sizeof (PeakData) * to_read) { + + off_t fend = lseek (peakfile, 0, SEEK_END); + cerr << "AudioSource[" << _name << "]: cannot read peak data from peakfile (" @@ -589,11 +600,11 @@ AudioSource::read_peaks (PeakData *peaks, nframes_t npeaks, nframes_t start, nfr << endl; goto out; } - + i = 0; stored_peaks_read = nread / sizeof(PeakData); } - + xmax = -1.0; xmin = 1.0; @@ -624,8 +635,9 @@ AudioSource::read_peaks (PeakData *peaks, nframes_t npeaks, nframes_t start, nfr } else { - // cerr << "UPSAMPLE\n"; - +#ifdef DEBUG_READ_PEAKS + cerr << "UPSAMPLE\n"; +#endif /* the caller wants - less frames-per-peak (more resolution) @@ -704,6 +716,10 @@ AudioSource::read_peaks (PeakData *peaks, nframes_t npeaks, nframes_t start, nfr delete [] raw_staging; } +#ifdef DEBUG_READ_PEAKS + cerr << "RP DONE\n"; +#endif + return ret; } @@ -777,6 +793,7 @@ AudioSource::do_build_peak (nframes_t first_frame, nframes_t cnt) off_t first_peak_byte; int peakfile = -1; int ret = -1; + off_t target_length; #ifdef DEBUG_PEAK_BUILD cerr << pthread_self() << ": " << _name << ": building peaks for " << first_frame << " to " << first_frame + cnt - 1 << endl; @@ -828,6 +845,20 @@ AudioSource::do_build_peak (nframes_t first_frame, nframes_t cnt) cnt -= frames_read; } +#define BLOCKSIZE (256 * 1024) + + target_length = BLOCKSIZE * ((first_peak_byte + BLOCKSIZE + 1) / BLOCKSIZE); + + /* on some filesystems (ext3, at least) this helps to reduce fragmentation of + the peakfiles. its not guaranteed to do so, and even on ext3 (as of december 2006) + it does not cause single-extent allocation even for peakfiles of + less than BLOCKSIZE bytes. + */ + + ftruncate (peakfile, target_length); + + /* error doesn't actually matter though, so continue on without testing */ + if (::pwrite (peakfile, peakbuf, sizeof (PeakData) * peaki, first_peak_byte) != (ssize_t) (sizeof (PeakData) * peaki)) { error << string_compose(_("%1: could not write peak file data (%2)"), _name, strerror (errno)) << endmsg; goto out; diff --git a/libs/ardour/control_protocol_manager.cc b/libs/ardour/control_protocol_manager.cc index a715254747..495a66465e 100644 --- a/libs/ardour/control_protocol_manager.cc +++ b/libs/ardour/control_protocol_manager.cc @@ -180,7 +180,7 @@ ControlProtocolManager::discover_control_protocols (string path) vector<string *> *found; PathScanner scanner; - info << string_compose (_("looking for control protocols in %1"), path) << endmsg; + // info << string_compose (_("looking for control protocols in %1"), path) << endmsg; found = scanner (path, protocol_filter, 0, false, true); diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 86770939da..932db17909 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -831,10 +831,6 @@ Session::when_engine_running () } } - - /* its safe to do this now */ - - restore_history (snap_name()); _state_of_the_state = StateOfTheState (_state_of_the_state & ~(CannotSave|Dirty)); @@ -861,7 +857,6 @@ Session::hookup_io () */ _state_of_the_state = StateOfTheState (_state_of_the_state | InitialConnecting); - cerr << "InitialConnecting set\n"; if (auditioner == 0) { @@ -917,7 +912,6 @@ Session::hookup_io () IOConnectionsComplete (); /* EMIT SIGNAL */ _state_of_the_state = StateOfTheState (_state_of_the_state & ~InitialConnecting); - cerr << "InitialConnectingUN set\n"; /* now handle the whole enchilada as if it was one graph reorder event. diff --git a/libs/ardour/session_command.cc b/libs/ardour/session_command.cc index 06ed44f722..022aa43145 100644 --- a/libs/ardour/session_command.cc +++ b/libs/ardour/session_command.cc @@ -22,7 +22,8 @@ void Session::register_with_memento_command_factory(PBD::ID id, PBD::StatefulThi registry[id] = ptr; } -Command *Session::memento_command_factory(XMLNode *n) +Command * +Session::memento_command_factory(XMLNode *n) { PBD::ID id; XMLNode *before = 0, *after = 0; @@ -87,6 +88,13 @@ Command *Session::memento_command_factory(XMLNode *n) return 0 ; } +Command * +Session::global_state_command_factory(XMLNode *n) +{ + error << string_compose (_("cannot reconstitute %1 from XML yet, ignored"), n->name()) << endmsg; + return 0 ; +} + // solo Session::GlobalSoloStateCommand::GlobalSoloStateCommand(Session &sess, void *src) : sess(sess), src(src) diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 55f2e4be29..cbc363a203 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -1218,7 +1218,6 @@ Session::set_state (const XMLNode& node) StateReady (); /* EMIT SIGNAL */ _state_of_the_state = Clean; - cerr << "session marked clean\n"; if (state_was_pending) { save_state (_current_snapshot_name); @@ -2818,6 +2817,12 @@ Session::set_clean () } void +Session::set_deletion_in_progress () +{ + _state_of_the_state = StateOfTheState (_state_of_the_state | Deletion); +} + +void Session::add_controllable (Controllable* c) { Glib::Mutex::Lock lm (controllables_lock); @@ -2917,6 +2922,10 @@ Session::restore_history (string snapshot_name) XMLTree tree; string xmlpath; + if (snapshot_name.empty()) { + snapshot_name = _current_snapshot_name; + } + /* read xml */ xmlpath = _path + snapshot_name + ".history"; cerr << string_compose(_("Loading history from '%1'."), xmlpath) << endmsg; @@ -2957,10 +2966,21 @@ Session::restore_history (string snapshot_name) if (n->name() == "MementoCommand" || n->name() == "MementoUndoCommand" || n->name() == "MementoRedoCommand") { + if ((c = memento_command_factory(n))) { ut->add_command(c); } + + } else if (n->name() == "GlobalRecordEnableStateCommand" || + n->name() == "GlobalSoloStateCommand" || + n->name() == "GlobalMuteStateCommand") { + + if ((c = global_state_command_factory (n))) { + ut->add_command (c); + } + } else { + error << string_compose(_("Couldn't figure out how to make a Command out of a %1 XMLNode."), n->name()) << endmsg; } } |