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
2c8b35bd
Kaydet (Commit)
2c8b35bd
authored
Eki 31, 1998
tarafından
Barry Warsaw
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
some rewriting, must do command line args
üst
b7d1d63f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
40 deletions
+91
-40
audiopy
Tools/audiopy/audiopy
+91
-40
No files found.
Tools/audiopy/audiopy
Dosyayı görüntüle @
2c8b35bd
...
@@ -6,23 +6,26 @@ When no arguments are given, this pops up a graphical window which lets you
...
@@ -6,23 +6,26 @@ When no arguments are given, this pops up a graphical window which lets you
choose which audio output device you want sound to go to.
choose which audio output device you want sound to go to.
This program can be driven via the command line, and when done so, no window
This program can be driven via the command line, and when done so, no window
pops up.
Here are the options
:
pops up.
Options have the general form
:
--headphones[={0,1}]
--device[={0,1}]
-p[={0,1}]
-d[={0,1}]
Set the headphones output device. With no value, it toggles the
Set the I/O device. With no value, it toggles the specified device.
headphone device. With a value, 0 turns the headphones off and 1
With a value, 0 turns the device off and 1 turns the device on.
turns the headphones on.
--speaker[={0,1}]
The list of devices and their short options are:
-s[={0,1}]
Set the speaker output device. Value semantics are the same as
above.
--lineout[={0,1}]
(input)
-l[={0,1}]
microphone -- m
Set the line out output device. Value semantics are the same as
linein -- i
above.
cd -- c
(output)
headphones -- p
speaker -- s
lineout -- o
Other options are:
--help
--help
-h
-h
...
@@ -41,38 +44,20 @@ KEEPALIVE_TIMER = 500
...
@@ -41,38 +44,20 @@ KEEPALIVE_TIMER = 500
class
MainWindow
:
class
MainWindow
:
def
__init__
(
self
):
def
__init__
(
self
,
device
):
self
.
__devctl
=
device
info
=
device
.
getinfo
()
#
self
.
__tkroot
=
tkroot
=
Tk
(
className
=
'Pynche'
)
self
.
__tkroot
=
tkroot
=
Tk
(
className
=
'Pynche'
)
tkroot
.
withdraw
()
tkroot
.
withdraw
()
# create the menubar
menubar
=
Menu
(
tkroot
)
#
# File menu
#
filemenu
=
Menu
(
menubar
,
tearoff
=
0
)
filemenu
.
add_command
(
label
=
'Quit'
,
command
=
self
.
__quit
,
accelerator
=
'Alt-Q'
,
underline
=
0
)
#
# Tie them together
#
menubar
.
add_cascade
(
label
=
'File'
,
menu
=
filemenu
,
underline
=
0
)
# now create the top level window
# now create the top level window
root
=
self
.
__root
=
Toplevel
(
tkroot
,
class_
=
'Audiopy'
,
menu
=
menubar
)
root
=
self
.
__root
=
Toplevel
(
tkroot
,
class_
=
'Audiopy'
)
root
.
protocol
(
'WM_DELETE_WINDOW'
,
self
.
__quit
)
root
.
protocol
(
'WM_DELETE_WINDOW'
,
self
.
__quit
)
root
.
title
(
'Audiopy'
)
root
.
title
(
'Audiopy'
)
root
.
iconname
(
'Audiopy'
)
root
.
iconname
(
'Audiopy'
)
root
.
tk
.
createtimerhandler
(
KEEPALIVE_TIMER
,
self
.
__keepalive
)
root
.
tk
.
createtimerhandler
(
KEEPALIVE_TIMER
,
self
.
__keepalive
)
root
.
bind
(
'<Alt-q>'
,
self
.
__quit
)
root
.
bind
(
'<Alt-Q>'
,
self
.
__quit
)
#
#
# Open up the audio control device and query for the current output
buttons
=
[]
# device
self
.
__devctl
=
sunaudiodev
.
open
(
'control'
)
info
=
self
.
__devctl
.
getinfo
()
#
#
# where does input come from?
# where does input come from?
frame
=
Frame
(
root
,
bd
=
1
,
relief
=
RAISED
)
frame
=
Frame
(
root
,
bd
=
1
,
relief
=
RAISED
)
...
@@ -89,6 +74,10 @@ class MainWindow:
...
@@ -89,6 +74,10 @@ class MainWindow:
btn
.
grid
(
row
=
0
,
column
=
1
,
sticky
=
W
)
btn
.
grid
(
row
=
0
,
column
=
1
,
sticky
=
W
)
root
.
bind
(
'<Alt-m>'
,
self
.
__mic
)
root
.
bind
(
'<Alt-m>'
,
self
.
__mic
)
root
.
bind
(
'<Alt-M>'
,
self
.
__mic
)
root
.
bind
(
'<Alt-M>'
,
self
.
__mic
)
if
not
info
.
i_avail_ports
&
MICROPHONE
:
btn
.
configure
(
state
=
DISABLED
)
buttons
.
append
(
btn
)
##
self
.
__lineinvar
=
IntVar
()
self
.
__lineinvar
=
IntVar
()
btn
=
Checkbutton
(
frame
,
btn
=
Checkbutton
(
frame
,
text
=
'Line In'
,
text
=
'Line In'
,
...
@@ -99,6 +88,10 @@ class MainWindow:
...
@@ -99,6 +88,10 @@ class MainWindow:
btn
.
grid
(
row
=
1
,
column
=
1
,
sticky
=
W
)
btn
.
grid
(
row
=
1
,
column
=
1
,
sticky
=
W
)
root
.
bind
(
'<Alt-i>'
,
self
.
__linein
)
root
.
bind
(
'<Alt-i>'
,
self
.
__linein
)
root
.
bind
(
'<Alt-I>'
,
self
.
__linein
)
root
.
bind
(
'<Alt-I>'
,
self
.
__linein
)
if
not
info
.
i_avail_ports
&
LINE_IN
:
btn
.
configure
(
state
=
DISABLED
)
buttons
.
append
(
btn
)
##
self
.
__cdvar
=
IntVar
()
self
.
__cdvar
=
IntVar
()
btn
=
Checkbutton
(
frame
,
btn
=
Checkbutton
(
frame
,
text
=
'CD'
,
text
=
'CD'
,
...
@@ -109,6 +102,9 @@ class MainWindow:
...
@@ -109,6 +102,9 @@ class MainWindow:
btn
.
grid
(
row
=
2
,
column
=
1
,
sticky
=
W
)
btn
.
grid
(
row
=
2
,
column
=
1
,
sticky
=
W
)
root
.
bind
(
'<Alt-c>'
,
self
.
__cd
)
root
.
bind
(
'<Alt-c>'
,
self
.
__cd
)
root
.
bind
(
'<Alt-C>'
,
self
.
__cd
)
root
.
bind
(
'<Alt-C>'
,
self
.
__cd
)
if
not
info
.
i_avail_ports
&
CD
:
btn
.
configure
(
state
=
DISABLED
)
buttons
.
append
(
btn
)
#
#
# where does output go to?
# where does output go to?
frame
=
Frame
(
root
,
bd
=
1
,
relief
=
RAISED
)
frame
=
Frame
(
root
,
bd
=
1
,
relief
=
RAISED
)
...
@@ -125,6 +121,10 @@ class MainWindow:
...
@@ -125,6 +121,10 @@ class MainWindow:
btn
.
grid
(
row
=
0
,
column
=
1
,
sticky
=
W
)
btn
.
grid
(
row
=
0
,
column
=
1
,
sticky
=
W
)
root
.
bind
(
'<Alt-s>'
,
self
.
__speaker
)
root
.
bind
(
'<Alt-s>'
,
self
.
__speaker
)
root
.
bind
(
'<Alt-S>'
,
self
.
__speaker
)
root
.
bind
(
'<Alt-S>'
,
self
.
__speaker
)
if
not
info
.
o_avail_ports
&
SPEAKER
:
btn
.
configure
(
state
=
DISABLED
)
buttons
.
append
(
btn
)
##
self
.
__headvar
=
IntVar
()
self
.
__headvar
=
IntVar
()
btn
=
Checkbutton
(
frame
,
btn
=
Checkbutton
(
frame
,
text
=
'Headphones'
,
text
=
'Headphones'
,
...
@@ -135,6 +135,10 @@ class MainWindow:
...
@@ -135,6 +135,10 @@ class MainWindow:
btn
.
grid
(
row
=
1
,
column
=
1
,
sticky
=
W
)
btn
.
grid
(
row
=
1
,
column
=
1
,
sticky
=
W
)
root
.
bind
(
'<Alt-h>'
,
self
.
__headphones
)
root
.
bind
(
'<Alt-h>'
,
self
.
__headphones
)
root
.
bind
(
'<Alt-H>'
,
self
.
__headphones
)
root
.
bind
(
'<Alt-H>'
,
self
.
__headphones
)
if
not
info
.
o_avail_ports
&
HEADPHONE
:
btn
.
configure
(
state
=
DISABLED
)
buttons
.
append
(
btn
)
##
self
.
__linevar
=
IntVar
()
self
.
__linevar
=
IntVar
()
btn
=
Checkbutton
(
frame
,
btn
=
Checkbutton
(
frame
,
variable
=
self
.
__linevar
,
variable
=
self
.
__linevar
,
...
@@ -145,6 +149,29 @@ class MainWindow:
...
@@ -145,6 +149,29 @@ class MainWindow:
btn
.
grid
(
row
=
2
,
column
=
1
,
sticky
=
W
)
btn
.
grid
(
row
=
2
,
column
=
1
,
sticky
=
W
)
root
.
bind
(
'<Alt-l>'
,
self
.
__lineout
)
root
.
bind
(
'<Alt-l>'
,
self
.
__lineout
)
root
.
bind
(
'<Alt-L>'
,
self
.
__lineout
)
root
.
bind
(
'<Alt-L>'
,
self
.
__lineout
)
if
not
info
.
o_avail_ports
&
LINE_OUT
:
btn
.
configure
(
state
=
DISABLED
)
buttons
.
append
(
btn
)
#
# Fix up widths
widest
=
0
for
b
in
buttons
:
width
=
b
[
'width'
]
if
width
>
widest
:
widest
=
width
for
b
in
buttons
:
b
.
configure
(
width
=
widest
)
#
# Add quit button
frame
=
Frame
(
root
)
frame
.
grid
(
row
=
2
,
column
=
0
,
sticky
=
'EW'
,
ipady
=
5
)
btn
=
Button
(
frame
,
text
=
'Quit'
,
command
=
self
.
__quit
,
underline
=
0
)
btn
.
pack
(
expand
=
YES
)
root
.
bind
(
'<Alt-q>'
,
self
.
__quit
)
root
.
bind
(
'<Alt-Q>'
,
self
.
__quit
)
#
#
# do we need to poll for changes?
# do we need to poll for changes?
self
.
__needtopoll
=
1
self
.
__needtopoll
=
1
...
@@ -211,7 +238,9 @@ class MainWindow:
...
@@ -211,7 +238,9 @@ class MainWindow:
self
.
__getset
(
self
.
__lineinvar
,
LINE_IN
)
self
.
__getset
(
self
.
__lineinvar
,
LINE_IN
)
def
__cd
(
self
,
event
=
None
):
def
__cd
(
self
,
event
=
None
):
print
'pre:'
,
self
.
__cdvar
.
get
()
self
.
__getset
(
self
.
__cdvar
,
CD
)
self
.
__getset
(
self
.
__cdvar
,
CD
)
print
'post:'
,
self
.
__cdvar
.
get
()
def
__speaker
(
self
,
event
=
None
):
def
__speaker
(
self
,
event
=
None
):
self
.
__getset
(
self
.
__spkvar
,
SPEAKER
)
self
.
__getset
(
self
.
__spkvar
,
SPEAKER
)
...
@@ -235,16 +264,38 @@ def usage(msg='', code=1):
...
@@ -235,16 +264,38 @@ def usage(msg='', code=1):
def
main
():
def
main
():
#
# Open up the audio control device and query for the current output
# device
device
=
sunaudiodev
.
open
(
'control'
)
if
len
(
sys
.
argv
)
==
1
:
if
len
(
sys
.
argv
)
==
1
:
# GUI
# GUI
w
=
MainWindow
()
w
=
MainWindow
(
device
)
try
:
try
:
w
.
start
()
w
.
start
()
except
KeyboardInterrupt
:
except
KeyboardInterrupt
:
pass
pass
return
return
# command line
# spec: LONG OPT, SHORT OPT, 0=input,1=output, MASK
options
=
((
'--microphone'
,
'-m'
,
0
,
MICROPHONE
),
(
'--linein'
,
'-i'
,
0
,
LINE_IN
),
(
'--cd'
,
'-c'
,
0
,
CD
),
(
'--headphones'
,
'-p'
,
1
,
HEADPHONE
),
(
'--speaker'
,
'-s'
,
1
,
SPEAKER
),
(
'--lineout'
,
'-o'
,
1
,
LINE_OUT
),
)
values
=
[]
info
=
device
.
getinfo
()
# first get the existing values
for
long
,
short
,
io
,
mask
in
options
:
if
io
==
0
:
flags
=
info
.
i_port
else
:
flags
=
info
.
o_port
values
.
append
(
flags
&
mask
)
sval
=
None
sval
=
None
hval
=
None
hval
=
None
lval
=
None
lval
=
None
...
...
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