Author: duncan
Date: Sun Oct 14 05:10:14 2007
New Revision: 9969
Log:
[ 1813088 ] Volume events without argument crashes Freevo
Patch from Gorka Olaizola applied
Modified:
branches/rel-1/freevo/ChangeLog
branches/rel-1/freevo/freevo_config.py
branches/rel-1/freevo/src/helpers/convert_config.py
branches/rel-1/freevo/src/plugins/alsamixer.py
branches/rel-1/freevo/src/plugins/freevused.py
branches/rel-1/freevo/src/plugins/mixer.py
branches/rel-1/freevo/src/plugins/ossmixer.py
Modified: branches/rel-1/freevo/ChangeLog
==============================================================================
--- branches/rel-1/freevo/ChangeLog (original)
+++ branches/rel-1/freevo/ChangeLog Sun Oct 14 05:10:14 2007
@@ -38,6 +38,7 @@
* Fixed df plug-in crashing when totalspace is zero (B#1812877)
* Fixed favourite crashing because of duplicate detection flag
(B#1778494,B#1777726)
* Fixed matching favourites, by initially restricting the search (B#1776072)
+ * Fixed mixer plug-ins to allow a configurable volume step size (B#1813088)
* Fixed screensaver crashing after a long run when an event is read
(B#1778894)
* Fixed tvmenu crashing because of the search plug-in (B#1774544)
Modified: branches/rel-1/freevo/freevo_config.py
==============================================================================
--- branches/rel-1/freevo/freevo_config.py (original)
+++ branches/rel-1/freevo/freevo_config.py Sun Oct 14 05:10:14 2007
@@ -307,6 +307,8 @@
VCR_IN_VOLUME to VOLUME_VCR_IN
RADIO_IN_VOLUME to VOLUME_RADIO_IN
MAX_VOLUME to VOLUME_MAX
+ DEV_MIXER to VOLUME_MIXER_DEV
+ Added VOLUME_MIXER_STEP to allow the mixer volume change to be specified
'''),
]
@@ -348,7 +350,9 @@
VOLUME_TV_IN = 60 # Set this to your preferred level 0-100.
VOLUME_VCR_IN = 90 # If you use different input from TV
VOLUME_RADIO_IN = 80 # Set this to your preferred level 0-100.
-DEV_MIXER = '/dev/mixer' # mixer device
+
+VOLUME_MIXER_DEV = '/dev/mixer' # mixer device
+VOLUME_MIXER_STEP = 5 # Amount to increment the mixer volume
START_FULLSCREEN_X = 0 # Start in fullscreen mode if using x11
or xv.
Modified: branches/rel-1/freevo/src/helpers/convert_config.py
==============================================================================
--- branches/rel-1/freevo/src/helpers/convert_config.py (original)
+++ branches/rel-1/freevo/src/helpers/convert_config.py Sun Oct 14 05:10:14 2007
@@ -92,6 +92,8 @@
'VCR_IN_VOLUME': 'VOLUME_VCR_IN',
'RADIO_IN_VOLUME': 'VOLUME_RADIO_IN',
'MAX_VOLUME': 'VOLUME_MAX',
+ 'DEV_MIXER': 'VOLUME_MIXER_DEV',
+ 'MIXER_DEFAULT_STEP': 'VOLUME_MIXER_STEP',
}
def help():
Modified: branches/rel-1/freevo/src/plugins/alsamixer.py
==============================================================================
--- branches/rel-1/freevo/src/plugins/alsamixer.py (original)
+++ branches/rel-1/freevo/src/plugins/alsamixer.py Sun Oct 14 05:10:14 2007
@@ -102,6 +102,8 @@
plugin.DaemonPlugin.__init__(self)
self.plugin_name = 'MIXER'
+ self.default_step = config.VOLUME_MIXER_STEP
+
self.mainVolume = 0
self.pcmVolume = 0
self.lineinVolume = 0
@@ -148,13 +150,19 @@
"""
eventhandler to handle the VOL events
"""
+ if event in (MIXER_VOLUP, MIXER_VOLDOWN):
+ step = event.arg
+ if not isinstance(step, int):
+ _debug_("%s event type '%s' is not 'int'" % (event, step),
DWARNING)
+ step = self.default_step
+
# Handle volume control
if event == MIXER_VOLUP:
if config.MAJOR_AUDIO_CTRL == 'VOL':
- self.incMainVolume(event.arg)
+ self.incMainVolume(step)
rc.post_event(Event(OSD_MESSAGE, arg=_('Volume: %s%%') %
self.getVolume()))
elif config.MAJOR_AUDIO_CTRL == 'PCM':
- self.incPcmVolume(event.arg)
+ self.incPcmVolume(step)
rc.post_event(Event(OSD_MESSAGE, arg=_('Volume: %s%%') %
self.getVolume()))
if config.ALSA_SYNCMIXER == 1:
self.setSyncVolume(self.getVolume())
@@ -162,10 +170,10 @@
elif event == MIXER_VOLDOWN:
if config.MAJOR_AUDIO_CTRL == 'VOL':
- self.decMainVolume(event.arg)
+ self.decMainVolume(step)
rc.post_event(Event(OSD_MESSAGE, arg=_('Volume: %s%%') %
self.getVolume()))
elif config.MAJOR_AUDIO_CTRL == 'PCM':
- self.decPcmVolume(event.arg)
+ self.decPcmVolume(step)
rc.post_event(Event(OSD_MESSAGE, arg=_('Volume: %s%%') %
self.getVolume()))
if config.ALSA_SYNCMIXER == 1:
self.setSyncVolume(self.getVolume())
@@ -223,13 +231,13 @@
self.mainVolume = volume
self._setVolume(self.main_mixer, self.mainVolume)
- def incMainVolume(self,step=5):
+ def incMainVolume(self, step=5):
self.mainVolume += step
if self.mainVolume > 100:
self.mainVolume = 100
self._setVolume(self.main_mixer, self.mainVolume)
- def decMainVolume(self,step=5):
+ def decMainVolume(self, step=5):
self.mainVolume -= step
if self.mainVolume < 0:
self.mainVolume = 0
Modified: branches/rel-1/freevo/src/plugins/freevused.py
==============================================================================
--- branches/rel-1/freevo/src/plugins/freevused.py (original)
+++ branches/rel-1/freevo/src/plugins/freevused.py Sun Oct 14 05:10:14 2007
@@ -278,6 +278,7 @@
self.FVUSED_ITEM_INFO = em.Event('FVUSED_ITEM_INFO')
+ self.mixer_default_step = config.VOLUME_MIXER_STEP
thread.start_new_thread(self.bluetoothListener, ())
@@ -379,7 +380,10 @@
command = self.cmds.get(str_cmd, '')
if command:
_debug_('Event Translation: "%s" -> "%s"' % (str_cmd, command))
- self.rc.post_event(em.Event(command))
+ if str_cmd in ('VOL-', 'VOL+'):
+ self.rc.post_event(em.Event(command,
arg=self.mixer_default_step))
+ else:
+ self.rc.post_event(em.Event(command))
elif str_cmd == 'TEXT':
str_arg = self.data[4:]
Modified: branches/rel-1/freevo/src/plugins/mixer.py
==============================================================================
--- branches/rel-1/freevo/src/plugins/mixer.py (original)
+++ branches/rel-1/freevo/src/plugins/mixer.py Sun Oct 14 05:10:14 2007
@@ -61,16 +61,18 @@
# If you're using ALSA or something and you don't set the mixer,
# why are we trying to open it?
- if config.DEV_MIXER:
+ if config.VOLUME_MIXER_DEV:
try:
- self.mixfd = open(config.DEV_MIXER, 'r')
+ self.mixfd = open(config.VOLUME_MIXER_DEV, 'r')
except IOError:
- print 'Couldn\'t open mixer %s' % config.DEV_MIXER
+ print 'Couldn\'t open mixer %s' % config.VOLUME_MIXER_DEV
return
# init here
plugin.DaemonPlugin.__init__(self)
self.plugin_name = 'MIXER'
+ self.default_step = config.VOLUME_MIXER_STEP
+
if 0:
self.mainVolume = 0
self.pcmVolume = 0
@@ -113,21 +115,27 @@
"""
eventhandler to handle the VOL events
"""
+ if event in (MIXER_VOLUP, MIXER_VOLDOWN):
+ step = event.arg
+ if not isinstance(step, int):
+ _debug_("%s event type '%s' is not 'int'" % (event, step),
DWARNING)
+ step = self.default_step
+
if event == MIXER_VOLUP:
if config.MAJOR_AUDIO_CTRL == 'VOL':
- self.incMainVolume(event.arg)
+ self.incMainVolume(step)
rc.post_event(Event(OSD_MESSAGE, arg=_('Volume: %s%%') %
self.getVolume()))
elif config.MAJOR_AUDIO_CTRL == 'PCM':
- self.incPcmVolume(event.arg)
+ self.incPcmVolume(step)
rc.post_event(Event(OSD_MESSAGE, arg=_('Volume: %s%%') %
self.getVolume()))
return True
elif event == MIXER_VOLDOWN:
- if( config.MAJOR_AUDIO_CTRL == 'VOL' ):
- self.decMainVolume(event.arg)
+ if config.MAJOR_AUDIO_CTRL == 'VOL':
+ self.decMainVolume(step)
rc.post_event(Event(OSD_MESSAGE, arg=_('Volume: %s%%') %
self.getVolume()))
elif( config.MAJOR_AUDIO_CTRL == 'PCM' ):
- self.decPcmVolume(event.arg)
+ self.decPcmVolume(step)
rc.post_event(Event(OSD_MESSAGE, arg=_('Volume: %s%%') %
self.getVolume()))
return True
Modified: branches/rel-1/freevo/src/plugins/ossmixer.py
==============================================================================
--- branches/rel-1/freevo/src/plugins/ossmixer.py (original)
+++ branches/rel-1/freevo/src/plugins/ossmixer.py Sun Oct 14 05:10:14 2007
@@ -66,17 +66,19 @@
# If you're using ALSA or something and you don't set the mixer,
# why are we trying to open it?
- if config.DEV_MIXER:
+ if config.VOLUME_MIXER_DEV:
try:
- self.mixfd = ossaudiodev.openmixer(config.DEV_MIXER)
+ self.mixfd = ossaudiodev.openmixer(config.VOLUME_MIXER_DEV)
except IOError:
- print 'Couldn\'t open mixer "%s"' % config.DEV_MIXER
+ print 'Couldn\'t open mixer "%s"' % config.VOLUME_MIXER_DEV
return
# init here
plugin.DaemonPlugin.__init__(self)
self.plugin_name = 'MIXER'
+ self.default_step = config.VOLUME_MIXER_STEP
+
if 0:
self.mainVolume = 0
self.pcmVolume = 0
@@ -107,22 +109,28 @@
"""
eventhandler to handle the VOL events
"""
+ if event in (MIXER_VOLUP, MIXER_VOLDOWN):
+ step = event.arg
+ if not isinstance(step, int):
+ _debug_("%s event type '%s' is not 'int'" % (event, step),
DWARNING)
+ step = self.default_step
+
# Handle volume control
if event == MIXER_VOLUP:
if config.MAJOR_AUDIO_CTRL == 'VOL':
- self.incMainVolume()
+ self.incMainVolume(step)
rc.post_event(Event(OSD_MESSAGE, arg=_('Volume: %s%%') %
self.getVolume()))
elif config.MAJOR_AUDIO_CTRL == 'PCM':
- self.incPcmVolume()
+ self.incPcmVolume(step)
rc.post_event(Event(OSD_MESSAGE, arg=_('Volume: %s%%') %
self.getVolume()))
return True
elif event == MIXER_VOLDOWN:
if config.MAJOR_AUDIO_CTRL == 'VOL':
- self.decMainVolume()
+ self.decMainVolume(step)
rc.post_event(Event(OSD_MESSAGE, arg=_('Volume: %s%%') %
self.getVolume()))
elif config.MAJOR_AUDIO_CTRL == 'PCM':
- self.decPcmVolume()
+ self.decPcmVolume(step)
rc.post_event(Event(OSD_MESSAGE, arg=_('Volume: %s%%') %
self.getVolume()))
return True
@@ -176,14 +184,14 @@
self.mainVolume = volume
self._setVolume(ossaudiodev.SOUND_MIXER_VOLUME, self.mainVolume)
- def incMainVolume(self):
- self.mainVolume += 5
+ def incMainVolume(self, step=5):
+ self.mainVolume += step
if self.mainVolume > 100:
self.mainVolume = 100
self._setVolume(ossaudiodev.SOUND_MIXER_VOLUME, self.mainVolume)
- def decMainVolume(self):
- self.mainVolume -= 5
+ def decMainVolume(self, step=5):
+ self.mainVolume -= step
if self.mainVolume < 0:
self.mainVolume = 0
self._setVolume(ossaudiodev.SOUND_MIXER_VOLUME, self.mainVolume)
@@ -195,14 +203,14 @@
self.pcmVolume = volume
self._setVolume(ossaudiodev.SOUND_MIXER_PCM, volume)
- def incPcmVolume(self):
- self.pcmVolume += 5
+ def incPcmVolume(self, step=5):
+ self.pcmVolume += step
if self.pcmVolume > 100:
self.pcmVolume = 100
self._setVolume( ossaudiodev.SOUND_MIXER_PCM, self.pcmVolume )
- def decPcmVolume(self):
- self.pcmVolume -= 5
+ def decPcmVolume(self, step=5):
+ self.pcmVolume -= step
if self.pcmVolume < 0:
self.pcmVolume = 0
self._setVolume( ossaudiodev.SOUND_MIXER_PCM, self.pcmVolume )
@@ -231,14 +239,14 @@
def getIgainVolume(self):
return self.igainVolume
- def decIgainVolume(self):
- self.igainVolume -= 5
+ def decIgainVolume(self, step=5):
+ self.igainVolume -= step
if self.igainVolume < 0:
self.igainVolume = 0
self._setVolume(ossaudiodev.SOUND_MIXER_IGAIN, volume)
- def incIgainVolume(self):
- self.igainVolume += 5
+ def incIgainVolume(self, step=5):
+ self.igainVolume += step
if self.igainVolume > 100:
self.igainVolume = 100
self._setVolume(ossaudiodev.SOUND_MIXER_IGAIN, volume)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog