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
36dacfa4
Kaydet (Commit)
36dacfa4
authored
Ara 10, 2002
tarafından
Greg Ward
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Initial revision is rev 1.8 of test_linuxaudiodev.py, with
the obvious s/linuxaudiodev/ossaudiodev/ change made.
üst
731a986d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
0 deletions
+89
-0
test_ossaudiodev.py
Lib/test/test_ossaudiodev.py
+89
-0
No files found.
Lib/test/test_ossaudiodev.py
0 → 100644
Dosyayı görüntüle @
36dacfa4
from
test.test_support
import
verbose
,
findfile
,
TestFailed
,
TestSkipped
import
errno
import
fcntl
import
ossaudiodev
import
os
import
sys
import
select
import
sunaudio
import
time
import
audioop
SND_FORMAT_MULAW_8
=
1
def
play_sound_file
(
path
):
fp
=
open
(
path
,
'r'
)
size
,
enc
,
rate
,
nchannels
,
extra
=
sunaudio
.
gethdr
(
fp
)
data
=
fp
.
read
()
fp
.
close
()
if
enc
!=
SND_FORMAT_MULAW_8
:
print
"Expect .au file with 8-bit mu-law samples"
return
try
:
a
=
ossaudiodev
.
open
(
'w'
)
except
ossaudiodev
.
error
,
msg
:
if
msg
[
0
]
in
(
errno
.
EACCES
,
errno
.
ENODEV
,
errno
.
EBUSY
):
raise
TestSkipped
,
msg
raise
TestFailed
,
msg
# convert the data to 16-bit signed
data
=
audioop
.
ulaw2lin
(
data
,
2
)
# set the data format
if
sys
.
byteorder
==
'little'
:
fmt
=
ossaudiodev
.
AFMT_S16_LE
else
:
fmt
=
ossaudiodev
.
AFMT_S16_BE
# at least check that these methods can be invoked
a
.
bufsize
()
a
.
obufcount
()
a
.
obuffree
()
a
.
getptr
()
a
.
fileno
()
# set parameters based on .au file headers
a
.
setparameters
(
rate
,
16
,
nchannels
,
fmt
)
a
.
write
(
data
)
a
.
flush
()
a
.
close
()
def
test_errors
():
a
=
ossaudiodev
.
open
(
"w"
)
size
=
8
fmt
=
ossaudiodev
.
AFMT_U8
rate
=
8000
nchannels
=
1
try
:
a
.
setparameters
(
-
1
,
size
,
nchannels
,
fmt
)
except
ValueError
,
msg
:
print
msg
try
:
a
.
setparameters
(
rate
,
-
2
,
nchannels
,
fmt
)
except
ValueError
,
msg
:
print
msg
try
:
a
.
setparameters
(
rate
,
size
,
3
,
fmt
)
except
ValueError
,
msg
:
print
msg
try
:
a
.
setparameters
(
rate
,
size
,
nchannels
,
177
)
except
ValueError
,
msg
:
print
msg
try
:
a
.
setparameters
(
rate
,
size
,
nchannels
,
ossaudiodev
.
AFMT_U16_LE
)
except
ValueError
,
msg
:
print
msg
try
:
a
.
setparameters
(
rate
,
16
,
nchannels
,
fmt
)
except
ValueError
,
msg
:
print
msg
def
test
():
play_sound_file
(
findfile
(
'audiotest.au'
))
test_errors
()
test
()
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