Author: duncan
Date: Mon Feb 25 14:38:33 2008
New Revision: 10437
Log:
Fixed merging too much after the consolidation from rel-1
Simplified debug messages
Modified:
branches/rel-1-7/freevo/src/tv/plugins/ivtv_xine_tv.py
Modified: branches/rel-1-7/freevo/src/tv/plugins/ivtv_xine_tv.py
==============================================================================
--- branches/rel-1-7/freevo/src/tv/plugins/ivtv_xine_tv.py (original)
+++ branches/rel-1-7/freevo/src/tv/plugins/ivtv_xine_tv.py Mon Feb 25
14:38:33 2008
@@ -128,9 +128,9 @@
| # This specifies the path and filemask that xine uses for
| # timeshifting. File can get quite big (several gigabytes)
- | XINE_TV_TIMESHIFT_FILEMASK = "/local/tmp/xine-buf-!/local/saved/!20"
+ | XINE_TV_TIMESHIFT_FILEMASK = '/local/tmp/xine-buf-!/local/saved/!20'
- Note: the format is "a!b!c", where:
+ Note: the format is 'a!b!c', where:
a = prefix (with path) for temporary file buffers
b = prefix (with path) for saved recordings
c = number of file buffers (200MB each) to use
@@ -267,11 +267,11 @@
Refer to the config file for further explanation.
"""
- __author__ = "Richard van Paasen"
- __author_email__ = "[EMAIL PROTECTED]"
+ __author__ = 'Richard van Paasen'
+ __author_email__ = '[EMAIL PROTECTED]'
__maintainer__ = __author__
__maintainer_email__ = __author_email__
- __version__ = "$Revision$"
+ __version__ = '$Revision$'
def __init__(self):
plugin.Plugin.__init__(self)
@@ -304,10 +304,6 @@
"""
def __init__(self):
""" IVTV_XINE_TV constructor """
- self.xine = XineControl()
- self.tuner = TunerControl(self.xine)
- self.mixer = MixerControl(self.xine)
-
self.xine = XineThread()
self.xine.setDaemon(1)
self.xine.start()
@@ -316,7 +312,7 @@
self.tuner.setParent(self)
self.mixer = MixerControl()
- self.app_mode = "tv"
+ self.app_mode = 'tv'
self.app = None
self.videodev = None
@@ -335,7 +331,7 @@
def Play(self, mode, channel=None, channel_change=0):
""" Start the xine player """
- _debug_("Play channel = '%s'" % channel)
+ _debug_('Play channel = %r' % channel)
self.mode = mode
@@ -350,9 +346,7 @@
time.sleep(0.6)
self.mixer.start()
- self.tuner.SetChannelByName(channel, True)
-
- _debug_("Started '%s' app" % self.mode)
+ _debug_('Started %r app' % self.mode)
def Stop(self):
@@ -360,56 +354,42 @@
confirmstop_time = int(time.time())
# note: the OSD msg is displayed for 5 seconds
if config.XINE_TV_CONFIRM_STOP and (confirmstop_time -
self.confirmstop_time) > 4:
- self.xine.ShowMessage(_('Please repeat to stop\n'))
+ self.ShowMessage(_('Please repeat to stop\n'))
self.confirmstop_time = confirmstop_time
else:
self.mixer.stop()
self.xine.stop()
rc.app(self.prev_app)
rc.post_event(PLAY_END)
- _debug_("Stopped '%s' app" % self.mode)
+ _debug_('Stopped %r app' % self.mode)
- #========================================================================
- # ShowMessage
- # show a message on the OSD
- #========================================================================
-
def ShowMessage(self, msg):
-
- _debug_("IVTV_XINE_TV: Show OSD Message: '%s'" % msg, DDEBUG)
- self.xine.write("OSDWriteText$ %s\n" % String(msg))
+ """ show a message on the OSD """
+ _debug_('Show OSD Message: %r' % (msg,))
+ self.xine.write('OSDWriteText$ %s\n' % String(msg))
- #========================================================================
- # SeekEnd
- # Skip to end of stream
- # The notahead flag indicates if the user has used the pause or rewind
- # buttons. That implies that the seek is needed.
- #========================================================================
-
def SeekEnd(self):
-
+ """ Skip to end of stream
+ The notahead flag indicates if the user has used the pause or rewind
+ buttons. That implies that the seek is needed.
+ """
if self.notahead == True:
- _debug_("IVTV_XINE_TV: Executing SeekEnd", DDEBUG)
+ _debug_('Executing SeekEnd')
- self.xine.write("SetPosition100%\n")
+ self.xine.write('SetPosition100%\n')
self.notahead = False
else:
- _debug_("IVTV_XINE_TV: SeekEnd not needed", DDEBUG)
-
+ _debug_('SeekEnd not needed')
- #========================================================================
- # eventhandler
- # freevo eventhandler
- #========================================================================
def eventhandler(self, event, menuw=None):
""" Event handler """
- _debug_("'%s' app got '%s' event" % (self.mode, event))
+ _debug_('%r app got %r event' % (self.mode, event.name))
- s_event = "%s" % event
+ s_event = '%s' % event
if event == STOP or event == PLAY_END:
self.Stop()
@@ -421,12 +401,12 @@
return True
- if event == "POPCHANNEL":
+ if event == 'POPCHANNEL':
self.tuner.PopChannel()
return True
- if event in [ TV_CHANNEL_UP, TV_CHANNEL_DOWN] or
s_event.startswith("INPUT_"):
+ if event in [ TV_CHANNEL_UP, TV_CHANNEL_DOWN] or
s_event.startswith('INPUT_'):
if event == TV_CHANNEL_UP:
# tune next channel
@@ -472,15 +452,15 @@
if event == SEEK:
seeksteps = int(event.arg)
if seeksteps == 0:
- _debug_("Ignoring seek 0")
+ _debug_('Ignoring seek 0')
return True
if seeksteps < 0:
- action = "SeekRelative-"
+ action = 'SeekRelative-'
seeksteps = 0 - seeksteps
self.notahead = True
else:
- action = "SeekRelative+"
+ action = 'SeekRelative+'
if config.XINE_TV_PROGRESSIVE_SEEK:
seekevent_current = event.arg
@@ -510,9 +490,9 @@
# limit seeksteps to [1 ; 120] seconds
seeksteps = min( max(1, seeksteps), 120 )
- _debug_("IVTV_XINE_TV: Seeking '%s%s' seconds" % (action,
seeksteps), DDEBUG)
+ _debug_('Seeking "%s%s" seconds' % (action, seeksteps))
- self.xine.write("%s#%s\n" % (action, seeksteps))
+ self.xine.write('%s#%s\n' % (action, seeksteps))
return True
@@ -551,8 +531,8 @@
# show channel info
vg = self.fc.getVideoGroup(self.curr_channel, True)
tuner_id, chan_name, prog_info =
self.fc.getChannelInfo(showtime=False)
- msg = "%s: %s" % (chan_name, prog_info)
- self.parent.ShowMessage("%s" % msg)
+ msg = '%s: %s' % (chan_name, prog_info)
+ self.parent.ShowMessage('%s' % msg)
def setParent(self, parent):
@@ -563,29 +543,29 @@
""" push the current channel on the channel stack """
if self.curr_channel != None:
self.stack.append(self.curr_channel)
- _debug_("TunerControl: Pushed channel %s" % self.curr_channel)
- _debug_("TunerControl: Channel stack = %s" % self.stack)
+ _debug_('TunerControl: Pushed channel %s' % self.curr_channel)
+ _debug_('TunerControl: Channel stack = %s' % self.stack)
def UnpushChannel(self):
""" remove the top channel fromthe channel stack """
if len(self.stack) == 0:
- _debug_("TunerControl: Channel stack is empty")
+ _debug_('TunerControl: Channel stack is empty')
else:
channel = self.stack.pop()
- _debug_("TunerControl: Unpushed channel %s" % channel)
- _debug_("TunerControl: Channel stack = %s" % self.stack)
+ _debug_('TunerControl: Unpushed channel %s' % channel)
+ _debug_('TunerControl: Channel stack = %s' % self.stack)
def PopChannel(self):
""" pop the top channel from the channel stack and switch channel """
if len(self.stack) == 0:
- _debug_("TunerControl: Channel stack is empty")
+ _debug_('TunerControl: Channel stack is empty')
else:
channel = self.stack.pop()
- _debug_("TunerControl: Popped channel %s" % channel)
+ _debug_('TunerControl: Popped channel %s' % channel)
self.SetVideoGroup(channel)
- _debug_("TunerControl: Channel stack = %s" % self.stack)
+ _debug_('TunerControl: Channel stack = %s' % self.stack)
def SetChannel(self, channel=None, clearstack=False):
@@ -614,7 +594,7 @@
pass
if (next_channel == None):
- _debug_("TunerControl: Cannot find tuner channel '%s' in the TV
channel listing" % channel, DWARNING)
+ _debug_('TunerControl: Cannot find tuner channel %r in the TV
channel listing' % channel, DWARNING)
else:
self.TuneChannelByIndex(channel_index + 1)
@@ -622,7 +602,7 @@
def TuneChannelByIndex(self, channel):
""" tune to a channel by index from the TV_CHANNELS list """
next_channel = self.fc.getManChannel(channel)
- _debug_("TunerControl: Explicit channel selection by index = '%s'" %
next_channel)
+ _debug_('TunerControl: Explicit channel selection by index = %r' %
next_channel)
self.PushChannel()
self.SetVideoGroup(next_channel)
@@ -630,7 +610,7 @@
def NextChannel(self):
""" tune to a channel by actual channel number """
next_channel = self.fc.getNextChannel()
- _debug_("TunerControl: Next channel selection = '%s'" % next_channel,
DDEBUG)
+ _debug_('Next channel selection = %r' % next_channel)
self.PushChannel()
self.SetVideoGroup(next_channel)
@@ -639,21 +619,21 @@
def PrevChannel(self):
""" jump to the previous channel in the TV_CHANNELS list """
prev_channel = self.fc.getPrevChannel()
- _debug_("TunerControl: Previous channel selection = '%s'" %
prev_channel)
+ _debug_('TunerControl: Previous channel selection = %r' % prev_channel)
self.PushChannel()
self.SetVideoGroup(prev_channel)
def SetVideoGroup(self, channel):
""" select a channel's video group and tune to that channel """
- _debug_("TunerControl: Channel: '%s'" % channel)
+ _debug_('TunerControl: Channel: %r' % channel)
new_vg = self.fc.getVideoGroup(channel, True)
- _debug_("TunerControl: Group: 'type=%s, desc=%s'" %
(new_vg.group_type, new_vg.desc))
- _debug_("TunerControl: Input: 'type=%s, num=%s'" % (new_vg.input_type,
new_vg.input_num))
+ _debug_('TunerControl: Group: type=%r, desc=%r' % (new_vg.group_type,
new_vg.desc))
+ _debug_('TunerControl: Input: type=%r, num=%r' % (new_vg.input_type,
new_vg.input_num))
- if (new_vg.group_type != "ivtv"):
- _debug_("TunerControl: Video group '%s' is not supported" %
new_vg.group_type, DERROR)
- pop = AlertBox(text=_("This plugin only supports the ivtv video
group!"))
+ if (new_vg.group_type != 'ivtv'):
+ _debug_('TunerControl: Video group %r is not supported' %
new_vg.group_type, DERROR)
+ pop = AlertBox(text=_('This plugin only supports the ivtv video
group!'))
pop.show()
return
@@ -662,9 +642,9 @@
(self.curr_channel == None) or \
(new_vg != self.fc.getVideoGroup(self.curr_channel, True))
- if switch_vg == True:
+ if switch_vg:
# switch to a different video group
- _debug_("TunerControl: Set video group: %s" % new_vg.vdev, DINFO)
+ _debug_('TunerControl: Set video group: %s' % new_vg.vdev, DINFO)
ivtv_dev = ivtv.IVTV(new_vg.vdev)
ivtv_dev.init_settings()
ivtv_dev.setinput(new_vg.input_num)
@@ -692,18 +672,18 @@
def __init__(self):
""" MixerControl constructor """
- self.mixer = plugin.getbyname("MIXER")
+ self.mixer = plugin.getbyname('MIXER')
self.volume = 0
def prepare(self):
""" turn down volume """
if (self.mixer != None):
- if config.MIXER_MAJOR_CTRL == "VOL":
+ if config.MIXER_MAJOR_CTRL == 'VOL':
self.volume = self.mixer.getMainVolume()
self.mixer.setMainVolume(0)
- elif config.MIXER_MAJOR_CTRL == "PCM":
+ elif config.MIXER_MAJOR_CTRL == 'PCM':
self.volume = self.mixer.getPcmVolume()
self.mixer.setPcmVolume(0)
@@ -714,10 +694,10 @@
self.mixer.setLineinVolume(config.MIXER_VOLUME_TV_IN)
self.mixer.setIgainVolume(config.MIXER_VOLUME_TV_IN)
- if config.MIXER_MAJOR_CTRL == "VOL":
+ if config.MIXER_MAJOR_CTRL == 'VOL':
self.mixer.setMainVolume(self.volume)
- elif config.MIXER_MAJOR_CTRL == "PCM":
+ elif config.MIXER_MAJOR_CTRL == 'PCM':
self.mixer.setPcmVolume(self.volume)
@@ -737,7 +717,7 @@
def __init__(self, app, item):
""" XineApp constructor """
self.item = item
- _debug_("XineApp: Starting xine, cmd = '%s'" % app)
+ _debug_('XineApp: Starting xine, cmd = %r' % app)
childapp.ChildApp2.__init__(self, app)
self.exit_type = None
self.done = False
@@ -745,7 +725,7 @@
def _kill_(self):
""" XineApp destructor """
- _debug_("XineApp: Stopping xine...")
+ _debug_('XineApp: Stopping xine...')
childapp.ChildApp2.kill(self,signal.SIGTERM)
self.done = True
@@ -756,106 +736,106 @@
Thread that handles Xine commands
"""
def __init__(self):
- """ XineControl constructor """
+ """ XineThread constructor """
threading.Thread.__init__(self)
self.app = None
self.item = None
- self.state = "idle"
+ self.state = 'idle'
self.start_flag = threading.Event()
try:
xinecmd = config.XINE_COMMAND.split(' ')[0].split('/')[-1]
- self.fbxine = xinecmd in ("fbxine", "df_xine")
+ self.fbxine = xinecmd in ('fbxine', 'df_xine')
except:
- xinecmd = ""
+ xinecmd = ''
self.fbxine = False
- _debug_("XineThread: configuration overview")
- _debug_(" config.CONF.xine = '%s'" % config.CONF.xine)
- _debug_(" config.XINE_COMMAND = '%s'" % config.XINE_COMMAND)
- _debug_(" config.XINE_ARGS_DEF = '%s'" % config.XINE_ARGS_DEF)
- _debug_(" config.XINE_TV_VO_DEV = '%s'" % config.XINE_TV_VO_DEV)
- _debug_(" config.XINE_TV_AO_DEV = '%s'" % config.XINE_TV_AO_DEV)
- _debug_(" config.XINE_TV_TIMESHIFT_FILEMASK = '%s'" %
config.XINE_TV_TIMESHIFT_FILEMASK)
- _debug_(" effective xinecmd = '%s'" % xinecmd)
- _debug_(" effective self.fbxine = '%s'" % self.fbxine)
+ _debug_('XineThread: configuration overview')
+ _debug_(' config.CONF.xine = %r' % config.CONF.xine)
+ _debug_(' config.XINE_COMMAND = %r' % config.XINE_COMMAND)
+ _debug_(' config.XINE_ARGS_DEF = %r' % config.XINE_ARGS_DEF)
+ _debug_(' config.XINE_TV_VO_DEV = %r' % config.XINE_TV_VO_DEV)
+ _debug_(' config.XINE_TV_AO_DEV = %r' % config.XINE_TV_AO_DEV)
+ _debug_(' config.XINE_TV_TIMESHIFT_FILEMASK = %r' %
config.XINE_TV_TIMESHIFT_FILEMASK)
+ _debug_(' effective xinecmd = %r' % xinecmd)
+ _debug_(' effective self.fbxine = %r' % self.fbxine)
if self.fbxine:
- self.command = "%s %s --stdctl pvr://%s" % \
+ self.command = '%s %s --stdctl pvr://%s' % \
(config.XINE_COMMAND, config.XINE_ARGS_DEF,
config.XINE_TV_TIMESHIFT_FILEMASK)
else:
- self.command = "%s %s -V %s -A %s --stdctl pvr://%s" % \
+ self.command = '%s %s -V %s -A %s --stdctl pvr://%s' % \
(config.XINE_COMMAND, config.XINE_ARGS_DEF,
config.XINE_TV_VO_DEV, \
config.XINE_TV_AO_DEV, config.XINE_TV_TIMESHIFT_FILEMASK)
def write(self, msg):
""" display a message to the xine player """
- _debug_("XineControl: Show OSD Message: '%s'" % msg)
- if self.state != "idle":
+ _debug_('XineThread: Show OSD Message: %r' % msg)
+ if self.state != 'idle':
self.app.write(msg)
def play(self):
""" start playing """
- if self.state == "idle":
+ if self.state == 'idle':
self.start_flag.set()
def pause(self):
""" pause playing """
- if self.state == "busy":
- self.state = "pause"
+ if self.state == 'busy':
+ self.state = 'pause'
def stop(self):
""" stop playing """
- if self.state == "busy":
- self.state = "stop"
+ if self.state == 'busy':
+ self.state = 'stop'
if self.fbxine:
while not self.app.done:
- _debug_("XineThread: Waiting for xine to end...", DDEBUG)
+ _debug_('Waiting for xine to end...')
time.sleep(0.1)
- _debug_("XineThread: Xine ended")
+ _debug_('XineThread: Xine ended')
def run(self):
""" worker method """
while 1:
- if self.state == "idle":
+ if self.state == 'idle':
self.start_flag.wait()
self.start_flag.clear()
else:
- _debug_("XineThread: Should be idle on thread entry!",
DWARNING)
+ _debug_('XineThread: Should be idle on thread entry!',
DWARNING)
self.app = XineApp(self.command, self.item)
- self.state = "busy"
+ self.state = 'busy'
laststate = None
while self.app.isAlive():
if laststate != self.state:
- _debug_("XineThread: state '%s' -> '%s'" % (laststate,
self.state), DDEBUG)
+ _debug_('state %r -> %r' % (laststate, self.state))
laststate = self.state
- if self.state == "busy":
+ if self.state == 'busy':
time.sleep(0.1)
- elif self.state == "pause":
- self.app.write("pause\n")
- self.state = "busy"
- elif self.state == "stop":
- _debug_("XineThread: Stoppping xine")
- self.app.stop("quit\n")
+ elif self.state == 'pause':
+ self.app.write('pause\n')
+ self.state = 'busy'
+ elif self.state == 'stop':
+ _debug_('XineThread: Stoppping xine')
+ self.app.stop('quit\n')
if self.fbxine:
# directfb needs xine to be killed
# else the display is messed up
# and freevo crashes
time.sleep(1.0)
- _debug_("XineThread: Killing xine", DDEBUG)
+ _debug_('Killing xine')
self.app._kill_()
- self.state = "busy"
+ self.state = 'busy'
- _debug_("XineThread: Stopped", DDEBUG)
+ _debug_('XineThread: Stopped')
self.state = 'idle'
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog