[brasero] Ensure the drive/medium combo supports TAO/Incremental write mode
- From: Philippe Rouquier <philippr src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [brasero] Ensure the drive/medium combo supports TAO/Incremental write mode
- Date: Mon, 24 Aug 2009 13:46:46 +0000 (UTC)
commit 201a2fd31a1e668dd7c7ac81f6a246c60396110e
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date: Sat Aug 22 16:07:08 2009 +0200
Ensure the drive/medium combo supports TAO/Incremental write mode
This is to avoid showing things that can't be done (like leaving the disc open) with DVD-RW (incremental) when they are quick blanked.
libbrasero-burn/brasero-caps-session.c | 54 ++++++++++++------
libbrasero-media/brasero-medium.c | 99 ++++++++++++++++++++++++++------
2 files changed, 117 insertions(+), 36 deletions(-)
---
diff --git a/libbrasero-burn/brasero-caps-session.c b/libbrasero-burn/brasero-caps-session.c
index d786f52..e6acee5 100644
--- a/libbrasero-burn/brasero-caps-session.c
+++ b/libbrasero-burn/brasero-caps-session.c
@@ -1308,9 +1308,16 @@ brasero_caps_get_flags (BraseroCaps *caps,
return retval;
}
-static BraseroBurnFlag
+/* FIXME: make this public */
+gboolean
+brasero_medium_can_use_sao (BraseroMedium *medium);
+gboolean
+brasero_medium_can_use_tao (BraseroMedium *medium);
+
+static void
brasero_medium_supported_flags (BraseroMedium *medium,
- BraseroBurnFlag flags)
+ BraseroBurnFlag *supported_flags,
+ BraseroBurnFlag *compulsory_flags)
{
BraseroMedia media;
@@ -1318,43 +1325,53 @@ brasero_medium_supported_flags (BraseroMedium *medium,
/* This is always FALSE */
if (media & BRASERO_MEDIUM_PLUS)
- flags &= ~BRASERO_BURN_FLAG_DUMMY;
+ (*supported_flags) &= ~BRASERO_BURN_FLAG_DUMMY;
/* Simulation is only possible according to write modes. This mode is
* mostly used by cdrecord/wodim for CLONE images. */
else if (media & BRASERO_MEDIUM_DVD) {
if (!brasero_medium_can_use_dummy_for_sao (medium))
- flags &= ~BRASERO_BURN_FLAG_DUMMY;
+ (*supported_flags) &= ~BRASERO_BURN_FLAG_DUMMY;
}
- else if (flags & BRASERO_BURN_FLAG_DAO) {
+ else if ((*supported_flags) & BRASERO_BURN_FLAG_DAO) {
if (!brasero_medium_can_use_dummy_for_sao (medium))
- flags &= ~BRASERO_BURN_FLAG_DUMMY;
+ (*supported_flags) &= ~BRASERO_BURN_FLAG_DUMMY;
}
else if (!brasero_medium_can_use_dummy_for_tao (medium))
- flags &= ~BRASERO_BURN_FLAG_DUMMY;
+ (*supported_flags) &= ~BRASERO_BURN_FLAG_DUMMY;
- if (!brasero_medium_can_use_burnfree (medium))
- flags &= ~BRASERO_BURN_FLAG_BURNPROOF;
+ if (!brasero_medium_can_use_tao (medium)) {
+ (*supported_flags) &= ~BRASERO_BURN_FLAG_MULTI;
- return flags;
+ if (brasero_medium_can_use_sao (medium))
+ (*compulsory_flags) |= BRASERO_BURN_FLAG_DAO;
+ else
+ (*supported_flags) &= ~BRASERO_BURN_FLAG_DAO;
+ }
+
+ if (!brasero_medium_can_use_burnfree (medium))
+ (*supported_flags) &= ~BRASERO_BURN_FLAG_BURNPROOF;
}
-static BraseroBurnFlag
-brasero_burn_caps_flags_update_for_drive (BraseroBurnFlag flags,
- BraseroBurnSession *session)
+static void
+brasero_burn_caps_flags_update_for_drive (BraseroBurnSession *session,
+ BraseroBurnFlag *supported_flags,
+ BraseroBurnFlag *compulsory_flags)
{
BraseroDrive *drive;
BraseroMedium *medium;
drive = brasero_burn_session_get_burner (session);
if (!drive)
- return flags;
+ return;
medium = brasero_drive_get_medium (drive);
if (!medium)
- return TRUE;
+ return;
- return brasero_medium_supported_flags (medium, flags);
+ brasero_medium_supported_flags (medium,
+ supported_flags,
+ compulsory_flags);
}
static BraseroBurnResult
@@ -1761,8 +1778,9 @@ brasero_burn_session_get_burn_flags (BraseroBurnSession *session,
if (result != BRASERO_BURN_OK)
return result;
- supported_flags = brasero_burn_caps_flags_update_for_drive (supported_flags,
- session);
+ brasero_burn_caps_flags_update_for_drive (session,
+ &supported_flags,
+ &compulsory_flags);
if (supported)
*supported = supported_flags;
diff --git a/libbrasero-media/brasero-medium.c b/libbrasero-media/brasero-medium.c
index 4f33abc..20cf758 100644
--- a/libbrasero-media/brasero-medium.c
+++ b/libbrasero-media/brasero-medium.c
@@ -114,6 +114,8 @@ struct _BraseroMediumPrivate
guint dummy_sao:1;
guint dummy_tao:1;
guint burnfree:1;
+ guint sao:1;
+ guint tao:1;
guint blank_command:1;
guint write_command:1;
@@ -833,7 +835,7 @@ brasero_medium_get_capacity (BraseroMedium *medium,
*/
static gboolean
-brasero_medium_test_simulate_CD_TAO (BraseroMedium *self,
+brasero_medium_test_CD_TAO_simulate (BraseroMedium *self,
BraseroDeviceHandle *handle,
BraseroScsiErrCode *code)
{
@@ -859,8 +861,8 @@ brasero_medium_test_simulate_CD_TAO (BraseroMedium *self,
}
desc = hdr->desc;
- if (!desc->current)
- BRASERO_MEDIA_LOG ("Feature is not current");
+ priv->tao = (desc->current != 0);
+ BRASERO_MEDIA_LOG ("TAO feature is %s", priv->tao? "supported":"not supported");
tao_desc = (BraseroScsiCDTAODesc *) desc->data;
priv->dummy_tao = tao_desc->dummy != 0;
@@ -876,7 +878,7 @@ brasero_medium_test_simulate_CD_TAO (BraseroMedium *self,
}
static gboolean
-brasero_medium_test_simulate_CD_SAO (BraseroMedium *self,
+brasero_medium_test_CD_SAO_simulate (BraseroMedium *self,
BraseroDeviceHandle *handle,
BraseroScsiErrCode *code)
{
@@ -901,8 +903,8 @@ brasero_medium_test_simulate_CD_SAO (BraseroMedium *self,
}
desc = hdr->desc;
- if (!desc->current)
- BRASERO_MEDIA_LOG ("Feature is not current");
+ priv->sao = (desc->current != 0);
+ BRASERO_MEDIA_LOG ("SAO feature is %s", priv->sao? "supported":"not supported");
sao_desc = (BraseroScsiCDSAODesc *) desc->data;
priv->dummy_sao = sao_desc->dummy != 0;
@@ -913,9 +915,9 @@ brasero_medium_test_simulate_CD_SAO (BraseroMedium *self,
}
static gboolean
-brasero_medium_test_simulate_DVDRW (BraseroMedium *self,
- BraseroDeviceHandle *handle,
- BraseroScsiErrCode *code)
+brasero_medium_test_DVDRW_incremental_simulate (BraseroMedium *self,
+ BraseroDeviceHandle *handle,
+ BraseroScsiErrCode *code)
{
BraseroScsiDVDRWlessWrtDesc *less_wrt_desc;
BraseroScsiGetConfigHdr *hdr = NULL;
@@ -926,8 +928,26 @@ brasero_medium_test_simulate_DVDRW (BraseroMedium *self,
priv = BRASERO_MEDIUM_PRIVATE (self);
+ /* Try incremental feature */
+ BRASERO_MEDIA_LOG ("Checking incremental and simulate feature");
+ result = brasero_mmc2_get_configuration_feature (handle,
+ BRASERO_SCSI_FEAT_WRT_INCREMENT,
+ &hdr,
+ &size,
+ code);
+ if (result != BRASERO_SCSI_OK) {
+ BRASERO_MEDIA_LOG ("GET CONFIGURATION failed");
+ return FALSE;
+ }
+
+ priv->tao = (hdr->desc->current != 0);
+ g_free (hdr);
+ hdr = NULL;
+
+ BRASERO_MEDIA_LOG ("Incremental feature is %s", priv->tao? "supported":"not supported");
+
/* Only DVD-R(W) support simulation */
- BRASERO_MEDIA_LOG ("Checking simulate (DVD-R/W)");
+ BRASERO_MEDIA_LOG ("Checking (DVD-R(W) simulate)");
result = brasero_mmc2_get_configuration_feature (handle,
BRASERO_SCSI_FEAT_WRT_DVD_LESS,
&hdr,
@@ -939,8 +959,11 @@ brasero_medium_test_simulate_DVDRW (BraseroMedium *self,
}
desc = hdr->desc;
- if (!desc->current)
- BRASERO_MEDIA_LOG ("Feature is not current");
+
+ /* NOTE: SAO feature is always supported if this feature is current
+ * See MMC5 5.3.25 Write feature parameters */
+ priv->sao = (desc->current != 0);
+ BRASERO_MEDIA_LOG ("SAO feature is %s", priv->sao? "supported":"not supported");
less_wrt_desc = (BraseroScsiDVDRWlessWrtDesc *) desc->data;
priv->dummy_sao = less_wrt_desc->dummy != 0;
@@ -961,7 +984,7 @@ brasero_medium_test_simulate_DVDRW (BraseroMedium *self,
*/
static void
-brasero_medium_test_simulate_2A (BraseroMedium *self,
+brasero_medium_test_2A_simulate (BraseroMedium *self,
BraseroDeviceHandle *handle,
BraseroScsiErrCode *code)
{
@@ -973,6 +996,7 @@ brasero_medium_test_simulate_2A (BraseroMedium *self,
priv = BRASERO_MEDIUM_PRIVATE (self);
+ /* FIXME: we need to get a way to get the write types */
result = brasero_spc1_mode_sense_get_page (handle,
BRASERO_SPC_PAGE_STATUS,
&data,
@@ -1008,18 +1032,18 @@ brasero_medium_init_caps (BraseroMedium *self,
priv = BRASERO_MEDIUM_PRIVATE (self);
- /* These special media don't support/need burnfree and simulation */
+ /* These special media don't support/need burnfree, simulation, tao/sao */
if (priv->info & (BRASERO_MEDIUM_PLUS|BRASERO_MEDIUM_BD))
return;
if (priv->info & BRASERO_MEDIUM_CD) {
/* we have to do both */
- res = brasero_medium_test_simulate_CD_SAO (self, handle, code);
+ res = brasero_medium_test_CD_SAO_simulate (self, handle, code);
if (res)
- brasero_medium_test_simulate_CD_TAO (self, handle, code);
+ brasero_medium_test_CD_TAO_simulate (self, handle, code);
}
else
- res = brasero_medium_test_simulate_DVDRW (self, handle, code);
+ res = brasero_medium_test_DVDRW_incremental_simulate (self, handle, code);
BRASERO_MEDIA_LOG ("Tested simulation %d %d, burnfree %d",
priv->dummy_tao,
@@ -1031,7 +1055,7 @@ brasero_medium_init_caps (BraseroMedium *self,
/* it didn't work out as expected use fallback */
BRASERO_MEDIA_LOG ("Using fallback 2A page for testing simulation and burnfree");
- brasero_medium_test_simulate_2A (self, handle, code);
+ brasero_medium_test_2A_simulate (self, handle, code);
BRASERO_MEDIA_LOG ("Re-tested simulation %d %d, burnfree %d",
priv->dummy_tao,
@@ -3227,6 +3251,45 @@ brasero_medium_can_be_rewritten (BraseroMedium *medium)
return FALSE;
}
+/**
+ * brasero_medium_can_use_sao:
+ * @medium: #BraseroMedium
+ *
+ * Gets whether the medium supports SAO.
+ *
+ * Return value: a #gboolean. TRUE if the medium can use SAO write mode , FALSE otherwise.
+ *
+ **/
+gboolean
+brasero_medium_can_use_sao (BraseroMedium *medium)
+{
+ BraseroMediumPrivate *priv;
+
+ g_return_val_if_fail (BRASERO_IS_MEDIUM (medium), FALSE);
+
+ priv = BRASERO_MEDIUM_PRIVATE (medium);
+ return priv->sao;
+}
+
+/**
+ * brasero_medium_can_use_tao:
+ * @medium: #BraseroMedium
+ *
+ * Gets whether the medium supports TAO.
+ *
+ * Return value: a #gboolean. TRUE if the medium can use TAO write mode, FALSE otherwise.
+ *
+ **/
+gboolean
+brasero_medium_can_use_tao (BraseroMedium *medium)
+{
+ BraseroMediumPrivate *priv;
+
+ g_return_val_if_fail (BRASERO_IS_MEDIUM (medium), FALSE);
+
+ priv = BRASERO_MEDIUM_PRIVATE (medium);
+ return priv->tao;
+}
/**
* brasero_medium_can_use_dummy_for_sao:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]