Bug 489597 - audio alarms do not play flac or mp3 files
Summary: audio alarms do not play flac or mp3 files
Status: RESOLVED FIXED
Alias: None
Product: kalarm
Classification: Applications
Component: sound (other bugs)
Version First Reported In: 3.8.1.1
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: David Jarvie
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-07-02 12:02 UTC by Dominick
Modified: 2024-07-09 19:41 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 24.08
Sentry Crash Report:


Attachments
Tarball of sample file in wav, flac, mp3, and ogg formats (1.29 MB, application/gzip)
2024-07-02 12:02 UTC, Dominick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dominick 2024-07-02 12:02:30 UTC
Created attachment 171274 [details]
Tarball of sample file in wav, flac, mp3, and ogg formats

***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***

SUMMARY

When trying to play a file unsupported by libcanberra, a dialog window pops up which says 
"Error playing audio file: '/PATH/TO/SPECIFIED/AUDIO/FILE.FORMAT'
Unsupported audio format, or corrupt data"

STEPS TO REPRODUCE
1. Create a new audio alarm
2. Specify for the audio alarm a file which is encoded in FLAC or MP3
3. Click "Try" and observe the previously mentioned error message which indicates the file is corrupt.
4. Verify the file is not corrupt by playing it with a different media player, such as vlc, mpv, mplayer, or a web browser.
5. Confirm that the command `canberra-gtk-play -f $SAMPLE_FILE_PATH` outputs the second part of the dialog's error message, "Failed to play sound: File or data corrupt"`

OBSERVED RESULT

Error message about a corrupt file.

EXPECTED RESULT

That it just works.

Linux/KDE Plasma: Fedora Linux 40
(available in About System)
KDE Plasma Version:  6.1.1
KDE Frameworks Version: 6.3.0 
Qt Version: 6.7.1

ADDITIONAL INFORMATION
Using wayland. The sample file is only five seconds long, you can confirm with a media player or audacity or whatever that none are corrupt and produce audio. This is a deficiency of libcanberra, rather than a specific problem with kalarm other than transitively.
Comment 1 David Jarvie 2024-07-04 14:56:23 UTC
I can confirm that when I set KAlarm to play the mp3 or flac file, libcanberra does not recognise them. It has been previously reported that opus files also don't work.

Harald: KAlarm changed from Phonon to libcanberra on your recommendation, but it doesn't handle as many audio formats as Phonon. Is there any way to be able to play MP3, FLAC or OPUS audio, perhaps using some other library, bearing in mind that it must be thread safe?
Comment 2 Harald Sitter 2024-07-08 09:41:56 UTC
Canberra can use gstreamer as backend at which point it should be able to play anything gstreamer can.
Comment 3 David Jarvie 2024-07-08 16:31:20 UTC
Canberra has a gstreamer backend, but because Canberra hasn't been updated in 12 years, at least one of the gstreamer calls is obsolete:

     gst_element_factory_make("decodebin2", NULL)

GStreamer no longer recognises decodebin2, so this call returns an error and playback fails. (decodebin and decodebin3 are recognised, but substituting them produces different errors.)

The conclusion is that Canberra can't be used any longer with GStreamer, so some other library is required. One possibility is to use ffmpeg libraries to convert to .wav first, and then continue to use Canberra, but this doesn't seem ideal. Do you have any other suggestions?
Comment 4 Harald Sitter 2024-07-09 06:25:05 UTC
> Do you have any other suggestions?

update the gstreamer backend maybe? or write a new one using ffmpeg or libvlc

Ultimately I don't think your idea of converting to wav is a bad one, it makes things work with any plugin. Perhaps cache the result of the conversion though?
Comment 5 David Jarvie 2024-07-09 19:41:20 UTC
KAlarm has now been converted to use the VLC library to play sound files, which fixes this bug. The fix will be in KAlarm version 3.9, which will be in the KDE Gear 24.08 release.

Commit https://invent.kde.org/pim/kalarm/-/commit/a3ce5043f2074829156f414cc32075579b3bbf94