aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernd Kuhls <berndkuhls@hotmail.com>2016-03-19 08:49:43 +0100
committerBernd Kuhls <bernd.kuhls@t-online.de>2016-03-19 18:10:59 +0100
commit6a9e2bf65a346a43caff06efbf6051318d11aa8e (patch)
treed4edd978ee874c13f627228b7c7766c5636d7ae3
parenta7caa16680f09810b730e88b3368f221465c9eee (diff)
[Jarvis] partly backport of PR 9231 to fix segfault
This patch is a backport of https://github.com/xbmc/xbmc/commit/a81208e3b53b84763fb9f20d8642ffc7bc63c9a7 to fix a segfault during playback of vaapi-accelerated mpeg2 content: terminate called after throwing an instance of 'std::logic_error' what(): basic_string::_S_construct null not valid [New LWP 3743] Program received signal SIGABRT, Aborted. [Switching to LWP 3743] 0xb5664a9b in raise () from /lib/libc.so.0 (gdb) bt full #0 0xb5664a9b in raise () from /lib/libc.so.0 No symbol table info available. #1 0xb5660520 in abort () from /lib/libc.so.0 No symbol table info available. #2 0xb56e6536 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/libstdc++.so.6 No symbol table info available. #3 0xb56e4a1c in ?? () from /usr/lib/libstdc++.so.6 No symbol table info available. #4 0xb56e4a80 in std::terminate() () from /usr/lib/libstdc++.so.6 No symbol table info available. #5 0xb56e4cc9 in __cxa_throw () from /usr/lib/libstdc++.so.6 No symbol table info available. #6 0xb5719d79 in std::__throw_logic_error(char const*) () from /usr/lib/libstdc++.so.6 No symbol table info available. #7 0xb5722c41 in char* std::string::_S_construct<char const*>(char const*, char const*, std::allocator<char> const&, std::forward_iterator_tag) () from /usr/lib/libstdc++.so.6 No symbol table info available. #8 0xb5722cc7 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) () from /usr/lib/libstdc++.so.6 No symbol table info available. #9 0x0848fea3 in CDVDVideoCodec::IsCodecDisabled (map=0x9130420 <g_vaapi_available>, size=5, id=AV_CODEC_ID_MPEG4) at DVDVideoCodec.cpp:75 index = <optimized out> #10 0x08499d04 in VAAPI::CDecoder::Open (this=0xd09e5e8, avctx=0xd6a2ec0, mainctx=0xd6a2ec0, fmt=AV_PIX_FMT_VAAPI_VLD, surfaces=6) at VAAPI.cpp:503 gpuvendor = {static npos = <optimized out>, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0xceb267c "intel open source technology center"}} profile = <optimized out> #11 0x08491bda in CDVDVideoCodecFFmpeg::GetFormat (avctx=0xd6a2ec0, fmt=0x986d9c0) at DVDVideoCodecFFmpeg.cpp:143 dec = 0xd09e5e8 ctx = <optimized out> cur = 0x986d9c0 #12 0xb61c8ced in ?? () from /usr/lib/libavcodec.so.56
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.cpp18
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h9
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp19
-rw-r--r--xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp19
4 files changed, 25 insertions, 40 deletions
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.cpp
index 2428696dbe..43e88445e2 100644
--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.cpp
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.cpp
@@ -60,19 +60,15 @@ bool CDVDVideoCodec::IsSettingVisible(const std::string &condition, const std::s
return true;
}
-bool CDVDVideoCodec::IsCodecDisabled(DVDCodecAvailableType* map, unsigned int size, AVCodecID id)
+bool CDVDVideoCodec::IsCodecDisabled(const std::map<AVCodecID, std::string> &map, AVCodecID id)
{
- int index = -1;
- for (unsigned int i = 0; i < size; ++i)
+ auto codec = map.find(id);
+ if (codec != map.end())
{
- if(map[i].codec == id)
- {
- index = (int) i;
- break;
- }
+ return (!CSettings::GetInstance().GetBool(codec->second) ||
+ !CDVDVideoCodec::IsSettingVisible("unused", "unused",
+ CSettings::GetInstance().GetSetting(codec->second),
+ NULL));
}
- if(index > -1)
- return (!CSettings::GetInstance().GetBool(map[index].setting) || !CDVDVideoCodec::IsSettingVisible("unused", "unused", CSettings::GetInstance().GetSetting(map[index].setting), NULL));
-
return false; //don't disable what we don't have
}
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
index c84bb70a83..68ada7dc58 100644
--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodec.h
@@ -24,6 +24,7 @@
#include <vector>
#include <string>
+#include <map>
#include "cores/VideoRenderers/RenderFormats.h"
@@ -34,12 +35,6 @@ extern "C" {
class CSetting;
-struct DVDCodecAvailableType
-{
- AVCodecID codec;
- const char* setting;
-};
-
// when modifying these structures, make sure you update all codecs accordingly
#define FRAME_TYPE_UNDEF 0
#define FRAME_TYPE_I 1
@@ -290,7 +285,7 @@ public:
/**
* Interact with user settings so that user disabled codecs are disabled
*/
- static bool IsCodecDisabled(DVDCodecAvailableType* map, unsigned int size, AVCodecID id);
+ static bool IsCodecDisabled(const std::map<AVCodecID, std::string> &map, AVCodecID id);
/* For calculation of dropping requirements player asks for some information.
*
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp
index 540f91484e..ff53dd5e59 100644
--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VAAPI.cpp
@@ -451,16 +451,6 @@ bool CVideoSurfaces::HasRefs()
// VAAPI
//-----------------------------------------------------------------------------
-// settings codecs mapping
-DVDCodecAvailableType g_vaapi_available[] = {
- { AV_CODEC_ID_H263, CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG4.c_str() },
- { AV_CODEC_ID_MPEG4, CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG4.c_str() },
- { AV_CODEC_ID_WMV3, CSettings::SETTING_VIDEOPLAYER_USEVAAPIVC1.c_str() },
- { AV_CODEC_ID_VC1, CSettings::SETTING_VIDEOPLAYER_USEVAAPIVC1.c_str() },
- { AV_CODEC_ID_MPEG2VIDEO, CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG2.c_str() },
-};
-const size_t settings_count = sizeof(g_vaapi_available) / sizeof(DVDCodecAvailableType);
-
CDecoder::CDecoder() : m_vaapiOutput(&m_inMsgEvent)
{
m_vaapiConfig.videoSurfaces = &m_videoSurfaces;
@@ -500,7 +490,14 @@ bool CDecoder::Open(AVCodecContext* avctx, AVCodecContext* mainctx, const enum P
}
// check if user wants to decode this format with VAAPI
- if (CDVDVideoCodec::IsCodecDisabled(g_vaapi_available, settings_count, avctx->codec_id))
+ std::map<AVCodecID, std::string> settings_map = {
+ { AV_CODEC_ID_H263, CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG4 },
+ { AV_CODEC_ID_MPEG4, CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG4 },
+ { AV_CODEC_ID_WMV3, CSettings::SETTING_VIDEOPLAYER_USEVAAPIVC1 },
+ { AV_CODEC_ID_VC1, CSettings::SETTING_VIDEOPLAYER_USEVAAPIVC1 },
+ { AV_CODEC_ID_MPEG2VIDEO, CSettings::SETTING_VIDEOPLAYER_USEVAAPIMPEG2 },
+ };
+ if (CDVDVideoCodec::IsCodecDisabled(settings_map, avctx->codec_id))
return false;
if (g_advancedSettings.CanLogComponent(LOGVIDEO))
diff --git a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
index 85d9295d2e..4e995b6f0a 100644
--- a/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
+++ b/xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
@@ -45,16 +45,6 @@ using namespace VDPAU;
#define ARSIZE(x) (sizeof(x) / sizeof((x)[0]))
-// settings codecs mapping
-DVDCodecAvailableType g_vdpau_available[] = {
- { AV_CODEC_ID_H263, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG4.c_str() },
- { AV_CODEC_ID_MPEG4, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG4.c_str() },
- { AV_CODEC_ID_WMV3, CSettings::SETTING_VIDEOPLAYER_USEVDPAUVC1.c_str() },
- { AV_CODEC_ID_VC1, CSettings::SETTING_VIDEOPLAYER_USEVDPAUVC1.c_str() },
- { AV_CODEC_ID_MPEG2VIDEO, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG2.c_str() },
-};
-const size_t settings_count = sizeof(g_vdpau_available) / sizeof(DVDCodecAvailableType);
-
CDecoder::Desc decoder_profiles[] = {
{"MPEG1", VDP_DECODER_PROFILE_MPEG1},
{"MPEG2_SIMPLE", VDP_DECODER_PROFILE_MPEG2_SIMPLE},
@@ -494,7 +484,14 @@ bool CDecoder::Open(AVCodecContext* avctx, AVCodecContext* mainctx, const enum P
// nvidia is whitelisted despite for mpeg-4 we need to query user settings
if ((gpuvendor.compare(0, 6, "nvidia") != 0) || (avctx->codec_id == AV_CODEC_ID_MPEG4) || (avctx->codec_id == AV_CODEC_ID_H263))
{
- if (CDVDVideoCodec::IsCodecDisabled(g_vdpau_available, settings_count, avctx->codec_id))
+ std::map<AVCodecID, std::string> settings_map = {
+ { AV_CODEC_ID_H263, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG4 },
+ { AV_CODEC_ID_MPEG4, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG4 },
+ { AV_CODEC_ID_WMV3, CSettings::SETTING_VIDEOPLAYER_USEVDPAUVC1 },
+ { AV_CODEC_ID_VC1, CSettings::SETTING_VIDEOPLAYER_USEVDPAUVC1 },
+ { AV_CODEC_ID_MPEG2VIDEO, CSettings::SETTING_VIDEOPLAYER_USEVDPAUMPEG2 },
+ };
+ if (CDVDVideoCodec::IsCodecDisabled(settings_map, avctx->codec_id))
return false;
}