summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-04-04 12:21:26 +0000
committerCarl Hetherington <carl@carlh.net>2011-04-04 12:21:26 +0000
commit02cfe41bff57712e59f7169037d694a3dd6a1420 (patch)
tree02d58170bfc5567caff21b8a6b08e66cd9f790dc /gtk2_ardour
parentb850f5846799ce416b3203a4ee585f5d925ef066 (diff)
Update region peak amplitude when the region is trimmed (#3931).
git-svn-id: svn://localhost/ardour2/branches/3.0@9276 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/audio_region_editor.cc19
-rw-r--r--gtk2_ardour/audio_region_editor.h3
2 files changed, 18 insertions, 4 deletions
diff --git a/gtk2_ardour/audio_region_editor.cc b/gtk2_ardour/audio_region_editor.cc
index e47f145c7e..806659b52c 100644
--- a/gtk2_ardour/audio_region_editor.cc
+++ b/gtk2_ardour/audio_region_editor.cc
@@ -53,8 +53,8 @@ _peak_amplitude_thread (void* arg)
AudioRegionEditor::AudioRegionEditor (Session* s, boost::shared_ptr<AudioRegion> r)
: RegionEditor (s, r)
, _audio_region (r)
- , gain_adjustment(accurate_coefficient_to_dB(_audio_region->scale_amplitude()), -40.0, +40.0, 0.1, 1.0, 0)
- , _peak_amplitude_found (false)
+ , gain_adjustment(accurate_coefficient_to_dB(_audio_region->scale_amplitude()), -40.0, +40.0, 0.1, 1.0, 0)
+ , _peak_channel (false)
{
Gtk::HBox* b = Gtk::manage (new Gtk::HBox);
@@ -91,6 +91,7 @@ AudioRegionEditor::AudioRegionEditor (Session* s, boost::shared_ptr<AudioRegion>
PeakAmplitudeFound.connect (_peak_amplitude_connection, invalidator (*this), boost::bind (&AudioRegionEditor::peak_amplitude_found, this, _1), gui_context ());
pthread_create_and_store (X_("peak-amplitude"), &_peak_amplitude_thread_handle, _peak_amplitude_thread, this);
+ _peak_channel.deliver ('c');
}
AudioRegionEditor::~AudioRegionEditor ()
@@ -109,6 +110,11 @@ AudioRegionEditor::region_changed (const PBD::PropertyChange& what_changed)
if (what_changed.contains (ARDOUR::Properties::scale_amplitude)) {
gain_changed ();
}
+
+ if (what_changed.contains (ARDOUR::Properties::start) || what_changed.contains (ARDOUR::Properties::length)) {
+ /* ask the peak thread to run again */
+ _peak_channel.deliver ('c');
+ }
}
void
AudioRegionEditor::gain_changed ()
@@ -131,7 +137,14 @@ AudioRegionEditor::gain_adjustment_changed ()
void
AudioRegionEditor::peak_amplitude_thread ()
{
- PeakAmplitudeFound (accurate_coefficient_to_dB (_audio_region->maximum_amplitude ())); /* EMIT SIGNAL */
+ while (1) {
+ /* await instructions to run */
+ char msg;
+ _peak_channel.receive (msg);
+
+ /* compute peak amplitude and signal the fact */
+ PeakAmplitudeFound (accurate_coefficient_to_dB (_audio_region->maximum_amplitude ())); /* EMIT SIGNAL */
+ }
}
void
diff --git a/gtk2_ardour/audio_region_editor.h b/gtk2_ardour/audio_region_editor.h
index f3accaf115..5c9e56d923 100644
--- a/gtk2_ardour/audio_region_editor.h
+++ b/gtk2_ardour/audio_region_editor.h
@@ -37,6 +37,7 @@
#include <libgnomecanvas/libgnomecanvas.h>
#include "pbd/signals.h"
+#include "pbd/crossthread.h"
#include "audio_clock.h"
#include "ardour_dialog.h"
@@ -73,11 +74,11 @@ class AudioRegionEditor : public RegionEditor
Gtk::Label _peak_amplitude_label;
Gtk::Entry _peak_amplitude;
- bool _peak_amplitude_found;
pthread_t _peak_amplitude_thread_handle;
void peak_amplitude_found (double);
PBD::Signal1<void, double> PeakAmplitudeFound;
PBD::ScopedConnection _peak_amplitude_connection;
+ CrossThreadChannel _peak_channel;
};
#endif /* __gtk_ardour_audio_region_edit_h__ */