[alsa-devel] Restart alsa-gi project as alsa-gobject project

Takashi Sakamoto o-takashi at sakamocchi.jp
Sun Dec 1 09:04:50 CET 2019


Hi Jaroslav,

Since Audio Mini Conference 2018, I continued to work for alsa-gi[1] in
my local to integrate toward better I/O libraries. However I realized
that its basic design includes some disadvantages to produce useful APIs.

I rethink the design and realize it better to wrap each of structures
in <sound/asound.h> simply. Then, I restart it as alsa-gobject[2].
At present, master branch includes a library, `libalsactl0` for the
most of I/O features in ALSA control interface, which is compatible with
GObject mechanism and GObject introspection.

Jaroslav, would you please delete the alsa-gi repository and fork
the master branch from my alsa-gobject repository, then apply enough
configurations to the new repository?


My repository includes four branches as well for ALSA
hwdep/rawmidi/timer/seq interfaces. The most of features in each
interface is already available via included libraries but under heavy
development.

I already start to test them with Python 3 (PyGObject) and they seem
work well. I also test them with Rust bindings generated by gtk-rs/gir[3]
tool. Near future I also publish Rust crates for further convenience.


For your interests, this Python 3 script is a sample to listen one
event from ALSA control character device. This simple program is not
terminated voluntarily or by sending UNIX signal, thus please generate
control event by alsamixer or amixer:

```
#!/usr/bin/env python3

import gi
gi.require_version('GLib', '2.0')
gi.require_version('ALSACtl', '0.0')
from gi.repository import GLib, ALSACtl

class MyCard(ALSACtl.Card):
    def __init__(self, card_id, ctx, dispatcher):
        super().__init__()
        self.open(card_id)

        self.create_source().attach(ctx)

        self.__dispatcher = dispatcher

    def do_handle_disconnection(self):
        self.__dispatcher.quit()

    def do_handle_elem_event(self, elem_id, events):
        # Print the first event and quit event loop.
        print(elem_id.get_iface().value_nick,
              elem_id.get_device_id(), elem_id.get_subdevice_id(),
              elem_id.get_name(), elem_id.get_index(),
              events.value_nicks)
        self.__dispatcher.quit()


ctx = GLib.MainContext.new()
dispatcher = GLib.MainLoop.new(ctx, False)
card = MyCard(0, ctx, dispatcher)

dispatcher.run()
```

[1] https://github.com/alsa-project/alsa-gi
[2] https://github.com/takaswie/alsa-gobject
[3] https://github.com/gtk-rs/gir


Regards

Takashi Sakamoto


More information about the Alsa-devel mailing list