0

I'm trying to create a small custom mixer that suits my needs, using python 2.7 and pyalsaaudio 0.7, but I'm stuck with events got from alsamixer when another program changes the volume values. I tried to understand how other mixers work (for example volti) and, as far as I understand, it should work as expected, but even if the method is similar, I still get a continuous loop of event response from io_add_watch. So, I suppose that I don't understand how io_add_watch works yet.

This is a small version of the code:

class MyMixer(gtk.Window):
    def __init__(self):
        super(MyMixer, self).__init__()
        self.m = alsaaudio.Mixer(control='Headphone', id=1, cardindex=0)
        """ here go the mixer widgets """
        self.show_all()
        fd, event = self.m.polldescriptors()[0]
        self.watch = gobject.io_add_watch(fd, event, self.update)


    def update(self, *args):
        print 'changed'
        """ here I update mixer widgets """
        return True

mixer = MyMixer()
gtk.main()

What am I getting wrong?

musicamante
  • 41,230
  • 6
  • 33
  • 58

1 Answers1

0

When you get an event from the poll descriptors, you must call snd_mixer_handle_events(). pyalsaaudio has no mechanism for that.

CL.
  • 173,858
  • 17
  • 217
  • 259
  • I found a patch submitted for this, but, if I understand correctly, it just let me handle specific events, which is not my issue: my problem is that after a value change in the mixer I get continous events, and I don't know how to "stop" it. I'm still a python beginner, and I may not have really understood how polling works, by the way. – musicamante Oct 23 '14 at 14:14
  • 1
    You get continuous events because the events are not handled. – CL. Oct 23 '14 at 17:03