Friday, 16 August 2013

Amarok 2.8 Released! (+MTP (Android) GSoC: weeks 8 & 9)

Folks,
the day has come. Amarok 2.8 is out! I know I've already said it about 2.7, but this is the best Amarok release. Ever. The number of improvements and bugfixes is insane. The official release announcement contains the most visible changes and the ChangeLog list them all, but let me highlight some that didn't fit into the announcement. We how (also) have:
  • Opus codec support including transcoding by Martin Brodbeck (only with development version of TagLib or 1.9 once it is released though).
  • ASX playlist support by Tatjana Gornak (used by many on-line radios).
  • Improved Nepomuk Collection that dynamically queries Nepomuk by Edward Toroshchin (still in beta state though).
  • Fixed Local Collection and Collection Browser that reflects removed files and folders immediately.
  • More keyboard shortcuts and possible UI workflows.
  • Improved and fixed Last.fm plugin.
  • More control over transcoding.
  • Improved File Browser.
We've changed a couple of existing things too:
  • We've removed the splash screen, with an SSD is it just an unnecessary flicker.
  • Album Artist level have replaced Artist one in the Collection Browser by default; the Artist level no-longer duplicates tracks under Various Artists.
  • Playback start on double-clicking has been made configurable, middle-click action to play tracks immediately has been added.
Apart from releasing Amarok, I've also done some work on my GSoC project, although the amount of it has been limited by my other responsibilities. Here comes the report for my project to rewrite MTP (Android) support in Amarok from scratch. I've mainly perfected editing of track metadata.


What I've done last weeks:
  • Finished support for editing track metadata in a way that I'm satisfied with. It is a bit elaborate, but anything less would be suboptimal, see:
    1. User changes some metadata.
      • we note the set of the metadata that she actually changed.
    2. Background job to process the change is initiated.
    3. MTP commands to update the properties are sent to the device. If the user has disabled Use File Metadata, the job is finished. Else...
    4. If the track is not yet cached locally, it is downloaded to the local filesystem.
      • Because the file tags are usually more accurate than the metadata the MTP device provides us, we update the current metadata with file tags, except the ones that were changed.
    5. Tags in the local cached file are updated using TagLib.
    6. The local cached file is (re)uploaded to the device under a temporary name with a random part in it.
    7. The old on-device track object is deleted
    8. The temporary on-device file is renamed back to the original one.
Problems I've faced:
  • There doesn't seem to be a way with MTP to replace contents of an existing object. This means that the item id of a existing tracks can change, which is unpleasant, but manageable.
What's next:
  • Config dialog, and finally transferring tracks to the device! (it is in fact half-done, because the code will be shared with track editing support)
You can view and test my code by checking out gsoc branch of my personal Amarok clone repository.

Monday, 5 August 2013

Amarok MTP (Android) GSoC: weeks 6 & 7

I was so busy coding in the last 2 weeks that I forgot a write a report. Here comes a combined report for weeks 6 and 7 concerning work on my Google Summer of Code project to rewrite MTP (Android) support in Amarok from scratch.
What I've done this week:
  • Changed MTP track cache path to be the "cache" directory (usually "/var/tmp/kdecache-$username/") instead of the "tmp" directory (usually /tmp/kde-$username/). The cache can get very big (gigabytes) in extreme cases and /tmp might be a size-constrained memory-backed filesystem.
  • Added code to explicitly remove stale files in MTP track cache. The relevant files are normally removed when the associated track is not referenced any more (i.e. when the device in unplugged), but for example when a MTP track remains in the playlist, it may be still referenced at the time Amarok quits.
  • Introduced support for keeping per-device MTP collection configuration (not yet represented in the UI).
  • Added first configuration option and associated feature: reading and writing file tags (in addition to MTP metadata; useful because at least my Samsung S II mini doesn't seem to be able to extract year and track number out of some files). This means that when a track file is available, tags are read from it, enhancing existing (MTP) tags. In future, it will work conversely when metadata are edited.
  • The trick from the previous post worked - track playback is started as soon as ~1 MB of it is cached. This means that playing even hours-long pieces straight off the devices should be instant.
  • Finally implemented edit-ability of MTP track metadata. It means that you can edit track tags in Amarok and it will tell the device to change them. See also What's next.
What's next:
  • According to my testing, at least my S III mini is able to remember track metadata we send to it, but it doesn't write it down to the actual files. I'll implement optional support to download, change and upload the file in metadata change.
  • Implementing a small dialog with configuration options and some device & troubleshooting info.
You can view and test my code by checking out gsoc branch of my personal Amarok clone repository.