[pitivi] viewer: Fixes peak meter not updated on audio channels change Fixes #2607
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] viewer: Fixes peak meter not updated on audio channels change Fixes #2607
- Date: Mon, 9 May 2022 14:58:08 +0000 (UTC)
commit 01854f2cf74871647a906cd97293d1473deeda95
Author: Aryan Kaushik <73686-Aryan20 users noreply gitlab gnome org>
Date: Sun May 8 23:48:19 2022 +0530
viewer: Fixes peak meter not updated on audio channels change
Fixes #2607
pitivi/project.py | 2 ++
pitivi/viewer/viewer.py | 7 ++++++-
tests/test_peak_meter.py | 12 ++++++++++++
3 files changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/pitivi/project.py b/pitivi/project.py
index 3da5d298b..9c10938ec 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -636,6 +636,7 @@ class Project(Loggable, GES.Project):
"settings-set-from-imported-asset": (GObject.SignalFlags.RUN_LAST, None,
(GES.Asset,)),
"video-size-changed": (GObject.SignalFlags.RUN_LAST, None, ()),
+ "audio-channels-changed": (GObject.SignalFlags.RUN_LAST, None, ()),
"safe-area-size-changed": (GObject.SignalFlags.RUN_LAST, None, ())
}
@@ -1002,6 +1003,7 @@ class Project(Loggable, GES.Project):
"""Updates the audio profile and the corresponding project settings."""
res = Project._set_restriction(self.audio_profile, name, value)
if res:
+ self.emit("audio-channels-changed")
self._has_default_audio_settings = False
self.update_restriction_caps()
return res
diff --git a/pitivi/viewer/viewer.py b/pitivi/viewer/viewer.py
index 042bddb66..00266d52e 100644
--- a/pitivi/viewer/viewer.py
+++ b/pitivi/viewer/viewer.py
@@ -111,18 +111,22 @@ class ViewerContainer(Gtk.Box, Loggable):
def _project_manager_project_closed_cb(self, unused_project_manager, project):
if self.project == project:
project.disconnect_by_func(self._project_video_size_changed_cb)
+ project.disconnect_by_func(self._project_audio_channels_changed_cb)
self.project = None
def _project_video_size_changed_cb(self, project):
"""Handles Project metadata changes."""
self._reset_viewer_aspect_ratio(project)
- self.__update_peak_meters(project)
def _reset_viewer_aspect_ratio(self, project):
"""Resets the viewer aspect ratio."""
self.target.update_aspect_ratio(project)
self.timecode_entry.set_framerate(project.videorate)
+ def _project_audio_channels_changed_cb(self, project):
+ """Handles Project audio channels changes."""
+ self.__update_peak_meters(project)
+
def __update_peak_meters(self, project):
for peak_meter in self.peak_meters:
self.peak_meter_box.remove(peak_meter)
@@ -168,6 +172,7 @@ class ViewerContainer(Gtk.Box, Loggable):
project.pipeline.pause()
project.connect("video-size-changed", self._project_video_size_changed_cb)
+ project.connect("audio-channels-changed", self._project_audio_channels_changed_cb)
def __create_new_viewer(self):
_, sink_widget = self.project.pipeline.create_sink()
diff --git a/tests/test_peak_meter.py b/tests/test_peak_meter.py
index e2086b96e..76b508b13 100644
--- a/tests/test_peak_meter.py
+++ b/tests/test_peak_meter.py
@@ -117,3 +117,15 @@ class TestPeakMeter(common.TestCase):
for peak in peaks:
self.assertGreaterEqual(0, peak, peaks)
self.assertGreaterEqual(peak, MIN_PEAK, peaks)
+
+ @common.setup_project(["tears_of_steel.webm"])
+ def test_peak_meter_channels_update(self):
+ """Checks that the peak meter channels updates correctly when audio channels changes."""
+ viewer = ViewerContainer(self.app)
+ viewer.set_project(self.project)
+
+ self.assertEqual(self.project.audiochannels, 1)
+ self.assertEqual(len(viewer.peak_meters), 1)
+
+ self.project.audiochannels = 6
+ self.assertEqual(len(viewer.peak_meters), 6)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]