[GSoC] UPnP progress report week 3

Nikhil Marathe nsm.nikhil at gmail.com
Sat Jun 5 19:17:08 CEST 2010


Hi,

The last two reports have been blog posts, but this week I have some
technical details and questions so the mail.

MediaServer kioslave: http://gitorious.org/kio-upnp-ms/mainline
Amarok Upnp Collection:
http://gitorious.org/~nikhilm/amarok/nikhilms-amarok/commits/upnp-collection

The amount of work done this week which someone would observe in the
UI is pretty much nil, and a case of coder's block attacked me for two
days :(

What I have done is:
* Add and remove UpnpCollection instances as Cagibi reports them,
* recursively scanning the MediaServer and parsing the tracks,
retrieving meta-data from the kioslave and even playing tracks when a
HTTP link is available!
* The slave itself is pretty fast and forgiving, and now does browsing
very well. Added support for listening for update events.

I have been thinking of how to:

1) Keep the UI from 'twitching' while the collection is updated. UPnP
collections are over the network and so using KIO::listRecursive is a
lengthy operation, which emits new entries every few signals.
UpnpCollection exposes a MemoryCollection/QueryMaker combination right
now, which overwrites the memory collection maps every time there are
new entries. This causes the UI to update quite frequently.

To prevent this, I have instead set a QTimer when I start a full scan
of the MediaServer, which is triggered every 5 seconds. Is that a good
way to do it, or am I still causing some heavy lifting under-the-hood?

A little issue I've found with multiple collections. Usually in the
Collections browser the 'Local Collection' is on top, and my
MediaServer is the second one. But every time an update occurs, the
MediaServer collection temporarily jumps to the top and then jumps
back down ( takes less than a second for the swap and reset ). Is this
expected behaviour?

2) Update checks and query parameters.

I have been wondering how to watch out for collection modifications
instead of doing full scans. Although updates aren't very frequent, I
love Amarok's way of updating local collections with new music I just
copied, and really want to implement this.
Since kioslaves lack event loops, it is not possible to have a
continous monitoring thread. My solution is:
 * Just like the slave is to have a HTTP like query parameter based
API for Search(),
   it will similarly have certain reserved parameters for notification tasks.
 * When a stat() is called on the slave with *any* path and a query parameter
    'checkupdate' set, it will just run the event loop and use KDirNotify to
    broadcast the updated paths. Right now their is code which does
this, although
    it has a limitation of not being able to resolve paths for all
items in the content
    directory, but which I will fix soon.
 * The UpnpCollection periodically calls a stat on the slave ( say
every 5 seconds? )
    and scans the relevant directories again. This is just like
polling used when inotify
    and friends aren't available on local filesystems.

I would love to hear your thoughts on these.

Regards,
Nikhil


More information about the Amarok-devel mailing list