diff options
author | Alexandre Moreno <alexmorenocano@gmail.com> | 2015-10-28 00:43:03 +0800 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2015-10-27 18:51:53 +0200 |
commit | a5920c9fe27c7f258bbf7c67810e74477c677be9 (patch) | |
tree | 3acfbb2ae8830502a7872ace1ac7e7b005c07494 | |
parent | ed68561af92fbcdb0d213780508ad07f7bdf89a1 (diff) |
qt: add a destructor and release resources
Fixes #129
-rw-r--r-- | qt/qgstplayer.cpp | 9 | ||||
-rw-r--r-- | qt/qgstplayer.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/qt/qgstplayer.cpp b/qt/qgstplayer.cpp index ab140f3..3aae93d 100644 --- a/qt/qgstplayer.cpp +++ b/qt/qgstplayer.cpp @@ -359,6 +359,15 @@ Player::Player(QObject *parent, VideoRenderer *renderer) gst_player_set_subtitle_track_enabled(player_, false); } +Player::~Player() +{ + if (player_) { + g_signal_handlers_disconnect_by_data(player_, this); + gst_player_stop(player_); + g_object_unref(player_); + } +} + void Player::onStateChanged(Player * player, GstPlayerState state) { diff --git a/qt/qgstplayer.h b/qt/qgstplayer.h index f5d4ab8..c060bc9 100644 --- a/qt/qgstplayer.h +++ b/qt/qgstplayer.h @@ -62,6 +62,7 @@ class Player : public QObject public: explicit Player(QObject *parent = 0, VideoRenderer *renderer = 0); + virtual ~Player(); typedef GstPlayerError Error; enum State { |