Bug 173333 - amarok file browser ignores wav, ogg, m4a, wmv, probably more
Summary: amarok file browser ignores wav, ogg, m4a, wmv, probably more
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: File Browser (show other bugs)
Version: 2.0-SVN
Platform: Compiled Sources Linux
: HI normal
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-23 02:21 UTC by Jason A. Donenfeld
Modified: 2009-12-09 11:28 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Partial fix using EngineController::canDecode (1.45 KB, patch)
2008-10-23 03:19 UTC, Jason A. Donenfeld
Details
Workaround to isMimeTypeAvailable bugs (1.54 KB, patch)
2008-10-23 03:38 UTC, Jason A. Donenfeld
Details
Fixes the problem using proper mime types and cleans up obsolete code (5.70 KB, patch)
2008-10-23 04:52 UTC, Jason A. Donenfeld
Details
Fixes the problem using proper mime types and cleans up obsolete code (5.51 KB, patch)
2008-10-23 05:07 UTC, Jason A. Donenfeld
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jason A. Donenfeld 2008-10-23 02:21:09 UTC
Version:           svn (using Devel)
Compiler:          gcc 4.3.2 gentoo
OS:                Linux
Installed from:    Compiled sources

The file browser seems only to show mp3s and folders. It does not show all the files that amarok is able to play. It shows nothing for a directory full of m4as, for example.
Comment 1 Seb Ruiz 2008-10-23 02:26:42 UTC
I've also seen similar behaviour of the filebrowser, with m4a files, even though my system can play them.
Comment 2 Jason A. Donenfeld 2008-10-23 03:19:53 UTC
Created attachment 28073 [details]
Partial fix using EngineController::canDecode

Patch by Jason A. Donenfeld <Jason@zx2c4.com>

The proper way to filter the filebrowser would be to use EngineController::canDecode, which the attached patch uses. The problem is that the EngineController::canDecode uses Phonon::BackendCapabilities::isMimeTypeAvailable, which seems to return false when it should not. Therefore, after applying this patch, the problem would exist with Phonon.
Comment 3 Jason A. Donenfeld 2008-10-23 03:38:15 UTC
Created attachment 28074 [details]
Workaround to isMimeTypeAvailable bugs

Patch by Jason A. Donenfeld <Jason@zx2c4.com>

This patch works around the flaws in Phonon::BackendCapabilities::isMimeTypeAvailable by using hard coded values.

All over Amarok, canDecode is used to determine if a file is playable, so any workarounds or replacements for isMimeTypeAvailable should be in canDecode.
Comment 4 Jason A. Donenfeld 2008-10-23 03:50:31 UTC
Comment on attachment 28074 [details]
Workaround to isMimeTypeAvailable bugs

>Index: src/EngineController.cpp
>===================================================================
>--- src/EngineController.cpp	(revision 874993)
>+++ src/EngineController.cpp	(working copy)
>@@ -162,7 +162,13 @@
>         return false;
> 
>     KFileItem item( KFileItem::Unknown, KFileItem::Unknown, url );
>-    const bool valid = Phonon::BackendCapabilities::isMimeTypeAvailable( item.mimetype() );
>+    const bool valid = Phonon::BackendCapabilities::isMimeTypeAvailable( item.mimetype() )
>+        //HACK: workaround for isMimeTypeAvailable's bugs
>+        || ext == "mp3"
+        || ext == "m4a"
>+        || ext == "wma"
>+        || ext == "ogg"
>+        || ext == "wav"
>+        || ext == "flac";
> 
>     //we special case this as otherwise users hate us
>     if ( !valid && ext.toLower() == "mp3" && !installDistroCodec() )
>Index: src/browsers/filebrowser/MyDirLister.cpp
>===================================================================
>--- src/browsers/filebrowser/MyDirLister.cpp	(revision 874993)
>+++ src/browsers/filebrowser/MyDirLister.cpp	(working copy)
>@@ -37,7 +37,6 @@
>         EngineController::canDecode( item.url() ) || 
>         item.url().protocol() == "audiocd" ||
>         PlaylistManager::isPlaylist( item.url() ) ||
>-        item.name().endsWith( ".mp3", Qt::CaseInsensitive ) || //for now this is less confusing for the user
>         item.name().endsWith( ".aa", Qt::CaseInsensitive ) ||  //for adding to iPod
>         item.name().endsWith( ".mp4", Qt::CaseInsensitive ) || //for adding to iPod
>         item.name().endsWith( ".m4v", Qt::CaseInsensitive ) || //for adding to iPod
Comment 5 Jason A. Donenfeld 2008-10-23 04:52:13 UTC
Created attachment 28075 [details]
Fixes the problem using proper mime types and cleans up obsolete code


Patch by Jason A. Donenfeld <Jason@zx2c4.com>

The old way of checking for file extensions is incompatible with the new way of checking for mime types, as one wrong mimetyped file would corrupt the file extension cache.

By using only mimetypes to check, we can filter out videos and images by filtering the mimetype list. This entire process is faster and has less overhead than the previous way.

The attached patch replaces the extensioncache with a mimetype qstringlist that is populated on the first call to canDecode.
Comment 6 Jason A. Donenfeld 2008-10-23 05:07:56 UTC
Created attachment 28076 [details]
Fixes the problem using proper mime types and cleans up obsolete code


Patch by Jason A. Donenfeld <Jason@zx2c4.com>

The old way of checking for file extensions is incompatible with the new way of checking for mime types, as one wrong mimetyped file would corrupt the file extension cache.

By using only mimetypes to check, we can filter out videos and images by filtering the mimetype list. This entire process is faster and has less overhead than the previous way.

The attached patch replaces the extensioncache with a mimetype qstringlist that is populated on the first call to canDecode. Additionally, the table is now local, and the accessor functions have been removed, as this data should only be queried by way of canDecode. 

MusicBrainz and FetchCover checks have been removed, as those were for amarok1.
Comment 7 Dan Meltzer 2008-10-23 05:33:25 UTC
SVN commit 875009 by dmeltzer:

Fix flaws in EngineController::canDecode that led to a number of false positives.

EngineController::canDecode was still caching extensions but checking mime types.  This patch resolves this by caching mime types instead.  This also simplifies the code in EngineController::canDecode and allows us to eliminate hacks to work around the issue in other parts of Amarok.  Patch by Jason A. Donenfeld <Jason@zx2c4.com>
BUG: 173333


 M  +3 -1      ChangeLog  
 M  +16 -30    src/EngineController.cpp  
 M  +1 -5      src/EngineController.h  
 M  +1 -5      src/collection/CollectionManager.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=875009