X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Faudio_region_editor.cc;h=2041d20335feb17e289c4d488db29f4817214416;hb=5e7d9d30e28e8022661497244ccd43a1f5a836c6;hp=806659b52c1f3b04a17733c3ef6d5ccbbd5af108;hpb=02cfe41bff57712e59f7169037d694a3dd6a1420;p=ardour.git diff --git a/gtk2_ardour/audio_region_editor.cc b/gtk2_ardour/audio_region_editor.cc index 806659b52c..2041d20335 100644 --- a/gtk2_ardour/audio_region_editor.cc +++ b/gtk2_ardour/audio_region_editor.cc @@ -17,22 +17,21 @@ */ +#include + +#include + #include "pbd/memento_command.h" #include "pbd/stateful_diff_command.h" #include "pbd/pthread_utils.h" -#include "ardour/session.h" #include "ardour/audioregion.h" -#include "ardour/playlist.h" -#include "ardour/utils.h" +#include "ardour/session_event.h" #include "ardour/dB.h" -#include -#include #include "audio_region_editor.h" #include "audio_region_view.h" #include "ardour_ui.h" -#include "utils.h" #include "gui_thread.h" #include "i18n.h" @@ -54,7 +53,9 @@ 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); @@ -74,14 +75,14 @@ AudioRegionEditor::AudioRegionEditor (Session* s, boost::shared_ptr b->set_spacing (6); b->pack_start (_peak_amplitude); b->pack_start (*Gtk::manage (new Gtk::Label (_("dBFS"))), false, false); - + _peak_amplitude_label.set_name ("AudioRegionEditorLabel"); _peak_amplitude_label.set_text (_("Peak amplitude:")); _peak_amplitude_label.set_alignment (1, 0.5); _table.attach (_peak_amplitude_label, 0, 1, _table_row, _table_row + 1, Gtk::FILL, Gtk::FILL); _table.attach (*b, 1, 2, _table_row, _table_row + 1, Gtk::FILL, Gtk::FILL); ++_table_row; - + gain_changed (); gain_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &AudioRegionEditor::gain_adjustment_changed)); @@ -91,29 +92,28 @@ AudioRegionEditor::AudioRegionEditor (Session* s, boost::shared_ptr 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'); + signal_peak_thread (); } AudioRegionEditor::~AudioRegionEditor () { - pthread_cancel_one (_peak_amplitude_thread_handle); void* v; - int const r = pthread_join (_peak_amplitude_thread_handle, &v); - assert (r == 0); + pthread_cancel_one (_peak_amplitude_thread_handle); + pthread_join (_peak_amplitude_thread_handle, &v); } void AudioRegionEditor::region_changed (const PBD::PropertyChange& what_changed) { RegionEditor::region_changed (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'); + signal_peak_thread (); } } void @@ -134,13 +134,33 @@ 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) { /* await instructions to run */ - char msg; - _peak_channel.receive (msg); + wait_for_signal (); /* compute peak amplitude and signal the fact */ PeakAmplitudeFound (accurate_coefficient_to_dB (_audio_region->maximum_amplitude ())); /* EMIT SIGNAL */