Skip to content

Commit b95de80

Browse files
committed
fix more warnings
1 parent 62ec238 commit b95de80

File tree

5 files changed

+71
-34
lines changed

5 files changed

+71
-34
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ add_library(
145145
src/dmabuf_surface.c
146146
src/frame_scheduler.c
147147
src/window.c
148-
src/vulkan.c
149148
src/dummy_render_surface.c
150149
src/plugins/services.c
151150
)
@@ -238,6 +237,7 @@ if (ENABLE_VULKAN)
238237
target_sources(flutterpi_module PRIVATE
239238
src/vk_gbm_render_surface.c
240239
src/vk_renderer.c
240+
src/vulkan.c
241241
)
242242
target_link_libraries(flutterpi_module PUBLIC
243243
PkgConfig::VULKAN

src/plugins/audioplayers/player.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ void audio_player_on_media_error(struct audio_player *self, GError *error, gchar
290290
void audio_player_on_media_state_change(struct audio_player *self, GstObject *src, GstState *old_state, GstState *new_state) {
291291
(void) old_state;
292292
if (src == GST_OBJECT(self->playbin)) {
293-
LOG_DEBUG("%s: on_media_state_change(old_state=%d, new_state=%d)\n", self->player_id, *old_state, *new_state);
293+
LOG_DEBUG("%s: on_media_state_change(old_state=%u, new_state=%u)\n", self->player_id, *old_state, *new_state);
294294
if (*new_state == GST_STATE_READY) {
295295
// Need to set to pause state, in order to make player functional
296296
GstStateChangeReturn ret = gst_element_set_state(self->playbin, GST_STATE_PAUSED);

src/plugins/gstreamer_video_player/plugin.c

Lines changed: 64 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,8 +1085,7 @@ static int on_create_v2(const struct raw_std_value *arg, FlutterPlatformMessageR
10851085
} else if (raw_std_value_is_string(arg)) {
10861086
asset = raw_std_string_dup(arg);
10871087
if (asset == NULL) {
1088-
ok = ENOMEM;
1089-
goto fail_respond_error;
1088+
return platch_respond_native_error_std(responsehandle, ENOMEM);
10901089
}
10911090
} else {
10921091
return platch_respond_illegal_arg_std(responsehandle, "Expected `arg[0]` to be a String or null.");
@@ -1104,11 +1103,12 @@ static int on_create_v2(const struct raw_std_value *arg, FlutterPlatformMessageR
11041103
} else if (raw_std_value_is_string(arg)) {
11051104
package_name = raw_std_string_dup(arg);
11061105
if (package_name == NULL) {
1107-
ok = ENOMEM;
1108-
goto fail_respond_error;
1106+
ok = platch_respond_native_error_std(responsehandle, ENOMEM);
1107+
goto fail_free_asset;
11091108
}
11101109
} else {
1111-
return platch_respond_illegal_arg_std(responsehandle, "Expected `arg[1]` to be a String or null.");
1110+
ok = platch_respond_illegal_arg_std(responsehandle, "Expected `arg[1]` to be a String or null.");
1111+
goto fail_free_asset;
11121112
}
11131113
} else {
11141114
package_name = NULL;
@@ -1123,11 +1123,12 @@ static int on_create_v2(const struct raw_std_value *arg, FlutterPlatformMessageR
11231123
} else if (raw_std_value_is_string(arg)) {
11241124
uri = raw_std_string_dup(arg);
11251125
if (uri == NULL) {
1126-
ok = ENOMEM;
1127-
goto fail_respond_error;
1126+
ok = platch_respond_native_error_std(responsehandle, ENOMEM);
1127+
goto fail_free_package_name;
11281128
}
11291129
} else {
1130-
return platch_respond_illegal_arg_std(responsehandle, "Expected `arg[2]` to be a String or null.");
1130+
ok = platch_respond_illegal_arg_std(responsehandle, "Expected `arg[2]` to be a String or null.");
1131+
goto fail_free_package_name;
11311132
}
11321133
} else {
11331134
uri = NULL;
@@ -1153,7 +1154,8 @@ static int on_create_v2(const struct raw_std_value *arg, FlutterPlatformMessageR
11531154
}
11541155
} else {
11551156
invalid_format_hint:
1156-
return platch_respond_illegal_arg_std(responsehandle, "Expected `arg[3]` to be one of 'ss', 'hls', 'dash', 'other' or null.");
1157+
ok = platch_respond_illegal_arg_std(responsehandle, "Expected `arg[3]` to be one of 'ss', 'hls', 'dash', 'other' or null.");
1158+
goto fail_free_uri;
11571159
}
11581160
} else {
11591161
format_hint = FORMAT_HINT_NONE;
@@ -1174,7 +1176,8 @@ static int on_create_v2(const struct raw_std_value *arg, FlutterPlatformMessageR
11741176
headers = arg;
11751177
} else {
11761178
invalid_headers:
1177-
return platch_respond_illegal_arg_std(responsehandle, "Expected `arg[4]` to be a map of strings or null.");
1179+
ok = platch_respond_illegal_arg_std(responsehandle, "Expected `arg[4]` to be a map of strings or null.");
1180+
goto fail_free_uri;
11781181
}
11791182
} else {
11801183
headers = NULL;
@@ -1189,51 +1192,64 @@ static int on_create_v2(const struct raw_std_value *arg, FlutterPlatformMessageR
11891192
} else if (raw_std_value_is_string(arg)) {
11901193
pipeline = raw_std_string_dup(arg);
11911194
} else {
1192-
return platch_respond_illegal_arg_std(responsehandle, "Expected `arg[5]` to be a string or null.");
1195+
ok = platch_respond_illegal_arg_std(responsehandle, "Expected `arg[5]` to be a string or null.");
1196+
goto fail_free_uri;
11931197
}
11941198
} else {
11951199
pipeline = NULL;
11961200
}
11971201

11981202
if ((asset ? 1 : 0) + (uri ? 1 : 0) + (pipeline ? 1 : 0) != 1) {
1199-
return platch_respond_illegal_arg_std(responsehandle, "Expected exactly one of `arg[0]`, `arg[2]` or `arg[5]` to be non-null.");
1203+
ok = platch_respond_illegal_arg_std(responsehandle, "Expected exactly one of `arg[0]`, `arg[2]` or `arg[5]` to be non-null.");
1204+
goto fail_free_pipeline;
12001205
}
12011206

12021207
// Create our actual player (this doesn't initialize it)
12031208
if (asset != NULL) {
1204-
player = gstplayer_new_from_asset(flutterpi, asset, package_name, NULL);
1205-
12061209
// gstplayer_new_from_network will construct a file:// URI out of the
12071210
// asset path internally.
1208-
free(asset);
1209-
asset = NULL;
1211+
player = gstplayer_new_from_asset(flutterpi, asset, package_name, NULL);
12101212
} else if (uri != NULL) {
1213+
// gstplayer_new_from_network will dup the uri internally.
12111214
player = gstplayer_new_from_network(flutterpi, uri, format_hint, NULL);
1215+
} else if (pipeline != NULL) {
1216+
// gstplayer_new_from_network will dup the pipeline internally.
1217+
player = gstplayer_new_from_pipeline(flutterpi, pipeline, NULL);
1218+
} else {
1219+
UNREACHABLE();
1220+
}
12121221

1213-
// gstplayer_new_from_network will dup the uri internally.
1222+
if (asset != NULL) {
1223+
free(asset);
1224+
asset = NULL;
1225+
}
1226+
1227+
if (package_name != NULL) {
1228+
free(package_name);
1229+
package_name = NULL;
1230+
}
1231+
1232+
if (uri != NULL) {
12141233
free(uri);
12151234
uri = NULL;
1216-
} else if (pipeline != NULL) {
1217-
player = gstplayer_new_from_pipeline(flutterpi, pipeline, NULL);
1235+
}
12181236

1219-
// gstplayer_new_from_network will dup the pipeline internally.
1237+
if (pipeline != NULL) {
12201238
free(pipeline);
12211239
pipeline = NULL;
1222-
} else {
1223-
UNREACHABLE();
12241240
}
12251241

12261242
if (player == NULL) {
12271243
LOG_ERROR("Couldn't create gstreamer video player.\n");
1228-
ok = EIO;
1229-
goto fail_respond_error;
1244+
ok = platch_respond_native_error_std(responsehandle, EIO);
1245+
goto fail_destroy_player;
12301246
}
12311247

12321248
// create a meta object so we can store the event channel name
12331249
// of a player with it
12341250
meta = create_meta(gstplayer_get_texture_id(player), player);
12351251
if (meta == NULL) {
1236-
ok = ENOMEM;
1252+
ok = platch_respond_native_error_std(responsehandle, ENOMEM);
12371253
goto fail_destroy_player;
12381254
}
12391255

@@ -1258,12 +1274,14 @@ static int on_create_v2(const struct raw_std_value *arg, FlutterPlatformMessageR
12581274
// Set a receiver on the videoEvents event channel
12591275
ok = plugin_registry_set_receiver(meta->event_channel_name, kStandardMethodCall, on_receive_evch);
12601276
if (ok != 0) {
1277+
platch_respond_native_error_std(responsehandle, ok);
12611278
goto fail_remove_player;
12621279
}
12631280

12641281
// Finally, start initializing
12651282
ok = gstplayer_initialize(player);
12661283
if (ok != 0) {
1284+
platch_respond_native_error_std(responsehandle, ok);
12671285
goto fail_remove_receiver;
12681286
}
12691287

@@ -1279,8 +1297,27 @@ static int on_create_v2(const struct raw_std_value *arg, FlutterPlatformMessageR
12791297
fail_destroy_player:
12801298
gstplayer_destroy(player);
12811299

1282-
fail_respond_error:
1283-
return platch_respond_native_error_std(responsehandle, ok);
1300+
fail_free_pipeline:
1301+
if (pipeline != NULL) {
1302+
free(pipeline);
1303+
}
1304+
1305+
fail_free_uri:
1306+
if (uri != NULL) {
1307+
free(uri);
1308+
}
1309+
1310+
fail_free_package_name:
1311+
if (package_name != NULL) {
1312+
free(package_name);
1313+
}
1314+
1315+
fail_free_asset:
1316+
if (asset != NULL) {
1317+
free(asset);
1318+
}
1319+
1320+
return ok;
12841321
}
12851322

12861323
static int on_dispose_v2(const struct raw_std_value *arg, FlutterPlatformMessageResponseHandle *responsehandle) {

src/util/lock_ops.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static inline void assert_mutex_locked(pthread_mutex_t *mutex) {
6868
}
6969
}
7070
#else
71-
static inline void assert_mutex_locked(mutex_t *mutex) {
71+
static inline void assert_mutex_locked(pthread_mutex_t *mutex) {
7272
(void) mutex;
7373
}
7474
#endif

src/util/macros.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@
421421
} while (0)
422422

423423
/** Compute ceiling of integer quotient of A divided by B. */
424-
#define DIV_ROUND_UP(A, B) (((A) + (B) -1) / (B))
424+
#define DIV_ROUND_UP(A, B) (((A) + (B) - 1) / (B))
425425

426426
/**
427427
* Clamp X to [MIN,MAX]. Turn NaN into MIN, arbitrarily.
@@ -450,10 +450,10 @@
450450
#define MAX4(A, B, C, D) ((A) > (B) ? MAX3(A, C, D) : MAX3(B, C, D))
451451

452452
/** Align a value to a power of two */
453-
#define ALIGN_POT(x, pot_align) (((x) + (pot_align) -1) & ~((pot_align) -1))
453+
#define ALIGN_POT(x, pot_align) (((x) + (pot_align) - 1) & ~((pot_align) - 1))
454454

455455
/** Checks is a value is a power of two. Does not handle zero. */
456-
#define IS_POT(v) (((v) & ((v) -1)) == 0)
456+
#define IS_POT(v) (((v) & ((v) - 1)) == 0)
457457

458458
/** Set a single bit */
459459
#define BITFIELD_BIT(b) (1u << (b))
@@ -594,7 +594,7 @@ typedef int lock_cap_t;
594594

595595
#define UNIMPLEMENTED() \
596596
do { \
597-
fprintf(stderr, "%s%s:%u: Unimplemented\n", __FILE__, __func__, __LINE__); \
597+
fprintf(stderr, "%s%s:%d: Unimplemented\n", __FILE__, __func__, __LINE__); \
598598
TRAP(); \
599599
} while (0)
600600

0 commit comments

Comments
 (0)