mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-20 12:32:18 +08:00
fix(gstreamer): fix buffer map memory leak (#9378)
This commit is contained in:
@@ -443,6 +443,17 @@ static void gstreamer_update_frame(lv_gstreamer_t * streamer)
|
||||
GstBuffer * buffer = gst_sample_get_buffer(sample);
|
||||
GstMapInfo map;
|
||||
if(buffer && gst_buffer_map(buffer, &map, GST_MAP_READ)) {
|
||||
if(streamer->last_buffer) {
|
||||
gst_buffer_unmap(streamer->last_buffer, &streamer->last_map_info);
|
||||
}
|
||||
if(streamer->last_sample) {
|
||||
gst_sample_unref(streamer->last_sample);
|
||||
}
|
||||
streamer->last_buffer = buffer;
|
||||
streamer->last_map_info = map;
|
||||
|
||||
streamer->last_sample = sample;
|
||||
|
||||
streamer->frame = (lv_image_dsc_t) {
|
||||
.data = map.data,
|
||||
.data_size = map.size,
|
||||
@@ -462,10 +473,6 @@ static void gstreamer_update_frame(lv_gstreamer_t * streamer)
|
||||
lv_obj_send_event((lv_obj_t *)streamer, LV_EVENT_READY, streamer);
|
||||
}
|
||||
|
||||
if(streamer->last_sample) {
|
||||
gst_sample_unref(streamer->last_sample);
|
||||
}
|
||||
streamer->last_sample = sample;
|
||||
}
|
||||
static void gstreamer_timer_cb(lv_timer_t * timer)
|
||||
{
|
||||
@@ -488,10 +495,13 @@ static void lv_gstreamer_destructor(const lv_obj_class_t * class_p, lv_obj_t * o
|
||||
gst_element_set_state(streamer->pipeline, GST_STATE_NULL);
|
||||
gst_object_unref(streamer->pipeline);
|
||||
}
|
||||
if(streamer->last_buffer) {
|
||||
gst_buffer_unmap(streamer->last_buffer, &streamer->last_map_info);
|
||||
}
|
||||
if(streamer->last_sample) {
|
||||
gst_sample_unref(streamer->last_sample);
|
||||
}
|
||||
|
||||
lv_timer_delete(streamer->gstreamer_timer);
|
||||
g_async_queue_unref(streamer->frame_queue);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,11 +37,13 @@ struct _lv_gstreamer_t {
|
||||
lv_image_t image;
|
||||
lv_image_dsc_t frame;
|
||||
GstVideoInfo video_info;
|
||||
GstMapInfo last_map_info;
|
||||
GstBuffer * last_buffer;
|
||||
GstSample * last_sample;
|
||||
GstElement * pipeline;
|
||||
GstElement * audio_convert;
|
||||
GstElement * video_convert;
|
||||
GstElement * audio_volume;
|
||||
GstSample * last_sample;
|
||||
lv_timer_t * gstreamer_timer;
|
||||
GAsyncQueue * frame_queue;
|
||||
bool is_video_info_valid;
|
||||
|
||||
Reference in New Issue
Block a user