diff options
author | Igor V. Kovalenko <igor.v.kovalenko@gmail.com> | 2021-08-14 19:41:27 +0300 |
---|---|---|
committer | Igor V. Kovalenko <igor.v.kovalenko@gmail.com> | 2021-08-15 12:26:23 +0300 |
commit | 4bc93d9d9c1d7f5d195076b514c6ac2391a7017f (patch) | |
tree | a086f9a60a75f942c0347999de7f8eae225ee4aa /src | |
parent | 223c6964a861a9046111a2a5f41c4f0c79fb8b17 (diff) |
Disconnect and unreference all peak indicator stream objects
Most of sink input peak indicator streams are still connected alive at the time
their widgets are destroyed. Disconnect and unreference each one to stop memory
leak.
When sink input peak indicator stream is recreated, previous stream is only
disconnected but not unreferenced. Unreference it to stop memory leak.
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pavucontrol/-/merge_requests/62>
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.cc | 1 | ||||
-rw-r--r-- | src/minimalstreamwidget.cc | 8 | ||||
-rw-r--r-- | src/minimalstreamwidget.h | 1 |
3 files changed, 10 insertions, 0 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc index bae4c7a..2e1c58b 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -703,6 +703,7 @@ void MainWindow::createMonitorStreamForSinkInput(SinkInputWidget* w, uint32_t si if (w->peak) { pa_stream_disconnect(w->peak); + pa_stream_unref(w->peak); w->peak = NULL; } diff --git a/src/minimalstreamwidget.cc b/src/minimalstreamwidget.cc index 017b2ed..b6c60e8 100644 --- a/src/minimalstreamwidget.cc +++ b/src/minimalstreamwidget.cc @@ -39,6 +39,14 @@ MinimalStreamWidget::MinimalStreamWidget(BaseObjectType* cobject) : volumeMeterVisible(true) { } +MinimalStreamWidget::~MinimalStreamWidget() { + if (peak) { + pa_stream_disconnect(peak); + pa_stream_unref(peak); + peak = NULL; + } +} + void MinimalStreamWidget::init() { /* Set up the peak meter. This is not done in the constructor, because * channelsVBox is initialized by the subclasses, so it's not yet available diff --git a/src/minimalstreamwidget.h b/src/minimalstreamwidget.h index e5d774c..fbf6a99 100644 --- a/src/minimalstreamwidget.h +++ b/src/minimalstreamwidget.h @@ -26,6 +26,7 @@ class MinimalStreamWidget : public Gtk::VBox { public: MinimalStreamWidget(BaseObjectType* cobject); + virtual ~MinimalStreamWidget(); /* Subclass constructors are expected to initialize these variables. * MinimalStreamWidget can't initialize these, because the glade object |