Commit 332a0165 authored by Martin Blumenstingl's avatar Martin Blumenstingl

Fixed a crash in libvlc if there are no subtitles available

kaffeine crashes, when watching DVB and there are no subtitles for the
current channel available.
DvbLiveView::pmtSectionChanged sets subtitlePid to -1 if there are no
subtitles available. VlcMediaWidget::setCurrentSubtitle unconditionally
adds 1 to the requested subtitle index.
Now we're trying to activate subtitle 0 which does not exist.
If subtitle -1 was given then we really want to disable subtitles
(= sending -1 to libvlc).

This patch also makes setCurrentSubtitle more robust.

REVIEW: 106297
parent d96941c6
......@@ -240,8 +240,25 @@ void VlcMediaWidget::setCurrentAudioStream(int currentAudioStream)
void VlcMediaWidget::setCurrentSubtitle(int currentSubtitle)
{
// skip the 'deactivate' subtitle
libvlc_video_set_spu(vlcMediaPlayer, currentSubtitle + 1);
int requestedSubtitle = currentSubtitle;
int availableSpuCount = libvlc_video_get_spu_count(vlcMediaPlayer);
if (requestedSubtitle >= availableSpuCount) {
Log("VlcMediaWidget::setCurrentSubtitle: subtitle is out of range") <<
requestedSubtitle << availableSpuCount;
// Disable subtitles.
requestedSubtitle = -1;
} else if (requestedSubtitle < 0) {
// Set all negative subtitle requests to -1 as this makes libvlc
// disable the subtitles.
requestedSubtitle = -1;
} else {
// We got a valid subtitle request - skip the 'deactivate' subtitle.
requestedSubtitle += 1;
}
libvlc_video_set_spu(vlcMediaPlayer, requestedSubtitle);
}
void VlcMediaWidget::setExternalSubtitle(const KUrl &subtitleUrl)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment