[vlc-devel] [PATCH 2/3] activex/npapi: fix vlc.video.subtitle index

Daniel Amm da2424 at t-online.de
Thu May 21 20:24:19 CEST 2015


---
 activex/vlccontrol2.cpp       |  7 +++++--
 npapi/npruntime/npolibvlc.cpp | 10 +++++-----
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/activex/vlccontrol2.cpp b/activex/vlccontrol2.cpp
index 14da696..84a4601 100644
--- a/activex/vlccontrol2.cpp
+++ b/activex/vlccontrol2.cpp
@@ -981,13 +981,16 @@ STDMETHODIMP VLCVideo::get_subtitle(long* spu)
     if( NULL == spu )
         return E_POINTER;
 
-    *spu = _plug->get_player().get_mp().spu();
+    *spu = _plug->get_player().currentSubtitleTrack();
     return S_OK;
 }
 
 STDMETHODIMP VLCVideo::put_subtitle(long spu)
 {
-    _plug->get_player().get_mp().setSpu( spu );
+    auto tracks = _plug->get_player().get_mp().spuDescription();
+    if ( spu >= tracks.size() )
+        return E_INVALIDARG;
+    _plug->get_player().get_mp().setSpu( tracks[spu].id() );
     return S_OK;
 }
 
diff --git a/npapi/npruntime/npolibvlc.cpp b/npapi/npruntime/npolibvlc.cpp
index 5329e8c..246fac3 100644
--- a/npapi/npruntime/npolibvlc.cpp
+++ b/npapi/npruntime/npolibvlc.cpp
@@ -1172,15 +1172,12 @@ LibvlcSubtitleNPObject::getProperty(int index, npapi::OutVariant& result)
         {
             case ID_subtitle_track:
             {
-                /* get the current internal subtitles track ID */
                 result = p_plugin->player().currentSubtitleTrack();
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_subtitle_count:
             {
-                /* get the number of subtitles available */
                 result = mp.spuCount();
-                /* return it */
                 return INVOKERESULT_NO_ERROR;
             }
         }
@@ -1353,7 +1350,7 @@ LibvlcVideoNPObject::getProperty(int index, npapi::OutVariant& result)
             }
             case ID_video_subtitle:
             {
-                result = mp.spu();
+                result = p_plugin->player().currentSubtitleTrack();
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_video_crop:
@@ -1436,7 +1433,10 @@ LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
             {
                 if( v.is<int>() )
                 {
-                    mp.setSpu( v );
+                    auto tracks = mp.spuDescription();
+                    if ( v >= tracks.size() )
+                        return INVOKERESULT_INVALID_ARGS;
+                    mp.setSpu( tracks[ v ].id() );
                     return INVOKERESULT_NO_ERROR;
                 }
                 return INVOKERESULT_INVALID_VALUE;
-- 
2.1.4




More information about the vlc-devel mailing list