Several people complained that my custom ringtones application is too slow when receiving calls, so I started analysing what ringtoned does when a new call is received. The three main operations in this case are creating the object that represents a call after retrieving all the needed information (caller ID, etc.) from Telepathy, looking up the contact that matches the caller and playing the ringtone.
The Telepathy bit just needed to be slightly smarter, but was already quite fast. The contact look up was already very fast, unless you have so many contacts to make your address book unusable.
The code that needed more optimisation was the one that plays ringtones. It turned out that using GStreamer with playbin2 (the element able to detect and play all the supported file types) is not fast enough for this use case. I tried different approaches and in the end I decided to always use uncompressed wave files and stream them directly to PulseAudio.
Note that GStreamer is not the best solution just in this very specific case, for all the other use cases GStreamer is still the best solution.
After these changes I was really expecting to get very good performances, but it was still quite slow. My analysis was showing that, since when ringtoned gets notified from Telepathy of the existence of a new call to when it starts streaming to PulseAudio, less than 0.1 seconds passes, so why was it still slow?
At this point I tried using bustle to generate graphs of the D-Bus activity when a call is received. The graphs showed that the delay was not ringtoned’s fault, but a bug in Maemo causing a freeze that made the dispatching of new calls about 4 seconds slower when ringtoned was running. Somebody is now working on the bug and trying to figure out why it’s happening, in the meantime I’m working around it watching for new calls in a different way.
Ringtoned and the related packages are available in Maemo extras-devel under the name “Custom ringtones for your contacts”. If you don’t want to add the extras-devel repository (as it contains a lot of unstable software, you have been warned!), you can download ringtoned directly from my personal repository:
Install from my personal repository
(follow the link on the N900 browser)
The only known big problem left is that ringtoned breaks vibration, I will fix it in the next days/week.
Update: It looks like MyContacts is incompatible with ringtoned, so you cannot use these two programs together.
 The file is uncompressed in background, so you can still use any type of file for ringtones. Just notice that, when you update from a previous version, the first time you receive a call from a contact that already had a custom ringtone you will get the default ringtone and not the custom one as previous versions were not generating the uncompressed file.
 For people interested in Telepathy: the freeze happens if there is an observer running, even if at that point the dispatching to observers didn’t start yet! The (ugly, but effective) solution was to just listens to the NewChannels signal directly. When the Maemo bug will be fixed I will revert my code to use an observer.
20 thoughts on “Faster custom ringtones”
Care to share a little more light on the Maemo bug in question.
Hi Marco, thanks a lot for providing ringtoned. Does it also use custom ringtones for incoming SMS depending on the sender? If not, where can I file a feature request?
hi marco, custom ringtones doesnt allow me to play the music from my othr folder other than the ringing tone….do you know if i can dowgrade to the first version..that new updates kill me
The policy daemon freezes applications based on their cgroup when a new call is received, so applications not involved in telephony (like the browser) don’t interfere.
For some reason also dbus-daemon is frozen if the previous version of ringtoned was running, even if it doesn’t make any sense.
No. It’s a less needed feature as for calls you often have to decide whether to answer or not very quickly, so the different ringtone is useful to make the decision.
It’s possible also to do the same for SMSes, but I don’t think I have enough time to be honest.
Sory, but I don’t understand what you mean. What doesn’t work exactly?
Regarding the slowness of playbin2 startup, that should have been solved since (i.e. the startup time has been smashed down since 0.10.25)…. but won’t help unless you (or Nokia 🙂 ) provide updated gstreamer packages.
Will you share the bug # so we may vote on it?
If the ringtones fail playing for you it’s because there is a bug in the service that encodes the files into wave files 😦
I’m trying to find a work around now.
marco, it doesnt play the music saved in other folder than my ringing tone. when one of my contact to which i assigned those songs calls, nothing is playind and i hear nothing.
however, everything was alright with the first version…can you send it to me so i can downgrade the applications
I released a new version with the fix for some ringtones not playing: https://blog.barisione.org/2010-08/ringtoned-021/
Dear I faced a problem after installing previous version. Vibrator was not working for incoming calls only… It works on silent mode and for sms and alarms etc. But not for ringtones… I reflashed my device. Restored from backup and didnt install this software only. And vibrator is working now. Can you please answer me what is the reason and is it resolved now?
It was working choppily in your first revision, but now not at all. It causes my phone to cease to vibrate and ring. I am trying it with my mp3s, I think you said something about using uncompressed .wav files. It now doesn’t seem to take well to .mp3 files. Please fix this when you can. Thanks for all of your effort in bringing this to the n900! 🙂
Can somebody with the ringtones still not working give me the logs I’m asking in bug 11145 please?
I also attached 3 updated packages to the bug report, does anybody want to try them?
I can’t get my phone to ring at all now with this app. Once I uninstalled it I can get my phone to ring. At first it worked fine now with the updates it doesn’t work at all.
Have you been using playbin2 as is? Then it is really too slow. One easy tweak is to use NATIVE_AUDIO on the flags. Also using “filesrc ! decodebin2 ! pulsesink” is faster.
I released 0.2.3, can people try it and tell me if it works for them?
Also with the suggestions that Collabora Multimedia people gave me it seems to be too slow for something like playing ringtones, at least in the version in Fremantle (Edward promises that new versions are much better).
In the end I went for wavparse directly, it seems to be fast enough and more tolerant with broken wav files than canberra.
Can I use MP3’s for my ringtone or not?
Yes, they should work fine.
Comments are closed.