|
21 | 21 |
|
22 | 22 | package org.freedesktop.gstreamer; |
23 | 23 |
|
| 24 | +import com.sun.jna.Native; |
24 | 25 | import com.sun.jna.Pointer; |
25 | 26 |
|
26 | 27 | import org.freedesktop.gstreamer.lowlevel.GType; |
@@ -49,9 +50,15 @@ public MiniObject(Initializer init) { |
49 | 50 | * Gives the type value. |
50 | 51 | */ |
51 | 52 | public static GType getType(Pointer ptr) { |
52 | | - // Quick getter for GType without allocation |
53 | | - // same as : new MiniObjectStruct(ptr).type |
54 | | - return GType.valueOf(ptr.getNativeLong(0).longValue()); |
| 53 | + // Quick getter for GType without allocation |
| 54 | + // same as : new MiniObjectStruct(ptr).type |
| 55 | + if (Native.SIZE_T_SIZE == 8) { |
| 56 | + return GType.valueOf(ptr.getLong(0)); |
| 57 | + } else if (Native.SIZE_T_SIZE == 4) { |
| 58 | + return GType.valueOf( ((long) ptr.getInt(0)) & 0xffffffffL ); |
| 59 | + } else { |
| 60 | + throw new IllegalStateException("SIZE_T size not supported: " + Native.SIZE_T_SIZE); |
| 61 | + } |
55 | 62 | } |
56 | 63 |
|
57 | 64 | /** |
@@ -87,32 +94,32 @@ protected <T extends MiniObject> T makeWritable() { |
87 | 94 | * @return the new MiniObject. |
88 | 95 | */ |
89 | 96 | public <T extends MiniObject> T copy() { |
90 | | - MiniObject result = GSTMINIOBJECT_API.gst_mini_object_copy(this); |
| 97 | + MiniObject result = GSTMINIOBJECT_API.gst_mini_object_copy(this); |
91 | 98 | if (result == null) { |
92 | 99 | throw new NullPointerException("Could not make a copy of " + this.getClass().getSimpleName()); |
93 | 100 | } |
94 | 101 | return (T)result; |
95 | 102 | } |
96 | 103 |
|
97 | 104 | @Override |
98 | | - protected void ref() { |
| 105 | + protected void ref() { |
99 | 106 | GSTMINIOBJECT_API.gst_mini_object_ref(this); |
100 | 107 | } |
101 | | - |
| 108 | + |
102 | 109 | @Override |
103 | | - protected void unref() { |
104 | | - GSTMINIOBJECT_API.gst_mini_object_unref(this); |
| 110 | + protected void unref() { |
| 111 | + GSTMINIOBJECT_API.gst_mini_object_unref(this); |
105 | 112 | } |
106 | 113 |
|
107 | 114 | public int getRefCount() { |
108 | | - final MiniObjectStruct struct = new MiniObjectStruct(handle()); |
109 | | - return (Integer) struct.readField("refcount"); |
| 115 | + final MiniObjectStruct struct = new MiniObjectStruct(handle()); |
| 116 | + return (Integer) struct.readField("refcount"); |
110 | 117 | } |
111 | 118 |
|
112 | 119 | @Override |
113 | | - protected void disposeNativeHandle(Pointer ptr) { |
114 | | - if (ownsHandle.get()) { |
115 | | - GSTMINIOBJECT_API.gst_mini_object_unref(ptr); |
116 | | - } |
117 | | - } |
| 120 | + protected void disposeNativeHandle(Pointer ptr) { |
| 121 | + if (ownsHandle.get()) { |
| 122 | + GSTMINIOBJECT_API.gst_mini_object_unref(ptr); |
| 123 | + } |
| 124 | + } |
118 | 125 | } |
0 commit comments