summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/audio_region_editor.cc19
-rw-r--r--gtk2_ardour/audio_region_editor.h3
-rw-r--r--libs/midi++2/port.cc2
-rw-r--r--libs/pbd/base_ui.cc3
-rw-r--r--libs/pbd/crossthread.cc20
-rw-r--r--libs/pbd/pbd/crossthread.h2
6 files changed, 34 insertions, 15 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__ */
diff --git a/libs/midi++2/port.cc b/libs/midi++2/port.cc
index 539d5c49cb..59f76041d6 100644
--- a/libs/midi++2/port.cc
+++ b/libs/midi++2/port.cc
@@ -50,6 +50,7 @@ Port::Port (string const & name, Flags flags, jack_client_t* jack_client)
, _jack_client (jack_client)
, _jack_port (0)
, _last_read_index (0)
+ , xthread (true)
, output_fifo (512)
, input_fifo (1024)
, _flags (flags)
@@ -64,6 +65,7 @@ Port::Port (const XMLNode& node, jack_client_t* jack_client)
, _jack_client (jack_client)
, _jack_port (0)
, _last_read_index (0)
+ , xthread (true)
, output_fifo (512)
, input_fifo (1024)
{
diff --git a/libs/pbd/base_ui.cc b/libs/pbd/base_ui.cc
index ce7018a005..d56e4a31a4 100644
--- a/libs/pbd/base_ui.cc
+++ b/libs/pbd/base_ui.cc
@@ -41,7 +41,8 @@ BaseUI::RequestType BaseUI::CallSlot = BaseUI::new_request_type();
BaseUI::RequestType BaseUI::Quit = BaseUI::new_request_type();
BaseUI::BaseUI (const string& str)
- : run_loop_thread (0)
+ : request_channel (true)
+ , run_loop_thread (0)
, _name (str)
{
base_ui_instance = this;
diff --git a/libs/pbd/crossthread.cc b/libs/pbd/crossthread.cc
index 12ca19b945..553c8d52f3 100644
--- a/libs/pbd/crossthread.cc
+++ b/libs/pbd/crossthread.cc
@@ -30,7 +30,7 @@ using namespace std;
using namespace PBD;
using namespace Glib;
-CrossThreadChannel::CrossThreadChannel ()
+CrossThreadChannel::CrossThreadChannel (bool non_blocking)
{
_ios = 0;
fds[0] = -1;
@@ -41,14 +41,16 @@ CrossThreadChannel::CrossThreadChannel ()
return;
}
- if (fcntl (fds[0], F_SETFL, O_NONBLOCK)) {
- error << "cannot set non-blocking mode for x-thread pipe (read) (" << ::strerror (errno) << ')' << endmsg;
- return;
- }
-
- if (fcntl (fds[1], F_SETFL, O_NONBLOCK)) {
- error << "cannot set non-blocking mode for x-thread pipe (write) (%2)" << ::strerror (errno) << ')' << endmsg;
- return;
+ if (non_blocking) {
+ if (fcntl (fds[0], F_SETFL, O_NONBLOCK)) {
+ error << "cannot set non-blocking mode for x-thread pipe (read) (" << ::strerror (errno) << ')' << endmsg;
+ return;
+ }
+
+ if (fcntl (fds[1], F_SETFL, O_NONBLOCK)) {
+ error << "cannot set non-blocking mode for x-thread pipe (write) (%2)" << ::strerror (errno) << ')' << endmsg;
+ return;
+ }
}
}
diff --git a/libs/pbd/pbd/crossthread.h b/libs/pbd/pbd/crossthread.h
index f16cab9405..a791be5798 100644
--- a/libs/pbd/pbd/crossthread.h
+++ b/libs/pbd/pbd/crossthread.h
@@ -28,7 +28,7 @@
class CrossThreadChannel {
public:
- CrossThreadChannel();
+ CrossThreadChannel(bool);
~CrossThreadChannel();
void wakeup();