~ubuntu-branches/debian/experimental/brasero/experimental

« back to all changes in this revision

Viewing changes to libbrasero-media/scsi-read-track-information.c

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette, Pedro Fragoso, Luca Bruno, Josselin Mouette, Emilio Pozuelo Monfort
  • Date: 2009-06-24 18:59:46 UTC
  • mfrom: (1.2.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20090624185946-iyxkgf3gjptir5y3
Tags: 2.26.2-1
[ Pedro Fragoso ]
* Add myself to Maintainer field
  - Thanks Ondřej Surý
* New upstream version (Closes: #528945)
  - Split package into brasero, libbrasero-media0 and libbrasero-dev
  - Add Replaces to libbrasero-media0
  - Bump libgtk to 2.14.0
  - Remove libnotify Build-dep
  - Add Build-dep libnautilus-extension-dev (>= 2.22.2)
    and install it.
  - Add Build-dep to libsm-dev
  - Add Build-dep on intltool
* Install omf files to prevent crash on Help
* Move gstreamer0.10-plugins-bad to Suggests, and add
  dvdauthor and vcdimager
* Recommends gvfs (Closes: #491827)
* Pass --disable-scrollkeeper in DEB_CONFIGURE_EXTRA_FLAGS
* debian/patches/007-fix-gnome-doc-utils-path.patch:
  - Removed, not needed anymore
* debian/patches/008-fix-volume-identifier-crash.patch:
  - Removed, merged upstream
* debian/patches/011_nautilus_menu_move.patch:
 - Move CD/DVD Creator Menu to Acessories, taken from Ubuntu

[ Luca Bruno ]
* debian/control.in:
  - Add Build-Depend gtk-doc-tools 1.9.
* debian/patches/006-fix-libdvdcss.patch:
  - Removed as applied upstream.

[ Josselin Mouette ]
* New upstream release.
* Update build-dependencies.
* Move the translations and data to a new brasero-common package.
* Rewrite the descriptions.
* Add -dev depends to the development package.
* Remove inappropriate recommends in the library package.
* Let’s not forget dvd+rw-tools so that we can write DVDs too.
* Rework dependencies accordingly.
* Put the nautilus extension in brasero.
* Conflict against nautilus-cd-burner to avoid having two burning 
  extensions.
* Include clean-la.mk and gnome-version.mk; build-depend on 
  gnome-pkg-tools 0.7.
* Don’t run dh_makeshlibs on brasero and libbrasero-plugins.
* 011_nautilus_menu_move.patch: add NoDisplay=true, this icon is 
  duplicating existing functionality (brasero icon in sound&video 
  menu, and nautilus autorun).
* Update list of copyright holders.

[ Emilio Pozuelo Monfort ]
* debian/copyright: updated.

[ Josselin Mouette ]
* copyright: improve indentation, and point to versioned LGPL.
* 090_relibtoolize.patch: add a relibtoolization patch to avoid the 
  rpath crap.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 
2
/*
 
3
 * Libbrasero-media
 
4
 * Copyright (C) Philippe Rouquier 2005-2009 <bonfire-app@wanadoo.fr>
 
5
 *
 
6
 * Libbrasero-media is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * The Libbrasero-media authors hereby grant permission for non-GPL compatible
 
12
 * GStreamer plugins to be used and distributed together with GStreamer
 
13
 * and Libbrasero-media. This permission is above and beyond the permissions granted
 
14
 * by the GPL license by which Libbrasero-media is covered. If you modify this code
 
15
 * you may extend this exception to your version of the code, but you are not
 
16
 * obligated to do so. If you do not wish to do so, delete this exception
 
17
 * statement from your version.
 
18
 * 
 
19
 * Libbrasero-media is distributed in the hope that it will be useful,
 
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
22
 * GNU Library General Public License for more details.
 
23
 * 
 
24
 * You should have received a copy of the GNU General Public License
 
25
 * along with this program; if not, write to:
 
26
 *      The Free Software Foundation, Inc.,
 
27
 *      51 Franklin Street, Fifth Floor
 
28
 *      Boston, MA  02110-1301, USA.
 
29
 */
 
30
 
 
31
#ifdef HAVE_CONFIG_H
 
32
#  include <config.h>
 
33
#endif
 
34
 
 
35
#include <glib.h>
 
36
 
 
37
#include "brasero-media-private.h"
 
38
 
 
39
#include "scsi-error.h"
 
40
#include "scsi-utils.h"
 
41
#include "scsi-base.h"
 
42
#include "scsi-command.h"
 
43
#include "scsi-opcodes.h"
 
44
#include "scsi-read-track-information.h"
 
45
 
 
46
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
 
47
 
 
48
struct _BraseroRdTrackInfoCDB {
 
49
        uchar opcode;
 
50
 
 
51
        uchar addr_num_type             :2;
 
52
        uchar open                      :1;     /* MMC5 field only */
 
53
        uchar reserved0                 :5;
 
54
 
 
55
        uchar blk_addr_trk_ses_num      [4];
 
56
 
 
57
        uchar reserved1;
 
58
 
 
59
        uchar alloc_len                 [2];
 
60
        uchar ctl;
 
61
};
 
62
 
 
63
#else
 
64
 
 
65
struct _BraseroRdTrackInfoCDB {
 
66
        uchar opcode;
 
67
 
 
68
        uchar reserved0                 :5;
 
69
        uchar open                      :1;
 
70
        uchar addr_num_type             :2;
 
71
 
 
72
        uchar blk_addr_trk_ses_num      [4];
 
73
 
 
74
        uchar reserved1;
 
75
 
 
76
        uchar alloc_len                 [2];
 
77
        uchar ctl;
 
78
};
 
79
 
 
80
#endif
 
81
 
 
82
typedef struct _BraseroRdTrackInfoCDB BraseroRdTrackInfoCDB;
 
83
 
 
84
BRASERO_SCSI_COMMAND_DEFINE (BraseroRdTrackInfoCDB,
 
85
                             READ_TRACK_INFORMATION,
 
86
                             BRASERO_SCSI_READ);
 
87
 
 
88
typedef enum {
 
89
BRASERO_FIELD_LBA                       = 0x00,
 
90
BRASERO_FIELD_TRACK_NUM                 = 0x01,
 
91
BRASERO_FIELD_SESSION_NUM               = 0x02,
 
92
        /* reserved */
 
93
} BraseroFieldType;
 
94
 
 
95
#define BRASERO_SCSI_INCOMPLETE_TRACK   0xFF
 
96
 
 
97
static BraseroScsiResult
 
98
brasero_read_track_info (BraseroRdTrackInfoCDB *cdb,
 
99
                         BraseroScsiTrackInfo *info,
 
100
                         int *size,
 
101
                         BraseroScsiErrCode *error)
 
102
{
 
103
        BraseroScsiTrackInfo hdr;
 
104
        BraseroScsiResult res;
 
105
        int datasize;
 
106
 
 
107
        if (!info || !size) {
 
108
                BRASERO_SCSI_SET_ERRCODE (error, BRASERO_SCSI_BAD_ARGUMENT);
 
109
                return BRASERO_SCSI_FAILURE;
 
110
        }
 
111
 
 
112
        /* first ask the drive how long should the data be and then ... */
 
113
        datasize = 4;
 
114
        memset (&hdr, 0, sizeof (info));
 
115
        BRASERO_SET_16 (cdb->alloc_len, datasize);
 
116
        res = brasero_scsi_command_issue_sync (cdb, &hdr, datasize, error);
 
117
        if (res)
 
118
                return res;
 
119
 
 
120
        /* ... check the size in case of a buggy firmware ... */
 
121
        if (BRASERO_GET_16 (hdr.len) + sizeof (hdr.len) >= datasize) {
 
122
                datasize = BRASERO_GET_16 (hdr.len) + sizeof (hdr.len);
 
123
 
 
124
                if (datasize > *size) {
 
125
                        /* it must not be over sizeof (BraseroScsiTrackInfo) */
 
126
                        if (datasize > sizeof (BraseroScsiTrackInfo)) {
 
127
                                BRASERO_MEDIA_LOG ("Oversized data received (%i) setting to %i", datasize, *size);
 
128
                                datasize = *size;
 
129
                        }
 
130
                        else
 
131
                                *size = datasize;
 
132
                }
 
133
                else if (*size < datasize) {
 
134
                        BRASERO_MEDIA_LOG ("Oversized data required (%i) setting to %i", *size, datasize);
 
135
                        *size = datasize;
 
136
                }
 
137
        }
 
138
        else {
 
139
                BRASERO_MEDIA_LOG ("Undersized data received (%i) setting to %i", datasize, *size);
 
140
                datasize = *size;
 
141
        }
 
142
 
 
143
        /* ... and re-issue the command */
 
144
        memset (info, 0, sizeof (BraseroScsiTrackInfo));
 
145
        BRASERO_SET_16 (cdb->alloc_len, datasize);
 
146
        res = brasero_scsi_command_issue_sync (cdb, info, datasize, error);
 
147
        if (res == BRASERO_SCSI_OK) {
 
148
                if (datasize != BRASERO_GET_16 (info->len) + sizeof (info->len))
 
149
                        BRASERO_MEDIA_LOG ("Sizes mismatch asked %i / received %i",
 
150
                                          datasize,
 
151
                                          BRASERO_GET_16 (info->len) + sizeof (info->len));
 
152
 
 
153
                *size = MIN (datasize, BRASERO_GET_16 (info->len) + sizeof (info->len));
 
154
        }
 
155
 
 
156
        return res;
 
157
}
 
158
 
 
159
/**
 
160
 * 
 
161
 * NOTE: if media is a CD and track_num = 0 then returns leadin
 
162
 * but since the other media don't have a leadin they error out.
 
163
 * if track_num = 255 returns last incomplete track.
 
164
 */
 
165
 
 
166
BraseroScsiResult
 
167
brasero_mmc1_read_track_info (BraseroDeviceHandle *handle,
 
168
                              int track_num,
 
169
                              BraseroScsiTrackInfo *track_info,
 
170
                              int *size,
 
171
                              BraseroScsiErrCode *error)
 
172
{
 
173
        BraseroRdTrackInfoCDB *cdb;
 
174
        BraseroScsiResult res;
 
175
 
 
176
        cdb = brasero_scsi_command_new (&info, handle);
 
177
        cdb->addr_num_type = BRASERO_FIELD_TRACK_NUM;
 
178
        BRASERO_SET_32 (cdb->blk_addr_trk_ses_num, track_num);
 
179
 
 
180
        res = brasero_read_track_info (cdb, track_info, size, error);
 
181
        brasero_scsi_command_free (cdb);
 
182
 
 
183
        return res;
 
184
}