Skip to content

Commit

Permalink
fix(visualizer): dont destroy on unmap
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr committed Dec 13, 2024
1 parent ed260e5 commit d9696c1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
10 changes: 6 additions & 4 deletions src/Widgets/AudioPlayer/Player.vala
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class Tuba.Widgets.Audio.Player : Adw.Bin {
player.ended.connect (on_ended);

this.child = overlay;
this.destroy.connect (on_destroy);
}

private void on_ended () {
Expand Down Expand Up @@ -130,10 +131,11 @@ public class Tuba.Widgets.Audio.Player : Adw.Bin {
on_reveal_media_buttons ();
}

public override void unmap () {
if (revealer_timeout > 0) GLib.Source.remove (revealer_timeout);

base.unmap ();
private void on_destroy () {
if (revealer_timeout > 0) {
GLib.Source.remove (revealer_timeout);
revealer_timeout = 0;
}
player.destroy ();
}

Expand Down
19 changes: 14 additions & 5 deletions src/Widgets/AudioPlayer/Stream.vala
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,20 @@ public class Tuba.Widgets.Audio.Stream : GLib.Object {
// Without disconnecting everything
// it leaks.
public void destroy () {
if (timeout_id > 0) GLib.Source.remove (timeout_id);
bus.remove_watch ();
bus = null;
this.state = Gst.State.NULL;
pipeline = null;
if (timeout_id > 0) {
GLib.Source.remove (timeout_id);
timeout_id = 0;
}

if (bus != null) {
bus.remove_watch ();
bus = null;
}

if (pipeline != null) {
this.state = Gst.State.NULL;
pipeline = null;
}
}

~Stream () {
Expand Down

0 comments on commit d9696c1

Please sign in to comment.