GNOME Bugzilla – Bug 705159
Only retrieve metadata once at start-up
Last modified: 2014-08-15 13:31:58 UTC
reread_cd was getting called twice at start-up if there was a disc in the drive, once from set_device and then again from media_added_cb. Fix this by removing the call from set_device.
Created attachment 250492 [details] [review] Only retrieve metadata once at start-up
Review of attachment 250492 [details] [review]: I would not remove the call from set_device actually, as when the cd reader that is being used is changed in the preferences, then set_device() is called from device_changed_cb(), and in that case we need to reread the CD.
I'm weary of removing it and breaking something but set_device calls set_drive_from_device which calls g_signal_connect (monitor, "medium-added", G_CALLBACK (media_added_cb), NULL); g_signal_connect (monitor, "medium-removed", G_CALLBACK (media_removed_cb), NULL); The 'medium-added' signal triggers the second call to reread_cd at start up so wont it do the same thing when the drive is changed? If so it would still be safe to remove the call to reread_cd from set_device as the reread would still be triggered. Unfortunately I don't have a second CD drive to test it.
For some reason, I remember checking that medium-added code and deciding the monitoring was per CD reader, not global. Looking again at that code, it's indeed global, not per CD reader, so this should work out. I should be able to test it with USB readers at work, I'll try to do that this week.
Now I remember why I ruled out media monitoring to do the right thing. The setup I had in mind was 2 CD readers, each already containing a CD. When you change the CD reader in the preferences, the UI does not get updated after your changes as this refresh is done through reread_cd. I've tested this with actual readers.
Created attachment 282769 [details] [review] Add utility functions for boolean actions. Avoid dealing with GVariants in the main code by adding getter and setter. This raises the required GLib version to 2.38 for g_action_parse_detailed_name().
Created attachment 282770 [details] [review] Give re-read action state Make re-read a boolean action so we can tell if a re-read is currently in progress.
Created attachment 282771 [details] [review] Don't retrieve metadata twice at start up When sound-juicer starts up it calls reread_cb() twice, once from set_device() and once from media_added_cb(). Add a check to media_added_cb() to see if the metadata is already being retrieved before calling reread_cd(). If the user changes the device while retrieving metadata we still start a new request for the new drive. It would be nice to make metadata retrieval cancellable in the future.
Attachment 282769 [details] pushed as 8dd1c00 - Add utility functions for boolean actions. Attachment 282770 [details] pushed as f9a94b7 - Give re-read action state Attachment 282771 [details] pushed as 8654a16 - Don't retrieve metadata twice at start up