Skip to content

Commit

Permalink
fix more warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ardera committed Sep 16, 2024
1 parent 62ec238 commit b95de80
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 34 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ add_library(
src/dmabuf_surface.c
src/frame_scheduler.c
src/window.c
src/vulkan.c
src/dummy_render_surface.c
src/plugins/services.c
)
Expand Down Expand Up @@ -238,6 +237,7 @@ if (ENABLE_VULKAN)
target_sources(flutterpi_module PRIVATE
src/vk_gbm_render_surface.c
src/vk_renderer.c
src/vulkan.c
)
target_link_libraries(flutterpi_module PUBLIC
PkgConfig::VULKAN
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/audioplayers/player.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ void audio_player_on_media_error(struct audio_player *self, GError *error, gchar
void audio_player_on_media_state_change(struct audio_player *self, GstObject *src, GstState *old_state, GstState *new_state) {
(void) old_state;
if (src == GST_OBJECT(self->playbin)) {
LOG_DEBUG("%s: on_media_state_change(old_state=%d, new_state=%d)\n", self->player_id, *old_state, *new_state);
LOG_DEBUG("%s: on_media_state_change(old_state=%u, new_state=%u)\n", self->player_id, *old_state, *new_state);
if (*new_state == GST_STATE_READY) {
// Need to set to pause state, in order to make player functional
GstStateChangeReturn ret = gst_element_set_state(self->playbin, GST_STATE_PAUSED);
Expand Down
91 changes: 64 additions & 27 deletions src/plugins/gstreamer_video_player/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1085,8 +1085,7 @@ static int on_create_v2(const struct raw_std_value *arg, FlutterPlatformMessageR
} else if (raw_std_value_is_string(arg)) {
asset = raw_std_string_dup(arg);
if (asset == NULL) {
ok = ENOMEM;
goto fail_respond_error;
return platch_respond_native_error_std(responsehandle, ENOMEM);
}
} else {
return platch_respond_illegal_arg_std(responsehandle, "Expected `arg[0]` to be a String or null.");
Expand All @@ -1104,11 +1103,12 @@ static int on_create_v2(const struct raw_std_value *arg, FlutterPlatformMessageR
} else if (raw_std_value_is_string(arg)) {
package_name = raw_std_string_dup(arg);
if (package_name == NULL) {
ok = ENOMEM;
goto fail_respond_error;
ok = platch_respond_native_error_std(responsehandle, ENOMEM);
goto fail_free_asset;
}
} else {
return platch_respond_illegal_arg_std(responsehandle, "Expected `arg[1]` to be a String or null.");
ok = platch_respond_illegal_arg_std(responsehandle, "Expected `arg[1]` to be a String or null.");
goto fail_free_asset;
}
} else {
package_name = NULL;
Expand All @@ -1123,11 +1123,12 @@ static int on_create_v2(const struct raw_std_value *arg, FlutterPlatformMessageR
} else if (raw_std_value_is_string(arg)) {
uri = raw_std_string_dup(arg);
if (uri == NULL) {
ok = ENOMEM;
goto fail_respond_error;
ok = platch_respond_native_error_std(responsehandle, ENOMEM);
goto fail_free_package_name;
}
} else {
return platch_respond_illegal_arg_std(responsehandle, "Expected `arg[2]` to be a String or null.");
ok = platch_respond_illegal_arg_std(responsehandle, "Expected `arg[2]` to be a String or null.");
goto fail_free_package_name;
}
} else {
uri = NULL;
Expand All @@ -1153,7 +1154,8 @@ static int on_create_v2(const struct raw_std_value *arg, FlutterPlatformMessageR
}
} else {
invalid_format_hint:
return platch_respond_illegal_arg_std(responsehandle, "Expected `arg[3]` to be one of 'ss', 'hls', 'dash', 'other' or null.");
ok = platch_respond_illegal_arg_std(responsehandle, "Expected `arg[3]` to be one of 'ss', 'hls', 'dash', 'other' or null.");
goto fail_free_uri;
}
} else {
format_hint = FORMAT_HINT_NONE;
Expand All @@ -1174,7 +1176,8 @@ static int on_create_v2(const struct raw_std_value *arg, FlutterPlatformMessageR
headers = arg;
} else {
invalid_headers:
return platch_respond_illegal_arg_std(responsehandle, "Expected `arg[4]` to be a map of strings or null.");
ok = platch_respond_illegal_arg_std(responsehandle, "Expected `arg[4]` to be a map of strings or null.");
goto fail_free_uri;
}
} else {
headers = NULL;
Expand All @@ -1189,51 +1192,64 @@ static int on_create_v2(const struct raw_std_value *arg, FlutterPlatformMessageR
} else if (raw_std_value_is_string(arg)) {
pipeline = raw_std_string_dup(arg);
} else {
return platch_respond_illegal_arg_std(responsehandle, "Expected `arg[5]` to be a string or null.");
ok = platch_respond_illegal_arg_std(responsehandle, "Expected `arg[5]` to be a string or null.");
goto fail_free_uri;
}
} else {
pipeline = NULL;
}

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

// Create our actual player (this doesn't initialize it)
if (asset != NULL) {
player = gstplayer_new_from_asset(flutterpi, asset, package_name, NULL);

// gstplayer_new_from_network will construct a file:// URI out of the
// asset path internally.
free(asset);
asset = NULL;
player = gstplayer_new_from_asset(flutterpi, asset, package_name, NULL);
} else if (uri != NULL) {
// gstplayer_new_from_network will dup the uri internally.
player = gstplayer_new_from_network(flutterpi, uri, format_hint, NULL);
} else if (pipeline != NULL) {
// gstplayer_new_from_network will dup the pipeline internally.
player = gstplayer_new_from_pipeline(flutterpi, pipeline, NULL);
} else {
UNREACHABLE();
}

// gstplayer_new_from_network will dup the uri internally.
if (asset != NULL) {
free(asset);
asset = NULL;
}

if (package_name != NULL) {
free(package_name);
package_name = NULL;
}

if (uri != NULL) {
free(uri);
uri = NULL;
} else if (pipeline != NULL) {
player = gstplayer_new_from_pipeline(flutterpi, pipeline, NULL);
}

// gstplayer_new_from_network will dup the pipeline internally.
if (pipeline != NULL) {
free(pipeline);
pipeline = NULL;
} else {
UNREACHABLE();
}

if (player == NULL) {
LOG_ERROR("Couldn't create gstreamer video player.\n");
ok = EIO;
goto fail_respond_error;
ok = platch_respond_native_error_std(responsehandle, EIO);
goto fail_destroy_player;
}

// create a meta object so we can store the event channel name
// of a player with it
meta = create_meta(gstplayer_get_texture_id(player), player);
if (meta == NULL) {
ok = ENOMEM;
ok = platch_respond_native_error_std(responsehandle, ENOMEM);
goto fail_destroy_player;
}

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

// Finally, start initializing
ok = gstplayer_initialize(player);
if (ok != 0) {
platch_respond_native_error_std(responsehandle, ok);
goto fail_remove_receiver;
}

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

fail_respond_error:
return platch_respond_native_error_std(responsehandle, ok);
fail_free_pipeline:
if (pipeline != NULL) {
free(pipeline);
}

fail_free_uri:
if (uri != NULL) {
free(uri);
}

fail_free_package_name:
if (package_name != NULL) {
free(package_name);
}

fail_free_asset:
if (asset != NULL) {
free(asset);
}

return ok;
}

static int on_dispose_v2(const struct raw_std_value *arg, FlutterPlatformMessageResponseHandle *responsehandle) {
Expand Down
2 changes: 1 addition & 1 deletion src/util/lock_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static inline void assert_mutex_locked(pthread_mutex_t *mutex) {
}
}
#else
static inline void assert_mutex_locked(mutex_t *mutex) {
static inline void assert_mutex_locked(pthread_mutex_t *mutex) {
(void) mutex;
}
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/util/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@
} while (0)

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

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

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

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

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

#define UNIMPLEMENTED() \
do { \
fprintf(stderr, "%s%s:%u: Unimplemented\n", __FILE__, __func__, __LINE__); \
fprintf(stderr, "%s%s:%d: Unimplemented\n", __FILE__, __func__, __LINE__); \
TRAP(); \
} while (0)

Expand Down

0 comments on commit b95de80

Please sign in to comment.