brasero r1242 - in trunk: . src
- From: philippr svn gnome org
- To: svn-commits-list gnome org
- Subject: brasero r1242 - in trunk: . src
- Date: Wed, 3 Sep 2008 18:10:16 +0000 (UTC)
Author: philippr
Date: Wed Sep 3 18:10:16 2008
New Revision: 1242
URL: http://svn.gnome.org/viewvc/brasero?rev=1242&view=rev
Log:
Added checks for simulation/burnfree to see if the drive supports them
* src/burn-caps.c (brasero_burn_caps_can_blank),
(brasero_burn_caps_flags_check_for_drive),
(brasero_burn_caps_new_task),
(brasero_burn_caps_flags_update_for_drive):
* src/burn-drive.c:
* src/burn-drive.h:
* src/burn-medium.c (brasero_medium_supported_flags),
(brasero_medium_support_flags),
(brasero_medium_test_simulate_CD_SAO),
(brasero_medium_test_simulate_CD_TAO),
(brasero_medium_test_simulate_DVDRW),
(brasero_medium_test_simulate_2A), (brasero_medium_init_caps),
(brasero_medium_init_real):
* src/burn-medium.h:
Modified:
trunk/ChangeLog
trunk/src/burn-caps.c
trunk/src/burn-drive.c
trunk/src/burn-drive.h
trunk/src/burn-medium.c
trunk/src/burn-medium.h
Modified: trunk/src/burn-caps.c
==============================================================================
--- trunk/src/burn-caps.c (original)
+++ trunk/src/burn-caps.c Wed Sep 3 18:10:16 2008
@@ -643,6 +643,7 @@
plugin = plugins->data;
if (!brasero_plugin_get_active (plugin))
continue;
+
if (brasero_plugin_check_blank_flags (plugin, media, flags)) {
BRASERO_BURN_LOG_DISC_TYPE (media, "Can blank");
return BRASERO_BURN_OK;
@@ -1210,18 +1211,19 @@
brasero_burn_caps_flags_check_for_drive (BraseroBurnSession *session)
{
BraseroDrive *drive;
+ BraseroMedium *medium;
BraseroBurnFlag flags;
drive = brasero_burn_session_get_burner (session);
if (!drive)
return TRUE;
- flags = brasero_burn_session_get_flags (session);
- if (!brasero_drive_has_safe_burn (drive)
- && !(flags & BRASERO_BURN_FLAG_BURNPROOF))
- return FALSE;
+ medium = brasero_drive_get_medium (drive);
+ if (!medium)
+ return TRUE;
- return TRUE;
+ flags = brasero_burn_session_get_flags (session);
+ return brasero_medium_support_flags (medium, flags);
}
GSList *
@@ -1276,10 +1278,11 @@
BRASERO_PLUGIN_IO_NONE,
"Input set =");
- session_flags = brasero_burn_session_get_flags (session);
if (!brasero_burn_caps_flags_check_for_drive (session))
BRASERO_BURN_CAPS_NOT_SUPPORTED_LOG (session);
+ session_flags = brasero_burn_session_get_flags (session);
+
/* Here remove BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE since we'll handle
* any possible need for blanking just afterwards if it doesn't work */
session_flags &= ~(BRASERO_BURN_FLAG_BLANK_BEFORE_WRITE|
@@ -1965,6 +1968,11 @@
return BRASERO_BURN_OK;
}
+/**
+ * This is only to be used in case one wants to copy using the same drive.
+ * It determines the possible middle image type.
+ */
+
static BraseroBurnResult
brasero_burn_caps_is_session_supported_same_src_dest (BraseroBurnCaps *self,
BraseroBurnSession *session)
@@ -2279,15 +2287,17 @@
BraseroBurnSession *session)
{
BraseroDrive *drive;
+ BraseroMedium *medium;
drive = brasero_burn_session_get_burner (session);
if (!drive)
return flags;
- if (!brasero_drive_has_safe_burn (drive))
- flags &= ~BRASERO_BURN_FLAG_BURNPROOF;
+ medium = brasero_drive_get_medium (drive);
+ if (!medium)
+ return TRUE;
- return flags;
+ return brasero_medium_supported_flags (medium, flags);
}
static BraseroBurnResult
Modified: trunk/src/burn-drive.c
==============================================================================
--- trunk/src/burn-drive.c (original)
+++ trunk/src/burn-drive.c Wed Sep 3 18:10:16 2008
@@ -376,15 +376,6 @@
BRASERO_DRIVE_CAPS_DVDRW_PLUS_DL));
}
-gboolean
-brasero_drive_has_safe_burn (BraseroDrive *self)
-{
- BraseroDrivePrivate *priv;
-
- priv = BRASERO_DRIVE_PRIVATE (self);
- return TRUE;
-}
-
static void
brasero_drive_init (BraseroDrive *object)
{ }
Modified: trunk/src/burn-drive.h
==============================================================================
--- trunk/src/burn-drive.h (original)
+++ trunk/src/burn-drive.h Wed Sep 3 18:10:16 2008
@@ -105,9 +105,6 @@
brasero_drive_can_write (BraseroDrive *drive);
gboolean
-brasero_drive_has_safe_burn (BraseroDrive *drive);
-
-gboolean
brasero_drive_is_door_open (BraseroDrive *drive);
gboolean
Modified: trunk/src/burn-medium.c
==============================================================================
--- trunk/src/burn-medium.c (original)
+++ trunk/src/burn-medium.c Wed Sep 3 18:10:16 2008
@@ -79,6 +79,11 @@
N_("Rewritable Blu-ray disc"),
NULL };
+typedef enum {
+ BRASERO_MEDIUM_CAP_INVALID = 0,
+ BRASERO_MEDIUM_CAP_TRUE = 1,
+ BRASERO_MEDIUM_CAP_FALSE = 2
+} BraseroMediumCapState;
typedef struct _BraseroMediumPrivate BraseroMediumPrivate;
struct _BraseroMediumPrivate
@@ -108,6 +113,11 @@
BraseroMedia info;
BraseroDrive *drive;
+
+ /* Do we really need both? */
+ guint dummy_sao:2;
+ guint dummy_tao:2;
+ guint burnfree:2;
};
#define BRASERO_MEDIUM_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_MEDIUM, BraseroMediumPrivate))
@@ -163,6 +173,69 @@
return priv->info;
}
+BraseroBurnFlag
+brasero_medium_supported_flags (BraseroMedium *self,
+ BraseroBurnFlag flags)
+{
+ BraseroMediumPrivate *priv;
+
+ priv = BRASERO_MEDIUM_PRIVATE (self);
+
+ /* This is always FALSE */
+ if (priv->info & BRASERO_MEDIUM_PLUS)
+ 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 (priv->info & BRASERO_MEDIUM_DVD) {
+ if (priv->dummy_sao != BRASERO_MEDIUM_CAP_TRUE)
+ flags &= ~BRASERO_BURN_FLAG_DUMMY;
+ }
+ else if (flags & BRASERO_BURN_FLAG_DAO) {
+ if (priv->dummy_sao != BRASERO_MEDIUM_CAP_TRUE)
+ flags &= ~BRASERO_BURN_FLAG_DUMMY;
+ }
+ else if (priv->dummy_tao != BRASERO_MEDIUM_CAP_TRUE)
+ flags &= ~BRASERO_BURN_FLAG_DUMMY;
+
+ if (!priv->burnfree)
+ flags &= ~BRASERO_BURN_FLAG_BURNPROOF;
+
+ return flags;
+}
+
+gboolean
+brasero_medium_support_flags (BraseroMedium *self,
+ BraseroBurnFlag flags)
+{
+ BraseroMediumPrivate *priv;
+
+ priv = BRASERO_MEDIUM_PRIVATE (self);
+
+ if (flags & BRASERO_BURN_FLAG_DUMMY) {
+ /* This is always FALSE */
+ if (priv->info & BRASERO_MEDIUM_PLUS)
+ return FALSE;
+
+ if (priv->info & BRASERO_MEDIUM_DVD) {
+ if (priv->dummy_sao != BRASERO_MEDIUM_CAP_TRUE)
+ return FALSE;
+ }
+ else if (flags & BRASERO_BURN_FLAG_DAO) {
+ if (priv->dummy_sao != BRASERO_MEDIUM_CAP_TRUE)
+ return FALSE;
+ }
+ else if (priv->dummy_tao != BRASERO_MEDIUM_CAP_TRUE)
+ return FALSE;
+ }
+
+ if (flags & BRASERO_BURN_FLAG_BURNPROOF) {
+ if (!priv->burnfree)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
GSList *
brasero_medium_get_tracks (BraseroMedium *medium)
{
@@ -560,6 +633,201 @@
}
/**
+ * Test presence of simulate burning
+ */
+
+static BraseroBurnResult
+brasero_medium_test_simulate_CD_SAO (BraseroMedium *self,
+ BraseroDeviceHandle *handle,
+ BraseroScsiErrCode *code)
+{
+ BraseroScsiGetConfigHdr *hdr = NULL;
+ BraseroScsiCDTAODesc *tao_desc;
+ BraseroScsiFeatureDesc *desc;
+ BraseroMediumPrivate *priv;
+ BraseroScsiResult result;
+ int size;
+
+ priv = BRASERO_MEDIUM_PRIVATE (self);
+
+ /* Try TAO and then SAO if it isn't persistent */
+ BRASERO_BURN_LOG ("Checking simulate (CD TAO)");
+ result = brasero_mmc2_get_configuration_feature (handle,
+ BRASERO_SCSI_FEAT_WRT_TAO,
+ &hdr,
+ &size,
+ code);
+ if (result != BRASERO_SCSI_OK) {
+ BRASERO_BURN_LOG ("GET CONFIGURATION failed");
+ return BRASERO_BURN_ERR;
+ }
+
+ desc = hdr->desc;
+ if (!desc->current)
+ BRASERO_BURN_LOG ("Feature is not current");
+
+ tao_desc = (BraseroScsiCDTAODesc *) desc->data;
+ priv->dummy_tao = tao_desc->dummy ? BRASERO_MEDIUM_CAP_TRUE:BRASERO_MEDIUM_CAP_FALSE;
+ priv->burnfree = tao_desc->buf ? BRASERO_MEDIUM_CAP_TRUE:BRASERO_MEDIUM_CAP_FALSE;
+ g_free (hdr);
+ return BRASERO_BURN_OK;
+}
+
+static BraseroBurnResult
+brasero_medium_test_simulate_CD_TAO (BraseroMedium *self,
+ BraseroDeviceHandle *handle,
+ BraseroScsiErrCode *code)
+{
+ BraseroScsiGetConfigHdr *hdr = NULL;
+ BraseroScsiCDSAODesc *sao_desc;
+ BraseroScsiFeatureDesc *desc;
+ BraseroMediumPrivate *priv;
+ BraseroScsiResult result;
+ int size;
+
+ priv = BRASERO_MEDIUM_PRIVATE (self);
+
+ BRASERO_BURN_LOG ("Checking simulate (CD SAO)");
+ result = brasero_mmc2_get_configuration_feature (handle,
+ BRASERO_SCSI_FEAT_WRT_SAO_RAW,
+ &hdr,
+ &size,
+ code);
+ if (result != BRASERO_SCSI_OK) {
+ BRASERO_BURN_LOG ("GET CONFIGURATION failed");
+ return BRASERO_BURN_ERR;
+ }
+
+ desc = hdr->desc;
+ if (!desc->current)
+ BRASERO_BURN_LOG ("Feature is not current");
+
+ sao_desc = (BraseroScsiCDSAODesc *) desc->data;
+ priv->dummy_sao = sao_desc->dummy ? BRASERO_MEDIUM_CAP_TRUE:BRASERO_MEDIUM_CAP_FALSE;
+ priv->burnfree = sao_desc->buf ? BRASERO_MEDIUM_CAP_TRUE:BRASERO_MEDIUM_CAP_FALSE;
+ g_free (hdr);
+ return BRASERO_BURN_OK;
+}
+
+static BraseroBurnResult
+brasero_medium_test_simulate_DVDRW (BraseroMedium *self,
+ BraseroDeviceHandle *handle,
+ BraseroScsiErrCode *code)
+{
+ BraseroScsiDVDRWlessWrtDesc *less_wrt_desc;
+ BraseroScsiGetConfigHdr *hdr = NULL;
+ BraseroScsiFeatureDesc *desc;
+ BraseroMediumPrivate *priv;
+ BraseroScsiResult result;
+ int size;
+
+ priv = BRASERO_MEDIUM_PRIVATE (self);
+
+ /* Only DVD-R(W) support simulation */
+ BRASERO_BURN_LOG ("Checking simulate (DVD-R/W)");
+ result = brasero_mmc2_get_configuration_feature (handle,
+ BRASERO_SCSI_FEAT_WRT_DVD_LESS,
+ &hdr,
+ &size,
+ code);
+ if (result != BRASERO_SCSI_OK) {
+ BRASERO_BURN_LOG ("GET CONFIGURATION failed");
+ return BRASERO_BURN_ERR;
+ }
+
+ desc = hdr->desc;
+ if (!desc->current)
+ BRASERO_BURN_LOG ("Feature is not current");
+
+ less_wrt_desc = (BraseroScsiDVDRWlessWrtDesc *) desc->data;
+ priv->dummy_sao = less_wrt_desc->dummy ? BRASERO_MEDIUM_CAP_TRUE:BRASERO_MEDIUM_CAP_FALSE;
+ priv->dummy_tao = less_wrt_desc->dummy ? BRASERO_MEDIUM_CAP_TRUE:BRASERO_MEDIUM_CAP_FALSE;
+ priv->burnfree = less_wrt_desc->buf ? BRASERO_MEDIUM_CAP_TRUE:BRASERO_MEDIUM_CAP_FALSE;
+ g_free (hdr);
+ return BRASERO_BURN_OK;
+}
+
+/**
+ * This is a last resort when the initialization has failed.
+ */
+
+static void
+brasero_medium_test_simulate_2A (BraseroMedium *self,
+ BraseroDeviceHandle *handle,
+ BraseroScsiErrCode *code)
+{
+ BraseroScsiStatusPage *page_2A = NULL;
+ BraseroScsiModeData *data = NULL;
+ BraseroMediumPrivate *priv;
+ BraseroScsiResult result;
+ int size = 0;
+
+ priv = BRASERO_MEDIUM_PRIVATE (self);
+
+ result = brasero_spc1_mode_sense_get_page (handle,
+ BRASERO_SPC_PAGE_STATUS,
+ &data,
+ &size,
+ code);
+ if (result != BRASERO_SCSI_OK) {
+ BRASERO_BURN_LOG ("MODE SENSE failed");
+ return;
+ }
+
+ /* NOTE: this bit is only valid:
+ * - for CDs when mode write is TAO or SAO
+ * - for DVDs when mode write is incremental or SAO
+ */
+
+ page_2A = (BraseroScsiStatusPage *) &data->page;
+ priv->dummy_sao = page_2A->dummy ? BRASERO_MEDIUM_CAP_TRUE:BRASERO_MEDIUM_CAP_FALSE;
+ priv->dummy_tao = page_2A->dummy ? BRASERO_MEDIUM_CAP_TRUE:BRASERO_MEDIUM_CAP_FALSE;
+ priv->burnfree = page_2A->buffer ? BRASERO_MEDIUM_CAP_TRUE:BRASERO_MEDIUM_CAP_FALSE;
+ g_free (data);
+}
+
+static void
+brasero_medium_init_caps (BraseroMedium *self,
+ BraseroDeviceHandle *handle,
+ BraseroScsiErrCode *code)
+{
+ BraseroMediumPrivate *priv;
+ BraseroScsiResult res;
+
+ priv = BRASERO_MEDIUM_PRIVATE (self);
+
+ /* These special media don't support/need burnfree and simulation */
+ if (priv->info & BRASERO_MEDIUM_PLUS)
+ return;
+
+ if (priv->info & BRASERO_MEDIUM_CD) {
+ /* we have to do both */
+ res = brasero_medium_test_simulate_CD_SAO (self, handle, code);
+ if (res == BRASERO_SCSI_OK)
+ brasero_medium_test_simulate_CD_TAO (self, handle, code);
+ }
+ else
+ res = brasero_medium_test_simulate_DVDRW (self, handle, code);
+
+ BRASERO_BURN_LOG ("Tested simulation %d %d, burnfree %d",
+ priv->dummy_tao,
+ priv->dummy_sao,
+ priv->burnfree);
+
+ if (res == BRASERO_SCSI_OK)
+ return;
+
+ /* it didn't work out as expected use fallback */
+ BRASERO_BURN_LOG ("Using fallback 2A page for testing simulation and burnfree");
+ brasero_medium_test_simulate_2A (self, handle, code);
+
+ BRASERO_BURN_LOG ("Re-tested simulation %d %d, burnfree %d",
+ priv->dummy_tao,
+ priv->dummy_sao,
+ priv->burnfree);
+}
+
+/**
* Function to retrieve the capacity of a media
*/
@@ -2307,6 +2575,8 @@
if (BRASERO_MEDIUM_IS (priv->info, (BRASERO_MEDIUM_DVD|BRASERO_MEDIUM_ROM)))
brasero_medium_get_css_feature (object, handle, &code);
+ brasero_medium_init_caps (object, handle, &code);
+
BRASERO_BURN_LOG_DISC_TYPE (priv->info, "media is ");
if (!priv->wr_speeds)
Modified: trunk/src/burn-medium.h
==============================================================================
--- trunk/src/burn-medium.h (original)
+++ trunk/src/burn-medium.h Wed Sep 3 18:10:16 2008
@@ -22,6 +22,8 @@
#include <glib-object.h>
+#include "burn-basics.h"
+
#ifndef _BURN_MEDIUM_H_
#define _BURN_MEDIUM_H_
@@ -202,12 +204,21 @@
guint64 blocks_num;
};
typedef struct _BraseroMediumTrack BraseroMediumTrack;
+
void
brasero_medium_reload_info (BraseroMedium *self);
BraseroMedia
brasero_medium_get_status (BraseroMedium *medium);
+gboolean
+brasero_medium_support_flags (BraseroMedium *medium,
+ BraseroBurnFlag flags);
+
+BraseroBurnFlag
+brasero_medium_supported_flags (BraseroMedium *self,
+ BraseroBurnFlag flags);
+
GSList *
brasero_medium_get_tracks (BraseroMedium *medium);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]