Bug 138409 - Patch for MTP-Media device
Summary: Patch for MTP-Media device
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Collections/MTP player (show other bugs)
Version: 1.4-SVN
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
: 138741 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-12-05 20:32 UTC by Mikko Seppälä
Modified: 2011-12-20 11:45 UTC (History)
2 users (show)

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


Attachments
The patch (3.88 KB, patch)
2006-12-05 20:33 UTC, Mikko Seppälä
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mikko Seppälä 2006-12-05 20:32:44 UTC
Version:            (using KDE KDE 3.5.5)
Installed from:    Unlisted Binary Package
OS:                Linux

This Patch fixes crash on connecting to empty MTP-Device and adds i18n for "unknown" tags. The patch also returns the devicename to MTP-Mediadevice as player is disconnected (instead of keeping it as "Model (User)"). NOTE: This reverses the commit for using latin1 instead of utf8 as a encoding when sending to the device.
Some formatting has also been replaced and eg reports if track exists on device in statusbar instead of the popup that user needs to call.
Comment 1 Mikko Seppälä 2006-12-05 20:33:23 UTC
Created attachment 18805 [details]
The patch
Comment 2 Mikko Seppälä 2006-12-06 12:01:15 UTC
Following bugs still exist:
1. Amarok tries to connect to the MTP device upon starting amarok if it is enabled or when adding new mtp device from settings.
2. CopyToDevice checks if track exists on device, but ignores album information.
Comment 3 Andy Kelk 2006-12-07 02:49:12 UTC
Mikko,

Thanks for the patch. I won't have time to look at it properly until next week.
I think you are right that not having any tracks on a device is not an error situation and should be dealt with gracefully.

With regards to the other bugs, I think (1) is the case for all Media Devices (they all try and connect at start-up). This should probably remain the behaviour but the GUI should be allowed to finish loading while the device is probed for contents. It's something I've been meaning to investigate for a bit. Thanks for the reminder.

When you say that it ignores album information, can you give an example. As far as I know, it should check for title/album/artist as a combination to detect duplicates.
Comment 4 Mikko Seppälä 2006-12-07 17:23:28 UTC
Libnjb plugin doesnt try to connect on startup (I updated Creative Zen sleek from NJB firmware to MTP). I tried to figure out how it does it but im not a c++ nor c programmer :p. When Amarok starts and it tries to connect (you can see on debug messages it runs ::openDevice on MTP plugin upon loading it), and I have the player plugged in since it charges from usb, it takes 11 minutes to connect (large collection and no usb2.0) and amarok wont show the main interface until it has connected (as you stated).
For the second one: I got 2 songs, their filenames are exact same, and their tracknumber is same and even lenght is same. Bitrate, ablum and year differ. When the other is on device and other starts to transfer, it informs that the track exists on device in both interface and debug. I can upload these files for test purposes if you want. The code should also check for tracknumber(?) since i got sets with "same" songs (same artist, title and album) but different tracknumber (some top 100 lists from different stations).
Comment 5 Mikko Seppälä 2006-12-07 20:32:47 UTC
Seems like there is two things to check if file exists on device, some tracks with same title, album and artist never get to copyTrackToDevice, only difference is lenght and tracknumber Those tracks are also removed from queue, whereas the one on copytracktodevice leaves em to queue.
This checking is in mediabrowser.cpp around lines 2940 (which uses trackExists on mtpmediadevice.cpp) and sending to copyTrackToDevice occours one line 2999 where it never gets. Smells like a bug (add checking for tracknumber if there is one).
The example in comment #4 gets passed from trackExists but fails the code on copyTrackToDevice, maybe it should be removed (the 'if( m_fileNameToItem[ bundle.filename() ] != 0 )' code)?
Comment 6 Mikko Seppälä 2006-12-08 22:10:08 UTC
Autoconnecting is on mtpmediadevice.h line 112, njb misses this variable so it doesnt connect. Setting it to false solves the "problem".
Comment 7 Andy Kelk 2006-12-13 05:39:59 UTC
SVN commit 612921 by kelk:

