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

Phone ringing and dialing sound #1203

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

emildekeyser
Copy link

@emildekeyser emildekeyser commented Feb 22, 2022

@emildekeyser emildekeyser marked this pull request as ready for review February 22, 2022 10:58
@mar-v-in
Copy link
Member

  1. I don't think we should ship sound files ourselves. There is a freedesktop standard for sound files and we should use it and thus use the sounds files proposed by the current sound theme instead of our own.
  2. Surely we could implement the freedesktop standard without using libcanberra. As libcanberra uses gstreamer in the background, I doubt there is any OS supported by directly using gstreamer that isn't supported by libcanberra. I also don't understand what you mean with API being incomplete: Canberra.Context.play_full() can be invoked with a callback which can be used to replay the file in a loop - same as your current code does with GStreamer.
  3. I don't think we'd need any configuration for incoming/outgoing call sounds. They are always a sane option. If you want your device to be silent, just mute it.
  4. We're currently playing sounds via the desktop's notification system. This doesn't work perfectly (as some desktops don't support it or delay the playing of the sound to the point when the notification is shown). As you do a proper sound playing, it would probably a good idea to at least remove the sound from the notification (as otherwise some users will have the sound played twice).

@mar-v-in mar-v-in added the 📞 Calling Related to Audio/Video calls using Jingle label Feb 22, 2022
@emildekeyser
Copy link
Author

emildekeyser commented Feb 22, 2022 via email

@emildekeyser
Copy link
Author

emildekeyser commented Feb 22, 2022 via email

@emildekeyser
Copy link
Author

Another small note about point 1.: This means also that its important to add freedesktop sound as a (optional) dependancy for packages otherwise you can get the fantastic user experience where it seems there is no sound but its just that you dont have a sound theme. But this is more of a distro maintainer's responsability I guess.

@mar-v-in
Copy link
Member

About 1: You'd also need to use the active theme (if any) from Gtk.Settings.gtk_sound_theme_name. Check the specification for a detailed pseudocode on the sound lookup routine.

About 2: The _userdata_ is implicitly used in Vala to allow you to either create closures or put a method pointer (which, in contrast to a function pointer, requires the reference to the containing object). I think the not about the context is that the callback may be called from another thread. In this case, you'd need to attach a signal source to the maincontext to ensure you are running on the main thread. The easiest way to do so is by using Idle.add() (which you give a reference to a method or a closure to be invoked on the main thread). The following should give you an idea of how this should probably work (untested):

private Canberra.Context ctx;
private Canberra.Proplist props;
private uint32 id;
private boolean playing;

public void play_again() {
  if (!playing) return;
  ctx.play(id, props, () => {
    Idle.add(() => {
      play_again();
      return Source.REMOVE;
    });
  });
}

public void play_loop() {
  playing = true;
  play_again();
}

public void cancel_loop() {
  playing = false;
  ctx.cancel(id);
}

Bonus: You can easily add a few ms of silence between the sound plays by using Timeout.add() instead of Idle.add() - in case that makes it sound better.

@emildekeyser
Copy link
Author

Nice! Thanks for the info. Il look into it.

@emildekeyser emildekeyser changed the title Basic phone ringing Phone ringing and dialing Feb 23, 2022
@emildekeyser emildekeyser changed the title Phone ringing and dialing Phone ringing and dialing sound Feb 23, 2022
@mar-v-in
Copy link
Member

  • main should not have a dependency on GStreamer.
  • I guess you misunderstood my comment about the notification thing. There is absolutely nothing wrong with listening on call specific events in the NotificationEvents module. What I meant was, that we already do play a sound on incoming calls (but only once and it depends on the notification system supporting it) via
    hash_table["sound-name"] = new Variant.string("phone-incoming-call");
    We don't want to play the sound twice at the same time (as it would sound ugly), so you'd need to make sure that won't happen.

@emildekeyser
Copy link
Author

Okay, I will remove the singular sound also. I don't understand what you mean by 'main should not have a dependency on GStreamer', I did remove my dependancy on gst back to libcanberra already, did I forget a refrence somewhere ?

main/CMakeLists.txt Outdated Show resolved Hide resolved
@emildekeyser
Copy link
Author

emildekeyser commented Mar 16, 2022

BTW, I am meaning to redo the commits once you guys are happy with the code because I find them very ugly (no/bad messages, redundancy) if you would like that ofcourse. (and do rebase if needed)

@emildekeyser
Copy link
Author

And if you like when we are done here I can put libcanberra on the deps wiki page.

@emildekeyser emildekeyser requested a review from fiaxh March 17, 2022 18:26
plugins/rtp/src/plugin.vala Show resolved Hide resolved
libdino/src/service/calls.vala Outdated Show resolved Hide resolved
plugins/phone-ringer/CMakeLists.txt Show resolved Hide resolved
plugins/phone-ringer/src/plugin.vala Outdated Show resolved Hide resolved
@emildekeyser
Copy link
Author

emildekeyser commented May 9, 2022 via email

emildekeyser pushed a commit to emildekeyser/dino-fork that referenced this pull request May 16, 2022
As mentioned here: dino#1203 (comment).

This is a first draft of what adding the ringer as a
NotificationProvider can look like. I made some assumptions which might
be wrong. Further review will reveal this.
Copy link
Member

@fiaxh fiaxh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looks quite good by now. But after trying it out, I think this really needs breaks between the sounds 😉 To put a delay between the sounds, you can replace Idle.add with Timeout.add_seconds, as mar-v-in mentioned before. You then need some variable to store whether it is currently supposed to be ringing or not (if the noise is retracted while the timeout is waiting), and then check it in the Timeout.

plugins/phone-ringer/src/plugin.vala Outdated Show resolved Hide resolved
plugins/phone-ringer/src/plugin.vala Outdated Show resolved Hide resolved
emildekeyser pushed a commit to emildekeyser/dino-fork that referenced this pull request May 18, 2022
As mentioned here: dino#1203 (comment).

This is a first draft of what adding the ringer as a
NotificationProvider can look like. I made some assumptions which might
be wrong. Further review will reveal this.
emil added 3 commits November 6, 2022 15:20
Gst.deinit caused the Dino proces to linger in the background when I
tried using Gst in the phone ringer plugin. My reasoning for leaving it
out even though Gst is not in use anymore in the ringer plugin is that
this is a nasty bug that might crop up again in the future when someone
tries to do anything else at all with Gst.

I did the following things:

- checked this https://gstreamer.freedesktop.org/documentation/gstreamer/gst.html#gst_deinit
- tested that Dino works without the Gst.deinit
- tried looking for a specific reason for the deinit with git log -L 276,+10 -- plugins/rtp/src/plugin.vala

I didn't find anything so this made me conclude that it is better to
leave it out.
@earboxer
Copy link

earboxer commented Mar 1, 2023

@emildekeyser, I tried this out, and I like it... except the call is ringing tone is made even if I'm making the call using another client.

What's worse is that that sound continues even after the call is connected (on the other device) and disconnected.

So big 😢 and 👎 until that's fixed. (it should only make that noise if you're placing the call from this device.

@emildekeyser
Copy link
Author

emildekeyser commented Mar 2, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📞 Calling Related to Audio/Video calls using Jingle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants