I upgraded my freevo box to the latest ubuntu. Unfortunately, ubuntu
uses pulseaudio no matter what I tried I could not get the freevo mixer
plugins to work. (also because I wanted to use the digital audio on my
HDMI port)
Eventually I gave up and approached the issue from the other side. Using
the the palib module (see http://code.google.com/p/pypactl/) I created
pulsemixer.py.
I installed it in my freevo/plugins directory and activated it with:
plugin.remove('mixer')
plugin.activate('pulsemixer')
I would appreciate feedback prior to submitting this code to the tree.
So please test this beta code and let me know if you find it useful.
Paul
--
Paul Sijben
tel 0334557522
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------
# pulsemixer.py - The Pulseaudio mixer interface for freevo.
# -----------------------------------------------------------------------
# $Id: pulsemixer.py 11239 2011-12-11 paul sijben $
#
# Notes:
#
# I propose this could replace 'mixer.py' when it's been tested adequately.
#
# And to activate:
#
# plugin.remove('mixer')
# plugin.activate('pulseixer')
#
#
# Todo:
#
# -----------------------------------------------------------------------
# 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
#
# -----------------------------------------------------------------------
__version__="0.1"
__author__="Paul Sijben <paul.sij...@gmail.com>"
__doc__="""For manipulating the mixer. pulsemixer.py plugin that works with
the palib module (http://code.google.com/p/pypactl/).
"""
import struct
import os
import config
import plugin
import rc
from event import *
import dialog
from palib import PulseObj, \
PulseSink, \
PulseSinkInfo, \
PulseSinkInputInfo, \
PulseVolume
class PluginInterface(plugin.DaemonPlugin):
"""
Mixer for pulse audio, requires palib module from
http://code.google.com/p/pypactl/
"""
def __init__(self):
self.muted = 0
# init here
plugin.DaemonPlugin.__init__(self)
self.plugin_name = 'MIXER'
self.default_step = config.MIXER_VOLUME_STEP
self.pulse = PulseObj("freevo", None, True)
self.sinks = self.pulse.pulse_sink_list()
#TODO make this a config option
self.selected_sink = self.sinks[0]
self.vol4channels = [config.MIXER_VOLUME_DEFAULT,\
config.MIXER_VOLUME_DEFAULT,\
config.MIXER_VOLUME_DEFAULT,\
config.MIXER_VOLUME_DEFAULT,\
config.MIXER_VOLUME_DEFAULT,\
config.MIXER_VOLUME_DEFAULT]
self.mainVolume = config.MIXER_VOLUME_DEFAULT
self.setMainVolume(config.MIXER_VOLUME_DEFAULT)
def incVolume_map(self, inc):
vol = self.selected_sink.volume
#vol_max=max(vol.values)
#vol_max=int(vol_max+inc)
for i in range(0,vol.channels):
vol.values[i] = vol.values[i]+inc
return vol
def setVolume_map(self, newvol):
vol = self.selected_sink.volume
for i in range(0,vol.channels):
vol.values[i]=newvol
return vol
def config(self):
'''config is called automatically, for default settings run:
freevo plugins -i alsamixer
'''
return [
]
def eventhandler(self, event=None, menuw=None, arg=None):
"""
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:
self.incMainVolume(step)
dialog.show_volume(self.getVolume(), False)
rc.post_event(Event('MIXER_VOLUME_INFO', arg='%s' %
self.getVolume()))
return True
elif event == MIXER_VOLDOWN:
self.decMainVolume(step)
dialog.show_volume(self.getVolume(), False)
rc.post_event(Event('MIXER_VOLUME_INFO', arg='%s' %
self.getVolume()))
return True
elif event == MIXER_MUTE:
if self.getMuted():
rc.post_event(Event('MIXER_VOLUME_INFO', arg='%s' %
self.getVolume()))
self.setMuted(0)
else:
rc.post_event(Event('MIXER_MUTE_INFO'))
self.setMuted(1)
dialog.show_volume(self.getVolume(), self.getMuted())
return True
return False
def getMuted(self):
if self.muted:
return 1
else:
return 0
def setMuted(self, mute):
#this will need work when the library has been improved
if mute:
self.muted = self.getVolume()
self.setMainVolume(0)
else:
self.setMainVolume(self.muted)
self.muted=0
def getVolume(self):
return self.mainVolume
#return self.selected_sink.volume[0]
def setMainVolume(self, volume):
self.mainVolume = volume
if volume:
self.muted = 0
newvol=self.setVolume_map(int(volume))
self.pulse.pulse_set_sink_volume(self.selected_sink.index,newvol)
def incMainVolume(self, step=5):
if self.muted:
#unmute
self.setMuted(0)
else:
newvol=self.incVolume_map(int(step))
self.pulse.pulse_set_sink_volume(self.selected_sink.index,newvol)
self.mainVolume += step
def decMainVolume(self, step=5):
self.incMainVolume(-step)
def reset(self):
self.setMainVolume(config.MIXER_VOLUME_DEFAULT)
------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Freevo-users mailing list
Freevo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-users