Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
777374e8
Kaydet (Commit)
777374e8
authored
Mar 09, 2005
tarafından
Greg Ward
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
SF #818006: revert addition of 'closed', 'mode', and 'name' attributes
to oss_audio_device objects.
üst
ad80c6bb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
84 deletions
+27
-84
libossaudiodev.tex
Doc/lib/libossaudiodev.tex
+1
-16
test_ossaudiodev.py
Lib/test/test_ossaudiodev.py
+0
-14
ossaudiodev.c
Modules/ossaudiodev.c
+26
-54
No files found.
Doc/lib/libossaudiodev.tex
Dosyayı görüntüle @
777374e8
...
@@ -115,7 +115,7 @@ three audio parameters at once. This is more convenient, but may not be
...
@@ -115,7 +115,7 @@ three audio parameters at once. This is more convenient, but may not be
as flexible in all cases.
as flexible in all cases.
The audio device objects returned by
\function
{
open()
}
define the
The audio device objects returned by
\function
{
open()
}
define the
following methods
and (read-only) attributes
:
following methods:
\begin{methoddesc}
[audio device]
{
close
}{}
\begin{methoddesc}
[audio device]
{
close
}{}
Explicitly close the audio device. When you are done writing to or
Explicitly close the audio device. When you are done writing to or
...
@@ -289,21 +289,6 @@ Returns the number of samples that could be queued into the hardware
...
@@ -289,21 +289,6 @@ Returns the number of samples that could be queued into the hardware
buffer to be played without blocking.
buffer to be played without blocking.
\end{methoddesc}
\end{methoddesc}
Audio device objects also support several read-only attributes:
\begin{memberdesc}
[audio device]
{
closed
}{}
Boolean indicating whether the device has been closed.
\end{memberdesc}
\begin{memberdesc}
[audio device]
{
name
}{}
String containing the name of the device file.
\end{memberdesc}
\begin{memberdesc}
[audio device]
{
mode
}{}
The I/O mode for the file, either
\code
{
"r"
}
,
\code
{
"rw"
}
, or
\code
{
"w"
}
.
\end{memberdesc}
\subsection
{
Mixer Device Objects
\label
{
mixer-device-objects
}}
\subsection
{
Mixer Device Objects
\label
{
mixer-device-objects
}}
The mixer object provides two file-like methods:
The mixer object provides two file-like methods:
...
...
Lib/test/test_ossaudiodev.py
Dosyayı görüntüle @
777374e8
...
@@ -56,19 +56,6 @@ def play_sound_file(data, rate, ssize, nchannels):
...
@@ -56,19 +56,6 @@ def play_sound_file(data, rate, ssize, nchannels):
dsp
.
getptr
()
dsp
.
getptr
()
dsp
.
fileno
()
dsp
.
fileno
()
# Make sure the read-only attributes work.
assert
dsp
.
closed
is
False
,
"dsp.closed is not False"
assert
dsp
.
name
==
"/dev/dsp"
assert
dsp
.
mode
==
'w'
,
"bad dsp.mode:
%
r"
%
dsp
.
mode
# And make sure they're really read-only.
for
attr
in
(
'closed'
,
'name'
,
'mode'
):
try
:
setattr
(
dsp
,
attr
,
42
)
raise
RuntimeError
(
"dsp.
%
s not read-only"
%
attr
)
except
TypeError
:
pass
# set parameters based on .au file headers
# set parameters based on .au file headers
dsp
.
setparameters
(
AFMT_S16_NE
,
nchannels
,
rate
)
dsp
.
setparameters
(
AFMT_S16_NE
,
nchannels
,
rate
)
t1
=
time
.
time
()
t1
=
time
.
time
()
...
@@ -145,6 +132,5 @@ def test():
...
@@ -145,6 +132,5 @@ def test():
#test_bad_setparameters(dsp)
#test_bad_setparameters(dsp)
finally
:
finally
:
dsp
.
close
()
dsp
.
close
()
assert
dsp
.
closed
is
True
,
"dsp.closed is not True"
test
()
test
()
Modules/ossaudiodev.c
Dosyayı görüntüle @
777374e8
...
@@ -46,12 +46,11 @@ typedef unsigned long uint32_t;
...
@@ -46,12 +46,11 @@ typedef unsigned long uint32_t;
typedef
struct
{
typedef
struct
{
PyObject_HEAD
;
PyObject_HEAD
;
char
*
devicename
;
/* name of the device file */
int
fd
;
/* The open file */
int
fd
;
/* file descriptor */
int
mode
;
/* file mode */
int
mode
;
/* file mode (O_RDONLY, etc.) */
int
icount
;
/* Input count */
int
icount
;
/* input count */
int
ocount
;
/* Output count */
int
ocount
;
/* output count */
uint32_t
afmts
;
/* Audio formats supported by hardware */
uint32_t
afmts
;
/* audio formats supported by hardware */
}
oss_audio_t
;
}
oss_audio_t
;
typedef
struct
{
typedef
struct
{
...
@@ -75,7 +74,7 @@ newossobject(PyObject *arg)
...
@@ -75,7 +74,7 @@ newossobject(PyObject *arg)
{
{
oss_audio_t
*
self
;
oss_audio_t
*
self
;
int
fd
,
afmts
,
imode
;
int
fd
,
afmts
,
imode
;
char
*
devicename
=
NULL
;
char
*
basedev
=
NULL
;
char
*
mode
=
NULL
;
char
*
mode
=
NULL
;
/* Two ways to call open():
/* Two ways to call open():
...
@@ -83,11 +82,11 @@ newossobject(PyObject *arg)
...
@@ -83,11 +82,11 @@ newossobject(PyObject *arg)
open(mode) (for backwards compatibility)
open(mode) (for backwards compatibility)
because the *first* argument is optional, parsing args is
because the *first* argument is optional, parsing args is
a wee bit tricky. */
a wee bit tricky. */
if
(
!
PyArg_ParseTuple
(
arg
,
"s|s:open"
,
&
devicename
,
&
mode
))
if
(
!
PyArg_ParseTuple
(
arg
,
"s|s:open"
,
&
basedev
,
&
mode
))
return
NULL
;
return
NULL
;
if
(
mode
==
NULL
)
{
/* only one arg supplied */
if
(
mode
==
NULL
)
{
/* only one arg supplied */
mode
=
devicename
;
mode
=
basedev
;
devicename
=
NULL
;
basedev
=
NULL
;
}
}
if
(
strcmp
(
mode
,
"r"
)
==
0
)
if
(
strcmp
(
mode
,
"r"
)
==
0
)
...
@@ -103,18 +102,18 @@ newossobject(PyObject *arg)
...
@@ -103,18 +102,18 @@ newossobject(PyObject *arg)
/* Open the correct device: either the 'device' argument,
/* Open the correct device: either the 'device' argument,
or the AUDIODEV environment variable, or "/dev/dsp". */
or the AUDIODEV environment variable, or "/dev/dsp". */
if
(
devicename
==
NULL
)
{
/* called with one arg */
if
(
basedev
==
NULL
)
{
/* called with one arg */
devicename
=
getenv
(
"AUDIODEV"
);
basedev
=
getenv
(
"AUDIODEV"
);
if
(
devicename
==
NULL
)
/* $AUDIODEV not set */
if
(
basedev
==
NULL
)
/* $AUDIODEV not set */
devicename
=
"/dev/dsp"
;
basedev
=
"/dev/dsp"
;
}
}
/* Open with O_NONBLOCK to avoid hanging on devices that only allow
/* Open with O_NONBLOCK to avoid hanging on devices that only allow
one open at a time. This does *not* affect later I/O; OSS
one open at a time. This does *not* affect later I/O; OSS
provides a special ioctl() for non-blocking read/write, which is
provides a special ioctl() for non-blocking read/write, which is
exposed via oss_nonblock() below. */
exposed via oss_nonblock() below. */
if
((
fd
=
open
(
devicename
,
imode
|
O_NONBLOCK
))
==
-
1
)
{
if
((
fd
=
open
(
basedev
,
imode
|
O_NONBLOCK
))
==
-
1
)
{
PyErr_SetFromErrnoWithFilename
(
PyExc_IOError
,
devicename
);
PyErr_SetFromErrnoWithFilename
(
PyExc_IOError
,
basedev
);
return
NULL
;
return
NULL
;
}
}
...
@@ -122,12 +121,12 @@ newossobject(PyObject *arg)
...
@@ -122,12 +121,12 @@ newossobject(PyObject *arg)
expected write() semantics. */
expected write() semantics. */
if
(
fcntl
(
fd
,
F_SETFL
,
0
)
==
-
1
)
{
if
(
fcntl
(
fd
,
F_SETFL
,
0
)
==
-
1
)
{
close
(
fd
);
close
(
fd
);
PyErr_SetFromErrnoWithFilename
(
PyExc_IOError
,
devicename
);
PyErr_SetFromErrnoWithFilename
(
PyExc_IOError
,
basedev
);
return
NULL
;
return
NULL
;
}
}
if
(
ioctl
(
fd
,
SNDCTL_DSP_GETFMTS
,
&
afmts
)
==
-
1
)
{
if
(
ioctl
(
fd
,
SNDCTL_DSP_GETFMTS
,
&
afmts
)
==
-
1
)
{
PyErr_SetFromErrnoWithFilename
(
PyExc_IOError
,
devicename
);
PyErr_SetFromErrnoWithFilename
(
PyExc_IOError
,
basedev
);
return
NULL
;
return
NULL
;
}
}
/* Create and initialize the object */
/* Create and initialize the object */
...
@@ -135,7 +134,6 @@ newossobject(PyObject *arg)
...
@@ -135,7 +134,6 @@ newossobject(PyObject *arg)
close
(
fd
);
close
(
fd
);
return
NULL
;
return
NULL
;
}
}
self
->
devicename
=
devicename
;
self
->
fd
=
fd
;
self
->
fd
=
fd
;
self
->
mode
=
imode
;
self
->
mode
=
imode
;
self
->
icount
=
self
->
ocount
=
0
;
self
->
icount
=
self
->
ocount
=
0
;
...
@@ -160,22 +158,22 @@ oss_dealloc(oss_audio_t *self)
...
@@ -160,22 +158,22 @@ oss_dealloc(oss_audio_t *self)
static
oss_mixer_t
*
static
oss_mixer_t
*
newossmixerobject
(
PyObject
*
arg
)
newossmixerobject
(
PyObject
*
arg
)
{
{
char
*
devicename
=
NULL
;
char
*
basedev
=
NULL
;
int
fd
;
int
fd
;
oss_mixer_t
*
self
;
oss_mixer_t
*
self
;
if
(
!
PyArg_ParseTuple
(
arg
,
"|s"
,
&
devicename
))
{
if
(
!
PyArg_ParseTuple
(
arg
,
"|s"
,
&
basedev
))
{
return
NULL
;
return
NULL
;
}
}
if
(
devicename
==
NULL
)
{
if
(
basedev
==
NULL
)
{
devicename
=
getenv
(
"MIXERDEV"
);
basedev
=
getenv
(
"MIXERDEV"
);
if
(
devicename
==
NULL
)
/* MIXERDEV not set */
if
(
basedev
==
NULL
)
/* MIXERDEV not set */
devicename
=
"/dev/mixer"
;
basedev
=
"/dev/mixer"
;
}
}
if
((
fd
=
open
(
devicename
,
O_RDWR
))
==
-
1
)
{
if
((
fd
=
open
(
basedev
,
O_RDWR
))
==
-
1
)
{
PyErr_SetFromErrnoWithFilename
(
PyExc_IOError
,
devicename
);
PyErr_SetFromErrnoWithFilename
(
PyExc_IOError
,
basedev
);
return
NULL
;
return
NULL
;
}
}
...
@@ -829,33 +827,7 @@ static PyMethodDef oss_mixer_methods[] = {
...
@@ -829,33 +827,7 @@ static PyMethodDef oss_mixer_methods[] = {
static
PyObject
*
static
PyObject
*
oss_getattr
(
oss_audio_t
*
self
,
char
*
name
)
oss_getattr
(
oss_audio_t
*
self
,
char
*
name
)
{
{
PyObject
*
rval
=
NULL
;
return
Py_FindMethod
(
oss_methods
,
(
PyObject
*
)
self
,
name
);
if
(
strcmp
(
name
,
"closed"
)
==
0
)
{
rval
=
(
self
->
fd
==
-
1
)
?
Py_True
:
Py_False
;
Py_INCREF
(
rval
);
}
else
if
(
strcmp
(
name
,
"name"
)
==
0
)
{
rval
=
PyString_FromString
(
self
->
devicename
);
}
else
if
(
strcmp
(
name
,
"mode"
)
==
0
)
{
/* No need for a "default" in this switch: from newossobject(),
self->mode can only be one of these three values. */
switch
(
self
->
mode
)
{
case
O_RDONLY
:
rval
=
PyString_FromString
(
"r"
);
break
;
case
O_RDWR
:
rval
=
PyString_FromString
(
"rw"
);
break
;
case
O_WRONLY
:
rval
=
PyString_FromString
(
"w"
);
break
;
}
}
else
{
rval
=
Py_FindMethod
(
oss_methods
,
(
PyObject
*
)
self
,
name
);
}
return
rval
;
}
}
static
PyObject
*
static
PyObject
*
...
...
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