aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2018-01-03 08:27:23 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2018-01-03 08:27:23 +0100
commitdeb7d524b6f400950a35ee1538e24239d2cd9874 (patch)
tree6f08579b3c7f8c5ab0b73000bf1404c76b843fe1
parent0621b5f0837656d0522ee94d5da536520edfe592 (diff)
downloadODR-AudioEnc-deb7d524b6f400950a35ee1538e24239d2cd9874.tar.gz
ODR-AudioEnc-deb7d524b6f400950a35ee1538e24239d2cd9874.tar.bz2
ODR-AudioEnc-deb7d524b6f400950a35ee1538e24239d2cd9874.zip
Avoid some VLC leaks
-rw-r--r--src/VLCInput.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/VLCInput.cpp b/src/VLCInput.cpp
index 837d94f..a215e9f 100644
--- a/src/VLCInput.cpp
+++ b/src/VLCInput.cpp
@@ -236,11 +236,18 @@ void VLCInput::prepare()
m_mp = libvlc_media_player_new_from_media(m);
libvlc_media_release(m);
+ if (!m_mp) {
+ throw runtime_error("VLC did not return media player");
+ }
+
// Start playing
int ret = libvlc_media_player_play(m_mp);
if (ret == 0) {
libvlc_media_t *media = libvlc_media_player_get_media(m_mp);
+ if (!media) {
+ throw runtime_error("VLC did not have a media");
+ }
libvlc_state_t st;
ret = -1;
@@ -253,6 +260,8 @@ void VLCInput::prepare()
break;
}
}
+
+ libvlc_media_release(media);
}
if (ret == -1) {
@@ -363,6 +372,12 @@ ssize_t VLCInput::m_read(uint8_t* buf, size_t length)
std::this_thread::sleep_for(std::chrono::milliseconds(1));
libvlc_media_t *media = libvlc_media_player_get_media(m_mp);
+ if (!media) {
+ fprintf(stderr, "VLC no media\n");
+ err = -1;
+ break;
+ }
+
libvlc_state_t st = libvlc_media_get_state(media);
if (!(st == libvlc_Opening ||
st == libvlc_Buffering ||
@@ -393,6 +408,8 @@ ssize_t VLCInput::m_read(uint8_t* buf, size_t length)
}
}
+ libvlc_media_release(media);
+
if (artist_sz)
free(artist_sz);
if (title_sz)