Commit df2c5327 authored by Daniel Amm's avatar Daniel Amm Committed by Jean-Baptiste Kempf

ActiveX/NPAPI: Don't return -1 for count properties (refs #14752)

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent e3a92482
...@@ -90,6 +90,8 @@ HRESULT object_get(I **dst, I *src) ...@@ -90,6 +90,8 @@ HRESULT object_get(I **dst, I *src)
static inline static inline
VARIANT_BOOL varbool(bool b) { return b ? VARIANT_TRUE : VARIANT_FALSE; } VARIANT_BOOL varbool(bool b) { return b ? VARIANT_TRUE : VARIANT_FALSE; }
static inline INT negativeToZero(int i) { return i < 0 ? 0 : i; }
static HRESULT parseStringOptions(int codePage, BSTR bstr, char*** cOptions, int *cOptionCount) static HRESULT parseStringOptions(int codePage, BSTR bstr, char*** cOptions, int *cOptionCount)
{ {
HRESULT hr = E_INVALIDARG; HRESULT hr = E_INVALIDARG;
...@@ -464,7 +466,7 @@ STDMETHODIMP VLCAudio::get_count(long* trackNumber) ...@@ -464,7 +466,7 @@ STDMETHODIMP VLCAudio::get_count(long* trackNumber)
if( NULL == trackNumber ) if( NULL == trackNumber )
return E_POINTER; return E_POINTER;
*trackNumber = _plug->get_player().get_mp().audioTrackCount(); *trackNumber = negativeToZero( _plug->get_player().get_mp().audioTrackCount() );
return S_OK; return S_OK;
} }
...@@ -530,7 +532,7 @@ STDMETHODIMP VLCTitle::get_count(long* countTracks) ...@@ -530,7 +532,7 @@ STDMETHODIMP VLCTitle::get_count(long* countTracks)
if( NULL == countTracks ) if( NULL == countTracks )
return E_POINTER; return E_POINTER;
*countTracks = _plug->get_player().get_mp().titleCount(); *countTracks = negativeToZero( _plug->get_player().get_mp().titleCount() );
return S_OK; return S_OK;
} }
...@@ -568,7 +570,7 @@ STDMETHODIMP VLCChapter::get_count(long* countTracks) ...@@ -568,7 +570,7 @@ STDMETHODIMP VLCChapter::get_count(long* countTracks)
if( NULL == countTracks ) if( NULL == countTracks )
return E_POINTER; return E_POINTER;
*countTracks = _plug->get_player().get_mp().chapterCount(); *countTracks = negativeToZero( _plug->get_player().get_mp().chapterCount() );
return S_OK; return S_OK;
} }
...@@ -577,7 +579,7 @@ STDMETHODIMP VLCChapter::countForTitle(long track, long* countTracks) ...@@ -577,7 +579,7 @@ STDMETHODIMP VLCChapter::countForTitle(long track, long* countTracks)
if( NULL == countTracks ) if( NULL == countTracks )
return E_POINTER; return E_POINTER;
*countTracks = _plug->get_player().get_mp().chapterCountForTitle(track); *countTracks = negativeToZero( _plug->get_player().get_mp().chapterCountForTitle(track) );
return S_OK; return S_OK;
} }
......
...@@ -262,7 +262,7 @@ LibvlcAudioNPObject::getProperty(int index, npapi::OutVariant& result) ...@@ -262,7 +262,7 @@ LibvlcAudioNPObject::getProperty(int index, npapi::OutVariant& result)
} }
case ID_audio_count: case ID_audio_count:
{ {
result = mp.audioTrackCount(); result = negativeToZero( mp.audioTrackCount() );
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_audio_channel: case ID_audio_channel:
...@@ -1975,7 +1975,7 @@ LibvlcTitleNPObject::getProperty(int index, npapi::OutVariant& result) ...@@ -1975,7 +1975,7 @@ LibvlcTitleNPObject::getProperty(int index, npapi::OutVariant& result)
{ {
case ID_title_count: case ID_title_count:
{ {
result = mp.titleCount(); result = negativeToZero( mp.titleCount() );
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_title_track: case ID_title_track:
...@@ -2099,7 +2099,7 @@ LibvlcChapterNPObject::getProperty(int index, npapi::OutVariant& result) ...@@ -2099,7 +2099,7 @@ LibvlcChapterNPObject::getProperty(int index, npapi::OutVariant& result)
{ {
case ID_chapter_count: case ID_chapter_count:
{ {
result = mp.chapterCount(); result = negativeToZero( mp.chapterCount() );
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_chapter_track: case ID_chapter_track:
...@@ -2181,7 +2181,7 @@ LibvlcChapterNPObject::invoke(int index, const NPVariant *args, ...@@ -2181,7 +2181,7 @@ LibvlcChapterNPObject::invoke(int index, const NPVariant *args,
const npapi::Variant v( args[0] ); const npapi::Variant v( args[0] );
if( v.is<int>() ) if( v.is<int>() )
{ {
result = mp.chapterCountForTitle( v ); result = negativeToZero( mp.chapterCountForTitle( v ) );
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
......
...@@ -49,6 +49,11 @@ public: ...@@ -49,6 +49,11 @@ public:
// ownership problems with firefox. // ownership problems with firefox.
template<class T> void InstantObj( NPObject *&obj ); template<class T> void InstantObj( NPObject *&obj );
inline int negativeToZero( int i )
{
return i < 0 ? 0 : i;
}
bool isValid() bool isValid()
{ {
return _instance != NULL; return _instance != NULL;
......
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