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
ad4d9b97
Commit
ad4d9b97
authored
Dec 30, 2002
by
Greg Ward
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Untabify.
parent
e7037664
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
106 additions
and
106 deletions
+106
-106
Modules/ossaudiodev.c
Modules/ossaudiodev.c
+106
-106
No files found.
Modules/ossaudiodev.c
View file @
ad4d9b97
...
@@ -56,7 +56,7 @@ typedef struct {
...
@@ -56,7 +56,7 @@ typedef struct {
typedef
struct
{
typedef
struct
{
PyObject_HEAD
;
PyObject_HEAD
;
int
fd
;
/* The open mixer device */
int
fd
;
/* The open mixer device */
}
oss_mixer_t
;
}
oss_mixer_t
;
/* XXX several format defined in soundcard.h are not supported,
/* XXX several format defined in soundcard.h are not supported,
...
@@ -64,19 +64,19 @@ typedef struct {
...
@@ -64,19 +64,19 @@ typedef struct {
*/
*/
static
struct
{
static
struct
{
int
a_bps
;
int
a_bps
;
uint32_t
a_fmt
;
uint32_t
a_fmt
;
char
*
a_name
;
char
*
a_name
;
}
audio_types
[]
=
{
}
audio_types
[]
=
{
{
8
,
AFMT_MU_LAW
,
"logarithmic mu-law 8-bit audio"
},
{
8
,
AFMT_MU_LAW
,
"logarithmic mu-law 8-bit audio"
},
{
8
,
AFMT_A_LAW
,
"logarithmic A-law 8-bit audio"
},
{
8
,
AFMT_A_LAW
,
"logarithmic A-law 8-bit audio"
},
{
8
,
AFMT_U8
,
"linear unsigned 8-bit audio"
},
{
8
,
AFMT_U8
,
"linear unsigned 8-bit audio"
},
{
8
,
AFMT_S8
,
"linear signed 8-bit audio"
},
{
8
,
AFMT_S8
,
"linear signed 8-bit audio"
},
{
16
,
AFMT_U16_BE
,
"linear unsigned 16-bit big-endian audio"
},
{
16
,
AFMT_U16_BE
,
"linear unsigned 16-bit big-endian audio"
},
{
16
,
AFMT_U16_LE
,
"linear unsigned 16-bit little-endian audio"
},
{
16
,
AFMT_U16_LE
,
"linear unsigned 16-bit little-endian audio"
},
{
16
,
AFMT_S16_BE
,
"linear signed 16-bit big-endian audio"
},
{
16
,
AFMT_S16_BE
,
"linear signed 16-bit big-endian audio"
},
{
16
,
AFMT_S16_LE
,
"linear signed 16-bit little-endian audio"
},
{
16
,
AFMT_S16_LE
,
"linear signed 16-bit little-endian audio"
},
{
16
,
AFMT_S16_NE
,
"linear signed 16-bit native-endian audio"
},
{
16
,
AFMT_S16_NE
,
"linear signed 16-bit native-endian audio"
},
};
};
static
int
n_audio_types
=
sizeof
(
audio_types
)
/
sizeof
(
audio_types
[
0
]);
static
int
n_audio_types
=
sizeof
(
audio_types
)
/
sizeof
(
audio_types
[
0
]);
...
@@ -150,7 +150,7 @@ oss_dealloc(oss_t *xp)
...
@@ -150,7 +150,7 @@ oss_dealloc(oss_t *xp)
{
{
/* if already closed, don't reclose it */
/* if already closed, don't reclose it */
if
(
xp
->
fd
!=
-
1
)
if
(
xp
->
fd
!=
-
1
)
close
(
xp
->
fd
);
close
(
xp
->
fd
);
PyObject_Del
(
xp
);
PyObject_Del
(
xp
);
}
}
...
@@ -162,13 +162,13 @@ newossmixerobject(PyObject *arg)
...
@@ -162,13 +162,13 @@ newossmixerobject(PyObject *arg)
oss_mixer_t
*
xp
;
oss_mixer_t
*
xp
;
if
(
!
PyArg_ParseTuple
(
arg
,
"|ss"
,
&
basedev
,
&
mode
))
{
if
(
!
PyArg_ParseTuple
(
arg
,
"|ss"
,
&
basedev
,
&
mode
))
{
return
NULL
;
return
NULL
;
}
}
if
(
basedev
==
NULL
)
{
if
(
basedev
==
NULL
)
{
basedev
=
getenv
(
"MIXERDEV"
);
basedev
=
getenv
(
"MIXERDEV"
);
if
(
basedev
==
NULL
)
/* MIXERDEV not set */
if
(
basedev
==
NULL
)
/* MIXERDEV not set */
basedev
=
"/dev/mixer"
;
basedev
=
"/dev/mixer"
;
}
}
if
(
mode
==
NULL
||
strcmp
(
mode
,
"r"
)
==
0
)
if
(
mode
==
NULL
||
strcmp
(
mode
,
"r"
)
==
0
)
...
@@ -202,7 +202,7 @@ oss_mixer_dealloc(oss_mixer_t *xp)
...
@@ -202,7 +202,7 @@ oss_mixer_dealloc(oss_mixer_t *xp)
{
{
/* if already closed, don't reclose it */
/* if already closed, don't reclose it */
if
(
xp
->
fd
!=
-
1
)
if
(
xp
->
fd
!=
-
1
)
close
(
xp
->
fd
);
close
(
xp
->
fd
);
PyObject_Del
(
xp
);
PyObject_Del
(
xp
);
}
}
...
@@ -233,7 +233,7 @@ _do_ioctl_1(int fd, PyObject *args, char *fname, int cmd)
...
@@ -233,7 +233,7 @@ _do_ioctl_1(int fd, PyObject *args, char *fname, int cmd)
assert
(
strlen
(
fname
)
<=
30
);
assert
(
strlen
(
fname
)
<=
30
);
strcat
(
argfmt
,
fname
);
strcat
(
argfmt
,
fname
);
if
(
!
PyArg_ParseTuple
(
args
,
argfmt
,
&
arg
))
if
(
!
PyArg_ParseTuple
(
args
,
argfmt
,
&
arg
))
return
NULL
;
return
NULL
;
if
(
ioctl
(
fd
,
cmd
,
&
arg
)
==
-
1
)
if
(
ioctl
(
fd
,
cmd
,
&
arg
)
==
-
1
)
return
PyErr_SetFromErrno
(
PyExc_IOError
);
return
PyErr_SetFromErrno
(
PyExc_IOError
);
...
@@ -258,7 +258,7 @@ _do_ioctl_1_internal(int fd, PyObject *args, char *fname, int cmd)
...
@@ -258,7 +258,7 @@ _do_ioctl_1_internal(int fd, PyObject *args, char *fname, int cmd)
assert
(
strlen
(
fname
)
<=
30
);
assert
(
strlen
(
fname
)
<=
30
);
strcat
(
argfmt
,
fname
);
strcat
(
argfmt
,
fname
);
if
(
!
PyArg_ParseTuple
(
args
,
argfmt
,
&
arg
))
if
(
!
PyArg_ParseTuple
(
args
,
argfmt
,
&
arg
))
return
NULL
;
return
NULL
;
if
(
ioctl
(
fd
,
cmd
,
&
arg
)
==
-
1
)
if
(
ioctl
(
fd
,
cmd
,
&
arg
)
==
-
1
)
return
PyErr_SetFromErrno
(
PyExc_IOError
);
return
PyErr_SetFromErrno
(
PyExc_IOError
);
...
@@ -277,7 +277,7 @@ _do_ioctl_0(int fd, PyObject *args, char *fname, int cmd)
...
@@ -277,7 +277,7 @@ _do_ioctl_0(int fd, PyObject *args, char *fname, int cmd)
assert
(
strlen
(
fname
)
<=
30
);
assert
(
strlen
(
fname
)
<=
30
);
strcat
(
argfmt
,
fname
);
strcat
(
argfmt
,
fname
);
if
(
!
PyArg_ParseTuple
(
args
,
argfmt
))
if
(
!
PyArg_ParseTuple
(
args
,
argfmt
))
return
NULL
;
return
NULL
;
if
(
ioctl
(
fd
,
cmd
,
0
)
==
-
1
)
if
(
ioctl
(
fd
,
cmd
,
0
)
==
-
1
)
return
PyErr_SetFromErrno
(
PyExc_IOError
);
return
PyErr_SetFromErrno
(
PyExc_IOError
);
...
@@ -292,7 +292,7 @@ oss_nonblock(oss_t *self, PyObject *args)
...
@@ -292,7 +292,7 @@ oss_nonblock(oss_t *self, PyObject *args)
/* Hmmm: it doesn't appear to be possible to return to blocking
/* Hmmm: it doesn't appear to be possible to return to blocking
mode once we're in non-blocking mode! */
mode once we're in non-blocking mode! */
if
(
!
PyArg_ParseTuple
(
args
,
":nonblock"
))
if
(
!
PyArg_ParseTuple
(
args
,
":nonblock"
))
return
NULL
;
return
NULL
;
if
(
ioctl
(
self
->
fd
,
SNDCTL_DSP_NONBLOCK
,
NULL
)
==
-
1
)
if
(
ioctl
(
self
->
fd
,
SNDCTL_DSP_NONBLOCK
,
NULL
)
==
-
1
)
return
PyErr_SetFromErrno
(
PyExc_IOError
);
return
PyErr_SetFromErrno
(
PyExc_IOError
);
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
...
@@ -310,7 +310,7 @@ oss_getfmts(oss_t *self, PyObject *args)
...
@@ -310,7 +310,7 @@ oss_getfmts(oss_t *self, PyObject *args)
{
{
int
mask
;
int
mask
;
if
(
!
PyArg_ParseTuple
(
args
,
":getfmts"
))
if
(
!
PyArg_ParseTuple
(
args
,
":getfmts"
))
return
NULL
;
return
NULL
;
if
(
ioctl
(
self
->
fd
,
SNDCTL_DSP_GETFMTS
,
&
mask
)
==
-
1
)
if
(
ioctl
(
self
->
fd
,
SNDCTL_DSP_GETFMTS
,
&
mask
)
==
-
1
)
return
PyErr_SetFromErrno
(
PyExc_IOError
);
return
PyErr_SetFromErrno
(
PyExc_IOError
);
return
PyInt_FromLong
(
mask
);
return
PyInt_FromLong
(
mask
);
...
@@ -356,7 +356,7 @@ oss_read(oss_t *self, PyObject *args)
...
@@ -356,7 +356,7 @@ oss_read(oss_t *self, PyObject *args)
int
size
,
count
;
int
size
,
count
;
char
*
cp
;
char
*
cp
;
PyObject
*
rv
;
PyObject
*
rv
;
if
(
!
PyArg_ParseTuple
(
args
,
"i:read"
,
&
size
))
if
(
!
PyArg_ParseTuple
(
args
,
"i:read"
,
&
size
))
return
NULL
;
return
NULL
;
rv
=
PyString_FromStringAndSize
(
NULL
,
size
);
rv
=
PyString_FromStringAndSize
(
NULL
,
size
);
...
@@ -380,7 +380,7 @@ oss_write(oss_t *self, PyObject *args)
...
@@ -380,7 +380,7 @@ oss_write(oss_t *self, PyObject *args)
int
rv
,
size
;
int
rv
,
size
;
if
(
!
PyArg_ParseTuple
(
args
,
"s#:write"
,
&
cp
,
&
size
))
{
if
(
!
PyArg_ParseTuple
(
args
,
"s#:write"
,
&
cp
,
&
size
))
{
return
NULL
;
return
NULL
;
}
}
if
((
rv
=
write
(
self
->
fd
,
cp
,
size
))
==
-
1
)
{
if
((
rv
=
write
(
self
->
fd
,
cp
,
size
))
==
-
1
)
{
return
PyErr_SetFromErrno
(
PyExc_IOError
);
return
PyErr_SetFromErrno
(
PyExc_IOError
);
...
@@ -439,7 +439,7 @@ static PyObject *
...
@@ -439,7 +439,7 @@ static PyObject *
oss_close
(
oss_t
*
self
,
PyObject
*
args
)
oss_close
(
oss_t
*
self
,
PyObject
*
args
)
{
{
if
(
!
PyArg_ParseTuple
(
args
,
":close"
))
if
(
!
PyArg_ParseTuple
(
args
,
":close"
))
return
NULL
;
return
NULL
;
if
(
self
->
fd
>=
0
)
{
if
(
self
->
fd
>=
0
)
{
close
(
self
->
fd
);
close
(
self
->
fd
);
...
@@ -453,7 +453,7 @@ static PyObject *
...
@@ -453,7 +453,7 @@ static PyObject *
oss_fileno
(
oss_t
*
self
,
PyObject
*
args
)
oss_fileno
(
oss_t
*
self
,
PyObject
*
args
)
{
{
if
(
!
PyArg_ParseTuple
(
args
,
":fileno"
))
if
(
!
PyArg_ParseTuple
(
args
,
":fileno"
))
return
NULL
;
return
NULL
;
return
PyInt_FromLong
(
self
->
fd
);
return
PyInt_FromLong
(
self
->
fd
);
}
}
...
@@ -471,45 +471,45 @@ oss_setparameters(oss_t *self, PyObject *args)
...
@@ -471,45 +471,45 @@ oss_setparameters(oss_t *self, PyObject *args)
return
NULL
;
return
NULL
;
if
(
rate
<
0
)
{
if
(
rate
<
0
)
{
PyErr_Format
(
PyExc_ValueError
,
"expected rate >= 0, not %d"
,
PyErr_Format
(
PyExc_ValueError
,
"expected rate >= 0, not %d"
,
rate
);
rate
);
return
NULL
;
return
NULL
;
}
}
if
(
ssize
<
0
)
{
if
(
ssize
<
0
)
{
PyErr_Format
(
PyExc_ValueError
,
"expected sample size >= 0, not %d"
,
PyErr_Format
(
PyExc_ValueError
,
"expected sample size >= 0, not %d"
,
ssize
);
ssize
);
return
NULL
;
return
NULL
;
}
}
if
(
nchannels
!=
1
&&
nchannels
!=
2
)
{
if
(
nchannels
!=
1
&&
nchannels
!=
2
)
{
PyErr_Format
(
PyExc_ValueError
,
"nchannels must be 1 or 2, not %d"
,
PyErr_Format
(
PyExc_ValueError
,
"nchannels must be 1 or 2, not %d"
,
nchannels
);
nchannels
);
return
NULL
;
return
NULL
;
}
}
for
(
n
=
0
;
n
<
n_audio_types
;
n
++
)
for
(
n
=
0
;
n
<
n_audio_types
;
n
++
)
if
(
fmt
==
audio_types
[
n
].
a_fmt
)
if
(
fmt
==
audio_types
[
n
].
a_fmt
)
break
;
break
;
if
(
n
==
n_audio_types
)
{
if
(
n
==
n_audio_types
)
{
PyErr_Format
(
PyExc_ValueError
,
"unknown audio encoding: %d"
,
fmt
);
PyErr_Format
(
PyExc_ValueError
,
"unknown audio encoding: %d"
,
fmt
);
return
NULL
;
return
NULL
;
}
}
if
(
audio_types
[
n
].
a_bps
!=
ssize
)
{
if
(
audio_types
[
n
].
a_bps
!=
ssize
)
{
PyErr_Format
(
PyExc_ValueError
,
PyErr_Format
(
PyExc_ValueError
,
"for %s, expected sample size %d, not %d"
,
"for %s, expected sample size %d, not %d"
,
audio_types
[
n
].
a_name
,
audio_types
[
n
].
a_bps
,
ssize
);
audio_types
[
n
].
a_name
,
audio_types
[
n
].
a_bps
,
ssize
);
return
NULL
;
return
NULL
;
}
}
if
(
emulate
==
0
)
{
if
(
emulate
==
0
)
{
if
((
self
->
afmts
&
audio_types
[
n
].
a_fmt
)
==
0
)
{
if
((
self
->
afmts
&
audio_types
[
n
].
a_fmt
)
==
0
)
{
PyErr_Format
(
PyExc_ValueError
,
PyErr_Format
(
PyExc_ValueError
,
"%s format not supported by device"
,
"%s format not supported by device"
,
audio_types
[
n
].
a_name
);
audio_types
[
n
].
a_name
);
return
NULL
;
return
NULL
;
}
}
}
}
if
(
ioctl
(
self
->
fd
,
SNDCTL_DSP_SETFMT
,
if
(
ioctl
(
self
->
fd
,
SNDCTL_DSP_SETFMT
,
&
audio_types
[
n
].
a_fmt
)
==
-
1
)
{
&
audio_types
[
n
].
a_fmt
)
==
-
1
)
{
PyErr_SetFromErrno
(
PyExc_IOError
);
PyErr_SetFromErrno
(
PyExc_IOError
);
return
NULL
;
return
NULL
;
}
}
...
@@ -633,12 +633,12 @@ oss_getptr(oss_t *self, PyObject *args)
...
@@ -633,12 +633,12 @@ oss_getptr(oss_t *self, PyObject *args)
int
req
;
int
req
;
if
(
!
PyArg_ParseTuple
(
args
,
":getptr"
))
if
(
!
PyArg_ParseTuple
(
args
,
":getptr"
))
return
NULL
;
return
NULL
;
if
(
self
->
mode
==
O_RDONLY
)
if
(
self
->
mode
==
O_RDONLY
)
req
=
SNDCTL_DSP_GETIPTR
;
req
=
SNDCTL_DSP_GETIPTR
;
else
else
req
=
SNDCTL_DSP_GETOPTR
;
req
=
SNDCTL_DSP_GETOPTR
;
if
(
ioctl
(
self
->
fd
,
req
,
&
info
)
==
-
1
)
{
if
(
ioctl
(
self
->
fd
,
req
,
&
info
)
==
-
1
)
{
PyErr_SetFromErrno
(
PyExc_IOError
);
PyErr_SetFromErrno
(
PyExc_IOError
);
return
NULL
;
return
NULL
;
...
@@ -651,7 +651,7 @@ static PyObject *
...
@@ -651,7 +651,7 @@ static PyObject *
oss_mixer_close
(
oss_mixer_t
*
self
,
PyObject
*
args
)
oss_mixer_close
(
oss_mixer_t
*
self
,
PyObject
*
args
)
{
{
if
(
!
PyArg_ParseTuple
(
args
,
":close"
))
if
(
!
PyArg_ParseTuple
(
args
,
":close"
))
return
NULL
;
return
NULL
;
if
(
self
->
fd
>=
0
)
{
if
(
self
->
fd
>=
0
)
{
close
(
self
->
fd
);
close
(
self
->
fd
);
...
@@ -665,7 +665,7 @@ static PyObject *
...
@@ -665,7 +665,7 @@ static PyObject *
oss_mixer_fileno
(
oss_mixer_t
*
self
,
PyObject
*
args
)
oss_mixer_fileno
(
oss_mixer_t
*
self
,
PyObject
*
args
)
{
{
if
(
!
PyArg_ParseTuple
(
args
,
":fileno"
))
if
(
!
PyArg_ParseTuple
(
args
,
":fileno"
))
return
NULL
;
return
NULL
;
return
PyInt_FromLong
(
self
->
fd
);
return
PyInt_FromLong
(
self
->
fd
);
}
}
...
@@ -699,15 +699,15 @@ oss_mixer_get(oss_mixer_t *self, PyObject *args)
...
@@ -699,15 +699,15 @@ oss_mixer_get(oss_mixer_t *self, PyObject *args)
/* Can't use _do_ioctl_1 because of encoded arg thingy. */
/* Can't use _do_ioctl_1 because of encoded arg thingy. */
if
(
!
PyArg_ParseTuple
(
args
,
"i:get"
,
&
channel
))
if
(
!
PyArg_ParseTuple
(
args
,
"i:get"
,
&
channel
))
return
NULL
;
return
NULL
;
if
(
channel
<
0
||
channel
>
SOUND_MIXER_NRDEVICES
)
{
if
(
channel
<
0
||
channel
>
SOUND_MIXER_NRDEVICES
)
{
PyErr_SetString
(
OSSAudioError
,
"Invalid mixer channel specified."
);
PyErr_SetString
(
OSSAudioError
,
"Invalid mixer channel specified."
);
return
NULL
;
return
NULL
;
}
}
if
(
ioctl
(
self
->
fd
,
MIXER_READ
(
channel
),
&
volume
)
==
-
1
)
if
(
ioctl
(
self
->
fd
,
MIXER_READ
(
channel
),
&
volume
)
==
-
1
)
return
PyErr_SetFromErrno
(
PyExc_IOError
);
return
PyErr_SetFromErrno
(
PyExc_IOError
);
return
Py_BuildValue
(
"(ii)"
,
volume
&
0xff
,
(
volume
&
0xff00
)
>>
8
);
return
Py_BuildValue
(
"(ii)"
,
volume
&
0xff
,
(
volume
&
0xff00
)
>>
8
);
}
}
...
@@ -719,22 +719,22 @@ oss_mixer_set(oss_mixer_t *self, PyObject *args)
...
@@ -719,22 +719,22 @@ oss_mixer_set(oss_mixer_t *self, PyObject *args)
/* Can't use _do_ioctl_1 because of encoded arg thingy. */
/* Can't use _do_ioctl_1 because of encoded arg thingy. */
if
(
!
PyArg_ParseTuple
(
args
,
"i(ii):set"
,
&
channel
,
&
leftVol
,
&
rightVol
))
if
(
!
PyArg_ParseTuple
(
args
,
"i(ii):set"
,
&
channel
,
&
leftVol
,
&
rightVol
))
return
NULL
;
return
NULL
;
if
(
channel
<
0
||
channel
>
SOUND_MIXER_NRDEVICES
)
{
if
(
channel
<
0
||
channel
>
SOUND_MIXER_NRDEVICES
)
{
PyErr_SetString
(
OSSAudioError
,
"Invalid mixer channel specified."
);
PyErr_SetString
(
OSSAudioError
,
"Invalid mixer channel specified."
);
return
NULL
;
return
NULL
;
}
}
if
(
leftVol
<
0
||
rightVol
<
0
||
leftVol
>
100
||
rightVol
>
100
)
{
if
(
leftVol
<
0
||
rightVol
<
0
||
leftVol
>
100
||
rightVol
>
100
)
{
PyErr_SetString
(
OSSAudioError
,
"Volumes must be between 0 and 100."
);
PyErr_SetString
(
OSSAudioError
,
"Volumes must be between 0 and 100."
);
return
NULL
;
return
NULL
;
}
}
volume
=
(
rightVol
<<
8
)
|
leftVol
;
volume
=
(
rightVol
<<
8
)
|
leftVol
;
if
(
ioctl
(
self
->
fd
,
MIXER_WRITE
(
channel
),
&
volume
)
==
-
1
)
if
(
ioctl
(
self
->
fd
,
MIXER_WRITE
(
channel
),
&
volume
)
==
-
1
)
return
PyErr_SetFromErrno
(
PyExc_IOError
);
return
PyErr_SetFromErrno
(
PyExc_IOError
);
return
Py_BuildValue
(
"(ii)"
,
volume
&
0xff
,
(
volume
&
0xff00
)
>>
8
);
return
Py_BuildValue
(
"(ii)"
,
volume
&
0xff
,
(
volume
&
0xff00
)
>>
8
);
}
}
...
@@ -756,50 +756,50 @@ oss_mixer_setrecsrc(oss_mixer_t *self, PyObject *args)
...
@@ -756,50 +756,50 @@ oss_mixer_setrecsrc(oss_mixer_t *self, PyObject *args)
static
PyMethodDef
oss_methods
[]
=
{
static
PyMethodDef
oss_methods
[]
=
{
/* Regular file methods */
/* Regular file methods */
{
"read"
,
(
PyCFunction
)
oss_read
,
METH_VARARGS
},
{
"read"
,
(
PyCFunction
)
oss_read
,
METH_VARARGS
},
{
"write"
,
(
PyCFunction
)
oss_write
,
METH_VARARGS
},
{
"write"
,
(
PyCFunction
)
oss_write
,
METH_VARARGS
},
{
"writeall"
,
(
PyCFunction
)
oss_writeall
,
METH_VARARGS
},
{
"writeall"
,
(
PyCFunction
)
oss_writeall
,
METH_VARARGS
},
{
"close"
,
(
PyCFunction
)
oss_close
,
METH_VARARGS
},
{
"close"
,
(
PyCFunction
)
oss_close
,
METH_VARARGS
},
{
"fileno"
,
(
PyCFunction
)
oss_fileno
,
METH_VARARGS
},
{
"fileno"
,
(
PyCFunction
)
oss_fileno
,
METH_VARARGS
},
/* Simple ioctl wrappers */
/* Simple ioctl wrappers */
{
"nonblock"
,
(
PyCFunction
)
oss_nonblock
,
METH_VARARGS
},
{
"nonblock"
,
(
PyCFunction
)
oss_nonblock
,
METH_VARARGS
},
{
"setfmt"
,
(
PyCFunction
)
oss_setfmt
,
METH_VARARGS
},
{
"setfmt"
,
(
PyCFunction
)
oss_setfmt
,
METH_VARARGS
},
{
"getfmts"
,
(
PyCFunction
)
oss_getfmts
,
METH_VARARGS
},
{
"getfmts"
,
(
PyCFunction
)
oss_getfmts
,
METH_VARARGS
},
{
"channels"
,
(
PyCFunction
)
oss_channels
,
METH_VARARGS
},
{
"channels"
,
(
PyCFunction
)
oss_channels
,
METH_VARARGS
},
{
"speed"
,
(
PyCFunction
)
oss_speed
,
METH_VARARGS
},
{
"speed"
,
(
PyCFunction
)
oss_speed
,
METH_VARARGS
},
{
"sync"
,
(
PyCFunction
)
oss_sync
,
METH_VARARGS
},
{
"sync"
,
(
PyCFunction
)
oss_sync
,
METH_VARARGS
},
{
"reset"
,
(
PyCFunction
)
oss_reset
,
METH_VARARGS
},
{
"reset"
,
(
PyCFunction
)
oss_reset
,
METH_VARARGS
},
{
"post"
,
(
PyCFunction
)
oss_post
,
METH_VARARGS
},
{
"post"
,
(
PyCFunction
)
oss_post
,
METH_VARARGS
},
/* Convenience methods -- wrap a couple of ioctls together */
/* Convenience methods -- wrap a couple of ioctls together */
{
"setparameters"
,
(
PyCFunction
)
oss_setparameters
,
METH_VARARGS
},
{
"setparameters"
,
(
PyCFunction
)
oss_setparameters
,
METH_VARARGS
},
{
"bufsize"
,
(
PyCFunction
)
oss_bufsize
,
METH_VARARGS
},
{
"bufsize"
,
(
PyCFunction
)
oss_bufsize
,
METH_VARARGS
},
{
"obufcount"
,
(
PyCFunction
)
oss_obufcount
,
METH_VARARGS
},
{
"obufcount"
,
(
PyCFunction
)
oss_obufcount
,
METH_VARARGS
},
{
"obuffree"
,
(
PyCFunction
)
oss_obuffree
,
METH_VARARGS
},
{
"obuffree"
,
(
PyCFunction
)
oss_obuffree
,
METH_VARARGS
},
{
"getptr"
,
(
PyCFunction
)
oss_getptr
,
METH_VARARGS
},
{
"getptr"
,
(
PyCFunction
)
oss_getptr
,
METH_VARARGS
},
/* Aliases for backwards compatibility */
/* Aliases for backwards compatibility */
{
"flush"
,
(
PyCFunction
)
oss_sync
,
METH_VARARGS
},
{
"flush"
,
(
PyCFunction
)
oss_sync
,
METH_VARARGS
},
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
static
PyMethodDef
oss_mixer_methods
[]
=
{
static
PyMethodDef
oss_mixer_methods
[]
=
{
/* Regular file method - OSS mixers are ioctl-only interface */
/* Regular file method - OSS mixers are ioctl-only interface */
{
"close"
,
(
PyCFunction
)
oss_mixer_close
,
METH_VARARGS
},
{
"close"
,
(
PyCFunction
)
oss_mixer_close
,
METH_VARARGS
},
{
"fileno"
,
(
PyCFunction
)
oss_mixer_fileno
,
METH_VARARGS
},
{
"fileno"
,
(
PyCFunction
)
oss_mixer_fileno
,
METH_VARARGS
},
/* Simple ioctl wrappers */
/* Simple ioctl wrappers */
{
"devices"
,
(
PyCFunction
)
oss_mixer_devices
,
METH_VARARGS
},
{
"devices"
,
(
PyCFunction
)
oss_mixer_devices
,
METH_VARARGS
},
{
"stereodevices"
,
(
PyCFunction
)
oss_mixer_stereodevices
,
METH_VARARGS
},
{
"stereodevices"
,
(
PyCFunction
)
oss_mixer_stereodevices
,
METH_VARARGS
},
{
"recdevices"
,
(
PyCFunction
)
oss_mixer_recdevices
,
METH_VARARGS
},
{
"recdevices"
,
(
PyCFunction
)
oss_mixer_recdevices
,
METH_VARARGS
},
{
"get"
,
(
PyCFunction
)
oss_mixer_get
,
METH_VARARGS
},
{
"get"
,
(
PyCFunction
)
oss_mixer_get
,
METH_VARARGS
},
{
"set"
,
(
PyCFunction
)
oss_mixer_set
,
METH_VARARGS
},
{
"set"
,
(
PyCFunction
)
oss_mixer_set
,
METH_VARARGS
},
{
"getrecsrc"
,
(
PyCFunction
)
oss_mixer_getrecsrc
,
METH_VARARGS
},
{
"getrecsrc"
,
(
PyCFunction
)
oss_mixer_getrecsrc
,
METH_VARARGS
},
{
"setrecsrc"
,
(
PyCFunction
)
oss_mixer_setrecsrc
,
METH_VARARGS
},
{
"setrecsrc"
,
(
PyCFunction
)
oss_mixer_setrecsrc
,
METH_VARARGS
},
{
NULL
,
NULL
}
{
NULL
,
NULL
}
};
};
static
PyObject
*
static
PyObject
*
...
@@ -816,32 +816,32 @@ oss_mixer_getattr(oss_mixer_t *xp, char *name)
...
@@ -816,32 +816,32 @@ oss_mixer_getattr(oss_mixer_t *xp, char *name)
static
PyTypeObject
OSSType
=
{
static
PyTypeObject
OSSType
=
{
PyObject_HEAD_INIT
(
&
PyType_Type
)
PyObject_HEAD_INIT
(
&
PyType_Type
)
0
,
/*ob_size*/
0
,
/*ob_size*/
"ossaudiodev.oss_audio_device"
,
/*tp_name*/
"ossaudiodev.oss_audio_device"
,
/*tp_name*/
sizeof
(
oss_t
),
/*tp_size*/
sizeof
(
oss_t
),
/*tp_size*/
0
,
/*tp_itemsize*/
0
,
/*tp_itemsize*/
/* methods */
/* methods */
(
destructor
)
oss_dealloc
,
/*tp_dealloc*/
(
destructor
)
oss_dealloc
,
/*tp_dealloc*/
0
,
/*tp_print*/
0
,
/*tp_print*/
(
getattrfunc
)
oss_getattr
,
/*tp_getattr*/
(
getattrfunc
)
oss_getattr
,
/*tp_getattr*/
0
,
/*tp_setattr*/
0
,
/*tp_setattr*/
0
,
/*tp_compare*/
0
,
/*tp_compare*/
0
,
/*tp_repr*/
0
,
/*tp_repr*/
};
};
static
PyTypeObject
OSSMixerType
=
{
static
PyTypeObject
OSSMixerType
=
{
PyObject_HEAD_INIT
(
&
PyType_Type
)
PyObject_HEAD_INIT
(
&
PyType_Type
)
0
,
/*ob_size*/
0
,
/*ob_size*/
"ossaudiodev.oss_mixer_device"
,
/*tp_name*/
"ossaudiodev.oss_mixer_device"
,
/*tp_name*/
sizeof
(
oss_mixer_t
),
/*tp_size*/
sizeof
(
oss_mixer_t
),
/*tp_size*/
0
,
/*tp_itemsize*/
0
,
/*tp_itemsize*/
/* methods */
/* methods */
(
destructor
)
oss_mixer_dealloc
,
/*tp_dealloc*/
(
destructor
)
oss_mixer_dealloc
,
/*tp_dealloc*/
0
,
/*tp_print*/
0
,
/*tp_print*/
(
getattrfunc
)
oss_mixer_getattr
,
/*tp_getattr*/
(
getattrfunc
)
oss_mixer_getattr
,
/*tp_getattr*/
0
,
/*tp_setattr*/
0
,
/*tp_setattr*/
0
,
/*tp_compare*/
0
,
/*tp_compare*/
0
,
/*tp_repr*/
0
,
/*tp_repr*/
};
};
...
@@ -876,7 +876,7 @@ initossaudiodev(void)
...
@@ -876,7 +876,7 @@ initossaudiodev(void)
OSSAudioError
=
PyErr_NewException
(
"ossaudiodev.error"
,
NULL
,
NULL
);
OSSAudioError
=
PyErr_NewException
(
"ossaudiodev.error"
,
NULL
,
NULL
);
if
(
OSSAudioError
)
if
(
OSSAudioError
)
PyModule_AddObject
(
m
,
"error"
,
OSSAudioError
);
PyModule_AddObject
(
m
,
"error"
,
OSSAudioError
);
/* Expose the audio format numbers -- essential! */
/* Expose the audio format numbers -- essential! */
_EXPORT_INT
(
m
,
AFMT_QUERY
);
_EXPORT_INT
(
m
,
AFMT_QUERY
);
...
@@ -892,7 +892,7 @@ initossaudiodev(void)
...
@@ -892,7 +892,7 @@ initossaudiodev(void)
_EXPORT_INT
(
m
,
AFMT_MPEG
);
_EXPORT_INT
(
m
,
AFMT_MPEG
);
_EXPORT_INT
(
m
,
AFMT_AC3
);
_EXPORT_INT
(
m
,
AFMT_AC3
);
_EXPORT_INT
(
m
,
AFMT_S16_NE
);
_EXPORT_INT
(
m
,
AFMT_S16_NE
);
/* Expose the sound mixer device numbers. */
/* Expose the sound mixer device numbers. */
_EXPORT_INT
(
m
,
SOUND_MIXER_NRDEVICES
);
_EXPORT_INT
(
m
,
SOUND_MIXER_NRDEVICES
);
_EXPORT_INT
(
m
,
SOUND_MIXER_VOLUME
);
_EXPORT_INT
(
m
,
SOUND_MIXER_VOLUME
);
...
...
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