mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Various potential memory leak fixed
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
FrameGrabbing::FrameGrabbing(): pbo_index_(0), pbo_next_index_(0), size_(0), width_(0), height_(0), use_alpha_(0), caps_(nullptr)
|
FrameGrabbing::FrameGrabbing(): pbo_index_(0), pbo_next_index_(0), size_(0), width_(0), height_(0), use_alpha_(0), caps_(NULL)
|
||||||
{
|
{
|
||||||
pbo_[0] = 0;
|
pbo_[0] = 0;
|
||||||
pbo_[1] = 0;
|
pbo_[1] = 0;
|
||||||
@@ -28,7 +28,7 @@ FrameGrabbing::~FrameGrabbing()
|
|||||||
clearAll();
|
clearAll();
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
if (caps_!=nullptr)
|
if (caps_)
|
||||||
gst_caps_unref (caps_);
|
gst_caps_unref (caps_);
|
||||||
if (pbo_[0])
|
if (pbo_[0])
|
||||||
glDeleteBuffers(2, pbo_);
|
glDeleteBuffers(2, pbo_);
|
||||||
@@ -73,7 +73,7 @@ FrameGrabber *FrameGrabbing::get(uint64_t id)
|
|||||||
void FrameGrabbing::stopAll()
|
void FrameGrabbing::stopAll()
|
||||||
{
|
{
|
||||||
std::list<FrameGrabber *>::iterator iter;
|
std::list<FrameGrabber *>::iterator iter;
|
||||||
for (iter=grabbers_.begin(); iter != grabbers_.end(); iter++ )
|
for (iter=grabbers_.begin(); iter != grabbers_.end(); ++iter )
|
||||||
(*iter)->stop();
|
(*iter)->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ void FrameGrabbing::grabFrame(FrameBuffer *frame_buffer, float dt)
|
|||||||
pbo_next_index_ = 0;
|
pbo_next_index_ = 0;
|
||||||
|
|
||||||
// new caps
|
// new caps
|
||||||
if (caps_!=nullptr)
|
if (caps_)
|
||||||
gst_caps_unref (caps_);
|
gst_caps_unref (caps_);
|
||||||
caps_ = gst_caps_new_simple ("video/x-raw",
|
caps_ = gst_caps_new_simple ("video/x-raw",
|
||||||
"format", G_TYPE_STRING, use_alpha_ ? "RGBA" : "RGB",
|
"format", G_TYPE_STRING, use_alpha_ ? "RGBA" : "RGB",
|
||||||
@@ -193,7 +193,7 @@ void FrameGrabbing::grabFrame(FrameBuffer *frame_buffer, float dt)
|
|||||||
delete rec;
|
delete rec;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
iter++;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
// unref / free the frame
|
// unref / free the frame
|
||||||
|
|||||||
@@ -142,13 +142,8 @@ string GstToolkit::gst_version()
|
|||||||
};
|
};
|
||||||
const int N = 10;
|
const int N = 10;
|
||||||
#elif GST_GL_HAVE_PLATFORM_CGL
|
#elif GST_GL_HAVE_PLATFORM_CGL
|
||||||
<<<<<<< HEAD
|
|
||||||
const char *plugins[1] = { "vtdec_hw" };
|
|
||||||
const int N = 1;
|
|
||||||
=======
|
|
||||||
const char *plugins[2] = { "vtdec_hw", "vtdechw" };
|
const char *plugins[2] = { "vtdec_hw", "vtdechw" };
|
||||||
const int N = 2;
|
const int N = 2;
|
||||||
>>>>>>> 7344258b2f761d53d617e272473381625652d30a
|
|
||||||
#else
|
#else
|
||||||
const char *plugins[0] = { };
|
const char *plugins[0] = { };
|
||||||
const int N = 0;
|
const int N = 0;
|
||||||
@@ -184,7 +179,7 @@ std::string GstToolkit::used_gpu_decoding_plugins(GstElement *gstbin)
|
|||||||
{
|
{
|
||||||
std::string found = "";
|
std::string found = "";
|
||||||
|
|
||||||
auto it = gst_bin_iterate_recurse(GST_BIN(gstbin));
|
GstIterator* it = gst_bin_iterate_recurse(GST_BIN(gstbin));
|
||||||
GValue value = G_VALUE_INIT;
|
GValue value = G_VALUE_INIT;
|
||||||
for(GstIteratorResult r = gst_iterator_next(it, &value); r != GST_ITERATOR_DONE; r = gst_iterator_next(it, &value))
|
for(GstIteratorResult r = gst_iterator_next(it, &value); r != GST_ITERATOR_DONE; r = gst_iterator_next(it, &value))
|
||||||
{
|
{
|
||||||
@@ -192,7 +187,9 @@ std::string GstToolkit::used_gpu_decoding_plugins(GstElement *gstbin)
|
|||||||
{
|
{
|
||||||
GstElement *e = static_cast<GstElement*>(g_value_peek_pointer(&value));
|
GstElement *e = static_cast<GstElement*>(g_value_peek_pointer(&value));
|
||||||
if (e) {
|
if (e) {
|
||||||
std::string e_name = gst_element_get_name(e);
|
gchar *name = gst_element_get_name(e);
|
||||||
|
std::string e_name(name);
|
||||||
|
g_free(name);
|
||||||
// g_print(" - %s", e_name.c_str());
|
// g_print(" - %s", e_name.c_str());
|
||||||
for (int i = 0; i < N; i++) {
|
for (int i = 0; i < N; i++) {
|
||||||
if (e_name.find(plugins[i]) != std::string::npos) {
|
if (e_name.find(plugins[i]) != std::string::npos) {
|
||||||
@@ -203,6 +200,7 @@ std::string GstToolkit::used_gpu_decoding_plugins(GstElement *gstbin)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
gst_iterator_free(it);
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ Timeline::Timeline()
|
|||||||
|
|
||||||
Timeline::~Timeline()
|
Timeline::~Timeline()
|
||||||
{
|
{
|
||||||
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
Timeline& Timeline::operator = (const Timeline& b)
|
Timeline& Timeline::operator = (const Timeline& b)
|
||||||
@@ -176,8 +177,7 @@ TimeIntervalSet Timeline::sections() const
|
|||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; it != gaps_.end(); ++it)
|
for (; it != gaps_.end(); ++it) {
|
||||||
{
|
|
||||||
sec.insert( TimeInterval(begin_sec, (*it).begin) );
|
sec.insert( TimeInterval(begin_sec, (*it).begin) );
|
||||||
begin_sec = (*it).end;
|
begin_sec = (*it).end;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ XMLElement *tinyxml2::XMLElementEncodeArray(XMLDocument *doc, const void *array,
|
|||||||
gchar *compressed_array = g_new(gchar, compressed_size);
|
gchar *compressed_array = g_new(gchar, compressed_size);
|
||||||
|
|
||||||
// encoded string will hold the base64 encoding of the array
|
// encoded string will hold the base64 encoding of the array
|
||||||
const gchar *encoded_array = nullptr;
|
gchar *encoded_array = nullptr;
|
||||||
|
|
||||||
// zlib compress ((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen));
|
// zlib compress ((Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen));
|
||||||
if ( Z_OK == compress((Bytef *)compressed_array, &compressed_size,
|
if ( Z_OK == compress((Bytef *)compressed_array, &compressed_size,
|
||||||
@@ -153,6 +153,7 @@ XMLElement *tinyxml2::XMLElementEncodeArray(XMLDocument *doc, const void *array,
|
|||||||
|
|
||||||
// free temporary array
|
// free temporary array
|
||||||
g_free(compressed_array);
|
g_free(compressed_array);
|
||||||
|
g_free(encoded_array);
|
||||||
|
|
||||||
return newelement;
|
return newelement;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user