X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Faudio_region_editor.cc;h=15186f2b8af4a9889ec8721986160974d6669af7;hb=cf52d6e4b40111eb04b244ec054055a4ec15dbe0;hp=730cd99b37cf2cb8c9f700930bf096a1dd4300fd;hpb=59631acc5f41153a294c97ab820a4b41a886e24c;p=ardour.git diff --git a/gtk2_ardour/audio_region_editor.cc b/gtk2_ardour/audio_region_editor.cc index 730cd99b37..15186f2b8a 100644 --- a/gtk2_ardour/audio_region_editor.cc +++ b/gtk2_ardour/audio_region_editor.cc @@ -31,11 +31,9 @@ #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; @@ -45,7 +43,6 @@ using namespace Gtkmm2ext; static void * _peak_amplitude_thread (void* arg) { - SessionEvent::create_per_thread_pool ("peak amplitude events", 64); static_cast(arg)->peak_amplitude_thread (); return 0; } @@ -54,9 +51,7 @@ AudioRegionEditor::AudioRegionEditor (Session* s, boost::shared_ptr : 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) -#ifndef PLATFORM_WINDOWS , _peak_channel (false) -#endif { Gtk::HBox* b = Gtk::manage (new Gtk::HBox); @@ -92,14 +87,17 @@ AudioRegionEditor::AudioRegionEditor (Session* s, boost::shared_ptr _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); + + 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); } @@ -138,30 +136,20 @@ AudioRegionEditor::gain_adjustment_changed () void AudioRegionEditor::signal_peak_thread () { -#ifdef PLATFORM_WINDOWS - m_peak_sem.post (); -#else _peak_channel.deliver ('c'); -#endif -} - -void -AudioRegionEditor::wait_for_signal () -{ -#ifdef PLATFORM_WINDOWS - m_peak_sem.wait (); -#else - char msg; - _peak_channel.receive (msg); -#endif } void AudioRegionEditor::peak_amplitude_thread () { while (1) { + char msg; /* await instructions to run */ - wait_for_signal (); + _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 */