diff options
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | 2020-08-04 11:30:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-04 11:30:56 +0300 |
commit | 38bee3092f2d477f1baebfcae464f888d3d04bbe (patch) | |
tree | 3c13af26923c64ea4b9dec87e1dbc93e5b01fd4b /kms++util/src | |
parent | d9d5e44526a3b8065e4ae913032020d0bfd93103 (diff) | |
parent | 85dbfbaedecb46ebd0aa89ffeb674de497555ca9 (diff) |
Merge pull request #57 from dreamer-dead/videodevice-unique-ptr
Use unique_ptr to prevent memory leaks in VideoDevice class
Diffstat (limited to 'kms++util/src')
-rw-r--r-- | kms++util/src/videodevice.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/kms++util/src/videodevice.cpp b/kms++util/src/videodevice.cpp index 89a7286..0121c7c 100644 --- a/kms++util/src/videodevice.cpp +++ b/kms++util/src/videodevice.cpp @@ -246,7 +246,7 @@ VideoDevice::VideoDevice(const string& dev) } VideoDevice::VideoDevice(int fd) - : m_fd(fd), m_has_capture(false), m_has_output(false), m_has_m2m(false), m_capture_streamer(0), m_output_streamer(0) + : m_fd(fd), m_has_capture(false), m_has_output(false), m_has_m2m(false) { if (fd < 0) throw runtime_error("bad fd"); @@ -299,10 +299,10 @@ VideoStreamer* VideoDevice::get_capture_streamer() if (!m_capture_streamer) { auto type = m_has_mplane_capture ? VideoStreamer::StreamerType::CaptureMulti : VideoStreamer::StreamerType::CaptureSingle; - m_capture_streamer = new VideoStreamer(m_fd, type); + m_capture_streamer = std::unique_ptr<VideoStreamer>(new VideoStreamer(m_fd, type)); } - return m_capture_streamer; + return m_capture_streamer.get(); } VideoStreamer* VideoDevice::get_output_streamer() @@ -311,10 +311,10 @@ VideoStreamer* VideoDevice::get_output_streamer() if (!m_output_streamer) { auto type = m_has_mplane_output ? VideoStreamer::StreamerType::OutputMulti : VideoStreamer::StreamerType::OutputSingle; - m_output_streamer = new VideoStreamer(m_fd, type); + m_output_streamer = std::unique_ptr<VideoStreamer>(new VideoStreamer(m_fd, type)); } - return m_output_streamer; + return m_output_streamer.get(); } vector<tuple<uint32_t, uint32_t>> VideoDevice::get_discrete_frame_sizes(PixelFormat fmt) |