Bug 139454

Summary: Media player devices (iPod): Call sync() after each transferred tracks to have correct progress indication
Product: [Applications] amarok Reporter: Gabriel Ambuehl <gabriel_ambuehl>
Component: Collections/iPod iPhoneAssignee: Amarok Developers <amarok-bugs-dist>
Status: RESOLVED FIXED    
Severity: wishlist CC: aikawarazuni, mail, matej, mike, petergaultney, richlv
Priority: NOR    
Version: 2.5-git   
Target Milestone: 2.6   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 2.6
Sentry Crash Report:

Description Gabriel Ambuehl 2007-01-01 00:59:41 UTC
Version:            (using KDE KDE 3.5.5)
Installed from:    Ubuntu Packages
OS:                Linux

Currently, all tracks seem to be written to the device and it's synced at the end (and/or) when Disconnect is called. Which takes forever if your device isn't very fast and you got a lot of RAM available for cache. I therefore propose to call sync() after each track so one gets a much more reliable indication of the progress the transfer has made so far.

Oh and happy new year, keep up the good work!
Comment 1 Martin Aumueller 2007-01-01 14:20:07 UTC
I think that this would slow down the process of transferring the files. So I'm not sure if this is actually a good idea.
Comment 2 Gabriel Ambuehl 2007-01-01 14:36:43 UTC
I'm not entirely sure if it would really slow down the process as opposed to 
make it reflect the progress much closer. 

When I think of it, MP3 are maybe 4mb per file or so, calling sync once every 
few MB shouldn't really kill performance very much. You do have to call it at 
the end of the process anyway (resulting in exactly the same amount of 
traffic to the device). Right now it looks like it's stuck on my machine when 
transfering say 500mb: the data is all stored in the cache very quickly then 
I have to wait forever for the "last" file to make it...
Comment 3 richlv 2007-01-03 11:01:01 UTC
i rarely use mediadevices with amarok, but i would prefer more useful progress bar over performace gain...

