Brewtarget / brewtarget

Main brewtarget source code repository.
GNU General Public License v3.0
312 stars 134 forks source link

Timer sound improvements #652

Closed matty0ung closed 2 years ago

matty0ung commented 2 years ago

This is a first attempt to address https://github.com/Brewtarget/brewtarget/issues/647

I have changed the way alarm sounds play back from QMediaPlayer + QMediaPlaylist to QSoundEffect. I noticed on my PC that there was a variable and sometimes very large lag between when we asked QMediaPlayer to play a sound and when it actually got played. Sometimes it was straight away and sometimes it was 10 seconds later! QSoundEffect is supposed to be more responsive (and seems to be so from the limited testing I've done). The cost of using QSoundEffect is that it only supports wav files, so I've converted all the ogg files to wav ones.

I've added some more logging so that we might get some more clues about why sounds aren't playing when there's a problem. (Though, unfortunately, Qt doesn't have the greatest diagnostic messages in this area.)

I also added a button to allow you to play the alarm sound without waiting for the alarm to go off. (This is for all timers except the main boil timer, because that has its own window and doesn't allow you to specify a custom sound. Personally I'd prefer a more uniform UI for all the timers but that's for another discussion.)

I have removed the "temporary fix" https://github.com/Brewtarget/brewtarget/pull/62 made in 2015 for https://github.com/Brewtarget/brewtarget/issues/9 as I think we are well past the problematic version of Qt and there is no other reason that we would want to have this compile flag.

I did a couple of things to enable compilation on Ubuntu 22.04:

Finally, timer code is a bit tidied up and I pulled out some copy-and-pasted code into a files utils/TimerUtils.*