Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
bf0c3ca9
Commit
bf0c3ca9
authored
Jan 03, 1997
by
Roger E. Masse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed but not well tested.
parent
32e949d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
278 additions
and
273 deletions
+278
-273
Modules/cdmodule.c
Modules/cdmodule.c
+278
-273
No files found.
Modules/cdmodule.c
View file @
bf0c3ca9
...
@@ -34,117 +34,113 @@ PERFORMANCE OF THIS SOFTWARE.
...
@@ -34,117 +34,113 @@ PERFORMANCE OF THIS SOFTWARE.
#include <sys/types.h>
#include <sys/types.h>
#include <cdaudio.h>
#include <cdaudio.h>
/* #include <sigfpe.h> */
#include "Python.h"
#include "allobjects.h"
#include "import.h"
#include "modsupport.h"
#include "ceval.h"
#define NCALLBACKS 8
#define NCALLBACKS 8
typedef
struct
{
typedef
struct
{
OB
_HEAD
PyObject
_HEAD
CDPLAYER
*
ob_cdplayer
;
CDPLAYER
*
ob_cdplayer
;
}
cdplayerobject
;
}
cdplayerobject
;
static
o
bject
*
CdError
;
/* exception cd.error */
static
PyO
bject
*
CdError
;
/* exception cd.error */
static
o
bject
*
static
PyO
bject
*
CD_allowremoval
(
self
,
args
)
CD_allowremoval
(
self
,
args
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
if
(
!
newgetargs
(
args
,
""
))
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
return
NULL
;
CDallowremoval
(
self
->
ob_cdplayer
);
CDallowremoval
(
self
->
ob_cdplayer
);
INCREF
(
None
);
Py_INCREF
(
Py_
None
);
return
None
;
return
Py_
None
;
}
}
static
o
bject
*
static
PyO
bject
*
CD_preventremoval
(
self
,
args
)
CD_preventremoval
(
self
,
args
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
if
(
!
newgetargs
(
args
,
""
))
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
return
NULL
;
CDpreventremoval
(
self
->
ob_cdplayer
);
CDpreventremoval
(
self
->
ob_cdplayer
);
INCREF
(
None
);
Py_INCREF
(
Py_
None
);
return
None
;
return
Py_
None
;
}
}
static
o
bject
*
static
PyO
bject
*
CD_bestreadsize
(
self
,
args
)
CD_bestreadsize
(
self
,
args
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
if
(
!
newgetargs
(
args
,
""
))
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
return
NULL
;
return
newintobject
((
long
)
CDbestreadsize
(
self
->
ob_cdplayer
));
return
PyInt_FromLong
((
long
)
CDbestreadsize
(
self
->
ob_cdplayer
));
}
}
static
o
bject
*
static
PyO
bject
*
CD_close
(
self
,
args
)
CD_close
(
self
,
args
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
if
(
!
newgetargs
(
args
,
""
))
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
return
NULL
;
if
(
!
CDclose
(
self
->
ob_cdplayer
))
{
if
(
!
CDclose
(
self
->
ob_cdplayer
))
{
err_e
rrno
(
CdError
);
/* XXX - ??? */
PyErr_SetFromE
rrno
(
CdError
);
/* XXX - ??? */
return
NULL
;
return
NULL
;
}
}
self
->
ob_cdplayer
=
NULL
;
self
->
ob_cdplayer
=
NULL
;
INCREF
(
None
);
Py_INCREF
(
Py_
None
);
return
None
;
return
Py_
None
;
}
}
static
o
bject
*
static
PyO
bject
*
CD_eject
(
self
,
args
)
CD_eject
(
self
,
args
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
CDSTATUS
status
;
CDSTATUS
status
;
if
(
!
newgetargs
(
args
,
""
))
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
return
NULL
;
if
(
!
CDeject
(
self
->
ob_cdplayer
))
{
if
(
!
CDeject
(
self
->
ob_cdplayer
))
{
if
(
CDgetstatus
(
self
->
ob_cdplayer
,
&
status
)
&&
if
(
CDgetstatus
(
self
->
ob_cdplayer
,
&
status
)
&&
status
.
state
==
CD_NODISC
)
status
.
state
==
CD_NODISC
)
err_setstr
(
CdError
,
"no disc in player"
);
PyErr_SetString
(
CdError
,
"no disc in player"
);
else
else
err_setstr
(
CdError
,
"eject failed"
);
PyErr_SetString
(
CdError
,
"eject failed"
);
return
NULL
;
return
NULL
;
}
}
INCREF
(
None
);
Py_INCREF
(
Py_
None
);
return
None
;
return
Py_
None
;
}
}
static
o
bject
*
static
PyO
bject
*
CD_getstatus
(
self
,
args
)
CD_getstatus
(
self
,
args
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
CDSTATUS
status
;
CDSTATUS
status
;
if
(
!
newgetargs
(
args
,
""
))
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
return
NULL
;
if
(
!
CDgetstatus
(
self
->
ob_cdplayer
,
&
status
))
{
if
(
!
CDgetstatus
(
self
->
ob_cdplayer
,
&
status
))
{
err_e
rrno
(
CdError
);
/* XXX - ??? */
PyErr_SetFromE
rrno
(
CdError
);
/* XXX - ??? */
return
NULL
;
return
NULL
;
}
}
return
mkv
alue
(
"(ii(iii)(iii)(iii)iiii)"
,
status
.
state
,
return
Py_BuildV
alue
(
"(ii(iii)(iii)(iii)iiii)"
,
status
.
state
,
status
.
track
,
status
.
min
,
status
.
sec
,
status
.
frame
,
status
.
track
,
status
.
min
,
status
.
sec
,
status
.
frame
,
status
.
abs_min
,
status
.
abs_sec
,
status
.
abs_frame
,
status
.
abs_min
,
status
.
abs_sec
,
status
.
abs_frame
,
status
.
total_min
,
status
.
total_sec
,
status
.
total_frame
,
status
.
total_min
,
status
.
total_sec
,
status
.
total_frame
,
...
@@ -152,294 +148,296 @@ CD_getstatus(self, args)
...
@@ -152,294 +148,296 @@ CD_getstatus(self, args)
status
.
cur_block
);
status
.
cur_block
);
}
}
static
o
bject
*
static
PyO
bject
*
CD_gettrackinfo
(
self
,
args
)
CD_gettrackinfo
(
self
,
args
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
int
track
;
int
track
;
CDTRACKINFO
info
;
CDTRACKINFO
info
;
CDSTATUS
status
;
CDSTATUS
status
;
if
(
!
newgetargs
(
args
,
"i"
,
&
track
))
if
(
!
PyArg_ParseTuple
(
args
,
"i"
,
&
track
))
return
NULL
;
return
NULL
;
if
(
!
CDgettrackinfo
(
self
->
ob_cdplayer
,
track
,
&
info
))
{
if
(
!
CDgettrackinfo
(
self
->
ob_cdplayer
,
track
,
&
info
))
{
if
(
CDgetstatus
(
self
->
ob_cdplayer
,
&
status
)
&&
if
(
CDgetstatus
(
self
->
ob_cdplayer
,
&
status
)
&&
status
.
state
==
CD_NODISC
)
status
.
state
==
CD_NODISC
)
err_setstr
(
CdError
,
"no disc in player"
);
PyErr_SetString
(
CdError
,
"no disc in player"
);
else
else
err_setstr
(
CdError
,
"gettrackinfo failed"
);
PyErr_SetString
(
CdError
,
"gettrackinfo failed"
);
return
NULL
;
return
NULL
;
}
}
return
mkv
alue
(
"((iii)(iii))"
,
return
Py_BuildV
alue
(
"((iii)(iii))"
,
info
.
start_min
,
info
.
start_sec
,
info
.
start_frame
,
info
.
start_min
,
info
.
start_sec
,
info
.
start_frame
,
info
.
total_min
,
info
.
total_sec
,
info
.
total_frame
);
info
.
total_min
,
info
.
total_sec
,
info
.
total_frame
);
}
}
static
o
bject
*
static
PyO
bject
*
CD_msftoblock
(
self
,
args
)
CD_msftoblock
(
self
,
args
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
int
min
,
sec
,
frame
;
int
min
,
sec
,
frame
;
if
(
!
newgetargs
(
args
,
"iii"
,
&
min
,
&
sec
,
&
frame
))
if
(
!
PyArg_ParseTuple
(
args
,
"iii"
,
&
min
,
&
sec
,
&
frame
))
return
NULL
;
return
NULL
;
return
newintobject
((
long
)
CDmsftoblock
(
self
->
ob_cdplayer
,
return
PyInt_FromLong
((
long
)
CDmsftoblock
(
self
->
ob_cdplayer
,
min
,
sec
,
frame
));
min
,
sec
,
frame
));
}
}
static
o
bject
*
static
PyO
bject
*
CD_play
(
self
,
args
)
CD_play
(
self
,
args
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
int
start
,
play
;
int
start
,
play
;
CDSTATUS
status
;
CDSTATUS
status
;
if
(
!
newgetargs
(
args
,
"ii"
,
&
start
,
&
play
))
if
(
!
PyArg_ParseTuple
(
args
,
"ii"
,
&
start
,
&
play
))
return
NULL
;
return
NULL
;
if
(
!
CDplay
(
self
->
ob_cdplayer
,
start
,
play
))
{
if
(
!
CDplay
(
self
->
ob_cdplayer
,
start
,
play
))
{
if
(
CDgetstatus
(
self
->
ob_cdplayer
,
&
status
)
&&
if
(
CDgetstatus
(
self
->
ob_cdplayer
,
&
status
)
&&
status
.
state
==
CD_NODISC
)
status
.
state
==
CD_NODISC
)
err_setstr
(
CdError
,
"no disc in player"
);
PyErr_SetString
(
CdError
,
"no disc in player"
);
else
else
err_setstr
(
CdError
,
"play failed"
);
PyErr_SetString
(
CdError
,
"play failed"
);
return
NULL
;
return
NULL
;
}
}
INCREF
(
None
);
Py_INCREF
(
Py_
None
);
return
None
;
return
Py_
None
;
}
}
static
o
bject
*
static
PyO
bject
*
CD_playabs
(
self
,
args
)
CD_playabs
(
self
,
args
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
int
min
,
sec
,
frame
,
play
;
int
min
,
sec
,
frame
,
play
;
CDSTATUS
status
;
CDSTATUS
status
;
if
(
!
newgetargs
(
args
,
"iiii"
,
&
min
,
&
sec
,
&
frame
,
&
play
))
if
(
!
PyArg_ParseTuple
(
args
,
"iiii"
,
&
min
,
&
sec
,
&
frame
,
&
play
))
return
NULL
;
return
NULL
;
if
(
!
CDplayabs
(
self
->
ob_cdplayer
,
min
,
sec
,
frame
,
play
))
{
if
(
!
CDplayabs
(
self
->
ob_cdplayer
,
min
,
sec
,
frame
,
play
))
{
if
(
CDgetstatus
(
self
->
ob_cdplayer
,
&
status
)
&&
if
(
CDgetstatus
(
self
->
ob_cdplayer
,
&
status
)
&&
status
.
state
==
CD_NODISC
)
status
.
state
==
CD_NODISC
)
err_setstr
(
CdError
,
"no disc in player"
);
PyErr_SetString
(
CdError
,
"no disc in player"
);
else
else
err_setstr
(
CdError
,
"playabs failed"
);
PyErr_SetString
(
CdError
,
"playabs failed"
);
return
NULL
;
return
NULL
;
}
}
INCREF
(
None
);
Py_INCREF
(
Py_
None
);
return
None
;
return
Py_
None
;
}
}
static
o
bject
*
static
PyO
bject
*
CD_playtrack
(
self
,
args
)
CD_playtrack
(
self
,
args
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
int
start
,
play
;
int
start
,
play
;
CDSTATUS
status
;
CDSTATUS
status
;
if
(
!
newgetargs
(
args
,
"ii"
,
&
start
,
&
play
))
if
(
!
PyArg_ParseTuple
(
args
,
"ii"
,
&
start
,
&
play
))
return
NULL
;
return
NULL
;
if
(
!
CDplaytrack
(
self
->
ob_cdplayer
,
start
,
play
))
{
if
(
!
CDplaytrack
(
self
->
ob_cdplayer
,
start
,
play
))
{
if
(
CDgetstatus
(
self
->
ob_cdplayer
,
&
status
)
&&
if
(
CDgetstatus
(
self
->
ob_cdplayer
,
&
status
)
&&
status
.
state
==
CD_NODISC
)
status
.
state
==
CD_NODISC
)
err_setstr
(
CdError
,
"no disc in player"
);
PyErr_SetString
(
CdError
,
"no disc in player"
);
else
else
err_setstr
(
CdError
,
"playtrack failed"
);
PyErr_SetString
(
CdError
,
"playtrack failed"
);
return
NULL
;
return
NULL
;
}
}
INCREF
(
None
);
Py_INCREF
(
Py_
None
);
return
None
;
return
Py_
None
;
}
}
static
o
bject
*
static
PyO
bject
*
CD_playtrackabs
(
self
,
args
)
CD_playtrackabs
(
self
,
args
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
int
track
,
min
,
sec
,
frame
,
play
;
int
track
,
min
,
sec
,
frame
,
play
;
CDSTATUS
status
;
CDSTATUS
status
;
if
(
!
newgetargs
(
args
,
"iiiii"
,
&
track
,
&
min
,
&
sec
,
&
frame
,
&
play
))
if
(
!
PyArg_ParseTuple
(
args
,
"iiiii"
,
&
track
,
&
min
,
&
sec
,
&
frame
,
&
play
))
return
NULL
;
return
NULL
;
if
(
!
CDplaytrackabs
(
self
->
ob_cdplayer
,
track
,
min
,
sec
,
frame
,
play
))
{
if
(
!
CDplaytrackabs
(
self
->
ob_cdplayer
,
track
,
min
,
sec
,
frame
,
play
))
{
if
(
CDgetstatus
(
self
->
ob_cdplayer
,
&
status
)
&&
if
(
CDgetstatus
(
self
->
ob_cdplayer
,
&
status
)
&&
status
.
state
==
CD_NODISC
)
status
.
state
==
CD_NODISC
)
err_setstr
(
CdError
,
"no disc in player"
);
PyErr_SetString
(
CdError
,
"no disc in player"
);
else
else
err_setstr
(
CdError
,
"playtrackabs failed"
);
PyErr_SetString
(
CdError
,
"playtrackabs failed"
);
return
NULL
;
return
NULL
;
}
}
INCREF
(
None
);
Py_INCREF
(
Py_
None
);
return
None
;
return
Py_
None
;
}
}
static
o
bject
*
static
PyO
bject
*
CD_readda
(
self
,
args
)
CD_readda
(
self
,
args
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
int
numframes
,
n
;
int
numframes
,
n
;
o
bject
*
result
;
PyO
bject
*
result
;
if
(
!
newgetargs
(
args
,
"i"
,
&
numframes
))
if
(
!
PyArg_ParseTuple
(
args
,
"i"
,
&
numframes
))
return
NULL
;
return
NULL
;
result
=
newsizedstringobject
(
NULL
,
numframes
*
sizeof
(
CDFRAME
));
result
=
PyString_FromStringAndSize
(
NULL
,
numframes
*
sizeof
(
CDFRAME
));
if
(
result
==
NULL
)
if
(
result
==
NULL
)
return
NULL
;
return
NULL
;
n
=
CDreadda
(
self
->
ob_cdplayer
,
(
CDFRAME
*
)
getstringvalue
(
result
),
numframes
);
n
=
CDreadda
(
self
->
ob_cdplayer
,
(
CDFRAME
*
)
PyString_AsString
(
result
),
numframes
);
if
(
n
==
-
1
)
{
if
(
n
==
-
1
)
{
DECREF
(
result
);
Py_
DECREF
(
result
);
err_e
rrno
(
CdError
);
PyErr_SetFromE
rrno
(
CdError
);
return
NULL
;
return
NULL
;
}
}
if
(
n
<
numframes
)
if
(
n
<
numframes
)
if
(
resizestring
(
&
result
,
n
*
sizeof
(
CDFRAME
)))
if
(
_PyString_Resize
(
&
result
,
n
*
sizeof
(
CDFRAME
)))
return
NULL
;
return
NULL
;
return
result
;
return
result
;
}
}
static
o
bject
*
static
PyO
bject
*
CD_seek
(
self
,
args
)
CD_seek
(
self
,
args
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
int
min
,
sec
,
frame
;
int
min
,
sec
,
frame
;
long
b
lock
;
long
PyTryB
lock
;
if
(
!
newgetargs
(
args
,
"iii"
,
&
min
,
&
sec
,
&
frame
))
if
(
!
PyArg_ParseTuple
(
args
,
"iii"
,
&
min
,
&
sec
,
&
frame
))
return
NULL
;
return
NULL
;
b
lock
=
CDseek
(
self
->
ob_cdplayer
,
min
,
sec
,
frame
);
PyTryB
lock
=
CDseek
(
self
->
ob_cdplayer
,
min
,
sec
,
frame
);
if
(
b
lock
==
-
1
)
{
if
(
PyTryB
lock
==
-
1
)
{
err_e
rrno
(
CdError
);
PyErr_SetFromE
rrno
(
CdError
);
return
NULL
;
return
NULL
;
}
}
return
newintobject
(
b
lock
);
return
PyInt_FromLong
(
PyTryB
lock
);
}
}
static
o
bject
*
static
PyO
bject
*
CD_seektrack
(
self
,
args
)
CD_seektrack
(
self
,
args
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
int
track
;
int
track
;
long
b
lock
;
long
PyTryB
lock
;
if
(
!
newgetargs
(
args
,
"i"
,
&
track
))
if
(
!
PyArg_ParseTuple
(
args
,
"i"
,
&
track
))
return
NULL
;
return
NULL
;
b
lock
=
CDseektrack
(
self
->
ob_cdplayer
,
track
);
PyTryB
lock
=
CDseektrack
(
self
->
ob_cdplayer
,
track
);
if
(
b
lock
==
-
1
)
{
if
(
PyTryB
lock
==
-
1
)
{
err_e
rrno
(
CdError
);
PyErr_SetFromE
rrno
(
CdError
);
return
NULL
;
return
NULL
;
}
}
return
newintobject
(
b
lock
);
return
PyInt_FromLong
(
PyTryB
lock
);
}
}
static
o
bject
*
static
PyO
bject
*
CD_seekblock
(
self
,
args
)
CD_seekblock
(
self
,
args
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
unsigned
long
b
lock
;
unsigned
long
PyTryB
lock
;
if
(
!
newgetargs
(
args
,
"l"
,
&
b
lock
))
if
(
!
PyArg_ParseTuple
(
args
,
"l"
,
&
PyTryB
lock
))
return
NULL
;
return
NULL
;
block
=
CDseekblock
(
self
->
ob_cdplayer
,
b
lock
);
PyTryBlock
=
CDseekblock
(
self
->
ob_cdplayer
,
PyTryB
lock
);
if
(
b
lock
==
(
unsigned
long
)
-
1
)
{
if
(
PyTryB
lock
==
(
unsigned
long
)
-
1
)
{
err_e
rrno
(
CdError
);
PyErr_SetFromE
rrno
(
CdError
);
return
NULL
;
return
NULL
;
}
}
return
newintobject
(
b
lock
);
return
PyInt_FromLong
(
PyTryB
lock
);
}
}
static
o
bject
*
static
PyO
bject
*
CD_stop
(
self
,
args
)
CD_stop
(
self
,
args
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
CDSTATUS
status
;
CDSTATUS
status
;
if
(
!
newgetargs
(
args
,
""
))
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
return
NULL
;
if
(
!
CDstop
(
self
->
ob_cdplayer
))
{
if
(
!
CDstop
(
self
->
ob_cdplayer
))
{
if
(
CDgetstatus
(
self
->
ob_cdplayer
,
&
status
)
&&
if
(
CDgetstatus
(
self
->
ob_cdplayer
,
&
status
)
&&
status
.
state
==
CD_NODISC
)
status
.
state
==
CD_NODISC
)
err_setstr
(
CdError
,
"no disc in player"
);
PyErr_SetString
(
CdError
,
"no disc in player"
);
else
else
err_setstr
(
CdError
,
"stop failed"
);
PyErr_SetString
(
CdError
,
"stop failed"
);
return
NULL
;
return
NULL
;
}
}
INCREF
(
None
);
Py_INCREF
(
Py_
None
);
return
None
;
return
Py_
None
;
}
}
static
o
bject
*
static
PyO
bject
*
CD_togglepause
(
self
,
args
)
CD_togglepause
(
self
,
args
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
CDSTATUS
status
;
CDSTATUS
status
;
if
(
!
newgetargs
(
args
,
""
))
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
return
NULL
;
if
(
!
CDtogglepause
(
self
->
ob_cdplayer
))
{
if
(
!
CDtogglepause
(
self
->
ob_cdplayer
))
{
if
(
CDgetstatus
(
self
->
ob_cdplayer
,
&
status
)
&&
if
(
CDgetstatus
(
self
->
ob_cdplayer
,
&
status
)
&&
status
.
state
==
CD_NODISC
)
status
.
state
==
CD_NODISC
)
err_setstr
(
CdError
,
"no disc in player"
);
PyErr_SetString
(
CdError
,
"no disc in player"
);
else
else
err_setstr
(
CdError
,
"togglepause failed"
);
PyErr_SetString
(
CdError
,
"togglepause failed"
);
return
NULL
;
return
NULL
;
}
}
INCREF
(
None
);
Py_INCREF
(
Py_
None
);
return
None
;
return
Py_
None
;
}
}
static
struct
methodlist
cdplayer_methods
[]
=
{
static
PyMethodDef
cdplayer_methods
[]
=
{
{
"allowremoval"
,
(
method
)
CD_allowremoval
,
1
},
{
"allowremoval"
,
(
PyCFunction
)
CD_allowremoval
,
1
},
{
"bestreadsize"
,
(
method
)
CD_bestreadsize
,
1
},
{
"bestreadsize"
,
(
PyCFunction
)
CD_bestreadsize
,
1
},
{
"close"
,
(
method
)
CD_close
,
1
},
{
"close"
,
(
PyCFunction
)
CD_close
,
1
},
{
"eject"
,
(
method
)
CD_eject
,
1
},
{
"eject"
,
(
PyCFunction
)
CD_eject
,
1
},
{
"getstatus"
,
(
method
)
CD_getstatus
,
1
},
{
"getstatus"
,
(
PyCFunction
)
CD_getstatus
,
1
},
{
"gettrackinfo"
,
(
method
)
CD_gettrackinfo
,
1
},
{
"gettrackinfo"
,
(
PyCFunction
)
CD_gettrackinfo
,
1
},
{
"msftoblock"
,
(
method
)
CD_msftoblock
,
1
},
{
"msftoblock"
,
(
PyCFunction
)
CD_msftoblock
,
1
},
{
"play"
,
(
method
)
CD_play
,
1
},
{
"play"
,
(
PyCFunction
)
CD_play
,
1
},
{
"playabs"
,
(
method
)
CD_playabs
,
1
},
{
"playabs"
,
(
PyCFunction
)
CD_playabs
,
1
},
{
"playtrack"
,
(
method
)
CD_playtrack
,
1
},
{
"playtrack"
,
(
PyCFunction
)
CD_playtrack
,
1
},
{
"playtrackabs"
,
(
method
)
CD_playtrackabs
,
1
},
{
"playtrackabs"
,
(
PyCFunction
)
CD_playtrackabs
,
1
},
{
"preventremoval"
,
(
method
)
CD_preventremoval
,
1
},
{
"preventremoval"
,
(
PyCFunction
)
CD_preventremoval
,
1
},
{
"readda"
,
(
method
)
CD_readda
,
1
},
{
"readda"
,
(
PyCFunction
)
CD_readda
,
1
},
{
"seek"
,
(
method
)
CD_seek
,
1
},
{
"seek"
,
(
PyCFunction
)
CD_seek
,
1
},
{
"seekblock"
,
(
method
)
CD_seekblock
,
1
},
{
"seekblock"
,
(
PyCFunction
)
CD_seekblock
,
1
},
{
"seektrack"
,
(
method
)
CD_seektrack
,
1
},
{
"seektrack"
,
(
PyCFunction
)
CD_seektrack
,
1
},
{
"stop"
,
(
method
)
CD_stop
,
1
},
{
"stop"
,
(
PyCFunction
)
CD_stop
,
1
},
{
"togglepause"
,
(
method
)
CD_togglepause
,
1
},
{
"togglepause"
,
(
PyCFunction
)
CD_togglepause
,
1
},
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
...
@@ -449,23 +447,23 @@ cdplayer_dealloc(self)
...
@@ -449,23 +447,23 @@ cdplayer_dealloc(self)
{
{
if
(
self
->
ob_cdplayer
!=
NULL
)
if
(
self
->
ob_cdplayer
!=
NULL
)
CDclose
(
self
->
ob_cdplayer
);
CDclose
(
self
->
ob_cdplayer
);
DEL
(
self
);
PyMem_
DEL
(
self
);
}
}
static
o
bject
*
static
PyO
bject
*
cdplayer_getattr
(
self
,
name
)
cdplayer_getattr
(
self
,
name
)
cdplayerobject
*
self
;
cdplayerobject
*
self
;
char
*
name
;
char
*
name
;
{
{
if
(
self
->
ob_cdplayer
==
NULL
)
{
if
(
self
->
ob_cdplayer
==
NULL
)
{
err_setstr
(
RuntimeError
,
"no player active"
);
PyErr_SetString
(
PyExc_
RuntimeError
,
"no player active"
);
return
NULL
;
return
NULL
;
}
}
return
findmethod
(
cdplayer_methods
,
(
o
bject
*
)
self
,
name
);
return
Py_FindMethod
(
cdplayer_methods
,
(
PyO
bject
*
)
self
,
name
);
}
}
typeo
bject
CdPlayertype
=
{
PyTypeO
bject
CdPlayertype
=
{
OB_HEAD_INIT
(
&
Typet
ype
)
PyObject_HEAD_INIT
(
&
PyType_T
ype
)
0
,
/*ob_size*/
0
,
/*ob_size*/
"cdplayer"
,
/*tp_name*/
"cdplayer"
,
/*tp_name*/
sizeof
(
cdplayerobject
),
/*tp_size*/
sizeof
(
cdplayerobject
),
/*tp_size*/
...
@@ -479,22 +477,22 @@ typeobject CdPlayertype = {
...
@@ -479,22 +477,22 @@ typeobject CdPlayertype = {
0
,
/*tp_repr*/
0
,
/*tp_repr*/
};
};
static
o
bject
*
static
PyO
bject
*
newcdplayerobject
(
cdp
)
newcdplayerobject
(
cdp
)
CDPLAYER
*
cdp
;
CDPLAYER
*
cdp
;
{
{
cdplayerobject
*
p
;
cdplayerobject
*
p
;
p
=
NEWOBJ
(
cdplayerobject
,
&
CdPlayertype
);
p
=
PyObject_NEW
(
cdplayerobject
,
&
CdPlayertype
);
if
(
p
==
NULL
)
if
(
p
==
NULL
)
return
NULL
;
return
NULL
;
p
->
ob_cdplayer
=
cdp
;
p
->
ob_cdplayer
=
cdp
;
return
(
o
bject
*
)
p
;
return
(
PyO
bject
*
)
p
;
}
}
static
o
bject
*
static
PyO
bject
*
CD_open
(
self
,
args
)
CD_open
(
self
,
args
)
o
bject
*
self
,
*
args
;
PyO
bject
*
self
,
*
args
;
{
{
char
*
dev
,
*
direction
;
char
*
dev
,
*
direction
;
CDPLAYER
*
cdp
;
CDPLAYER
*
cdp
;
...
@@ -505,12 +503,12 @@ CD_open(self, args)
...
@@ -505,12 +503,12 @@ CD_open(self, args)
*/
*/
dev
=
NULL
;
dev
=
NULL
;
direction
=
"r"
;
direction
=
"r"
;
if
(
!
newgetargs
(
args
,
"|zs"
,
&
dev
,
&
direction
))
if
(
!
PyArg_ParseTuple
(
args
,
"|zs"
,
&
dev
,
&
direction
))
return
NULL
;
return
NULL
;
cdp
=
CDopen
(
dev
,
direction
);
cdp
=
CDopen
(
dev
,
direction
);
if
(
cdp
==
NULL
)
{
if
(
cdp
==
NULL
)
{
err_e
rrno
(
CdError
);
PyErr_SetFromE
rrno
(
CdError
);
return
NULL
;
return
NULL
;
}
}
...
@@ -518,11 +516,11 @@ CD_open(self, args)
...
@@ -518,11 +516,11 @@ CD_open(self, args)
}
}
typedef
struct
{
typedef
struct
{
OB
_HEAD
PyObject
_HEAD
CDPARSER
*
ob_cdparser
;
CDPARSER
*
ob_cdparser
;
struct
{
struct
{
o
bject
*
ob_cdcallback
;
PyO
bject
*
ob_cdcallback
;
o
bject
*
ob_cdcallbackarg
;
PyO
bject
*
ob_cdcallbackarg
;
}
ob_cdcallbacks
[
NCALLBACKS
];
}
ob_cdcallbacks
[
NCALLBACKS
];
}
cdparserobject
;
}
cdparserobject
;
...
@@ -532,45 +530,45 @@ CD_callback(arg, type, data)
...
@@ -532,45 +530,45 @@ CD_callback(arg, type, data)
CDDATATYPES
type
;
CDDATATYPES
type
;
void
*
data
;
void
*
data
;
{
{
o
bject
*
result
,
*
args
,
*
v
=
NULL
;
PyO
bject
*
result
,
*
args
,
*
v
=
NULL
;
char
*
p
;
char
*
p
;
int
i
;
int
i
;
cdparserobject
*
self
;
cdparserobject
*
self
;
self
=
(
cdparserobject
*
)
arg
;
self
=
(
cdparserobject
*
)
arg
;
args
=
newtupleobject
(
3
);
args
=
PyTuple_New
(
3
);
if
(
args
==
NULL
)
if
(
args
==
NULL
)
return
;
return
;
INCREF
(
self
->
ob_cdcallbacks
[
type
].
ob_cdcallbackarg
);
Py_
INCREF
(
self
->
ob_cdcallbacks
[
type
].
ob_cdcallbackarg
);
settuplei
tem
(
args
,
0
,
self
->
ob_cdcallbacks
[
type
].
ob_cdcallbackarg
);
PyTuple_SetI
tem
(
args
,
0
,
self
->
ob_cdcallbacks
[
type
].
ob_cdcallbackarg
);
settupleitem
(
args
,
1
,
newintobject
((
long
)
type
));
PyTuple_SetItem
(
args
,
1
,
PyInt_FromLong
((
long
)
type
));
switch
(
type
)
{
switch
(
type
)
{
case
cd_audio
:
case
cd_audio
:
v
=
newsizedstringobject
(
data
,
CDDA_DATASIZE
);
v
=
PyString_FromStringAndSize
(
data
,
CDDA_DATASIZE
);
break
;
break
;
case
cd_pnum
:
case
cd_pnum
:
case
cd_index
:
case
cd_index
:
v
=
newintobject
(((
CDPROGNUM
*
)
data
)
->
value
);
v
=
PyInt_FromLong
(((
CDPROGNUM
*
)
data
)
->
value
);
break
;
break
;
case
cd_ptime
:
case
cd_ptime
:
case
cd_atime
:
case
cd_atime
:
#define ptr ((struct cdtimecode *) data)
#define ptr ((struct cdtimecode *) data)
v
=
mkv
alue
(
"(iii)"
,
v
=
Py_BuildV
alue
(
"(iii)"
,
ptr
->
mhi
*
10
+
ptr
->
mlo
,
ptr
->
mhi
*
10
+
ptr
->
mlo
,
ptr
->
shi
*
10
+
ptr
->
slo
,
ptr
->
shi
*
10
+
ptr
->
slo
,
ptr
->
fhi
*
10
+
ptr
->
flo
);
ptr
->
fhi
*
10
+
ptr
->
flo
);
#undef ptr
#undef ptr
break
;
break
;
case
cd_catalog
:
case
cd_catalog
:
v
=
newsizedstringobject
(
NULL
,
13
);
v
=
PyString_FromStringAndSize
(
NULL
,
13
);
p
=
getstringvalue
(
v
);
p
=
PyString_AsString
(
v
);
for
(
i
=
0
;
i
<
13
;
i
++
)
for
(
i
=
0
;
i
<
13
;
i
++
)
*
p
++
=
((
char
*
)
data
)[
i
]
+
'0'
;
*
p
++
=
((
char
*
)
data
)[
i
]
+
'0'
;
break
;
break
;
case
cd_ident
:
case
cd_ident
:
#define ptr ((struct cdident *) data)
#define ptr ((struct cdident *) data)
v
=
newsizedstringobject
(
NULL
,
12
);
v
=
PyString_FromStringAndSize
(
NULL
,
12
);
p
=
getstringvalue
(
v
);
p
=
PyString_AsString
(
v
);
CDsbtoa
(
p
,
ptr
->
country
,
2
);
CDsbtoa
(
p
,
ptr
->
country
,
2
);
p
+=
2
;
p
+=
2
;
CDsbtoa
(
p
,
ptr
->
owner
,
3
);
CDsbtoa
(
p
,
ptr
->
owner
,
3
);
...
@@ -585,28 +583,29 @@ CD_callback(arg, type, data)
...
@@ -585,28 +583,29 @@ CD_callback(arg, type, data)
#undef ptr
#undef ptr
break
;
break
;
case
cd_control
:
case
cd_control
:
v
=
newintobject
((
long
)
*
((
unchar
*
)
data
));
v
=
PyInt_FromLong
((
long
)
*
((
unchar
*
)
data
));
break
;
break
;
}
}
settuplei
tem
(
args
,
2
,
v
);
PyTuple_SetI
tem
(
args
,
2
,
v
);
if
(
err_o
ccurred
())
{
if
(
PyErr_O
ccurred
())
{
DECREF
(
args
);
Py_
DECREF
(
args
);
return
;
return
;
}
}
result
=
call_object
(
self
->
ob_cdcallbacks
[
type
].
ob_cdcallback
,
args
);
result
=
PyEval_CallObject
(
self
->
ob_cdcallbacks
[
type
].
ob_cdcallback
,
DECREF
(
args
);
args
);
XDECREF
(
result
);
Py_DECREF
(
args
);
Py_XDECREF
(
result
);
}
}
static
o
bject
*
static
PyO
bject
*
CD_deleteparser
(
self
,
args
)
CD_deleteparser
(
self
,
args
)
cdparserobject
*
self
;
cdparserobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
int
i
;
int
i
;
if
(
!
newgetargs
(
args
,
""
))
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
return
NULL
;
CDdeleteparser
(
self
->
ob_cdparser
);
CDdeleteparser
(
self
->
ob_cdparser
);
...
@@ -614,30 +613,30 @@ CD_deleteparser(self, args)
...
@@ -614,30 +613,30 @@ CD_deleteparser(self, args)
/* no sense in keeping the callbacks, so remove them */
/* no sense in keeping the callbacks, so remove them */
for
(
i
=
0
;
i
<
NCALLBACKS
;
i
++
)
{
for
(
i
=
0
;
i
<
NCALLBACKS
;
i
++
)
{
XDECREF
(
self
->
ob_cdcallbacks
[
i
].
ob_cdcallback
);
Py_
XDECREF
(
self
->
ob_cdcallbacks
[
i
].
ob_cdcallback
);
self
->
ob_cdcallbacks
[
i
].
ob_cdcallback
=
NULL
;
self
->
ob_cdcallbacks
[
i
].
ob_cdcallback
=
NULL
;
XDECREF
(
self
->
ob_cdcallbacks
[
i
].
ob_cdcallbackarg
);
Py_
XDECREF
(
self
->
ob_cdcallbacks
[
i
].
ob_cdcallbackarg
);
self
->
ob_cdcallbacks
[
i
].
ob_cdcallbackarg
=
NULL
;
self
->
ob_cdcallbacks
[
i
].
ob_cdcallbackarg
=
NULL
;
}
}
INCREF
(
None
);
Py_INCREF
(
Py_
None
);
return
None
;
return
Py_
None
;
}
}
static
o
bject
*
static
PyO
bject
*
CD_parseframe
(
self
,
args
)
CD_parseframe
(
self
,
args
)
cdparserobject
*
self
;
cdparserobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
char
*
cdfp
;
char
*
cdfp
;
int
length
;
int
length
;
CDFRAME
*
p
;
CDFRAME
*
p
;
if
(
!
newgetargs
(
args
,
"s#"
,
&
cdfp
,
&
length
))
if
(
!
PyArg_ParseTuple
(
args
,
"s#"
,
&
cdfp
,
&
length
))
return
NULL
;
return
NULL
;
if
(
length
%
sizeof
(
CDFRAME
)
!=
0
)
{
if
(
length
%
sizeof
(
CDFRAME
)
!=
0
)
{
err_setstr
(
TypeError
,
"bad length"
);
PyErr_SetString
(
PyExc_
TypeError
,
"bad length"
);
return
NULL
;
return
NULL
;
}
}
...
@@ -646,102 +645,106 @@ CD_parseframe(self, args)
...
@@ -646,102 +645,106 @@ CD_parseframe(self, args)
CDparseframe
(
self
->
ob_cdparser
,
p
);
CDparseframe
(
self
->
ob_cdparser
,
p
);
length
-=
sizeof
(
CDFRAME
);
length
-=
sizeof
(
CDFRAME
);
p
++
;
p
++
;
if
(
err_o
ccurred
())
if
(
PyErr_O
ccurred
())
return
NULL
;
return
NULL
;
}
}
INCREF
(
None
);
Py_INCREF
(
Py_
None
);
return
None
;
return
Py_
None
;
}
}
static
o
bject
*
static
PyO
bject
*
CD_removecallback
(
self
,
args
)
CD_removecallback
(
self
,
args
)
cdparserobject
*
self
;
cdparserobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
int
type
;
int
type
;
if
(
!
newgetargs
(
args
,
"i"
,
&
type
))
if
(
!
PyArg_ParseTuple
(
args
,
"i"
,
&
type
))
return
NULL
;
return
NULL
;
if
(
type
<
0
||
type
>=
NCALLBACKS
)
{
if
(
type
<
0
||
type
>=
NCALLBACKS
)
{
err_setstr
(
TypeError
,
"bad type"
);
PyErr_SetString
(
PyExc_
TypeError
,
"bad type"
);
return
NULL
;
return
NULL
;
}
}
CDremovecallback
(
self
->
ob_cdparser
,
(
CDDATATYPES
)
type
);
CDremovecallback
(
self
->
ob_cdparser
,
(
CDDATATYPES
)
type
);
XDECREF
(
self
->
ob_cdcallbacks
[
type
].
ob_cdcallback
);
Py_
XDECREF
(
self
->
ob_cdcallbacks
[
type
].
ob_cdcallback
);
self
->
ob_cdcallbacks
[
type
].
ob_cdcallback
=
NULL
;
self
->
ob_cdcallbacks
[
type
].
ob_cdcallback
=
NULL
;
XDECREF
(
self
->
ob_cdcallbacks
[
type
].
ob_cdcallbackarg
);
Py_
XDECREF
(
self
->
ob_cdcallbacks
[
type
].
ob_cdcallbackarg
);
self
->
ob_cdcallbacks
[
type
].
ob_cdcallbackarg
=
NULL
;
self
->
ob_cdcallbacks
[
type
].
ob_cdcallbackarg
=
NULL
;
INCREF
(
None
);
Py_INCREF
(
Py_
None
);
return
None
;
return
Py_
None
;
}
}
static
o
bject
*
static
PyO
bject
*
CD_resetparser
(
self
,
args
)
CD_resetparser
(
self
,
args
)
cdparserobject
*
self
;
cdparserobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
if
(
!
newgetargs
(
args
,
""
))
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
return
NULL
;
CDresetparser
(
self
->
ob_cdparser
);
CDresetparser
(
self
->
ob_cdparser
);
INCREF
(
None
);
Py_INCREF
(
Py_
None
);
return
None
;
return
Py_
None
;
}
}
static
o
bject
*
static
PyO
bject
*
CD_addcallback
(
self
,
args
)
CD_addcallback
(
self
,
args
)
cdparserobject
*
self
;
cdparserobject
*
self
;
o
bject
*
args
;
PyO
bject
*
args
;
{
{
int
type
;
int
type
;
o
bject
*
func
,
*
funcarg
;
PyO
bject
*
func
,
*
funcarg
;
/* XXX - more work here */
/* XXX - more work here */
if
(
!
newgetargs
(
args
,
"iOO"
,
&
type
,
&
func
,
&
funcarg
))
if
(
!
PyArg_ParseTuple
(
args
,
"iOO"
,
&
type
,
&
func
,
&
funcarg
))
return
NULL
;
return
NULL
;
if
(
type
<
0
||
type
>=
NCALLBACKS
)
{
if
(
type
<
0
||
type
>=
NCALLBACKS
)
{
err_setstr
(
TypeError
,
"argument out of range"
);
PyErr_SetString
(
PyExc_
TypeError
,
"argument out of range"
);
return
NULL
;
return
NULL
;
}
}
#ifdef CDsetcallback
#ifdef CDsetcallback
CDaddcallback
(
self
->
ob_cdparser
,
(
CDDATATYPES
)
type
,
CD_callback
,
(
void
*
)
self
);
CDaddcallback
(
self
->
ob_cdparser
,
(
CDDATATYPES
)
type
,
CD_callback
,
(
void
*
)
self
);
#else
#else
CDsetcallback
(
self
->
ob_cdparser
,
(
CDDATATYPES
)
type
,
CD_callback
,
(
void
*
)
self
);
CDsetcallback
(
self
->
ob_cdparser
,
(
CDDATATYPES
)
type
,
CD_callback
,
(
void
*
)
self
);
#endif
#endif
XDECREF
(
self
->
ob_cdcallbacks
[
type
].
ob_cdcallback
);
Py_
XDECREF
(
self
->
ob_cdcallbacks
[
type
].
ob_cdcallback
);
INCREF
(
func
);
Py_
INCREF
(
func
);
self
->
ob_cdcallbacks
[
type
].
ob_cdcallback
=
func
;
self
->
ob_cdcallbacks
[
type
].
ob_cdcallback
=
func
;
XDECREF
(
self
->
ob_cdcallbacks
[
type
].
ob_cdcallbackarg
);
Py_
XDECREF
(
self
->
ob_cdcallbacks
[
type
].
ob_cdcallbackarg
);
INCREF
(
funcarg
);
Py_
INCREF
(
funcarg
);
self
->
ob_cdcallbacks
[
type
].
ob_cdcallbackarg
=
funcarg
;
self
->
ob_cdcallbacks
[
type
].
ob_cdcallbackarg
=
funcarg
;
/*
/*
if (type == cd_audio) {
if (type == cd_audio) {
sigfpe_[_UNDERFL].repls = _ZERO;
sigfpe_[_UNDERFL].repls = _ZERO;
handle_sigfpes(_ON, _EN_UNDERFL, NULL, _ABORT_ON_ERROR, NULL);
handle_sigfpes(_ON, _EN_UNDERFL, NULL,
_ABORT_ON_ERROR, NULL);
}
}
*/
*/
INCREF
(
None
);
Py_INCREF
(
Py_
None
);
return
None
;
return
Py_
None
;
}
}
static
struct
methodlist
cdparser_methods
[]
=
{
static
PyMethodDef
cdparser_methods
[]
=
{
{
"addcallback"
,
(
method
)
CD_addcallback
,
1
},
{
"addcallback"
,
(
PyCFunction
)
CD_addcallback
,
1
},
{
"deleteparser"
,
(
method
)
CD_deleteparser
,
1
},
{
"deleteparser"
,
(
PyCFunction
)
CD_deleteparser
,
1
},
{
"parseframe"
,
(
method
)
CD_parseframe
,
1
},
{
"parseframe"
,
(
PyCFunction
)
CD_parseframe
,
1
},
{
"removecallback"
,
(
method
)
CD_removecallback
,
1
},
{
"removecallback"
,
(
PyCFunction
)
CD_removecallback
,
1
},
{
"resetparser"
,
(
method
)
CD_resetparser
,
1
},
{
"resetparser"
,
(
PyCFunction
)
CD_resetparser
,
1
},
{
"setcallback"
,
(
method
)
CD_addcallback
,
1
},
/* backward compatibility */
/* backward compatibility */
{
"setcallback"
,
(
PyCFunction
)
CD_addcallback
,
1
},
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
...
@@ -752,30 +755,30 @@ cdparser_dealloc(self)
...
@@ -752,30 +755,30 @@ cdparser_dealloc(self)
int
i
;
int
i
;
for
(
i
=
0
;
i
<
NCALLBACKS
;
i
++
)
{
for
(
i
=
0
;
i
<
NCALLBACKS
;
i
++
)
{
XDECREF
(
self
->
ob_cdcallbacks
[
i
].
ob_cdcallback
);
Py_
XDECREF
(
self
->
ob_cdcallbacks
[
i
].
ob_cdcallback
);
self
->
ob_cdcallbacks
[
i
].
ob_cdcallback
=
NULL
;
self
->
ob_cdcallbacks
[
i
].
ob_cdcallback
=
NULL
;
XDECREF
(
self
->
ob_cdcallbacks
[
i
].
ob_cdcallbackarg
);
Py_
XDECREF
(
self
->
ob_cdcallbacks
[
i
].
ob_cdcallbackarg
);
self
->
ob_cdcallbacks
[
i
].
ob_cdcallbackarg
=
NULL
;
self
->
ob_cdcallbacks
[
i
].
ob_cdcallbackarg
=
NULL
;
}
}
CDdeleteparser
(
self
->
ob_cdparser
);
CDdeleteparser
(
self
->
ob_cdparser
);
DEL
(
self
);
PyMem_
DEL
(
self
);
}
}
static
o
bject
*
static
PyO
bject
*
cdparser_getattr
(
self
,
name
)
cdparser_getattr
(
self
,
name
)
cdparserobject
*
self
;
cdparserobject
*
self
;
char
*
name
;
char
*
name
;
{
{
if
(
self
->
ob_cdparser
==
NULL
)
{
if
(
self
->
ob_cdparser
==
NULL
)
{
err_setstr
(
RuntimeError
,
"no parser active"
);
PyErr_SetString
(
PyExc_
RuntimeError
,
"no parser active"
);
return
NULL
;
return
NULL
;
}
}
return
findmethod
(
cdparser_methods
,
(
o
bject
*
)
self
,
name
);
return
Py_FindMethod
(
cdparser_methods
,
(
PyO
bject
*
)
self
,
name
);
}
}
typeo
bject
CdParsertype
=
{
PyTypeO
bject
CdParsertype
=
{
OB_HEAD_INIT
(
&
Typet
ype
)
PyObject_HEAD_INIT
(
&
PyType_T
ype
)
0
,
/*ob_size*/
0
,
/*ob_size*/
"cdparser"
,
/*tp_name*/
"cdparser"
,
/*tp_name*/
sizeof
(
cdparserobject
),
/*tp_size*/
sizeof
(
cdparserobject
),
/*tp_size*/
...
@@ -789,14 +792,14 @@ typeobject CdParsertype = {
...
@@ -789,14 +792,14 @@ typeobject CdParsertype = {
0
,
/*tp_repr*/
0
,
/*tp_repr*/
};
};
static
o
bject
*
static
PyO
bject
*
newcdparserobject
(
cdp
)
newcdparserobject
(
cdp
)
CDPARSER
*
cdp
;
CDPARSER
*
cdp
;
{
{
cdparserobject
*
p
;
cdparserobject
*
p
;
int
i
;
int
i
;
p
=
NEWOBJ
(
cdparserobject
,
&
CdParsertype
);
p
=
PyObject_NEW
(
cdparserobject
,
&
CdParsertype
);
if
(
p
==
NULL
)
if
(
p
==
NULL
)
return
NULL
;
return
NULL
;
p
->
ob_cdparser
=
cdp
;
p
->
ob_cdparser
=
cdp
;
...
@@ -804,81 +807,83 @@ newcdparserobject(cdp)
...
@@ -804,81 +807,83 @@ newcdparserobject(cdp)
p
->
ob_cdcallbacks
[
i
].
ob_cdcallback
=
NULL
;
p
->
ob_cdcallbacks
[
i
].
ob_cdcallback
=
NULL
;
p
->
ob_cdcallbacks
[
i
].
ob_cdcallbackarg
=
NULL
;
p
->
ob_cdcallbacks
[
i
].
ob_cdcallbackarg
=
NULL
;
}
}
return
(
o
bject
*
)
p
;
return
(
PyO
bject
*
)
p
;
}
}
static
o
bject
*
static
PyO
bject
*
CD_createparser
(
self
,
args
)
CD_createparser
(
self
,
args
)
o
bject
*
self
,
*
args
;
PyO
bject
*
self
,
*
args
;
{
{
CDPARSER
*
cdp
;
CDPARSER
*
cdp
;
if
(
!
newgetargs
(
args
,
""
))
if
(
!
PyArg_ParseTuple
(
args
,
""
))
return
NULL
;
return
NULL
;
cdp
=
CDcreateparser
();
cdp
=
CDcreateparser
();
if
(
cdp
==
NULL
)
{
if
(
cdp
==
NULL
)
{
err_setstr
(
CdError
,
"createparser failed"
);
PyErr_SetString
(
CdError
,
"createparser failed"
);
return
NULL
;
return
NULL
;
}
}
return
newcdparserobject
(
cdp
);
return
newcdparserobject
(
cdp
);
}
}
static
o
bject
*
static
PyO
bject
*
CD_msftoframe
(
self
,
args
)
CD_msftoframe
(
self
,
args
)
o
bject
*
self
,
*
args
;
PyO
bject
*
self
,
*
args
;
{
{
int
min
,
sec
,
frame
;
int
min
,
sec
,
frame
;
if
(
!
newgetargs
(
args
,
"iii"
,
&
min
,
&
sec
,
&
frame
))
if
(
!
PyArg_ParseTuple
(
args
,
"iii"
,
&
min
,
&
sec
,
&
frame
))
return
NULL
;
return
NULL
;
return
newintobject
((
long
)
CDmsftoframe
(
min
,
sec
,
frame
));
return
PyInt_FromLong
((
long
)
CDmsftoframe
(
min
,
sec
,
frame
));
}
}
static
struct
methodlist
CD_methods
[]
=
{
static
PyMethodDef
CD_methods
[]
=
{
{
"open"
,
(
method
)
CD_open
,
1
},
{
"open"
,
(
PyCFunction
)
CD_open
,
1
},
{
"createparser"
,
(
method
)
CD_createparser
,
1
},
{
"createparser"
,
(
PyCFunction
)
CD_createparser
,
1
},
{
"msftoframe"
,
(
method
)
CD_msftoframe
,
1
},
{
"msftoframe"
,
(
PyCFunction
)
CD_msftoframe
,
1
},
{
NULL
,
NULL
}
/* Sentinel */
{
NULL
,
NULL
}
/* Sentinel */
};
};
void
void
initcd
()
initcd
()
{
{
o
bject
*
m
,
*
d
;
PyO
bject
*
m
,
*
d
;
m
=
initm
odule
(
"cd"
,
CD_methods
);
m
=
Py_InitM
odule
(
"cd"
,
CD_methods
);
d
=
getmoduled
ict
(
m
);
d
=
PyModule_GetD
ict
(
m
);
CdError
=
newstringobject
(
"cd.error"
);
CdError
=
PyString_FromString
(
"cd.error"
);
dictinsert
(
d
,
"error"
,
CdError
);
PyDict_SetItemString
(
d
,
"error"
,
CdError
);
/* Identifiers for the different types of callbacks from the parser */
/* Identifiers for the different types of callbacks from the parser */
dictinsert
(
d
,
"audio"
,
newintobject
((
long
)
cd_audio
));
PyDict_SetItemString
(
d
,
"audio"
,
PyInt_FromLong
((
long
)
cd_audio
));
dictinsert
(
d
,
"pnum"
,
newintobject
((
long
)
cd_pnum
));
PyDict_SetItemString
(
d
,
"pnum"
,
PyInt_FromLong
((
long
)
cd_pnum
));
dictinsert
(
d
,
"index"
,
newintobject
((
long
)
cd_index
));
PyDict_SetItemString
(
d
,
"index"
,
PyInt_FromLong
((
long
)
cd_index
));
dictinsert
(
d
,
"ptime"
,
newintobject
((
long
)
cd_ptime
));
PyDict_SetItemString
(
d
,
"ptime"
,
PyInt_FromLong
((
long
)
cd_ptime
));
dictinsert
(
d
,
"atime"
,
newintobject
((
long
)
cd_atime
));
PyDict_SetItemString
(
d
,
"atime"
,
PyInt_FromLong
((
long
)
cd_atime
));
dictinsert
(
d
,
"catalog"
,
newintobject
((
long
)
cd_catalog
));
PyDict_SetItemString
(
d
,
"catalog"
,
PyInt_FromLong
((
long
)
cd_catalog
));
dictinsert
(
d
,
"ident"
,
newintobject
((
long
)
cd_ident
));
PyDict_SetItemString
(
d
,
"ident"
,
PyInt_FromLong
((
long
)
cd_ident
));
dictinsert
(
d
,
"control"
,
newintobject
((
long
)
cd_control
));
PyDict_SetItemString
(
d
,
"control"
,
PyInt_FromLong
((
long
)
cd_control
));
/* Block size information for digital audio data */
/* Block size information for digital audio data */
dictinsert
(
d
,
"DATASIZE"
,
newintobject
((
long
)
CDDA_DATASIZE
));
PyDict_SetItemString
(
d
,
"DATASIZE"
,
dictinsert
(
d
,
"BLOCKSIZE"
,
newintobject
((
long
)
CDDA_BLOCKSIZE
));
PyInt_FromLong
((
long
)
CDDA_DATASIZE
));
PyDict_SetItemString
(
d
,
"BLOCKSIZE"
,
PyInt_FromLong
((
long
)
CDDA_BLOCKSIZE
));
/* Possible states for the cd player */
/* Possible states for the cd player */
dictinsert
(
d
,
"ERROR"
,
newintobject
((
long
)
CD_ERROR
));
PyDict_SetItemString
(
d
,
"ERROR"
,
PyInt_FromLong
((
long
)
CD_ERROR
));
dictinsert
(
d
,
"NODISC"
,
newintobject
((
long
)
CD_NODISC
));
PyDict_SetItemString
(
d
,
"NODISC"
,
PyInt_FromLong
((
long
)
CD_NODISC
));
dictinsert
(
d
,
"READY"
,
newintobject
((
long
)
CD_READY
));
PyDict_SetItemString
(
d
,
"READY"
,
PyInt_FromLong
((
long
)
CD_READY
));
dictinsert
(
d
,
"PLAYING"
,
newintobject
((
long
)
CD_PLAYING
));
PyDict_SetItemString
(
d
,
"PLAYING"
,
PyInt_FromLong
((
long
)
CD_PLAYING
));
dictinsert
(
d
,
"PAUSED"
,
newintobject
((
long
)
CD_PAUSED
));
PyDict_SetItemString
(
d
,
"PAUSED"
,
PyInt_FromLong
((
long
)
CD_PAUSED
));
dictinsert
(
d
,
"STILL"
,
newintobject
((
long
)
CD_STILL
));
PyDict_SetItemString
(
d
,
"STILL"
,
PyInt_FromLong
((
long
)
CD_STILL
));
#ifdef CD_CDROM
/* only newer versions of the library */
#ifdef CD_CDROM
/* only newer versions of the library */
dictinsert
(
d
,
"CDROM"
,
newintobject
((
long
)
CD_CDROM
));
PyDict_SetItemString
(
d
,
"CDROM"
,
PyInt_FromLong
((
long
)
CD_CDROM
));
#endif
#endif
if
(
err_o
ccurred
())
if
(
PyErr_O
ccurred
())
fatal
(
"can't initialize module cd"
);
Py_FatalError
(
"can't initialize module cd"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment