StreamVolume.getType() only returns null #295

Closed
opened 2025-11-03 18:11:56 +01:00 by Nyeksenn · 2 comments
Nyeksenn commented 2025-11-03 18:11:56 +01:00 (Migrated from github.com)

I am currently trying to use Gstreamers Bin.getByInterface method to obtain an object which implements StreamVolume
from my pipeline. This method takes a org.gnome.glib.Type as an argument.
However, if I try to obtain this by calling StreamVolume.getType(), it always returns null even though
it is a static method. I currently use jars built from main.

var type = StreamVolume.getType();
// type is always null
var sink = (StreamVolume) this.pipeline.pipeline.getByInterface(type);
I am currently trying to use Gstreamers Bin.getByInterface method to obtain an object which implements StreamVolume from my pipeline. This method takes a org.gnome.glib.Type as an argument. However, if I try to obtain this by calling StreamVolume.getType(), it always returns null even though it is a static method. I currently use jars built from main. ```java var type = StreamVolume.getType(); // type is always null var sink = (StreamVolume) this.pipeline.pipeline.getByInterface(type); ```
jwharm commented 2025-11-03 22:06:20 +01:00 (Migrated from github.com)

This happens when the native library hasn't been loaded. Add this line at the start of your app:

GstAudio.javagi$ensureInitialized();

All classes in the GstAudio module have this line in a static initializer block, so this is triggered automatically by Java's classloader. But interfaces don't support static initializers, so when you use an interface (before a class), you need to manually force the initialization.

This happens when the native library hasn't been loaded. Add this line at the start of your app: ```java GstAudio.javagi$ensureInitialized(); ``` All classes in the GstAudio module have this line in a static initializer block, so this is triggered automatically by Java's classloader. But interfaces don't support static initializers, so when you use an interface (before a class), you need to manually force the initialization.
Nyeksenn commented 2025-11-04 21:33:18 +01:00 (Migrated from github.com)

Ok, good to know. Thanks.

Ok, good to know. Thanks.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
java-gi/java-gi#295
No description provided.