archSeer/ruby-mpd — pull request #7 by federicobond (2013-09-24 03:25:37+00:00)
Title: Fix song callback when song number does not change

Currently, the MPD callback mechanism seems to be missing some song updates because of the way it compares against the last version of the status hash. The `:song` key stores an integer corresponding to the song number in the playlist. As far as I know (and please correct me if I'm wrong), this integer can remain constant even though the current song changed. E.g. when you are playing single songs from the library and the playlist is cleared before adding every new song, keeping `status[:song] == 0`.

This patch overrides the `:song` key in the status hash with the current song, performing an additional request to the MPD daemon, but thus making sure that we have correct information before entering the update loop. The `MPD::Song#==` method was also updated so that songs can be compared against nil.