Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent notifs and scrshot from locking up when sink is locked #406

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 25 additions & 17 deletions src/daemon/notifications/dbus.vala
Original file line number Diff line number Diff line change
Expand Up @@ -471,28 +471,13 @@
sound_name = notification.hints.get("sound-name").get_string();
}

play_sound(notification, sound_name);
}

/**
* Play a sound for a notification.
*/
private void play_sound(Notification notification, string? sound_name = "dialog-information") {
// Try to map the notification's category to a sound name to use
if (sound_name == "dialog-information" && notification.category != null) {
sound_name = get_sound_for_category(notification.category);
}

// Play the sound
if (sound_name != null) {
Canberra.Proplist props;
Canberra.Proplist.create(out props);

props.sets(Canberra.PROP_CANBERRA_CACHE_CONTROL, "volatile");
props.sets(Canberra.PROP_EVENT_ID, sound_name);

CanberraGtk.context_get().play_full(0, props);
}
var player = new SoundPlayer(notification, sound_name);
new Thread<void>(null, player.play);
}

/**
Expand Down Expand Up @@ -618,4 +603,27 @@
}
}
}

class SoundPlayer {
private Notification notification;
private string? sound_name;

public SoundPlayer(Notification notification, string? sound_name = "dialog-information") {
this.notification = notification;
this.sound_name = sound_name;
}

public void play() {
// Play the sound
if (sound_name != null) {
Canberra.Proplist props;
Canberra.Proplist.create(out props);

props.sets(Canberra.PROP_CANBERRA_CACHE_CONTROL, "volatile");
props.sets(Canberra.PROP_EVENT_ID, sound_name);

CanberraGtk.context_get().play_full(0, props);
}
}
}
}
3 changes: 2 additions & 1 deletion src/daemon/screenshot.vala
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ namespace BudgieScr {
// fake thread to make sure flash and shutter are in sync
pipeline.set_state(State.PLAYING);
Gst.Bus bus = pipeline.get_bus();
bus.timed_pop_filtered(Gst.CLOCK_TIME_NONE, Gst.MessageType.ERROR | Gst.MessageType.EOS);
// time out after 2 seconds, in case the output is locked
bus.timed_pop_filtered(2000000000, Gst.MessageType.ERROR | Gst.MessageType.EOS);
pipeline.set_state(Gst.State.NULL);

return false;
Expand Down