Hi again,

I forgot a couple of details:
-> MPLAYER_AO_DEV = 'alsa' (I guess you knew that)
-> If the sound is lagged, try adding srate=48000 at the end of
/etc/mplayer/mplayer.conf



--
Cyril



Cyril wrote:

>Hi all,
>
>I've been having a few problems with my new onboard soundcard (sis7012),
>because it has no hardware volume control available. As a consequence of
>this, the only way to set the volume in freevo (or anything else) is to
>use alsa's plugin dmix.
>The way ossmixer was made couldn't work with my setup, so as a result of
>my frustration, I edited the ossmixer.py plugin to make it use amixer to
>set the volume.
>Then, as it doesn't qualify as 'oss'mixer anymore, I changed its name
>and cleaned up the code a bit.
>
>I don't know if there's a library to control alsa devices with python,
>so I only used os.system('amixer ...') calls to set the volume, but it
>seems to work really well (even to control different channels apprently).
>
>Maybe this plugin could find its place in the default plugins, i think
>it can be useful for someone :)
>
>alsamixer.py is included, so ... do whatever you want with it :)
>
>
>And congratulations to everyone in the dev team, great work!
>
>--
>Cyril
>
>  
>
>------------------------------------------------------------------------
>
># -*- coding: iso-8859-1 -*-
># -----------------------------------------------------------------------
># alsamixer.py - The ALSA mixer interface for freevo.
># -----------------------------------------------------------------------
>#
># Note : Based on ossmixer.py, Rev 1.8.2.2 2005/01/20 16:32:11
>#
># To activate:
>#
># plugin.remove('mixer')
># plugin.remove('ossmixer')
># plugin.activate('alsamixer')
>#
>#
># Todo:        
>#
># -----------------------------------------------------------------------
># $Log$
>#
># -----------------------------------------------------------------------
># Freevo - A Home Theater PC framework
># Copyright (C) 2002 Krister Lagerstrom, et al. 
># Please see the file freevo/Docs/CREDITS for a complete list of authors.
>#
># This program is free software; you can redistribute it and/or modify
># it under the terms of the GNU General Public License as published by
># the Free Software Foundation; either version 2 of the License, or
># (at your option) any later version.
>#
># This program is distributed in the hope that it will be useful, but
># WITHOUT ANY WARRANTY; without even the implied warranty of MER-
># CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
># Public License for more details.
>#
># You should have received a copy of the GNU General Public License along
># with this program; if not, write to the Free Software Foundation, Inc.,
># 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
>#
># ----------------------------------------------------------------------- */
>
>
>"""For manipulating the mixer.
>"""
>
>import struct
>import os
>
>import config
>import plugin
>import rc
>from event import *
>
>import ossaudiodev
>
>
>class PluginInterface(plugin.DaemonPlugin):
>    SOUND_MIXER_LINE = 7
>    SOUND_MASK_LINE = 64
>    
>    def __init__(self):
>        self.plugin_name = 'ALSAMIXER'
>        self.mixfd = None
>        self.muted = 0
>        
>        # init here
>        plugin.DaemonPlugin.__init__(self)
>
>        if 0:
>            self.mainVolume   = 0
>            self.pcmVolume    = 0
>            self.lineinVolume = 0
>            self.micVolume    = 0
>            self.igainVolume  = 0 
>            self.ogainVolume  = 0
>
>        if config.MAJOR_AUDIO_CTRL == 'VOL':
>            self.setMainVolume(config.DEFAULT_VOLUME)
>            if config.CONTROL_ALL_AUDIO:
>                self.setPcmVolume(config.MAX_VOLUME)
>                self.setOgainVolume(config.MAX_VOLUME)
>
>        elif config.MAJOR_AUDIO_CTRL == 'PCM':
>            self.setPcmVolume(config.DEFAULT_VOLUME)
>            if config.CONTROL_ALL_AUDIO:
>                self.setMainVolume(config.MAX_VOLUME)
>                self.setOgainVolume(config.MAX_VOLUME)
>        else:
>            _debug_("No appropriate audio channel found for mixer")
>
>
>        if config.CONTROL_ALL_AUDIO:
>            self.setLineinVolume(0)
>            self.setMicVolume(0)
>
>
>    def eventhandler(self, event = None, menuw=None, arg=None):
>        """
>        eventhandler to handle the VOL events
>        """
>        # Handle volume control
>        if event == MIXER_VOLUP:
>            if config.MAJOR_AUDIO_CTRL == 'VOL':
>                self.incMainVolume()
>                rc.post_event(Event(OSD_MESSAGE, arg=_('Volume: %s%%') % 
> self.getVolume()))
>
>            elif config.MAJOR_AUDIO_CTRL == 'PCM':
>                self.incPcmVolume()
>                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()
>                rc.post_event(Event(OSD_MESSAGE, arg=_('Volume: %s%%') % 
> self.getVolume()))
>                
>            elif config.MAJOR_AUDIO_CTRL == 'PCM':
>                self.decPcmVolume()
>                rc.post_event(Event(OSD_MESSAGE, arg=_('Volume: %s%%') % 
> self.getVolume()))
>                
>            return True
>
>        elif event == MIXER_MUTE:
>            if self.getMuted() == 1:
>                rc.post_event(Event(OSD_MESSAGE, arg=_('Volume: %s%%') % 
> self.getVolume()))
>                self.setMuted(0)
>    
>            else:
>                rc.post_event(Event(OSD_MESSAGE, arg=_('Mute')))
>                self.setMuted(1)
>
>            return True
>
>        return False
>
>
>
>    def _setVolume(self, channel, volume):
>       import os
>       vol = volume*2.56
>        os.system('amixer sset '+channel+' '+str(vol))
>
>    def getMuted(self):
>        return(self.muted)
>
>    def setMuted(self, mute):
>       import os
>       self.muted = mute
>
>       if mute == 1:
>            os.system('amixer sset Master mute')
>            os.system('amixer sset PCM mute')
>        else:
>            os.system('amixer sset Master umute')
>            os.system('amixer sset PCM unmute')
>
>    
>    def getVolume(self):
>        if config.MAJOR_AUDIO_CTRL == 'VOL':
>            return self.mainVolume
>        elif config.MAJOR_AUDIO_CTRL == 'PCM':
>            return self.pcmVolume
>        
>    def getMainVolume(self):
>        return self.mainVolume
>
>    def setMainVolume(self, volume):
>        self.mainVolume = volume
>        self._setVolume('Master', self.mainVolume)
>
>    def incMainVolume(self):
>        self.mainVolume += 5
>        if self.mainVolume > 100:
>            self.mainVolume = 100
>        self._setVolume('Master', self.mainVolume)
>
>    def decMainVolume(self):
>        self.mainVolume -= 5
>        if self.mainVolume < 0:
>            self.mainVolume = 0
>        self._setVolume('Master', self.mainVolume)
>
>    def getPcmVolume(self):
>        return self.pcmVolume
>    
>    def setPcmVolume(self, volume):
>        self.pcmVolume = volume
>        self._setVolume('PCM', volume)
>
>    def incPcmVolume(self):
>        self.pcmVolume += 5
>        if self.pcmVolume > 100:
>            self.pcmVolume = 100
>        self._setVolume('PCM', self.pcmVolume )
>
>    def decPcmVolume(self):
>        self.pcmVolume -= 5
>        if self.pcmVolume < 0:
>            self.pcmVolume = 0
>        self._setVolume('PCM', self.pcmVolume )
>    
>    def setLineinVolume(self, volume):
>        if config.CONTROL_ALL_AUDIO:
>            self.lineinVolume = volume
>            self._setVolume('Line', volume)
>
>    def getLineinVolume(self):
>        return self.lineinVolume
>       
>    def setMicVolume(self, volume):
>        if config.CONTROL_ALL_AUDIO:
>            self.micVolume = volume
>            self._setVolume('Mic', volume)
>
>    def setIgainVolume(self, volume):
>        print "Not Implemented"
>        #if config.CONTROL_ALL_AUDIO:
>        #    if volume > 100:
>        #        volume = 100 
>        #    elif volume < 0:
>        #        volume = 0
>        #    self._setVolume(ossaudiodev.SOUND_MIXER_IGAIN, volume)
>
>    def getIgainVolume(self):
>        print "Not Implemented"
>        #return self.igainVolume
>
>    def decIgainVolume(self):
>        print "Not Implemented"
>        #self.igainVolume -= 5
>        #if self.igainVolume < 0:
>        #    self.igainVolume = 0
>        #self._setVolume(ossaudiodev.SOUND_MIXER_IGAIN, volume)
>        
>    def incIgainVolume(self):
>        print "Not Implemented"
>        #self.igainVolume += 5
>        #if self.igainVolume > 100:
>        #    self.igainVolume = 100
>        #self._setVolume(ossaudiodev.SOUND_MIXER_IGAIN, volume)
>
>    def setOgainVolume(self, volume):
>        print "Not Implemented"
>        #if volume > 100:
>        #    volume = 100 
>        #elif volume < 0:
>        #    volume = 0
>        #self.ogainVolume = volume
>        #self._setVolume(ossaudiodev.SOUND_MIXER_IGAIN, volume)
>
>    def reset(self):
>        if config.CONTROL_ALL_AUDIO:
>            self.setLineinVolume(0)
>            self.setMicVolume(0)
>            if config.MAJOR_AUDIO_CTRL == 'VOL':
>                self.setPcmVolume(config.MAX_VOLUME)
>            elif config.MAJOR_AUDIO_CTRL == 'PCM':
>                self.setMainVolume(config.MAX_VOLUME)
>
>        #self.setIgainVolume(0) # SB Live input from TV Card.
>
>  
>



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Freevo-devel mailing list
Freevo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to