/src/mpv/fuzzers/common.h
Line | Count | Source |
1 | | /* |
2 | | * This file is part of mpv. |
3 | | * |
4 | | * mpv is free software; you can redistribute it and/or |
5 | | * modify it under the terms of the GNU Lesser General Public |
6 | | * License as published by the Free Software Foundation; either |
7 | | * version 2.1 of the License, or (at your option) any later version. |
8 | | * |
9 | | * mpv is distributed in the hope that it will be useful, |
10 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | | * GNU Lesser General Public License for more details. |
13 | | * |
14 | | * You should have received a copy of the GNU Lesser General Public |
15 | | * License along with mpv. If not, see <http://www.gnu.org/licenses/>. |
16 | | */ |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include <limits.h> |
21 | | #include <stdbool.h> |
22 | | #include <stdint.h> |
23 | | #include <stdio.h> |
24 | | #include <stdlib.h> |
25 | | #include <string.h> |
26 | | #include <unistd.h> |
27 | | |
28 | | #include <mpv/client.h> |
29 | | |
30 | 218k | #define MAX_FUZZ_SIZE (100 << 10) // 100 KiB |
31 | | |
32 | | int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); |
33 | | |
34 | 550k | #define MPV_STRINGIFY_(X) #X |
35 | 550k | #define MPV_STRINGIFY(X) MPV_STRINGIFY_(X) |
36 | | |
37 | | static inline void check_error(int status) |
38 | 3.44M | { |
39 | 3.44M | if (status < 0) { |
40 | 0 | fprintf(stderr, "mpv API error: %s\n", mpv_error_string(status)); |
41 | 0 | exit(1); |
42 | 0 | } |
43 | 3.44M | } fuzzer_loadfile_direct.c:check_error Line | Count | Source | 38 | 1.58M | { | 39 | 1.58M | if (status < 0) { | 40 | | fprintf(stderr, "mpv API error: %s\n", mpv_error_string(status)); | 41 | 0 | exit(1); | 42 | 0 | } | 43 | 1.58M | } |
fuzzer_options_parser.c:check_error Line | Count | Source | 38 | 16.4k | { | 39 | 16.4k | if (status < 0) { | 40 | | fprintf(stderr, "mpv API error: %s\n", mpv_error_string(status)); | 41 | 0 | exit(1); | 42 | 0 | } | 43 | 16.4k | } |
fuzzer_load.c:check_error Line | Count | Source | 38 | 1.28M | { | 39 | 1.28M | if (status < 0) { | 40 | | fprintf(stderr, "mpv API error: %s\n", mpv_error_string(status)); | 41 | 0 | exit(1); | 42 | 0 | } | 43 | 1.28M | } |
fuzzer_set_property.c:check_error Line | Count | Source | 38 | 441k | { | 39 | 441k | if (status < 0) { | 40 | | fprintf(stderr, "mpv API error: %s\n", mpv_error_string(status)); | 41 | 0 | exit(1); | 42 | 0 | } | 43 | 441k | } |
Unexecuted instantiation: fuzzer_json.c:check_error Line | Count | Source | 38 | 116k | { | 39 | 116k | if (status < 0) { | 40 | | fprintf(stderr, "mpv API error: %s\n", mpv_error_string(status)); | 41 | 0 | exit(1); | 42 | 0 | } | 43 | 116k | } |
|
44 | | |
45 | | static inline bool str_startswith(const char *str, size_t str_len, |
46 | | const char *prefix, size_t prefix_len) |
47 | 116k | { |
48 | 116k | if (str_len < prefix_len) |
49 | 21 | return false; |
50 | 116k | return !memcmp(str, prefix, prefix_len); |
51 | 116k | } fuzzer_loadfile_direct.c:str_startswith Line | Count | Source | 47 | 116k | { | 48 | 116k | if (str_len < prefix_len) | 49 | 21 | return false; | 50 | 116k | return !memcmp(str, prefix, prefix_len); | 51 | 116k | } |
Unexecuted instantiation: fuzzer_options_parser.c:str_startswith Unexecuted instantiation: fuzzer_load.c:str_startswith Unexecuted instantiation: fuzzer_set_property.c:str_startswith Unexecuted instantiation: fuzzer_json.c:str_startswith Unexecuted instantiation: fuzzer_ipc.c:str_startswith |
52 | | |
53 | | static inline void set_fontconfig_sysroot(void) |
54 | 317k | { |
55 | 317k | #ifdef MPV_FONTCONFIG_SYSROOT |
56 | 317k | const char *sysroot = MPV_STRINGIFY(MPV_FONTCONFIG_SYSROOT); |
57 | 317k | char path[PATH_MAX]; |
58 | 317k | if (sysroot[0] != '/') { |
59 | 317k | ssize_t len = readlink("/proc/self/exe", path, sizeof(path) - 1); |
60 | 317k | if (len < 0) |
61 | 0 | exit(1); |
62 | 317k | path[len] = '\0'; |
63 | 317k | char *name = strrchr(path, '/') + 1; |
64 | 317k | snprintf(name, path + sizeof(path) - name, "%s", sysroot); |
65 | 317k | sysroot = path; |
66 | 317k | } |
67 | 317k | setenv("FONTCONFIG_SYSROOT", sysroot, 1); |
68 | 317k | #endif |
69 | 317k | } fuzzer_loadfile_direct.c:set_fontconfig_sysroot Line | Count | Source | 54 | 144k | { | 55 | 144k | #ifdef MPV_FONTCONFIG_SYSROOT | 56 | 144k | const char *sysroot = MPV_STRINGIFY(MPV_FONTCONFIG_SYSROOT); | 57 | 144k | char path[PATH_MAX]; | 58 | 144k | if (sysroot[0] != '/') { | 59 | 144k | ssize_t len = readlink("/proc/self/exe", path, sizeof(path) - 1); | 60 | 144k | if (len < 0) | 61 | 0 | exit(1); | 62 | 144k | path[len] = '\0'; | 63 | 144k | char *name = strrchr(path, '/') + 1; | 64 | 144k | snprintf(name, path + sizeof(path) - name, "%s", sysroot); | 65 | 144k | sysroot = path; | 66 | 144k | } | 67 | 144k | setenv("FONTCONFIG_SYSROOT", sysroot, 1); | 68 | 144k | #endif | 69 | 144k | } |
fuzzer_options_parser.c:set_fontconfig_sysroot Line | Count | Source | 54 | 16.4k | { | 55 | 16.4k | #ifdef MPV_FONTCONFIG_SYSROOT | 56 | 16.4k | const char *sysroot = MPV_STRINGIFY(MPV_FONTCONFIG_SYSROOT); | 57 | 16.4k | char path[PATH_MAX]; | 58 | 16.4k | if (sysroot[0] != '/') { | 59 | 16.4k | ssize_t len = readlink("/proc/self/exe", path, sizeof(path) - 1); | 60 | 16.4k | if (len < 0) | 61 | 0 | exit(1); | 62 | 16.4k | path[len] = '\0'; | 63 | 16.4k | char *name = strrchr(path, '/') + 1; | 64 | 16.4k | snprintf(name, path + sizeof(path) - name, "%s", sysroot); | 65 | 16.4k | sysroot = path; | 66 | 16.4k | } | 67 | 16.4k | setenv("FONTCONFIG_SYSROOT", sysroot, 1); | 68 | 16.4k | #endif | 69 | 16.4k | } |
fuzzer_load.c:set_fontconfig_sysroot Line | Count | Source | 54 | 105k | { | 55 | 105k | #ifdef MPV_FONTCONFIG_SYSROOT | 56 | 105k | const char *sysroot = MPV_STRINGIFY(MPV_FONTCONFIG_SYSROOT); | 57 | 105k | char path[PATH_MAX]; | 58 | 105k | if (sysroot[0] != '/') { | 59 | 105k | ssize_t len = readlink("/proc/self/exe", path, sizeof(path) - 1); | 60 | 105k | if (len < 0) | 61 | 0 | exit(1); | 62 | 105k | path[len] = '\0'; | 63 | 105k | char *name = strrchr(path, '/') + 1; | 64 | 105k | snprintf(name, path + sizeof(path) - name, "%s", sysroot); | 65 | 105k | sysroot = path; | 66 | 105k | } | 67 | 105k | setenv("FONTCONFIG_SYSROOT", sysroot, 1); | 68 | 105k | #endif | 69 | 105k | } |
fuzzer_set_property.c:set_fontconfig_sysroot Line | Count | Source | 54 | 38.8k | { | 55 | 38.8k | #ifdef MPV_FONTCONFIG_SYSROOT | 56 | 38.8k | const char *sysroot = MPV_STRINGIFY(MPV_FONTCONFIG_SYSROOT); | 57 | 38.8k | char path[PATH_MAX]; | 58 | 38.8k | if (sysroot[0] != '/') { | 59 | 38.8k | ssize_t len = readlink("/proc/self/exe", path, sizeof(path) - 1); | 60 | 38.8k | if (len < 0) | 61 | 0 | exit(1); | 62 | 38.8k | path[len] = '\0'; | 63 | 38.8k | char *name = strrchr(path, '/') + 1; | 64 | 38.8k | snprintf(name, path + sizeof(path) - name, "%s", sysroot); | 65 | 38.8k | sysroot = path; | 66 | 38.8k | } | 67 | 38.8k | setenv("FONTCONFIG_SYSROOT", sysroot, 1); | 68 | 38.8k | #endif | 69 | 38.8k | } |
Unexecuted instantiation: fuzzer_json.c:set_fontconfig_sysroot fuzzer_ipc.c:set_fontconfig_sysroot Line | Count | Source | 54 | 11.6k | { | 55 | 11.6k | #ifdef MPV_FONTCONFIG_SYSROOT | 56 | 11.6k | const char *sysroot = MPV_STRINGIFY(MPV_FONTCONFIG_SYSROOT); | 57 | 11.6k | char path[PATH_MAX]; | 58 | 11.6k | if (sysroot[0] != '/') { | 59 | 11.6k | ssize_t len = readlink("/proc/self/exe", path, sizeof(path) - 1); | 60 | 11.6k | if (len < 0) | 61 | 0 | exit(1); | 62 | 11.6k | path[len] = '\0'; | 63 | 11.6k | char *name = strrchr(path, '/') + 1; | 64 | 11.6k | snprintf(name, path + sizeof(path) - name, "%s", sysroot); | 65 | 11.6k | sysroot = path; | 66 | 11.6k | } | 67 | 11.6k | setenv("FONTCONFIG_SYSROOT", sysroot, 1); | 68 | 11.6k | #endif | 69 | 11.6k | } |
|
70 | | |
71 | | static inline bool wait_event(mpv_handle *ctx, mpv_event_id id) |
72 | 278k | { |
73 | 278k | while (1) { |
74 | 278k | mpv_event *event = mpv_wait_event(ctx, -1); |
75 | 278k | if (event->event_id == id) |
76 | 278k | return true; |
77 | 0 | if (event->event_id == MPV_EVENT_SHUTDOWN) |
78 | 0 | return false; |
79 | 0 | } |
80 | 278k | } fuzzer_loadfile_direct.c:wait_event Line | Count | Source | 72 | 144k | { | 73 | 144k | while (1) { | 74 | 144k | mpv_event *event = mpv_wait_event(ctx, -1); | 75 | 144k | if (event->event_id == id) | 76 | 144k | return true; | 77 | 0 | if (event->event_id == MPV_EVENT_SHUTDOWN) | 78 | 0 | return false; | 79 | 0 | } | 80 | 144k | } |
fuzzer_options_parser.c:wait_event Line | Count | Source | 72 | 16.4k | { | 73 | 16.4k | while (1) { | 74 | 16.4k | mpv_event *event = mpv_wait_event(ctx, -1); | 75 | 16.4k | if (event->event_id == id) | 76 | 16.4k | return true; | 77 | 0 | if (event->event_id == MPV_EVENT_SHUTDOWN) | 78 | 0 | return false; | 79 | 0 | } | 80 | 16.4k | } |
Line | Count | Source | 72 | 105k | { | 73 | 105k | while (1) { | 74 | 105k | mpv_event *event = mpv_wait_event(ctx, -1); | 75 | 105k | if (event->event_id == id) | 76 | 105k | return true; | 77 | 0 | if (event->event_id == MPV_EVENT_SHUTDOWN) | 78 | 0 | return false; | 79 | 0 | } | 80 | 105k | } |
Unexecuted instantiation: fuzzer_set_property.c:wait_event Unexecuted instantiation: fuzzer_json.c:wait_event Line | Count | Source | 72 | 11.6k | { | 73 | 11.6k | while (1) { | 74 | 11.6k | mpv_event *event = mpv_wait_event(ctx, -1); | 75 | 11.6k | if (event->event_id == id) | 76 | 11.6k | return true; | 77 | 0 | if (event->event_id == MPV_EVENT_SHUTDOWN) | 78 | 0 | return false; | 79 | 0 | } | 80 | 11.6k | } |
|
81 | | |
82 | | // Waits for the core thread to process the current iteration and any pending requests. |
83 | | static inline bool sync_core(mpv_handle *ctx) |
84 | 579k | { |
85 | 579k | uint64_t sync_id = 1; |
86 | 579k | mpv_observe_property(ctx, sync_id, "user-data/fuzzer-sync", MPV_FORMAT_NONE); |
87 | 579k | bool ok; |
88 | 606k | while (1) { |
89 | 606k | mpv_event *event = mpv_wait_event(ctx, -1); |
90 | 606k | ok = event->event_id != MPV_EVENT_SHUTDOWN; |
91 | 606k | if (!ok || (event->event_id == MPV_EVENT_PROPERTY_CHANGE && |
92 | 300k | event->reply_userdata == sync_id)) |
93 | 579k | break; |
94 | 606k | } |
95 | 579k | mpv_unobserve_property(ctx, sync_id); |
96 | 579k | return ok; |
97 | 579k | } fuzzer_loadfile_direct.c:sync_core Line | Count | Source | 84 | 288k | { | 85 | 288k | uint64_t sync_id = 1; | 86 | 288k | mpv_observe_property(ctx, sync_id, "user-data/fuzzer-sync", MPV_FORMAT_NONE); | 87 | 288k | bool ok; | 88 | 289k | while (1) { | 89 | 289k | mpv_event *event = mpv_wait_event(ctx, -1); | 90 | 289k | ok = event->event_id != MPV_EVENT_SHUTDOWN; | 91 | 289k | if (!ok || (event->event_id == MPV_EVENT_PROPERTY_CHANGE && | 92 | 145k | event->reply_userdata == sync_id)) | 93 | 288k | break; | 94 | 289k | } | 95 | 288k | mpv_unobserve_property(ctx, sync_id); | 96 | 288k | return ok; | 97 | 288k | } |
Unexecuted instantiation: fuzzer_options_parser.c:sync_core Line | Count | Source | 84 | 211k | { | 85 | 211k | uint64_t sync_id = 1; | 86 | 211k | mpv_observe_property(ctx, sync_id, "user-data/fuzzer-sync", MPV_FORMAT_NONE); | 87 | 211k | bool ok; | 88 | 218k | while (1) { | 89 | 218k | mpv_event *event = mpv_wait_event(ctx, -1); | 90 | 218k | ok = event->event_id != MPV_EVENT_SHUTDOWN; | 91 | 218k | if (!ok || (event->event_id == MPV_EVENT_PROPERTY_CHANGE && | 92 | 106k | event->reply_userdata == sync_id)) | 93 | 211k | break; | 94 | 218k | } | 95 | 211k | mpv_unobserve_property(ctx, sync_id); | 96 | 211k | return ok; | 97 | 211k | } |
fuzzer_set_property.c:sync_core Line | Count | Source | 84 | 55.6k | { | 85 | 55.6k | uint64_t sync_id = 1; | 86 | 55.6k | mpv_observe_property(ctx, sync_id, "user-data/fuzzer-sync", MPV_FORMAT_NONE); | 87 | 55.6k | bool ok; | 88 | 55.7k | while (1) { | 89 | 55.7k | mpv_event *event = mpv_wait_event(ctx, -1); | 90 | 55.7k | ok = event->event_id != MPV_EVENT_SHUTDOWN; | 91 | 55.7k | if (!ok || (event->event_id == MPV_EVENT_PROPERTY_CHANGE && | 92 | 27.8k | event->reply_userdata == sync_id)) | 93 | 55.6k | break; | 94 | 55.7k | } | 95 | 55.6k | mpv_unobserve_property(ctx, sync_id); | 96 | 55.6k | return ok; | 97 | 55.6k | } |
Unexecuted instantiation: fuzzer_json.c:sync_core Line | Count | Source | 84 | 23.3k | { | 85 | 23.3k | uint64_t sync_id = 1; | 86 | 23.3k | mpv_observe_property(ctx, sync_id, "user-data/fuzzer-sync", MPV_FORMAT_NONE); | 87 | 23.3k | bool ok; | 88 | 42.8k | while (1) { | 89 | 42.8k | mpv_event *event = mpv_wait_event(ctx, -1); | 90 | 42.8k | ok = event->event_id != MPV_EVENT_SHUTDOWN; | 91 | 42.8k | if (!ok || (event->event_id == MPV_EVENT_PROPERTY_CHANGE && | 92 | 21.5k | event->reply_userdata == sync_id)) | 93 | 23.3k | break; | 94 | 42.8k | } | 95 | 23.3k | mpv_unobserve_property(ctx, sync_id); | 96 | 23.3k | return ok; | 97 | 23.3k | } |
|
98 | | |
99 | | static inline void initialize(mpv_handle *ctx) |
100 | 289k | { |
101 | 289k | check_error(mpv_initialize(ctx)); |
102 | 289k | if (!wait_event(ctx, MPV_EVENT_IDLE) || !sync_core(ctx)) |
103 | 0 | exit(1); |
104 | 289k | } fuzzer_loadfile_direct.c:initialize Line | Count | Source | 100 | 144k | { | 101 | 144k | check_error(mpv_initialize(ctx)); | 102 | 144k | if (!wait_event(ctx, MPV_EVENT_IDLE) || !sync_core(ctx)) | 103 | 0 | exit(1); | 104 | 144k | } |
Unexecuted instantiation: fuzzer_options_parser.c:initialize Line | Count | Source | 100 | 105k | { | 101 | 105k | check_error(mpv_initialize(ctx)); | 102 | 105k | if (!wait_event(ctx, MPV_EVENT_IDLE) || !sync_core(ctx)) | 103 | 0 | exit(1); | 104 | 105k | } |
Unexecuted instantiation: fuzzer_json.c:initialize fuzzer_set_property.c:initialize Line | Count | Source | 100 | 27.8k | { | 101 | 27.8k | check_error(mpv_initialize(ctx)); | 102 | 27.8k | if (!wait_event(ctx, MPV_EVENT_IDLE) || !sync_core(ctx)) | 103 | 0 | exit(1); | 104 | 27.8k | } |
Line | Count | Source | 100 | 11.6k | { | 101 | 11.6k | check_error(mpv_initialize(ctx)); | 102 | 11.6k | if (!wait_event(ctx, MPV_EVENT_IDLE) || !sync_core(ctx)) | 103 | 0 | exit(1); | 104 | 11.6k | } |
|
105 | | |
106 | | static inline void destroy(mpv_handle *ctx) |
107 | 300k | { |
108 | 300k | if (mpv_command(ctx, (const char *[]){"quit", NULL}) != MPV_ERROR_UNINITIALIZED) |
109 | 289k | sync_core(ctx); |
110 | 300k | mpv_terminate_destroy(ctx); |
111 | 300k | } fuzzer_loadfile_direct.c:destroy Line | Count | Source | 107 | 144k | { | 108 | 144k | if (mpv_command(ctx, (const char *[]){"quit", NULL}) != MPV_ERROR_UNINITIALIZED) | 109 | 144k | sync_core(ctx); | 110 | 144k | mpv_terminate_destroy(ctx); | 111 | 144k | } |
Unexecuted instantiation: fuzzer_options_parser.c:destroy Line | Count | Source | 107 | 105k | { | 108 | 105k | if (mpv_command(ctx, (const char *[]){"quit", NULL}) != MPV_ERROR_UNINITIALIZED) | 109 | 105k | sync_core(ctx); | 110 | 105k | mpv_terminate_destroy(ctx); | 111 | 105k | } |
fuzzer_set_property.c:destroy Line | Count | Source | 107 | 38.8k | { | 108 | 38.8k | if (mpv_command(ctx, (const char *[]){"quit", NULL}) != MPV_ERROR_UNINITIALIZED) | 109 | 27.8k | sync_core(ctx); | 110 | 38.8k | mpv_terminate_destroy(ctx); | 111 | 38.8k | } |
Unexecuted instantiation: fuzzer_json.c:destroy Line | Count | Source | 107 | 11.6k | { | 108 | 11.6k | if (mpv_command(ctx, (const char *[]){"quit", NULL}) != MPV_ERROR_UNINITIALIZED) | 109 | 11.6k | sync_core(ctx); | 110 | 11.6k | mpv_terminate_destroy(ctx); | 111 | 11.6k | } |
|
112 | | |
113 | | #ifndef PLAYBACK_TIME_LIMIT |
114 | 12.5M | #define PLAYBACK_TIME_LIMIT 1 |
115 | | #endif |
116 | | |
117 | | #ifndef EVENTS_LIMIT |
118 | 1.05M | #define EVENTS_LIMIT 10 |
119 | | #endif |
120 | | |
121 | | static inline void player_loop(mpv_handle *ctx) |
122 | 249k | { |
123 | 249k | bool playing = false; |
124 | 249k | bool loaded = false; |
125 | 249k | int timeout = -1; |
126 | 249k | int events_limit_after_restart = EVENTS_LIMIT; |
127 | 3.08M | while (1) { |
128 | 3.08M | mpv_event *event = mpv_wait_event(ctx, timeout); |
129 | | // If some events are spamming, like audio-reconfig preventing our |
130 | | // timeout to trigger stop after N events. |
131 | 3.08M | if (timeout == PLAYBACK_TIME_LIMIT && events_limit_after_restart-- < 0) |
132 | 1.01k | break; |
133 | 3.08M | if (timeout == PLAYBACK_TIME_LIMIT && event->event_id == MPV_EVENT_NONE) |
134 | 166 | break; |
135 | 3.08M | if (event->event_id == MPV_EVENT_START_FILE) |
136 | 785k | loaded = playing = true; |
137 | 3.08M | if (event->event_id == MPV_EVENT_END_FILE) { |
138 | 784k | playing = false; |
139 | 784k | events_limit_after_restart = EVENTS_LIMIT; |
140 | 784k | timeout = -1; |
141 | 784k | } |
142 | 3.08M | if (playing && event->event_id == MPV_EVENT_PLAYBACK_RESTART) |
143 | 178k | timeout = PLAYBACK_TIME_LIMIT; |
144 | 3.08M | if (loaded && event->event_id == MPV_EVENT_IDLE) |
145 | 248k | break; |
146 | 3.08M | } |
147 | 249k | } fuzzer_loadfile_direct.c:player_loop Line | Count | Source | 122 | 144k | { | 123 | 144k | bool playing = false; | 124 | 144k | bool loaded = false; | 125 | 144k | int timeout = -1; | 126 | 144k | int events_limit_after_restart = EVENTS_LIMIT; | 127 | 2.04M | while (1) { | 128 | 2.04M | mpv_event *event = mpv_wait_event(ctx, timeout); | 129 | | // If some events are spamming, like audio-reconfig preventing our | 130 | | // timeout to trigger stop after N events. | 131 | 2.04M | if (timeout == PLAYBACK_TIME_LIMIT && events_limit_after_restart-- < 0) | 132 | 783 | break; | 133 | 2.04M | if (timeout == PLAYBACK_TIME_LIMIT && event->event_id == MPV_EVENT_NONE) | 134 | 91 | break; | 135 | 2.04M | if (event->event_id == MPV_EVENT_START_FILE) | 136 | 680k | loaded = playing = true; | 137 | 2.04M | if (event->event_id == MPV_EVENT_END_FILE) { | 138 | 679k | playing = false; | 139 | 679k | events_limit_after_restart = EVENTS_LIMIT; | 140 | 679k | timeout = -1; | 141 | 679k | } | 142 | 2.04M | if (playing && event->event_id == MPV_EVENT_PLAYBACK_RESTART) | 143 | 86.1k | timeout = PLAYBACK_TIME_LIMIT; | 144 | 2.04M | if (loaded && event->event_id == MPV_EVENT_IDLE) | 145 | 143k | break; | 146 | 2.04M | } | 147 | 144k | } |
Unexecuted instantiation: fuzzer_options_parser.c:player_loop Unexecuted instantiation: fuzzer_load.c:player_loop fuzzer_load.c:player_loop Line | Count | Source | 122 | 85.1k | { | 123 | 85.1k | bool playing = false; | 124 | 85.1k | bool loaded = false; | 125 | 85.1k | int timeout = -1; | 126 | 85.1k | int events_limit_after_restart = EVENTS_LIMIT; | 127 | 756k | while (1) { | 128 | 756k | mpv_event *event = mpv_wait_event(ctx, timeout); | 129 | | // If some events are spamming, like audio-reconfig preventing our | 130 | | // timeout to trigger stop after N events. | 131 | 756k | if (timeout == PLAYBACK_TIME_LIMIT && events_limit_after_restart-- < 0) | 132 | 229 | break; | 133 | 756k | if (timeout == PLAYBACK_TIME_LIMIT && event->event_id == MPV_EVENT_NONE) | 134 | 14 | break; | 135 | 756k | if (event->event_id == MPV_EVENT_START_FILE) | 136 | 85.1k | loaded = playing = true; | 137 | 756k | if (event->event_id == MPV_EVENT_END_FILE) { | 138 | 84.8k | playing = false; | 139 | 84.8k | events_limit_after_restart = EVENTS_LIMIT; | 140 | 84.8k | timeout = -1; | 141 | 84.8k | } | 142 | 756k | if (playing && event->event_id == MPV_EVENT_PLAYBACK_RESTART) | 143 | 72.6k | timeout = PLAYBACK_TIME_LIMIT; | 144 | 756k | if (loaded && event->event_id == MPV_EVENT_IDLE) | 145 | 84.8k | break; | 146 | 756k | } | 147 | 85.1k | } |
Unexecuted instantiation: fuzzer_set_property.c:player_loop Unexecuted instantiation: fuzzer_json.c:player_loop fuzzer_set_property.c:player_loop Line | Count | Source | 122 | 20.1k | { | 123 | 20.1k | bool playing = false; | 124 | 20.1k | bool loaded = false; | 125 | 20.1k | int timeout = -1; | 126 | 20.1k | int events_limit_after_restart = EVENTS_LIMIT; | 127 | 274k | while (1) { | 128 | 274k | mpv_event *event = mpv_wait_event(ctx, timeout); | 129 | | // If some events are spamming, like audio-reconfig preventing our | 130 | | // timeout to trigger stop after N events. | 131 | 274k | if (timeout == PLAYBACK_TIME_LIMIT && events_limit_after_restart-- < 0) | 132 | 0 | break; | 133 | 274k | if (timeout == PLAYBACK_TIME_LIMIT && event->event_id == MPV_EVENT_NONE) | 134 | 61 | break; | 135 | 274k | if (event->event_id == MPV_EVENT_START_FILE) | 136 | 20.1k | loaded = playing = true; | 137 | 274k | if (event->event_id == MPV_EVENT_END_FILE) { | 138 | 20.0k | playing = false; | 139 | 20.0k | events_limit_after_restart = EVENTS_LIMIT; | 140 | 20.0k | timeout = -1; | 141 | 20.0k | } | 142 | 274k | if (playing && event->event_id == MPV_EVENT_PLAYBACK_RESTART) | 143 | 20.0k | timeout = PLAYBACK_TIME_LIMIT; | 144 | 274k | if (loaded && event->event_id == MPV_EVENT_IDLE) | 145 | 20.0k | break; | 146 | 274k | } | 147 | 20.1k | } |
Unexecuted instantiation: fuzzer_ipc.c:player_loop |