Skip to content

Commit cf4ca3c

Browse files
Fix ControlBinding::getValueArray with updated test.
1 parent f18ecd2 commit cf4ca3c

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

src/org/freedesktop/gstreamer/ControlBinding.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ public Object getValue(long timestamp) {
7474
* @return false if the given array could not be filled
7575
*/
7676
public boolean getValueArray(long timestamp, long interval, Object[] values) {
77-
GValueAPI.GValueArray gValues = new GValueAPI.GValueArray(values.length);
77+
GValueAPI.GValue[] gValues = new GValueAPI.GValue[values.length];
7878
boolean ok = GSTCONTROLBINDING_API.gst_control_binding_get_g_value_array(
7979
handle.getPointer(),
8080
timestamp,
8181
interval,
82-
gValues.n_values,
82+
gValues.length,
8383
gValues);
8484
if (ok) {
8585
for (int i = 0; i < values.length; i++) {
86-
values[i] = gValues.getValue(i);
86+
values[i] = gValues[i].getValue();
8787
}
8888
}
8989
return ok;

src/org/freedesktop/gstreamer/lowlevel/GstControlBindingAPI.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ boolean gst_control_binding_get_g_value_array(GstControlBindingPtr binding,
4444
long timestamp,
4545
long internal,
4646
int n_values,
47-
GValueAPI.GValueArray values);
47+
GValueAPI.GValue[] values);
4848

4949
void gst_control_binding_set_disabled(GstControlBindingPtr binding,
5050
boolean disabled);

test/org/freedesktop/gstreamer/controller/InterpolationControlSourceTest.java

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.freedesktop.gstreamer.controller;
22

3+
import java.util.Arrays;
34
import java.util.Collections;
45
import java.util.List;
56
import java.util.stream.Collectors;
@@ -16,6 +17,7 @@
1617
import org.junit.Before;
1718
import org.junit.BeforeClass;
1819
import org.junit.Test;
20+
1921
import static org.junit.Assert.*;
2022

2123
/**
@@ -115,13 +117,25 @@ public void testLinearInterpolationAbsolute() {
115117
controller.setFromList(timedValues);
116118

117119
Element volume = ElementFactory.make("volume", "volume");
118-
volume.addControlBinding(DirectControlBinding.createAbsolute(volume, "volume", controller));
120+
ControlBinding binding = DirectControlBinding.createAbsolute(volume, "volume", controller);
121+
122+
assertEquals(2.5,
123+
(Double) binding.getValue(ClockTime.fromMillis(500)),
124+
0.01);
125+
126+
Object[] values = new Object[3];
127+
binding.getValueArray(0, ClockTime.fromMillis(500), values);
128+
assertEquals(0, (Double) values[0], 0.01);
129+
assertEquals(2.5, (Double) values[1], 0.01);
130+
assertEquals(5, (Double) values[2], 0.01);
131+
132+
volume.addControlBinding(binding);
119133
volume.syncValues(0);
120-
assertEquals(0, ((Double) volume.get("volume")).doubleValue(), 0.001);
134+
assertEquals(0, ((Double) volume.get("volume")), 0.001);
121135
volume.syncValues(ClockTime.fromMillis(500));
122-
assertEquals(2.5, ((Double) volume.get("volume")).doubleValue(), 0.001);
136+
assertEquals(2.5, ((Double) volume.get("volume")), 0.001);
123137
volume.syncValues(ClockTime.fromSeconds(1));
124-
assertEquals(5, ((Double) volume.get("volume")).doubleValue(), 0.001);
138+
assertEquals(5, ((Double) volume.get("volume")), 0.001);
125139

126140
}
127141

0 commit comments

Comments
 (0)