brasero r1835 - in trunk: . libbrasero-media
- From: philippr svn gnome org
- To: svn-commits-list gnome org
- Subject: brasero r1835 - in trunk: . libbrasero-media
- Date: Wed, 28 Jan 2009 17:15:56 +0000 (UTC)
Author: philippr
Date: Wed Jan 28 17:15:56 2009
New Revision: 1835
URL: http://svn.gnome.org/viewvc/brasero?rev=1835&view=rev
Log:
2009-01-28 Philippe Rouquier <ykw localhost localdomain>
Removed dead code and try to fix #57561 â Brasero don't recognize empty disk (comment #25).
To retrieve correct next writable addresses, brasero sets write modes to TAO, which is not
supported by DVD-Rs so now mode is set to incremental for these media.
* libbrasero-media/brasero-medium.c
(brasero_medium_track_set_leadout):
* libbrasero-media/scsi-read-track-information.c
(brasero_read_track_info):
* libbrasero-media/scsi-write-page.h:
Modified:
trunk/ChangeLog
trunk/libbrasero-media/brasero-medium.c
trunk/libbrasero-media/scsi-read-track-information.c
trunk/libbrasero-media/scsi-write-page.h
Modified: trunk/libbrasero-media/brasero-medium.c
==============================================================================
--- trunk/libbrasero-media/brasero-medium.c (original)
+++ trunk/libbrasero-media/brasero-medium.c Wed Jan 28 17:15:56 2009
@@ -1766,8 +1766,15 @@
wrt_page->session_format = 0;
BRASERO_SET_16 (wrt_page->pause_len, 150);
- wrt_page->write_type = BRASERO_SCSI_WRITE_TAO;
- wrt_page->track_mode = 4; /* should be 5 for DVD-R(W) */
+ if (priv->info & BRASERO_MEDIUM_CD) {
+ wrt_page->write_type = BRASERO_SCSI_WRITE_TAO;
+ wrt_page->track_mode = 4;
+ }
+ else if (priv->info & BRASERO_MEDIUM_DVD) {
+ wrt_page->write_type = BRASERO_SCSI_WRITE_PACKET_INC;
+ wrt_page->track_mode = 5;
+ }
+
wrt_page->data_block_type = 8;
result = brasero_spc1_mode_select (handle, data, size, code);
@@ -1828,7 +1835,6 @@
&track_info,
&size,
code);
-
if (result != BRASERO_SCSI_OK) {
/* This only for CD-R */
if (BRASERO_MEDIUM_IS (priv->info, BRASERO_MEDIUM_CDR|BRASERO_MEDIUM_BLANK))
@@ -2206,463 +2212,6 @@
return result;
}
-#if 0
-
-/**
- * These are special routines for old CD-R(W) drives that don't conform to MMC
- */
-
-static void
-brasero_medium_set_track_type (BraseroMedium *self,
- BraseroMediumTrack *track,
- guchar control)
-{
- BraseroMediumPrivate *priv;
-
- priv = BRASERO_MEDIUM_PRIVATE (self);
-
- if (control & BRASERO_SCSI_TRACK_COPY)
- track->type |= BRASERO_MEDIUM_TRACK_COPY;
-
- if (!(control & BRASERO_SCSI_TRACK_DATA)) {
- track->type |= BRASERO_MEDIUM_TRACK_AUDIO;
- priv->info |= BRASERO_MEDIUM_HAS_AUDIO;
-
- if (control & BRASERO_SCSI_TRACK_PREEMP)
- track->type |= BRASERO_MEDIUM_TRACK_PREEMP;
-
- if (control & BRASERO_SCSI_TRACK_4_CHANNELS)
- track->type |= BRASERO_MEDIUM_TRACK_4_CHANNELS;
- }
- else {
- track->type |= BRASERO_MEDIUM_TRACK_DATA;
- priv->info |= BRASERO_MEDIUM_HAS_DATA;
-
- if (control & BRASERO_SCSI_TRACK_DATA_INCREMENTAL)
- track->type |= BRASERO_MEDIUM_TRACK_INCREMENTAL;
- }
-}
-
-/**
- * return :
- * 0 when it's not possible to determine (fallback to formatted toc)
- * -1 for BCD
- * 1 for HEX */
-static guint
-brasero_medium_check_BCD_use (BraseroMedium *self,
- BraseroDeviceHandle *handle,
- BraseroScsiRawTocDesc *desc,
- guint num,
- BraseroScsiErrCode *code)
-{
- guint i;
- int size;
- guint leadout = 0;
- guint track_num = 0;
- gboolean use_BCD = TRUE;
- gboolean use_HEX = TRUE;
- BraseroScsiResult result;
- BraseroScsiTrackInfo track_info;
- guint start_BCD, start_LBA, track_start;
-
- /* first check if all values are valid BCD numbers in the descriptors */
- for (i = 0; i < num; i++) {
- if (desc [i].adr == 1 && desc [i].point <= BRASERO_SCSI_Q_SUB_CHANNEL_TRACK_START) {
- if (!BRASERO_IS_BCD_VALID (desc [i].p_min)
- || !BRASERO_IS_BCD_VALID (desc [i].p_sec)
- || !BRASERO_IS_BCD_VALID (desc [i].p_frame)) {
- use_BCD = FALSE;
- break;
- }
- }
- else if (desc [i].point == BRASERO_SCSI_Q_SUB_CHANNEL_LEADOUT_START) {
- if (!BRASERO_IS_BCD_VALID (desc [i].p_min)
- || !BRASERO_IS_BCD_VALID (desc [i].p_sec)
- || !BRASERO_IS_BCD_VALID (desc [i].p_frame)) {
- use_BCD = FALSE;
- break;
- }
- }
- }
-
- /* then check if there are valid Hex values */
- for (i = 0; i < num; i++) {
- if (desc [i].adr != 1 || desc [i].point > BRASERO_SCSI_Q_SUB_CHANNEL_TRACK_START)
- continue;
-
- if (desc [i].p_min > 99
- || desc [i].p_sec > 59
- || desc [i].p_frame > 74) {
- use_HEX = FALSE;
- break;
- }
- }
-
- if (use_BCD != use_HEX) {
- if (use_BCD)
- return -1;
-
- return 1;
- }
-
- /* To check if the drive uses BCD values or HEX values we ask for the
- * track information that contains also the start for the track but in
- * HEX values. If values are the same then it works. */
-
- /* NOTE: there could be another way to do it: get first track, in LBA
- * and BCD it must be 150. */
-
- /* First find the first track and get track start address in BCD */
- BRASERO_MEDIA_LOG ("Retrieving track information to determine number format");
-
- for (i = 0; i < num; i++) {
- if (desc [i].adr == BRASERO_SCSI_Q_SUB_CHANNEL_LEADIN_MODE5
- && desc [i].point == BRASERO_SCSI_Q_SUB_CHANNEL_MULTI_NEXT_SESSION) {
- /* store the leadout number just in case */
- leadout = i;
- continue;
- }
-
- if (desc [i].adr != 1 || desc [i].point > BRASERO_SCSI_Q_SUB_CHANNEL_TRACK_START)
- continue;
-
- track_num ++;
-
- start_BCD = BRASERO_MSF_TO_LBA (BRASERO_GET_BCD (desc [i].p_min),
- BRASERO_GET_BCD (desc [i].p_sec),
- BRASERO_GET_BCD (desc [i].p_frame));
-
- start_LBA = BRASERO_MSF_TO_LBA (desc [i].p_min,
- desc [i].p_sec,
- desc [i].p_frame);
-
- BRASERO_MEDIA_LOG ("Comparing to track information from READ TRACK INFO for track %i", track_num);
-
- size = 36;
- start_LBA -= 150;
- start_BCD -= 150;
-
-/*
- result = brasero_mmc1_read_track_info (handle,
- track_num,
- &track_info,
- &size,
- code);
-
- if (result != BRASERO_SCSI_OK) {
- BRASERO_MEDIA_LOG ("READ TRACK INFO failed");
-*/ /* Fallback to formatted toc */
-/* return 0;
- }
-*/
- track_start = BRASERO_GET_32 (track_info.start_lba);
- BRASERO_MEDIA_LOG ("comparing DCB %i and LBA %i to real start address %i",
- start_BCD, start_LBA, track_start);
-
- /* try to find a conclusive match */
- if (track_start == start_BCD && track_start != start_LBA)
- return -1;
-
- if (track_start == start_LBA && track_start != start_BCD)
- return 1;
- }
-
- /* Our last chance, the leadout.
- * NOTE: no need to remove 150 sectors here. */
- start_BCD = BRASERO_MSF_TO_LBA (BRASERO_GET_BCD (desc [leadout].min),
- BRASERO_GET_BCD (desc [leadout].sec),
- BRASERO_GET_BCD (desc [leadout].frame));
-
- start_LBA = BRASERO_MSF_TO_LBA (desc [leadout].min,
- desc [leadout].sec,
- desc [leadout].frame);
-
- BRASERO_MEDIA_LOG ("Comparing to track information from READ TRACK INFO for leadout");
-
- size = 36;
-
- /* leadout number is number of tracks + 1 */
- result = brasero_mmc1_read_track_info (handle,
- track_num + 1,
- &track_info,
- &size,
- code);
-
- if (result != BRASERO_SCSI_OK) {
- BRASERO_MEDIA_LOG ("READ TRACK INFO failed for leadout");
- /* Fallback to formatted toc */
- return 0;
- }
-
- track_start = BRASERO_GET_32 (track_info.start_lba);
- BRASERO_MEDIA_LOG ("comparing DCB %i and LBA %i to real start address %i",
- start_BCD, start_LBA, track_start);
-
- /* try to find a conclusive match */
- if (track_start == start_BCD && track_start != start_LBA)
- return -1;
-
- if (track_start == start_LBA && track_start != start_BCD)
- return 1;
-
- /* fallback to formatted toc */
- return 0;
-}
-
-/**
- * The reason why we use this perhaps more lengthy method is that with
- * multisession discs, the first track is reported to be two sectors shorter
- * than it should. As I don't know why and since the following works we use
- * this one. */
-static BraseroBurnResult
-brasero_medium_get_CD_sessions_info (BraseroMedium *self,
- BraseroDeviceHandle *handle,
- BraseroScsiErrCode *code)
-{
- gint use_bcd;
- GSList *iter;
- int num, i, size;
- gint leadout_start = 0;
- BraseroScsiResult result;
- BraseroMediumPrivate *priv;
- BraseroScsiRawTocDesc *desc;
- BraseroScsiRawTocData *toc = NULL;
-
- BRASERO_MEDIA_LOG ("Reading Raw Toc");
-
- priv = BRASERO_MEDIUM_PRIVATE (self);
-
- size = 0;
- result = brasero_mmc1_read_toc_raw (handle,
- 0,
- &toc,
- &size,
- code);
- if (result != BRASERO_SCSI_OK) {
- BRASERO_MEDIA_LOG ("READ TOC failed");
- return BRASERO_BURN_ERR;
- }
-
- num = (size - sizeof (BraseroScsiRawTocData)) /
- sizeof (BraseroScsiRawTocDesc);
-
- BRASERO_MEDIA_LOG ("%i track(s) found", num);
-
- desc = toc->desc;
- use_bcd = brasero_medium_check_BCD_use (self, handle, desc, num, code);
- if (!use_bcd) {
- g_free (toc);
-
- BRASERO_MEDIA_LOG ("Fallback to formatted toc");
- return BRASERO_BURN_ERR;
- }
-
- if (use_bcd > 0)
- use_bcd = 0;
-
- if (use_bcd) {
- BRASERO_MEDIA_LOG ("Using BCD format");
- }
- else {
- BRASERO_MEDIA_LOG ("Using HEX format");
- }
-
- for (i = 0; i < num; i++, desc ++) {
- BraseroMediumTrack *track;
-
- track = NULL;
- if (desc->adr == 1 && desc->point <= BRASERO_SCSI_Q_SUB_CHANNEL_TRACK_START) {
- track = g_new0 (BraseroMediumTrack, 1);
- track->session = desc->session_num;
-
- brasero_medium_set_track_type (self, track, desc->control);
- if (use_bcd)
- track->start = BRASERO_MSF_TO_LBA (BRASERO_GET_BCD (desc->p_min),
- BRASERO_GET_BCD (desc->p_sec),
- BRASERO_GET_BCD (desc->p_frame));
- else
- track->start = BRASERO_MSF_TO_LBA (desc->p_min,
- desc->p_sec,
- desc->p_frame);
-
- track->start -= 150;
-
- /* if there are tracks and the last previously added track is in
- * the same session then set the size */
- if (priv->tracks) {
- BraseroMediumTrack *last_track;
-
- last_track = priv->tracks->data;
- if (last_track->session == track->session)
- last_track->blocks_num = track->start - last_track->start;
- }
-
- priv->tracks = g_slist_prepend (priv->tracks, track);
- }
- else if (desc->point == BRASERO_SCSI_Q_SUB_CHANNEL_LEADOUT_START) {
- /* NOTE: the leadout session is first in the list. So if
- * we have tracks in the list set the last session track
- * size when we reach a new leadout (and therefore a new
- * session). */
-
- if (priv->tracks) {
- BraseroMediumTrack *last_track;
-
- last_track = priv->tracks->data;
- last_track->blocks_num = leadout_start - last_track->start;
- }
-
- if (use_bcd)
- leadout_start = BRASERO_MSF_TO_LBA (BRASERO_GET_BCD (desc->p_min),
- BRASERO_GET_BCD (desc->p_sec),
- BRASERO_GET_BCD (desc->p_frame));
- else
- leadout_start = BRASERO_MSF_TO_LBA (desc->p_min,
- desc->p_sec,
- desc->p_frame);
- leadout_start -= 150;
- }
- }
-
- if (priv->tracks) {
- BraseroMediumTrack *last_track;
-
- /* set the last found track size */
- last_track = priv->tracks->data;
- last_track->blocks_num = leadout_start - last_track->start;
- }
-
- /* Add a leadout */
- if (!(priv->info & BRASERO_MEDIUM_CLOSED)) {
- BraseroMediumTrack *track;
-
- /* we shouldn't request info on leadout if the disc is closed */
- track = g_new0 (BraseroMediumTrack, 1);
- priv->tracks = g_slist_prepend (priv->tracks, track);
- track->start = leadout_start;
- track->type = BRASERO_MEDIUM_TRACK_LEADOUT;
-
- brasero_medium_track_get_info (self,
- FALSE,
- track,
- g_slist_length (priv->tracks),
- handle,
- code);
- }
-
- priv->tracks = g_slist_reverse (priv->tracks);
-
- for (iter = priv->tracks; iter; iter = iter->next) {
- BraseroMediumTrack *track;
-
- track = iter->data;
-
- /* check for tracks less that 300 sectors */
- if (track->blocks_num <= 300 && track->type != BRASERO_MEDIUM_TRACK_LEADOUT) {
- BRASERO_MEDIA_LOG ("300 sectors size. Checking for real size");
- brasero_medium_track_volume_size (self, track, handle);
- }
-
- BRASERO_MEDIA_LOG ("Track %i: type = %i start = %llu size = %llu",
- g_slist_index (priv->tracks, track),
- track->type,
- track->start,
- track->blocks_num);
- }
-
- g_free (toc);
- return BRASERO_BURN_OK;
-}
-
-static BraseroBurnResult
-brasero_medium_old_drive_get_disc_info (BraseroMedium *self,
- BraseroDeviceHandle *handle,
- BraseroScsiErrCode *code)
-{
- int size;
- BraseroScsiResult result;
- BraseroMediumPrivate *priv;
- BraseroScsiDiscInfoStd *info = NULL;
-
- BRASERO_MEDIA_LOG ("Retrieving media status for old drive");
-
- priv = BRASERO_MEDIUM_PRIVATE (self);
-
- result = brasero_mmc1_read_disc_information_std (handle,
- &info,
- &size,
- code);
- if (result != BRASERO_SCSI_OK) {
- g_free (info);
-
- BRASERO_MEDIA_LOG ("READ DISC INFORMATION failed for old drive");
- return BRASERO_BURN_ERR;
- }
-
- /* Try to identify the type: can only be CDROM CDR CDRW.
- * NOTE: since there is no way to distinguish a CDROM and a closed CDR
- * if the disc is closed we set it as CDROM (except if it's RW). */
- if (info->erasable)
- priv->info = BRASERO_MEDIUM_CDRW;
- else if (info->status == BRASERO_SCSI_DISC_FINALIZED)
- priv->info = BRASERO_MEDIUM_CDROM;
- else
- priv->info = BRASERO_MEDIUM_CDR;
-
- if (info->status == BRASERO_SCSI_DISC_EMPTY) {
- priv->info |= BRASERO_MEDIUM_BLANK;
- priv->block_size = 2048;
- priv->next_wr_add = 0;
- BRASERO_MEDIA_LOG ("Empty media (old drive)");
- }
- else if (info->status == BRASERO_SCSI_DISC_INCOMPLETE) {
- priv->info |= BRASERO_MEDIUM_APPENDABLE;
- priv->block_size = 2048;
- priv->next_wr_add = 0;
- BRASERO_MEDIA_LOG ("Appendable media (old drive)");
- }
- else if (info->status == BRASERO_SCSI_DISC_FINALIZED) {
- priv->info |= BRASERO_MEDIUM_CLOSED;
- BRASERO_MEDIA_LOG ("Closed media (old drive)");
- }
-
- /* get the contents */
- result = brasero_medium_get_CD_sessions_info (self, handle, code);
- return result;
-}
-
-static BraseroBurnResult
-brasero_medium_check_old_drive (BraseroMedium *self,
- BraseroDeviceHandle *handle,
- BraseroScsiErrCode *code)
-{
- gchar *model;
- BraseroMediumPrivate *priv;
-
- priv = BRASERO_MEDIUM_PRIVATE (self);
-
- model = brasero_drive_get_display_name (priv->drive);
- if (!model)
- return BRASERO_BURN_ERR;
-
- if (!strcmp (model, "CD-R55S")) {
- g_free (model);
- priv->max_rd = BRASERO_SPEED_TO_RATE_CD (12);
- priv->max_wrt = BRASERO_SPEED_TO_RATE_CD (4);
- BRASERO_MEDIA_LOG ("Maximum Speed (old drive) %i", priv->max_wrt);
-
- return brasero_medium_old_drive_get_disc_info (self,
- handle,
- code);
- }
-
- BRASERO_MEDIA_LOG ("Not an old drive model");
-
- return BRASERO_BURN_ERR;
-}
-
-#endif
-
/**
* Some identification functions
*/
Modified: trunk/libbrasero-media/scsi-read-track-information.c
==============================================================================
--- trunk/libbrasero-media/scsi-read-track-information.c (original)
+++ trunk/libbrasero-media/scsi-read-track-information.c Wed Jan 28 17:15:56 2009
@@ -144,7 +144,6 @@
memset (info, 0, sizeof (BraseroScsiTrackInfo));
BRASERO_SET_16 (cdb->alloc_len, datasize);
res = brasero_scsi_command_issue_sync (cdb, info, datasize, error);
-
if (res == BRASERO_SCSI_OK) {
if (datasize != BRASERO_GET_16 (info->len) + sizeof (info->len))
BRASERO_MEDIA_LOG ("Sizes mismatch asked %i / received %i",
Modified: trunk/libbrasero-media/scsi-write-page.h
==============================================================================
--- trunk/libbrasero-media/scsi-write-page.h (original)
+++ trunk/libbrasero-media/scsi-write-page.h Wed Jan 28 17:15:56 2009
@@ -146,7 +146,7 @@
typedef struct _BraseroScsiWritePage BraseroScsiWritePage;
typedef enum {
- BRASERO_SCSI_WRITE_PACKET = 0x00,
+ BRASERO_SCSI_WRITE_PACKET_INC = 0x00,
BRASERO_SCSI_WRITE_TAO = 0x01,
BRASERO_SCSI_WRITE_SAO = 0x02,
BRASERO_SCSI_WRITE_RAW = 0x03
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]