Skip to content

Commit 74b47cf

Browse files
committed
test/libmpv_test_sdh_filter: start test paused and at 1 second
There is some race condition where MPV_EVENT_PROPERTY_CHANGE sometimes gives us sub-text with an empty string which is unwanted and causes the test to fail. Avoid this by starting the file at 1 second and paused which hopefully avoids this. Do some additional checking on the actual MPV_EVENT_PROPERTY_CHANGE as well to make sure we don't try to read something we shouldn't.
1 parent be98b35 commit 74b47cf

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

test/libmpv_test_sdh_filter.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static void test_sdh_filter(char *file, char *path, char *harder)
6363
switch (event->event_id) {
6464
case MPV_EVENT_PROPERTY_CHANGE: {
6565
mpv_event_property *prop = event->data;
66-
if (strcmp(prop->name, "sub-text") == 0) {
66+
if (prop->format == MPV_FORMAT_STRING && strcmp(prop->name, "sub-text") == 0) {
6767
char *value = *(char **)(prop->data);
6868
if (!value || strcmp(expect, value) != 0)
6969
fail("String: expected '%s' but got '%s'!\n", expect, value);
@@ -90,6 +90,9 @@ int main(int argc, char *argv[])
9090

9191
const char *fmt = "================ TEST: %s %s ================\n";
9292
printf(fmt, "test_sdh_filter", argv[1]);
93+
// Set pause and start from 1 second to ensure the subtitle is loaded.
94+
mpv_set_property_string(ctx, "pause", "yes");
95+
mpv_set_property_string(ctx, "start", "1");
9396
mpv_observe_property(ctx, 0, "sub-text", MPV_FORMAT_STRING);
9497
test_sdh_filter(argv[1], argv[2], argv[3]);
9598
printf("================ SHUTDOWN ================\n");

0 commit comments

Comments
 (0)