Code Monkey home page Code Monkey logo

apply-equalizer's People

Contributors

nulleuro avatar sgourichon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

sgourichon

apply-equalizer's Issues

Settings go back-and-forth many times

Context: plug a jack into a sound output.

Expected: equalizer changes once

Observed: equalizer changes back and forth many times between setup for "nothing plugged in" and "something plugged in". Can be tens of times for a duration of possibly one minute.

Reproducible: sometimes, hardware-dependent. Happens on my main working machine, a laptop less than two years old.

Comments:

A perfect jack sensor would only send one and only one event on jack plug/unplug.
A real sensor sometimes "bounces". This indeed is a hardware issue.
When the programs reacting to it act quickly, it's not really an issue. For example, xfce4-volumed automatically adjusts volume level depending on active output. When problem occurs one just sees volume slide back and forth quickly and that's all.
But apply-equalizer is much longer to appy settings. Events get queued. When bounces trigger tens of events, queue can take a long time to drain and appear like an endless loop.

Fail at start with dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NameHasNoOwner: Could not get owner of name 'org.PulseAudio1': no such name

Some times, the script fails at start and outputs this:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/dbus/bus.py", line 175, in activate_name_owner
    return self.get_name_owner(bus_name)
  File "/usr/lib/python3/dist-packages/dbus/bus.py", line 361, in get_name_owner
    's', (bus_name,), **keywords)
  File "/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NameHasNoOwner: Could not get owner of name 'org.PulseAudio1': no such name

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./apply-equalizer.py", line 70, in <module>
    'org.PulseAudio1', '/org/pulseaudio/server_lookup1')\
  File "/usr/lib/python3/dist-packages/dbus/bus.py", line 241, in get_object
    follow_name_owner_changes=follow_name_owner_changes)
  File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 248, in __init__
    self._named_service = conn.activate_name_owner(bus_name)
  File "/usr/lib/python3/dist-packages/dbus/bus.py", line 180, in activate_name_owner
    self.start_service_by_name(bus_name)
  File "/usr/lib/python3/dist-packages/dbus/bus.py", line 278, in start_service_by_name
    'su', (bus_name, flags)))
  File "/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name org.PulseAudio1 was not provided by any .service files

Running the script again doesn't change anything.

Logging out and in, it then succeeds.

Perhaps a bug in pulseaudio's module-dbus-protocol ?

Fail at start with "cannot look up address!"

Symptom:

./apply-equalizer.py

load dbus-module into PA
27
cannot look up address!
cannot look up address!
cannot look up address!
cannot look up address!
cannot look up address!
cannot look up address!

Goes on forever, about one line per second.
Ctrl-C does not kill process.
Manual kill with PID quits.
Running process again -> same failure.
pulseaudio -k then running again -> works

./apply-equalizer.py

load dbus-module into PA
17
Got pa-server address from dbus: unix:path=/run/user/1000/pulse/dbus-socket
Disabling persistence...
Current operation: saving configuration (disable-config)
-------------------------------------
Equalizer setting saved (disable-config).
-------------------------------------
Disabling...
PulseAudio Equalizer/LADSPA Processor 2.7 (05/02/2010)
-------------------------------------
Current operation: disabling equalizer
-------------------------------------
Unloading & reloading stream-restore module...
Unloading module-ladspa-sink...
Moving active PulseAudio clients to ALSA sink (alsa_output.pci-0000_00_1b.0.analog-stereo)...
Transferring current mute (0) & volume (45%) to ALSA sink (alsa_output.pci-0000_00_1b.0.analog-stereo)...
-------------------------------------
Equalizer status: [disabled]
Equalizer configuration status: [disabled]
-------------------------------------
connected to pulseaudio

Run as non-root: automatically adjust ~/.config/pulse/default.pa

For various reasons it is desirable to be able to run software as non-root. Example reasons: having several variants available for different users (e.g. developer using unstable version vs regular users wanting something less powerful that just works, or even the same user depending on time), systems where administrator cannot not approve that change quickly enough (security, policy, whatever).

Currently, this could mean that when

        dbus.connection.Connection(srv_addr)

fails with

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.FileNotFound: Failed to connect to socket /run/user/1000/pulse/dbus-socket: No such file or directory

The script automatically adds

load-module module-dbus-protocol

to the user's ~/.config/pulse/default.pa after checking that it's not already there ?

        pa_config_path = os.path.join(xdg_config_home, 'pulse', 'default.pa')
        with open(pa_config_path, "a") as pa_config_fh:
            pa_config_fh.write("load-module module-dbus-protocol\n")

Checking to avoid duplicates is important else we break pulseaudio for the user...

Run at login time

Currently the user has to manually run the script.

Let's figure out how to have it run at login time.

This may be more or less desktop-environment dependent (I'm using XFCE on Ubuntu.) but thanks to freedesktop.org there's probably a common way.

My first guess: look in /etc/xdg/autostart/ and add something there.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.