FriendlyCaps: Fix memory leak
Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
parent
126504d740
commit
6c1fb2e13a
2 changed files with 12 additions and 16 deletions
|
@ -31,8 +31,10 @@ public class EyeNeko.Gstreamer : Object {
|
|||
can_start_stream = false;
|
||||
available_caps.remove_all ();
|
||||
for (uint i = 0; i < caps.get_size (); i++) {
|
||||
var cap = new FriendlyCaps.with_struct (caps.get_structure (i));
|
||||
available_caps.append (cap);
|
||||
var cap = new Gst.Caps.empty ();
|
||||
cap.append_structure (caps.get_structure (i).copy ());
|
||||
var fcap = new FriendlyCaps.with_caps (cap);
|
||||
available_caps.append (fcap);
|
||||
}
|
||||
can_start_stream = true;
|
||||
caps_selecton_model.selected = 0;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
namespace EyeNeko {
|
||||
public class FriendlyCaps : Object {
|
||||
public unowned Gst.Structure struct { get; construct set; }
|
||||
public Gst.Caps caps { get; construct set; }
|
||||
public enum Format {
|
||||
RAW,
|
||||
JPEG,
|
||||
|
@ -35,12 +35,12 @@ namespace EyeNeko {
|
|||
public string pixelformat { get; default = ""; }
|
||||
|
||||
construct {
|
||||
struct.get_int ("width", out _width);
|
||||
struct.get_int ("height", out _height);
|
||||
_format_name = struct.get_name ();
|
||||
caps.get_structure (0).get_int ("width", out _width);
|
||||
caps.get_structure (0).get_int ("height", out _height);
|
||||
_format_name = caps.get_structure (0).get_name ();
|
||||
_format = Format.from_gst_name (format_name);
|
||||
_pixelformat = struct.get_string ("format"); int num, denom;
|
||||
struct.get_fraction ("framerate", out num, out denom);
|
||||
_pixelformat = caps.get_structure (0).get_string ("format"); int num, denom;
|
||||
caps.get_structure (0).get_fraction ("framerate", out num, out denom);
|
||||
if (denom == 0)
|
||||
denom = 1;
|
||||
_fps = num / denom;
|
||||
|
@ -51,11 +51,7 @@ namespace EyeNeko {
|
|||
warning ("Unsupported caps structute count (%u)", caps.get_size ());
|
||||
return;
|
||||
}
|
||||
Object (struct : caps.get_structure (0).copy ());
|
||||
}
|
||||
|
||||
public FriendlyCaps.with_struct (Gst.Structure struct) {
|
||||
Object (struct : struct);
|
||||
Object (caps: caps);
|
||||
}
|
||||
|
||||
public string to_string () {
|
||||
|
@ -80,9 +76,7 @@ namespace EyeNeko {
|
|||
}
|
||||
|
||||
public Gst.Caps to_caps () {
|
||||
var res = new Gst.Caps.empty ();
|
||||
res.append_structure (struct.copy ());
|
||||
return res;
|
||||
return caps.copy ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue