[sound-juicer] sj_metadata_helper_check_media: error out when polling is in progress



commit ade4834ef8b3c6ca01127cb22d0768ac673d0275
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Mon Aug 1 12:49:55 2011 +0200

    sj_metadata_helper_check_media: error out when polling is in progress

 libjuicer/sj-error.h    |    3 ++-
 libjuicer/sj-metadata.c |    9 +++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/libjuicer/sj-error.h b/libjuicer/sj-error.h
index d23e577..3d8e94e 100644
--- a/libjuicer/sj-error.h
+++ b/libjuicer/sj-error.h
@@ -32,7 +32,8 @@ typedef enum {
   SJ_ERROR_INTERNAL_ERROR,
   SJ_ERROR_CD_PERMISSION_ERROR,
   SJ_ERROR_CD_NO_MEDIA,
-  SJ_ERROR_CD_LOOKUP_ERROR
+  SJ_ERROR_CD_LOOKUP_ERROR,
+  SJ_ERROR_CD_BUSY
 } SjError;
 
 GQuark sj_error_quark (void) G_GNUC_CONST;
diff --git a/libjuicer/sj-metadata.c b/libjuicer/sj-metadata.c
index 797c9ff..ce25cf6 100644
--- a/libjuicer/sj-metadata.c
+++ b/libjuicer/sj-metadata.c
@@ -175,10 +175,19 @@ sj_metadata_helper_check_media (const char *cdrom, GError **error)
 
   /* This initialize the library if it isn't done yet */
   monitor = brasero_medium_monitor_get_default ();
+  if (brasero_medium_monitor_is_probing (monitor)) {
+      /* FIXME: would be nicer to only check if "cdrom" is being probed,
+       * but libbrasero doesn't seem to have an API for that
+       */
+      g_set_error (error, SJ_ERROR, SJ_ERROR_CD_BUSY, _("Cannot read CD: %s"),
+                   _("Devices haven't been all probed yet"));
+      return FALSE;
+  }
   drive = brasero_medium_monitor_get_drive (monitor, cdrom);
   if (drive == NULL) {
     return FALSE;
   }
+
   medium = brasero_drive_get_medium (drive);
   g_object_unref (drive);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]