Comments (8)
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.
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.
Did you try 'd-feet' (apt-get install d-feet)? Is pulseaudio visable/accessable there?
from dbus-java.
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.
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.
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.
"" 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.
Thank you very much :) I think this issue can be closed
from dbus-java.
Related Issues (20)
- DBusSignal constructor is package private HOT 1
- Kotlin Interface does not work HOT 3
- NPE in org.freedesktop.dbus.connections.AbstractConnection.internalDisconnect(IOException) prevents JVM shutdown HOT 4
- Documentation example does not work correctly. HOT 1
- In version 5, `withAutoConnect(false)` appears broken. HOT 2
- Cleanup AbstractConnection
- `default` interface methods. Or not. HOT 7
- problem to execute DBusViewer HOT 3
- How to export/publish Property in interface? HOT 2
- Properties Get method endless waiting HOT 1
- Cannot connect to DBUS HOT 11
- Sending signal with byte[] fails with verbose logging HOT 1
- [Feature request] Any plan in adding a module-info ? HOT 2
- Custom ITransportProvider cannot be found by ServiceLoader HOT 4
- Something a bit wrong with `@DBusBoundProperty` HOT 9
- Incorrect code generation for systemd StartTransientUnit HOT 3
- Add dbus-java-transport-junixsocket to dbus-java-bom
- Help with DBusConnectionBuilder HOT 2
- CodeGenerator does not create @DBusBoundProperty annotated fields properly for types TypeRef ans Struct HOT 2
- GetAll is not callable when using @DBusBoundProperty on a List<DBusPath> property HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dbus-java.