maybe it is possible to make some temporary option in svn version so people with mediadevices could test the change (unfortunately, i won't be able to not test it myself) ?
Comment 4 Myriam Schweingruber 2009-08-03 18:02:27 UTC
Not sure if this makes sense...
Comment 5 Peter Gaultney 2009-09-07 21:28:23 UTC
It makes a *ton* of sense.  Right now, Amarok's GUI often freezes entirely during file copy, and the progress bar jumps all over the place.  Why bother having a progress bar if it's going to jump from 6% to 29% to done?  

I definitely support this so-called 'feature request'.  Frankly, it's not just that; it's a bug, because the application's usability is substantially affected.
Comment 6 Mikko C. 2010-03-19 10:01:58 UTC
*** Bug 215728 has been marked as a duplicate of this bug. ***
Comment 7 Mike Bridge 2010-03-19 10:04:46 UTC
I definitely agree with Peter. Amarok's progress bar will stop three times while transferring a 12 song album. While running in debug mode, I notice the below indications. Something needs to be done to increase the amount of knowledge I have about what Amarok is doing relative to portable media transfer. As of now, I will run in debug mode whenever I transfer media.


amarok:         [IpodHandler] Adding  "The Pietasters"  -  "Drunken Master" 
amarok:       END__: virtual void Meta::IpodHandler::addTrackInDB(const Meta::MediaDeviceTrackPtr&) - Took 0.00042s 
amarok:       BEGIN: void Meta::MediaDeviceHandler::addMediaDeviceTrackToCollection(Meta::MediaDeviceTrackPtr&) 
amarok:         BEGIN: void Meta::MediaDeviceHandler::setupReadCapability() 
amarok:         END__: void Meta::MediaDeviceHandler::setupReadCapability() - Took 0.0002s 
amarok:       END__: void Meta::MediaDeviceHandler::addMediaDeviceTrackToCollection(Meta::MediaDeviceTrackPtr&) - Took 0.0013s 
amarok:        Tracks left to copy after this one is now done:  0 
amarok:     END__: void Meta::MediaDeviceHandler::slotFinalizeTrackCopy(const Meta::TrackPtr&) - Took 0.0025s 
amarok:   END__: void Meta::IpodHandler::slotCopyingDone(KIO::Job*, KUrl, KUrl, time_t, bool, bool) - Took 0.0031s 
amarok:   BEGIN: void CollectionLocation::slotFinishCopy() 
amarok:   END__: void CollectionLocation::slotFinishCopy() - Took 0.00031s 
amarok:   BEGIN: void Meta::IpodHandler::fileTransferred(KJob*) 
amarok:     [IpodHandler] Tracks to copy still remain 
amarok:     [IpodHandler] Jobs:  0 
amarok:     BEGIN: void Meta::MediaDeviceHandler::copyNextTrackToDevice() 
amarok:     END__: void Meta::MediaDeviceHandler::copyNextTrackToDevice() - Took 0.00021s
Comment 8 Matěj Laitl 2011-12-11 00:51:25 UTC
I think of implementing this for Amarok 2.6. There will be no performance penalty, fsync() will be called on individual files, and waiting for fsync() will be in a separate thread, so no regression shall be introduced.
Comment 9 Matěj Laitl 2012-04-15 15:43:43 UTC
Git commit 9bfe431375630655047ea8681a12ff6bd5422839 by Matěj Laitl.
Committed on 15/04/2012 at 12:24.
Pushed by laitl into branch 'master'.

Complete iPod collection rewrite (also supports iPad, iPhone)

This is a result of 3-month effort to make Amarok iPod-like device
support future-proof and less buggy by using more modern MemoryMeta
framework to manage tracks internally.

The new plugin still uses libgpod [1] to access the devices and
supports all devices supported by it. The newest models may need the
infamous libashab.so library.

FEATURES:
 * Small configuration dialog for iPods that shows troubleshooting information
   and allows to change iPod name.
 * Improved usability of iPod playlists: iPod collection automatically transfers
   tracks dropped to iPod playlists to iPod when it is needed.
 * Tracks can now be transcoded when transferring them to iPod.

CHANGES:
 * optional libgpod dependency raised to 0.8.2 to support newest iPods.
 * Amarok now prevents accidental unmounting of iPods in (small) time-frames
   when iTunes database on iPod is not yet updated.
 * Amarok detects when iPod is to be ejected from system and gracefully
   disconnects it when it occurs.
 * Hitting the eject button on iPod collection ejects it also from the system.
 * iPod collection now detects whether iPod is safe to write and marks iPod
   as read-only if not. This prevents "iPod shows 0 tracks" problem.
 * Correct progress bar advancement when transferring tracks to iPod.
 * iPod Collection supports multiple simultaneous cancellable transfers.
 * Improved dialog to initialize iPod.

BUGFIXES:
 * Detection and elimination of stale and orphaned iPod tracks now works
   correctly; users are notified about these when iPod is plugged in.
 * iPod playlists now work correctly.
 * Show correct error when transferring unsupported files to iPod.

[1] http://www.gtkpod.org/wiki/Libgpod
Related: bug 291722, bug 219963, bug 279797, bug 289304, bug 234876
FIXED-IN: 2.6
DIGEST: Amarok's iPod support is completely rewritten fixing many bugs
        and adding features

M  +3    -2    CMakeLists.txt
M  +21   -0    ChangeLog
M  +2    -2    README
M  +1    -1    src/core-impl/collections/CMakeLists.txt
A  +80   -0    src/core-impl/collections/ipodcollection/CMakeLists.txt
A  +642  -0    src/core-impl/collections/ipodcollection/IpodCollection.cpp     [License: GPL (v2+)]
A  +260  -0    src/core-impl/collections/ipodcollection/IpodCollection.h     [License: GPL (v2+)]
A  +259  -0    src/core-impl/collections/ipodcollection/IpodCollectionFactory.cpp     [License: GPL (v2+)]
A  +93   -0    src/core-impl/collections/ipodcollection/IpodCollectionFactory.h     [License: GPL (v2+)]
A  +119  -0    src/core-impl/collections/ipodcollection/IpodCollectionLocation.cpp     [License: GPL (v2+)]
A  +74   -0    src/core-impl/collections/ipodcollection/IpodCollectionLocation.h     [License: GPL (v2+)]
A  +845  -0    src/core-impl/collections/ipodcollection/IpodMeta.cpp     [License: GPL (v2+)]
A  +327  -0    src/core-impl/collections/ipodcollection/IpodMeta.h     [License: GPL (v2+)]
A  +141  -0    src/core-impl/collections/ipodcollection/IpodMetaEditCapability.cpp     [License: GPL (v2+)]
A  +63   -0    src/core-impl/collections/ipodcollection/IpodMetaEditCapability.h     [License: GPL (v2+)]
A  +248  -0    src/core-impl/collections/ipodcollection/IpodPlaylist.cpp     [License: GPL (v2+)]
A  +113  -0    src/core-impl/collections/ipodcollection/IpodPlaylist.h     [License: GPL (v2+)]
A  +496  -0    src/core-impl/collections/ipodcollection/IpodPlaylistProvider.cpp     [License: GPL (v2+)]
A  +114  -0    src/core-impl/collections/ipodcollection/IpodPlaylistProvider.h     [License: GPL (v2+)]
A  +24   -0    src/core-impl/collections/ipodcollection/amarok_collection-ipodcollection.desktop
A  +1    -0    src/core-impl/collections/ipodcollection/config-ipodcollection.h.cmake
A  +414  -0    src/core-impl/collections/ipodcollection/jobs/IpodCopyTracksJob.cpp     [License: GPL (v2+)]
A  +108  -0    src/core-impl/collections/ipodcollection/jobs/IpodCopyTracksJob.h     [License: GPL (v2+)]
A  +69   -0    src/core-impl/collections/ipodcollection/jobs/IpodDeleteTracksJob.cpp     [License: GPL (v2+)]
A  +46   -0    src/core-impl/collections/ipodcollection/jobs/IpodDeleteTracksJob.h     [License: GPL (v2+)]
A  +83   -0    src/core-impl/collections/ipodcollection/jobs/IpodParseTracksJob.cpp     [License: GPL (v2+)]
A  +49   -0    src/core-impl/collections/ipodcollection/jobs/IpodParseTracksJob.h     [License: GPL (v2+)]
A  +33   -0    src/core-impl/collections/ipodcollection/jobs/IpodWriteDatabaseJob.cpp     [License: GPL (v2+)]
A  +37   -0    src/core-impl/collections/ipodcollection/jobs/IpodWriteDatabaseJob.h     [License: GPL (v2+)]
A  +205  -0    src/core-impl/collections/ipodcollection/support/IphoneMountPoint.cpp     [License: GPL (v2+)]
A  +53   -0    src/core-impl/collections/ipodcollection/support/IphoneMountPoint.h     [License: GPL (v2+)]
A  +229  -0    src/core-impl/collections/ipodcollection/support/IpodConfiguration.ui
A  +466  -0    src/core-impl/collections/ipodcollection/support/IpodDeviceHelper.cpp     [License: GPL (v2+)]
A  +102  -0    src/core-impl/collections/ipodcollection/support/IpodDeviceHelper.h     [License: GPL (v2+)]
A  +58   -0    src/core-impl/collections/ipodcollection/support/IpodTranscodeCapability.cpp     [License: GPL (v2+)]
A  +49   -0    src/core-impl/collections/ipodcollection/support/IpodTranscodeCapability.h     [License: GPL (v2+)]

http://commits.kde.org/amarok/9bfe431375630655047ea8681a12ff6bd5422839