Internationalize the strings for unknown artist, album, etc on MTP media devices.
Don't give an error if a device has no tracks on it. This is valid.
Don't automatically connect to MTP media devices.
CCBUG: 138409



 M  +7 -0      ChangeLog  
 M  +6 -13     src/mediadevice/mtp/mtpmediadevice.cpp  
 M  +1 -1      src/mediadevice/mtp/mtpmediadevice.h  


--- trunk/extragear/multimedia/amarok/ChangeLog #612920:612921
@@ -32,6 +32,13 @@
       you move and rename them.
 
   CHANGES:
+    * MTP media devices are not automatically connected on start-up. This 
+      should solve slow loading times for those with large collections on an 
+      MTP media device. Contributed by Mikko Seppälä. (BR 138409)
+    * Internationalize unknown artist/album/genre strings. Contributed by Mikko
+      Seppälä. (BR 138409)
+    * Don't assume that a device returning 0 tracks is invalid. It could just
+      have no tracks on. Contributed by Mikko Seppälä. (BR 138409)
     * Magnatune store look now matches rest of Amarok much better
     * Album art is displayed on the Magnatune purchase dialog
     * Generic media device now has an option to force VFAT-safe filenames even
--- trunk/extragear/multimedia/amarok/src/mediadevice/mtp/mtpmediadevice.cpp #612920:612921
@@ -59,7 +59,7 @@
 
 MtpMediaDevice::MtpMediaDevice() : MediaDevice()
 {
-    m_name = "MTP Device";
+    m_name = i18n("MTP Media Device");
     m_device = 0;
     m_folders = 0;
     m_playlistItem = 0;
@@ -224,7 +224,7 @@
 
     if( bundle.title().isEmpty() )
     {
-        trackmeta->title = qstrdup( "<Unknown title>" );
+        trackmeta->title = qstrdup( i18n( "Unknown title" ).utf8() );
     }
     else
     {
@@ -233,7 +233,7 @@
 
     if( bundle.album().isEmpty() )
     {
-        trackmeta->album = qstrdup( "<Unknown album>" );
+        trackmeta->album = qstrdup( i18n( "Unknown album" ).utf8() );
     }
     else
     {
@@ -242,7 +242,7 @@
 
     if( bundle.artist().isEmpty() )
     {
-        trackmeta->artist = qstrdup( "<Unknown artist>" );
+        trackmeta->artist = qstrdup( i18n( "Unknown artist" ).utf8() );
     }
     else
     {
@@ -251,7 +251,7 @@
 
     if( bundle.genre().isEmpty() )
     {
-        trackmeta->genre = qstrdup( "<Unknown genre>" );
+        trackmeta->genre = qstrdup( i18n( "Unknown genre" ).utf8() );
     }
     else
     {
@@ -1484,14 +1484,7 @@
 
     if( tracks == 0 )
     {
-        debug()<< "Error reading tracks. 0 returned." << endl;
-        Amarok::StatusBar::instance()->shortLongMessage(
-            genericError,
-            i18n( "Could not read MTP Device tracks" ),
-            KDE::StatusBar::Error
-        );
-        hideProgress();
-        return -1;
+        debug() << "0 tracks returned. Empty device..." << endl;
     }
     else
     {
--- trunk/extragear/multimedia/amarok/src/mediadevice/mtp/mtpmediadevice.h #612920:612921
@@ -128,7 +128,7 @@
 
     public:
         MtpMediaDevice();
-        virtual bool            autoConnect()          { return true; }
+        virtual bool            autoConnect()          { return false; }
         virtual bool            asynchronousTransfer() { return false; }
         bool                    isConnected();
         LIBMTP_mtpdevice_t      *current_device();
Comment 8 Alexandre Oliveira 2006-12-18 01:20:47 UTC
Patch was applied.
Comment 9 Alexandre Oliveira 2006-12-18 01:21:02 UTC
*** Bug 138741 has been marked as a duplicate of this bug. ***