2007-08-15 11:28:01 -03:00
|
|
|
|
|
|
|
:mod:`cd` --- CD-ROM access on SGI systems
|
|
|
|
==========================================
|
|
|
|
|
|
|
|
.. module:: cd
|
|
|
|
:platform: IRIX
|
|
|
|
:synopsis: Interface to the CD-ROM on Silicon Graphics systems.
|
2008-05-15 01:34:17 -03:00
|
|
|
:deprecated:
|
Merged revisions 68133-68134,68141-68142,68145-68146,68148-68149,68159-68162,68166,68171-68174,68179,68195-68196,68210,68214-68215,68217-68222 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r68133 | antoine.pitrou | 2009-01-01 16:38:03 +0100 (Thu, 01 Jan 2009) | 1 line
fill in actual issue number in tests
........
r68134 | hirokazu.yamamoto | 2009-01-01 16:45:39 +0100 (Thu, 01 Jan 2009) | 2 lines
Issue #4797: IOError.filename was not set when _fileio.FileIO failed to open
file with `str' filename on Windows.
........
r68141 | benjamin.peterson | 2009-01-01 17:43:12 +0100 (Thu, 01 Jan 2009) | 1 line
fix highlighting
........
r68142 | benjamin.peterson | 2009-01-01 18:29:49 +0100 (Thu, 01 Jan 2009) | 2 lines
welcome to 2009, Python!
........
r68145 | amaury.forgeotdarc | 2009-01-02 01:03:54 +0100 (Fri, 02 Jan 2009) | 5 lines
#4801 _collections module fails to build on cygwin.
_PyObject_GC_TRACK is the macro version of PyObject_GC_Track,
and according to documentation it should not be used for extension modules.
........
r68146 | ronald.oussoren | 2009-01-02 11:44:46 +0100 (Fri, 02 Jan 2009) | 2 lines
Fix for issue4472: "configure --enable-shared doesn't work on OSX"
........
r68148 | ronald.oussoren | 2009-01-02 11:48:31 +0100 (Fri, 02 Jan 2009) | 2 lines
Forgot to add a NEWS item in my previous checkin
........
r68149 | ronald.oussoren | 2009-01-02 11:50:48 +0100 (Fri, 02 Jan 2009) | 2 lines
Fix for issue4780
........
r68159 | ronald.oussoren | 2009-01-02 15:48:17 +0100 (Fri, 02 Jan 2009) | 2 lines
Fix for issue 1627952
........
r68160 | ronald.oussoren | 2009-01-02 15:52:09 +0100 (Fri, 02 Jan 2009) | 2 lines
Fix for issue r1737832
........
r68161 | ronald.oussoren | 2009-01-02 16:00:05 +0100 (Fri, 02 Jan 2009) | 3 lines
Fix for issue 1149804
........
r68162 | ronald.oussoren | 2009-01-02 16:06:00 +0100 (Fri, 02 Jan 2009) | 3 lines
Fix for issue 4472 is incompatible with Cygwin, this patch
should fix that.
........
r68166 | benjamin.peterson | 2009-01-02 19:26:23 +0100 (Fri, 02 Jan 2009) | 1 line
document PyMemberDef
........
r68171 | georg.brandl | 2009-01-02 21:25:14 +0100 (Fri, 02 Jan 2009) | 3 lines
#4811: fix markup glitches (mostly remains of the conversion),
found by Gabriel Genellina.
........
r68172 | martin.v.loewis | 2009-01-02 21:32:55 +0100 (Fri, 02 Jan 2009) | 2 lines
Issue #4075: Use OutputDebugStringW in Py_FatalError.
........
r68173 | martin.v.loewis | 2009-01-02 21:40:14 +0100 (Fri, 02 Jan 2009) | 2 lines
Issue #4051: Prevent conflict of UNICODE macros in cPickle.
........
r68174 | benjamin.peterson | 2009-01-02 21:47:27 +0100 (Fri, 02 Jan 2009) | 1 line
fix compilation on non-Windows platforms
........
r68179 | raymond.hettinger | 2009-01-02 22:26:45 +0100 (Fri, 02 Jan 2009) | 1 line
Issue #4615. Document how to use itertools for de-duping.
........
r68195 | georg.brandl | 2009-01-03 14:45:15 +0100 (Sat, 03 Jan 2009) | 2 lines
Remove useless string literal.
........
r68196 | georg.brandl | 2009-01-03 15:29:53 +0100 (Sat, 03 Jan 2009) | 2 lines
Fix indentation.
........
r68210 | georg.brandl | 2009-01-03 20:10:12 +0100 (Sat, 03 Jan 2009) | 2 lines
Set eol-style correctly for mp_distributing.py.
........
r68214 | georg.brandl | 2009-01-03 20:44:48 +0100 (Sat, 03 Jan 2009) | 2 lines
Make indentation consistent.
........
r68215 | georg.brandl | 2009-01-03 21:15:14 +0100 (Sat, 03 Jan 2009) | 2 lines
Fix role name.
........
r68217 | georg.brandl | 2009-01-03 21:30:15 +0100 (Sat, 03 Jan 2009) | 2 lines
Add rstlint, a little tool to find subtle markup problems and inconsistencies in the Doc sources.
........
r68218 | georg.brandl | 2009-01-03 21:38:59 +0100 (Sat, 03 Jan 2009) | 2 lines
Recognize usage of the default role.
........
r68219 | georg.brandl | 2009-01-03 21:47:01 +0100 (Sat, 03 Jan 2009) | 2 lines
Fix uses of the default role.
........
r68220 | georg.brandl | 2009-01-03 21:55:06 +0100 (Sat, 03 Jan 2009) | 2 lines
Remove trailing whitespace.
........
r68221 | georg.brandl | 2009-01-03 22:04:55 +0100 (Sat, 03 Jan 2009) | 2 lines
Remove tabs from the documentation.
........
r68222 | georg.brandl | 2009-01-03 22:11:58 +0100 (Sat, 03 Jan 2009) | 2 lines
Disable the line length checker by default.
........
2009-01-03 17:55:17 -04:00
|
|
|
|
|
|
|
|
2008-05-15 01:34:17 -03:00
|
|
|
.. deprecated:: 2.6
|
|
|
|
The :mod:`cd` module has been deprecated for removal in Python 3.0.
|
2007-08-15 11:28:01 -03:00
|
|
|
|
|
|
|
|
|
|
|
This module provides an interface to the Silicon Graphics CD library. It is
|
|
|
|
available only on Silicon Graphics systems.
|
|
|
|
|
|
|
|
The way the library works is as follows. A program opens the CD-ROM device with
|
2009-10-27 11:36:50 -03:00
|
|
|
:func:`.open` and creates a parser to parse the data from the CD with
|
|
|
|
:func:`createparser`. The object returned by :func:`.open` can be used to read
|
2007-08-15 11:28:01 -03:00
|
|
|
data from the CD, but also to get status information for the CD-ROM device, and
|
|
|
|
to get information about the CD, such as the table of contents. Data from the
|
|
|
|
CD is passed to the parser, which parses the frames, and calls any callback
|
|
|
|
functions that have previously been added.
|
|
|
|
|
|
|
|
An audio CD is divided into :dfn:`tracks` or :dfn:`programs` (the terms are used
|
|
|
|
interchangeably). Tracks can be subdivided into :dfn:`indices`. An audio CD
|
|
|
|
contains a :dfn:`table of contents` which gives the starts of the tracks on the
|
|
|
|
CD. Index 0 is usually the pause before the start of a track. The start of the
|
|
|
|
track as given by the table of contents is normally the start of index 1.
|
|
|
|
|
|
|
|
Positions on a CD can be represented in two ways. Either a frame number or a
|
|
|
|
tuple of three values, minutes, seconds and frames. Most functions use the
|
|
|
|
latter representation. Positions can be both relative to the beginning of the
|
|
|
|
CD, and to the beginning of the track.
|
|
|
|
|
|
|
|
Module :mod:`cd` defines the following functions and constants:
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: createparser()
|
|
|
|
|
|
|
|
Create and return an opaque parser object. The methods of the parser object are
|
|
|
|
described below.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: msftoframe(minutes, seconds, frames)
|
|
|
|
|
|
|
|
Converts a ``(minutes, seconds, frames)`` triple representing time in absolute
|
|
|
|
time code into the corresponding CD frame number.
|
|
|
|
|
|
|
|
|
|
|
|
.. function:: open([device[, mode]])
|
|
|
|
|
|
|
|
Open the CD-ROM device. The return value is an opaque player object; methods of
|
|
|
|
the player object are described below. The device is the name of the SCSI
|
|
|
|
device file, e.g. ``'/dev/scsi/sc0d4l0'``, or ``None``. If omitted or ``None``,
|
|
|
|
the hardware inventory is consulted to locate a CD-ROM drive. The *mode*, if
|
|
|
|
not omitted, should be the string ``'r'``.
|
|
|
|
|
|
|
|
The module defines the following variables:
|
|
|
|
|
|
|
|
|
|
|
|
.. exception:: error
|
|
|
|
|
|
|
|
Exception raised on various errors.
|
|
|
|
|
|
|
|
|
|
|
|
.. data:: DATASIZE
|
|
|
|
|
|
|
|
The size of one frame's worth of audio data. This is the size of the audio data
|
|
|
|
as passed to the callback of type ``audio``.
|
|
|
|
|
|
|
|
|
|
|
|
.. data:: BLOCKSIZE
|
|
|
|
|
|
|
|
The size of one uninterpreted frame of audio data.
|
|
|
|
|
|
|
|
The following variables are states as returned by :func:`getstatus`:
|
|
|
|
|
|
|
|
|
|
|
|
.. data:: READY
|
|
|
|
|
|
|
|
The drive is ready for operation loaded with an audio CD.
|
|
|
|
|
|
|
|
|
|
|
|
.. data:: NODISC
|
|
|
|
|
|
|
|
The drive does not have a CD loaded.
|
|
|
|
|
|
|
|
|
|
|
|
.. data:: CDROM
|
|
|
|
|
|
|
|
The drive is loaded with a CD-ROM. Subsequent play or read operations will
|
|
|
|
return I/O errors.
|
|
|
|
|
|
|
|
|
|
|
|
.. data:: ERROR
|
|
|
|
|
|
|
|
An error occurred while trying to read the disc or its table of contents.
|
|
|
|
|
|
|
|
|
|
|
|
.. data:: PLAYING
|
|
|
|
|
|
|
|
The drive is in CD player mode playing an audio CD through its audio jacks.
|
|
|
|
|
|
|
|
|
|
|
|
.. data:: PAUSED
|
|
|
|
|
|
|
|
The drive is in CD layer mode with play paused.
|
|
|
|
|
|
|
|
|
|
|
|
.. data:: STILL
|
|
|
|
|
|
|
|
The equivalent of :const:`PAUSED` on older (non 3301) model Toshiba CD-ROM
|
|
|
|
drives. Such drives have never been shipped by SGI.
|
|
|
|
|
|
|
|
|
|
|
|
.. data:: audio
|
|
|
|
pnum
|
|
|
|
index
|
|
|
|
ptime
|
|
|
|
atime
|
|
|
|
catalog
|
|
|
|
ident
|
|
|
|
control
|
|
|
|
|
|
|
|
Integer constants describing the various types of parser callbacks that can be
|
|
|
|
set by the :meth:`addcallback` method of CD parser objects (see below).
|
|
|
|
|
|
|
|
|
|
|
|
.. _player-objects:
|
|
|
|
|
|
|
|
Player Objects
|
|
|
|
--------------
|
|
|
|
|
2009-10-27 11:36:50 -03:00
|
|
|
Player objects (returned by :func:`.open`) have the following methods:
|
2007-08-15 11:28:01 -03:00
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD player.allowremoval()
|
|
|
|
|
|
|
|
Unlocks the eject button on the CD-ROM drive permitting the user to eject the
|
|
|
|
caddy if desired.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD player.bestreadsize()
|
|
|
|
|
|
|
|
Returns the best value to use for the *num_frames* parameter of the
|
|
|
|
:meth:`readda` method. Best is defined as the value that permits a continuous
|
|
|
|
flow of data from the CD-ROM drive.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD player.close()
|
|
|
|
|
|
|
|
Frees the resources associated with the player object. After calling
|
|
|
|
:meth:`close`, the methods of the object should no longer be used.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD player.eject()
|
|
|
|
|
|
|
|
Ejects the caddy from the CD-ROM drive.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD player.getstatus()
|
|
|
|
|
|
|
|
Returns information pertaining to the current state of the CD-ROM drive. The
|
|
|
|
returned information is a tuple with the following values: *state*, *track*,
|
|
|
|
*rtime*, *atime*, *ttime*, *first*, *last*, *scsi_audio*, *cur_block*. *rtime*
|
|
|
|
is the time relative to the start of the current track; *atime* is the time
|
|
|
|
relative to the beginning of the disc; *ttime* is the total time on the disc.
|
|
|
|
For more information on the meaning of the values, see the man page
|
|
|
|
:manpage:`CDgetstatus(3dm)`. The value of *state* is one of the following:
|
|
|
|
:const:`ERROR`, :const:`NODISC`, :const:`READY`, :const:`PLAYING`,
|
|
|
|
:const:`PAUSED`, :const:`STILL`, or :const:`CDROM`.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD player.gettrackinfo(track)
|
|
|
|
|
|
|
|
Returns information about the specified track. The returned information is a
|
|
|
|
tuple consisting of two elements, the start time of the track and the duration
|
|
|
|
of the track.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD player.msftoblock(min, sec, frame)
|
|
|
|
|
|
|
|
Converts a minutes, seconds, frames triple representing a time in absolute time
|
|
|
|
code into the corresponding logical block number for the given CD-ROM drive.
|
|
|
|
You should use :func:`msftoframe` rather than :meth:`msftoblock` for comparing
|
|
|
|
times. The logical block number differs from the frame number by an offset
|
|
|
|
required by certain CD-ROM drives.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD player.play(start, play)
|
|
|
|
|
|
|
|
Starts playback of an audio CD in the CD-ROM drive at the specified track. The
|
|
|
|
audio output appears on the CD-ROM drive's headphone and audio jacks (if
|
|
|
|
fitted). Play stops at the end of the disc. *start* is the number of the track
|
|
|
|
at which to start playing the CD; if *play* is 0, the CD will be set to an
|
|
|
|
initial paused state. The method :meth:`togglepause` can then be used to
|
|
|
|
commence play.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD player.playabs(minutes, seconds, frames, play)
|
|
|
|
|
|
|
|
Like :meth:`play`, except that the start is given in minutes, seconds, and
|
|
|
|
frames instead of a track number.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD player.playtrack(start, play)
|
|
|
|
|
|
|
|
Like :meth:`play`, except that playing stops at the end of the track.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD player.playtrackabs(track, minutes, seconds, frames, play)
|
|
|
|
|
|
|
|
Like :meth:`play`, except that playing begins at the specified absolute time and
|
|
|
|
ends at the end of the specified track.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD player.preventremoval()
|
|
|
|
|
|
|
|
Locks the eject button on the CD-ROM drive thus preventing the user from
|
|
|
|
arbitrarily ejecting the caddy.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD player.readda(num_frames)
|
|
|
|
|
|
|
|
Reads the specified number of frames from an audio CD mounted in the CD-ROM
|
|
|
|
drive. The return value is a string representing the audio frames. This string
|
|
|
|
can be passed unaltered to the :meth:`parseframe` method of the parser object.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD player.seek(minutes, seconds, frames)
|
|
|
|
|
|
|
|
Sets the pointer that indicates the starting point of the next read of digital
|
|
|
|
audio data from a CD-ROM. The pointer is set to an absolute time code location
|
|
|
|
specified in *minutes*, *seconds*, and *frames*. The return value is the
|
|
|
|
logical block number to which the pointer has been set.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD player.seekblock(block)
|
|
|
|
|
|
|
|
Sets the pointer that indicates the starting point of the next read of digital
|
|
|
|
audio data from a CD-ROM. The pointer is set to the specified logical block
|
|
|
|
number. The return value is the logical block number to which the pointer has
|
|
|
|
been set.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD player.seektrack(track)
|
|
|
|
|
|
|
|
Sets the pointer that indicates the starting point of the next read of digital
|
|
|
|
audio data from a CD-ROM. The pointer is set to the specified track. The
|
|
|
|
return value is the logical block number to which the pointer has been set.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD player.stop()
|
|
|
|
|
|
|
|
Stops the current playing operation.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD player.togglepause()
|
|
|
|
|
|
|
|
Pauses the CD if it is playing, and makes it play if it is paused.
|
|
|
|
|
|
|
|
|
|
|
|
.. _cd-parser-objects:
|
|
|
|
|
|
|
|
Parser Objects
|
|
|
|
--------------
|
|
|
|
|
|
|
|
Parser objects (returned by :func:`createparser`) have the following methods:
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD parser.addcallback(type, func, arg)
|
|
|
|
|
|
|
|
Adds a callback for the parser. The parser has callbacks for eight different
|
|
|
|
types of data in the digital audio data stream. Constants for these types are
|
|
|
|
defined at the :mod:`cd` module level (see above). The callback is called as
|
|
|
|
follows: ``func(arg, type, data)``, where *arg* is the user supplied argument,
|
|
|
|
*type* is the particular type of callback, and *data* is the data returned for
|
|
|
|
this *type* of callback. The type of the data depends on the *type* of callback
|
|
|
|
as follows:
|
|
|
|
|
|
|
|
+-------------+---------------------------------------------+
|
|
|
|
| Type | Value |
|
|
|
|
+=============+=============================================+
|
|
|
|
| ``audio`` | String which can be passed unmodified to |
|
|
|
|
| | :func:`al.writesamps`. |
|
|
|
|
+-------------+---------------------------------------------+
|
|
|
|
| ``pnum`` | Integer giving the program (track) number. |
|
|
|
|
+-------------+---------------------------------------------+
|
|
|
|
| ``index`` | Integer giving the index number. |
|
|
|
|
+-------------+---------------------------------------------+
|
|
|
|
| ``ptime`` | Tuple consisting of the program time in |
|
|
|
|
| | minutes, seconds, and frames. |
|
|
|
|
+-------------+---------------------------------------------+
|
|
|
|
| ``atime`` | Tuple consisting of the absolute time in |
|
|
|
|
| | minutes, seconds, and frames. |
|
|
|
|
+-------------+---------------------------------------------+
|
|
|
|
| ``catalog`` | String of 13 characters, giving the catalog |
|
|
|
|
| | number of the CD. |
|
|
|
|
+-------------+---------------------------------------------+
|
|
|
|
| ``ident`` | String of 12 characters, giving the ISRC |
|
|
|
|
| | identification number of the recording. |
|
|
|
|
| | The string consists of two characters |
|
|
|
|
| | country code, three characters owner code, |
|
|
|
|
| | two characters giving the year, and five |
|
|
|
|
| | characters giving a serial number. |
|
|
|
|
+-------------+---------------------------------------------+
|
|
|
|
| ``control`` | Integer giving the control bits from the CD |
|
|
|
|
| | subcode data |
|
|
|
|
+-------------+---------------------------------------------+
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD parser.deleteparser()
|
|
|
|
|
|
|
|
Deletes the parser and frees the memory it was using. The object should not be
|
|
|
|
used after this call. This call is done automatically when the last reference
|
|
|
|
to the object is removed.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD parser.parseframe(frame)
|
|
|
|
|
|
|
|
Parses one or more frames of digital audio data from a CD such as returned by
|
|
|
|
:meth:`readda`. It determines which subcodes are present in the data. If these
|
|
|
|
subcodes have changed since the last frame, then :meth:`parseframe` executes a
|
|
|
|
callback of the appropriate type passing to it the subcode data found in the
|
|
|
|
frame. Unlike the C function, more than one frame of digital audio data can be
|
|
|
|
passed to this method.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD parser.removecallback(type)
|
|
|
|
|
|
|
|
Removes the callback for the given *type*.
|
|
|
|
|
|
|
|
|
|
|
|
.. method:: CD parser.resetparser()
|
|
|
|
|
|
|
|
Resets the fields of the parser used for tracking subcodes to an initial state.
|
|
|
|
:meth:`resetparser` should be called after the disc has been changed.
|
|
|
|
|