Amarok Mobile – The Beginning
This post is actually rather after the fact. I’ve been super busy, and my blogging tends to fall way, way behind when that happens. But I wanted to tell people about plans for Amarok Mobile, where things stand now, and what needs to be done. (And how you could help!)
First off, I need to give a big shout-out to Nokia. A while back, they donated ten n900 devices to KDE developers who submitted proposals describing what they would work on. I was one of the lucky winners, and this provided both the motivation and means to start working on an Amarok Mobile.
I actually was not initially supposed to use this for Amarok Mobile development — I had sumitted a proposal to bring functionality similar to the beloved* Popup Dropper into a library for Maemo programs. Problem: having never used Maemo before, I didn’t realize it had longpress functionality (my previous phone was an iPhone).
So, not wanting to reinvent the wheel needlessely, I instead decided to start working on exactly what everyone had assumed/thought/wanted me to be working on when they heard I was one of the n900 recipients: Amarok Mobile.
Below is a record of some of the work that has been done, and that remains to be done.
Core work
In large part due to its very rapid pace of development, Amarok’s code base has had a habit of growing haphazardly, and one of the results has been a lot of incestuous code…things coupled when they really shouldn’t be, code being referenced and implemented all over the place, and so on.
As a result, one of the first things I did was to work on separating out code that provide core functionality — things like podcasts, playlists, our metadata system, collections, and more — and boil them down to the basics. The rule for the core library is: no GUI code, and nothing inside core may reference any files outside of core. The point is that core should comprise the essence of Amarok, and much of what’s left are the possibly platform-specific implementations. In addition, I standardized namespaces for the parts of core, standardized include headers (which makes it much easier to handle file moves later, since they are fully-pathed from the top level source directory), and had absolutely countless compilation cycles. It was an absolute fsckload of work.
However, I think it paid off. We now have, inside src/, a core/ directory and a core-impl/ directory. If we studiously keep core/ separated, it will provide an excellent base on which alternative GUIs and implementations of those core classes can be built. In addition, more things will be moved there, or at least the paradigm will continue being followed; for instance, our great contributor Erik Hovland has been making progress on separating out the GUI layer from our Services framework so that we can have the great services like Ampache and Magnatune and Last.fm and so on be relatively easily activated on other platforms.
SQL
Amarok 2 currently uses MySQL exclusively, allowing you to either use a MySQL server or libmysqld for an embedded database. This has pros and cons, but the really relevant pro is the huge speed gains we get over SQLite. (Before people comment about how we must be doing something wrong: we’re not the only project that has seen serious speed problems with SQLite — I know that Quassel has had similar issues; and if you’re convinced that it’s our schema or some other such thing, you’re welcome to help us improve it. Many others have made this claim, and none of them have ever taken our invitation to actually help us improve things.)
So the obvious question comes up: what about Amarok Mobile? I’m not sure how realistic it is to expect that we can get libmysqld running efficiently on the n900, especially given its memory limitations. At the same time, SQLite is readily available. But, we want to avoid writing tons of custom code.
As it turns out Quassel has a really great storage abstraction using QtSql, and they use both SQLite and PostgreSQL. So, if we copied their really nice approach, we could maybe support SQLite with Amarok Mobile while reducing developer effort to a minimum (since none of us are SQL experts).
One of the big problems we’ve had with QtSql before is that the QMYSQL plugin can support libmysqld (except that it can’t; more on that in a second), but in one of the most boneheaded software design choices I’ve ever seen in my life, MySQL determines whether you’re connecting to a server or an embedded server based on which library your program *links* to. This is not a runtime option. Wut.
So — the obvious option is to bring to Qt what we do in Amarok — instead of having a QMYSQL driver that has to link to one of the other, have a QMYSQL driver linking to the server libraries and a QMYSQLE driver linking to the embedded libraries, and let application developers choose one or both. I began working on this, and have been successful in building both drivers, and have high hopes I can get it included into Qt 4.8 (there’s necessarily a lot of code duplication, so I’ll have to see what they say about that…I may be able to abstract some of it into shared functions, but anywhere that mysql in any case was used, I had to replace with mysqle).
Now, I said that it can’t actually support libmysqld. The reason is that you pass in options for the embedded server upon library init — but QtSql *always* initializes the library with null options. Which means, among other things, that it will use /var/lib/mysql (or whatever your compiled-in default is) for its database directory, which normally means that if you’re not the root user, you can’t actually do anything because it can’t create its files. Whoops.
I can’t break ABI or API, so I’ve been wondering what to do about this — some of the Qt guys suggested I create a new SQL framework with these drivers in it, but I don’t think that’s a great option. Instead, I plan on creating a new connection option (see the table here). Normally these are basically mapped to MySQL options and used like this:
db.setConnectOptions("CLIENT_SSL=1;CLIENT_IGNORE_SPACE=1");
This connection option will not be mapped directly to a MySQL option, but will instead take a delimited list of options, something like this:
db.setConnectOptions("CLIENT_SSL=1;CLIENT_IGNORE_SPACE=1;MYSQLD_INIT_OPTIONS=myoption1=myvalue1;;myoption2=myvalue2;;myoption3=myvalue3");
This would let you pass arbitrary options, and this list would be split and each of the options would be passed into library initialization. It’s API/ABI compatible and relatively straightforward, so it’s the best thing I can think of right now.
Future work
The next steps are to finish the QtSql modifications and get those submitted upstream. Maemo right now has Qt 4.6, but *eventually* will have 4.8…so when 4.8 is coming around, if my QtSql changes are in there, Amarok can try migrating to QtSql; to finish services GUI separation and separation of other parts of Amarok (like AmarokURLs), and to begin writing a GUI, ideally using the Qt Kinetic declarative UI library — when you’re starting from scratch, you might as well do it right. Fortunately some of these tasks will be much easier now that Qt is fully supported/included in the proper locations with the n900 PR 1.2 firmware release.
My time has become incredibly limited in the past month, so if you have time and are interested in helping, join us!
* Okay, I know one person that really, really hates it. And a lot of people that never really realized it was there. But a lot like it!
RSS
email
Print
PDF
Add to favorites
Identi.ca
Twitter
Google Buzz
Facebook
del.icio.us
Google Bookmarks
Reddit
Technorati
Slashdot
Digg
*Hat tip* for the name mention. I guess I had better stop messing around w/ my new N900 running PR1.2 and get to a little more hacking.
*whipcrack*
Amarok 3 – Ubiquitous Mobility
Congrats on taking these next important steps. For many people, these new devices will replace the desktop they currently use by transitioning them off of the personal computer completely. They also will for most of us, make use maintain multiple devices each with some or all of our media collection. Striped into these collections will surely be federated data from emerging online retailers as well as sites such as Spotify and Youtube. And Youtube type of content implies lots more metadata and tons of more data to shunt around.
Regardless of how you slice it, software like Amarok serves an important role assisting the user curate media that comes attached with very personal meanings. As developers, we may be one group that continues to depend on workstations at least a bit longer than the main stream. As for how we consume media however, we can expect to be following everybody else.
These critical observations suggest to me very clearly that sql as an abstraction is simply insufficient and will only serve to leave us less than fully inspired. In short we will invebitably be focused on solving symptomatic problems that are a throw back to broken relational database management systems. We are easily sidetracked and prevented from better investing our engergy. One example is how an example circumstance is in how near the top of the requirements for our mobile selves is a use case for painless replication of content between more than two devices. In the SQL world of yesteryear, this feature would have to be hand coded coded even though replication is a supposed to be feature of many databases. working with a databse layer we already identify as being fcukde is so not going to make us all better programmers.
Apple has been well served in how it has managed utilizing text/xml as a datastore while using its own event subscription model for data navigation within the app. I think that this demonstrates that performance is predicated on much more than the selected database. What Ubuntu is doing with its various DesktopCouch initiatives (including its Music Store) also echos this same non-sql architectural sentiment. Some of the most exciting stuff going on right now (node.js framework) has yet to be exploited in a major project.
The real challenges are problems that lay underneath the managed metadata anyway. Users notice if applications they use demonstrate fluidity when it comes to file management operations, data-streaming, and background task processing. And I am not inferring even winning fans. Users could not give a crap about the database engine. Software usualy is taken for granted. Bug slaying and delivering on over inflated expectations has been responsible for much developer joy kill. As much as I love what has been going on with the current releases of Amarok as desktop software, when saved metadata is unavailable such as in the case of new content on portable media players, everthing grinds to a halt. It can happen with iTunes as well. Here users do give a big crap.
The improvements with the Amarok’s collection scanning are super impressive already. A major performance bottleneck continues to be with in direct media access. I am not sure even how feasible it would be to construct non-blocking wrappers to act as proxy interfaces to the descriptive information encoded in the underlying binary files. Second, they would also serve lazy getter and setter functions to help to gather and manage a cache of key/value pairs of underlying metadata media property values. There is a bit of an opportunity to stand back and design a functional object model. Doing so would be a huge luxury; definitely one that few projects get to take advantage of.
It is ok to want to avoid writing a lot of custom code. When faced with a situation like this, there may be more effort loaded into the front end. Dropping QT’s built in support for SQL may not not solve any pressing short term problems and in fact may even not be feasible in a mobile Amarok’s debut release. Huge significance resulting from such an investment in the applications’s future would. Help create momentum for releasing an app that could make a difference in how people consume media just like version 1.4 did way back. Mobile is where all the action is going to be going forward. At best innovation that occurs in the mobile project may be folded back into the current desktop application.
Amarok itself will need to change into a different tool to meet new challenges. Making the departure from the \slave to the data layer mode of working\ and moving towards \a world of intuative and iterable rich media objects\ would make for a great way of enforcing the separation of core/ directory and a core-impl/ . The resulting components themselves are useful building blocks for others to use. This then makes it possible then for an expanded ecosystem made up of less technical developers who to tweak personalized curation tools for groups and organizations they associate with. This would be a worthwhile path and one that would surely make it a valuable project attracting contributors and help make Amarok a serious place for people wanting to effectively approach media management not just for themselves but also collaboratively. There are also generators like phonegap that make it possible to model functionality that can be deployed over muliple technologies.
I appologize for taking this detour and diverting from your message. i guess I got carried away. I have been thinking a lot about these things. I am totally impressed by all the hard work that went into making version 2 into the worthy successor to 1.4. I hope lots more great stuff is in store for the future!
Thanks for the detailed comment. You have a lot of good points, and many of them are in line with where we want to take Amarok eventually. I agree that SQL has its downsides, but when you mention things like Desktop Couch, remember that Ubuntu isn’t everything, and we must balance interoperability and diverse distribution needs with functionality. Do feel free to come talk to me some more on IRC if you like…I’m jefferai on FreeNode.