1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#!/usr/bin/python2.4
import pygtk
pygtk.require( '2.0' )
import gtk
from Framework.Constants import Constants
from Framework.CSound.CSoundConstants import CSoundConstants
from Framework.CSound.CSoundClient import CSoundClient
from Framework.CSound.CSoundServer import CsoundServerMult
from GUI.Core.MainWindow import MainWindow
import os
import sys
import signal
import time
from GUI.StandalonePlayer import StandAlonePlayer
if __name__ == "__main__":
# TODO this should get started outside of TamTam (perhaps by Sugar?)
# start the CSoundServer
def do_quit(event, param):
CSoundClient.sendText('off()')
print 'do_quit() waiting'
#we know that quitting doesn't really work
time.sleep(0.5)
os.kill(pid, signal.SIGKILL)
time.sleep(0.3)
os.wait()
print '... phew!'
try :
pid = os.fork()
if pid > 0 :
time.sleep(1)
CSoundClient.initialize()
tamtam = StandAlonePlayer()
tamtam.connect('destroy', do_quit, pid)
gtk.main()
else:
server = CsoundServerMult( ( CSoundConstants.SERVER_ADDRESS, CSoundConstants.SERVER_PORT ) )
server.interpret()
except OSError, e:
print >>sys.stderr, "fork failed: %d (%s)" % (e.errno, e.strerror)
sys.exit(1)
from sugar.activity.Activity import Activity
class TamTam(Activity):
def __init__(self):
Activity.__init__(self)
def do_quit(event, param):
CSoundClient.sendText('off()')
print 'do_quit() waiting'
#we know that quitting doesn't really work
time.sleep(0.5)
os.kill(pid, signal.SIGKILL)
time.sleep(0.3)
os.wait()
print '... phew!'
try :
pid = os.fork()
if pid > 0 :
time.sleep(1)
CSoundClient.initialize()
tamtam = StandAlonePlayer()
tamtam.connect('destroy', do_quit, pid)
self.add(tamtam)
tamtam.show()
else:
server = CsoundServerMult( ( CSoundConstants.SERVER_ADDRESS, CSoundConstants.SERVER_PORT ) )
server.interpret()
except OSError, e:
print >>sys.stderr, "fork failed: %d (%s)" % (e.errno, e.strerror)
sys.exit(1)
def do_quit(self, event, app):
del app
|