#include "audio_region_editor.h"
#include "audio_region_view.h"
-#include "ardour_ui.h"
-#include "utils.h"
#include "gui_thread.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
using namespace ARDOUR;
using namespace PBD;
static void *
_peak_amplitude_thread (void* arg)
{
- SessionEvent::create_per_thread_pool ("peak amplitude events", 64);
static_cast<AudioRegionEditor*>(arg)->peak_amplitude_thread ();
return 0;
}
_peak_amplitude.set_text (_("Calculating..."));
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');
+
+ char name[64];
+ snprintf (name, 64, "peak amplitude-%p", this);
+ pthread_create_and_store (name, &_peak_amplitude_thread_handle, _peak_amplitude_thread, this);
+ signal_peak_thread ();
}
AudioRegionEditor::~AudioRegionEditor ()
{
void* v;
- pthread_cancel_one (_peak_amplitude_thread_handle);
+ _peak_channel.deliver ('t');
pthread_join (_peak_amplitude_thread_handle, &v);
}
if (what_changed.contains (ARDOUR::Properties::start) || what_changed.contains (ARDOUR::Properties::length)) {
/* ask the peak thread to run again */
- _peak_channel.deliver ('c');
+ signal_peak_thread ();
}
}
void
}
}
+void
+AudioRegionEditor::signal_peak_thread ()
+{
+ _peak_channel.deliver ('c');
+}
+
void
AudioRegionEditor::peak_amplitude_thread ()
{
while (1) {
- /* await instructions to run */
char msg;
+ /* await instructions to run */
_peak_channel.receive (msg);
+ if (msg == 't') {
+ break;
+ }
+
/* compute peak amplitude and signal the fact */
PeakAmplitudeFound (accurate_coefficient_to_dB (_audio_region->maximum_amplitude ())); /* EMIT SIGNAL */
}