1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

- removed PyMediaAudioClient

git-svn-id: file:///home/shlomif/Backup/svn-dumps/PySolFC/svnsync-repos/pysolfc/PySolFC/trunk@64 efabe8c0-fbe8-4139-b769-b5e6d273206e
This commit is contained in:
skomoroh 2006-09-06 21:26:48 +00:00
parent 28099110b9
commit 575c8d7bde
2 changed files with 13 additions and 89 deletions

View file

@ -138,14 +138,18 @@ def parse_option(argv):
if opts["help"]:
print _("""Usage: %s [OPTIONS] [FILE]
-g --game=GAMENAME start game GAMENAME
-i --gameid=GAMEID
--french-only
--fg --foreground=COLOR foreground color
--bg --background=COLOR background color
--fn --font=FONT default font
--sound-mod=MOD
--nosound disable sound support
--noplugins disable load plugins
-h --help display this help and exit
FILE - file name of a saved game
MOD - one of following: pss(default), pygame, oss, win
""") % prog_name
return None
@ -242,7 +246,9 @@ def pysol_init(app, args):
warn_thread = 0
warn_pysolsoundserver = 0
app.audio = None
if not opts["nosound"]:
if opts["nosound"]:
app.audio = AbstractAudioClient()
else:
if opts['sound-mod']:
d = {'pss': PysolSoundServerModuleClient,
'pygame': PyGameAudioClient,

View file

@ -72,7 +72,10 @@ class AbstractAudioClient:
self.music_loop = 0
def __del__(self):
self.destroy()
try:
self.destroy()
except:
pass
# start server - set self.server on success (may also set self.audiodev)
def startServer(self):
@ -92,11 +95,7 @@ class AbstractAudioClient:
# disconnect and stop server
def destroy(self):
if self.audiodev is not None:
try:
self._destroy()
except:
pass
self._destroy()
self.server = None
self.audiodev = None
self.connected = 0
@ -430,88 +429,6 @@ class OSSAudioClient(AbstractAudioClient):
os.write(self.pout, '\0\0\0')
# /***********************************************************************
# // PyMedia (http://pymedia.org/)
# ************************************************************************/
class PyMediaAudioClient(AbstractAudioClient):
CAN_PLAY_SOUND = True
CAN_PLAY_MUSIC = True
def __init__(self):
import pymedia, wave
AbstractAudioClient.__init__(self)
def startServer(self):
try:
import pymedia, wave
self.server = 1 # success - see also tk/menubar.py
self.audiodev = pymedia
self.splayer = pymedia.Player()
self.splayer.start()
self.mplayer = pymedia.Player()
self.mplayer.start()
except:
if traceback: traceback.print_exc()
self.server = None
self.audiodev = None
def _playSample(self, filename, priority, loop, volume):
print '_playSample:', filename, loop
self.splayer.setLoops(loop)
self.splayer.startPlayback(filename)
return 1
def _stopSamples(self):
self.splayer.stopPlayback()
def _playMusicLoop(self, music_list):
while True:
if not self.play_music:
break
for m in music_list:
if not self.play_music:
break
if m.absname.endswith('.mp3'):
print m.absname, m.volume
self.mplayer.startPlayback(m.absname)
while self.mplayer and self.mplayer.isPlaying() and self.play_music:
time.sleep(0.1)
if self.mplayer:
self.mplayer.stopPlayback()
def playContinuousMusic(self, music_list):
print 'playContinuousMusic'
if self.audiodev is None or not self.app:
return
self.play_music = True
th = Thread(target=self._playMusicLoop, args=(music_list,))
th.start()
def updateSettings(self):
if self.audiodev is None or not self.app:
return
s, m = 0, 0
if self.app.opt.sound:
s = self.app.opt.sound_sample_volume*512
s = min(65535, s)
s = max(0, s)
m = self.app.opt.sound_music_volume*512
m = min(65535, m)
m = max(0, m)
print 'updateSettings:', s, m
try:
pass
self.splayer.setVolume(s)
self.mplayer.setVolume(m)
except:
if traceback: traceback.print_exc()
# /***********************************************************************
# // PyGame
# ************************************************************************/
@ -630,3 +547,4 @@ class PyGameAudioClient(AbstractAudioClient):
def playNextMusic(self):
if self.music:
self.music.stop()