Giter VIP home page Giter VIP logo

Comments (8)

hypfvieh avatar hypfvieh commented on July 17, 2024

I'm not sure what's wrong with your code, because it works for me on Ubuntu 16.04 (except of line 6 of your sample because the returned address is not a valid file/unix-socket on the file system).

Could you verify with e.g. 'd-feet' that your used parameters are available on Dbus.

from dbus-java.

Silveryard avatar Silveryard commented on July 17, 2024

Interestingly pulseaudios server lookup seems to return this path even if the dbus server is not active.
Make sure the pulses dbus protocol module is loaded. This can be done with 'pacmd load-module module-dbus-protocol'. After this the dbus-socket file should be avaliable

I get the same error with 17.04 and 16.04

from dbus-java.

hypfvieh avatar hypfvieh commented on July 17, 2024

Did you try 'd-feet' (apt-get install d-feet)? Is pulseaudio visable/accessable there?

from dbus-java.

Silveryard avatar Silveryard commented on July 17, 2024

When I try to connect to "unix:path=/run/user/1000/pulse/dbus-socket" d-feet just does nothing.
The CLI command "dbus-monitor --address "unix:path=/run/user/1000/pulse/dbus-socket"" gives me the same error as stated above.

One application that connects to the pulse dbus is qpaeq. qpaeq is used to control the pulseaudio equalizer and is essentially a python script. I read through the sourcecode and tried it myself. Connecting to the dbus-socket via python works just fine. I suspect that the python dbus library does not call the "Hello()" method when connecting

Edit: The problematic line always is the last one in my sample code

from dbus-java.

hypfvieh avatar hypfvieh commented on July 17, 2024

I guess I have found the problematic part.
In DBusConnection.getConnection(address), a new DBusConnection instance is created, which will 'self-register' the session to DBus.

This is done by calling dbus = getRemoteObject("org.freedesktop.DBus", "/org/freedesktop/DBus", DBus.class) and afterwards busnames.add(dbus.Hello()).

The call to dbus.Hello() will raise the Exception as described above.

I've added a workaround by adding a new variant of DBusConnection.getConnection which uses 2 parameters, the address and a boolean which will register or not register the session on Dbus.

In case of pulse audio, you have to use DBusConnection.getConnection(address, false) to get a working connection to pulse audio DBus address.

To test this feature, please download the source code and compile it yourself (should be working out-of-the-box using maven). Also update the referenced version in your project to 2.7.3-SNAPSHOT.

If your test is successful, please let me know, so I can create an upstream release on maven central.

After all, I'm not sure if this is a bug in dbus-java or more a bug in pulse audio which is not implementing the 'Hello()' method which seems to be called by most DBus-client application like dbus-monitor or d-feet.

from dbus-java.

Silveryard avatar Silveryard commented on July 17, 2024

This changes allow me to connect to the dbus. But as I cannot find any documentation on what bus names are present on this dbus server may be out of luck calling any functions. The python code in qpaeq does not expect a bus name whereas dbus-java does but neither '' nor '/' work.

You are right. In the end it's a bug in pulse audio.

from dbus-java.

hypfvieh avatar hypfvieh commented on July 17, 2024

"" and "/" are wrong. Check the source of qpaeq, they use something like "/org/pulseaudio/equalizing1" and "org.PulseAudio.Ext.Equalizing1.Manager" or "org.PulseAudio.Core1" and "/org/pulseaudio/core1".

So the code could look like this:

public static void main(String[] _args) throws DBusException {
        DBusConnection sessionConnection = DBusConnection.getConnection(DBusConnection.SESSION);

        Properties properties = sessionConnection.getRemoteObject("org.pulseaudio.Server", "/org/pulseaudio/server_lookup1", org.freedesktop.DBus.Properties.class);
        String address =  properties.Get("org.PulseAudio.ServerLookup1", "Address");

        System.out.println("Found address: " + address + "\n");

        sessionConnection.disconnect();

        File file = new File(address.replace("unix:path=", ""));
        if (!file.exists()) {
            System.out.println("Extracted address " + address + " is not a valid file/unix-socket");
        } else {
        	DBusConnection connection = DBusConnection.getConnection(address, false);

            Properties core1Props = connection.getRemoteObject("org.PulseAudio.Core1", "/org/pulseaudio/core1", org.freedesktop.DBus.Properties.class);
            System.out.println("PulseAudio Name: " + core1Props.Get("org.PulseAudio.Core1", "Name"));
            System.out.println("PulseAudio Version: " + core1Props.Get("org.PulseAudio.Core1", "Version"));

            System.out.println("-----------------------------------------");
            System.out.println("PulseAudio Hostname: " + core1Props.Get("org.PulseAudio.Core1", "Hostname"));
            System.out.println("PulseAudio Username: " + core1Props.Get("org.PulseAudio.Core1", "Username"));

            connection.disconnect();
        }

This code will print something like:

Found address: unix:path=/run/user/1000/pulse/dbus-socket

PulseAudio Name: pulseaudio
PulseAudio Version: 8.0
-----------------------------------------
PulseAudio Hostname: penguin
PulseAudio Username: hypfvieh

For more details on the DBus specs for PulseAudio, take a look here:
https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/Clients/DBus/

from dbus-java.

Silveryard avatar Silveryard commented on July 17, 2024

Thank you very much :) I think this issue can be closed

from dbus-java.

Related Issues (20)

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.