]> git.sesse.net Git - vlc/commitdiff
Remove VLCPlugin::getVLCObject() methond from ActiveX
authorJean-Paul Saman <jpsaman@videolan.org>
Tue, 10 Jun 2008 07:43:29 +0000 (09:43 +0200)
committerJean-Paul Saman <jpsaman@videolan.org>
Sat, 14 Jun 2008 08:09:05 +0000 (10:09 +0200)
projects/activex/plugin.cpp
projects/activex/plugin.h
projects/activex/vlccontrol.cpp

index 5aa6400e4c290fd6421754fa3b7fc85e9f31233e..72d9848e90b200661dfd9c8472def01b34b2b0e3 100644 (file)
@@ -410,21 +410,6 @@ HRESULT VLCPlugin::onLoad(void)
     return S_OK;
 };
 
-HRESULT VLCPlugin::getVLCObject(int* i_vlc)
-{
-    libvlc_instance_t *p_libvlc;
-    HRESULT result = getVLC(&p_libvlc);
-    if( SUCCEEDED(result) )
-    {
-        *i_vlc = libvlc_get_vlc_id(p_libvlc);
-    }
-    else
-    {
-        *i_vlc = 0;
-    }
-    return result;
-}
-
 HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
 {
     extern HMODULE DllGetModule();
@@ -485,16 +470,21 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
         /* common settings */
         ppsz_argv[ppsz_argc++] = "--no-stats";
         ppsz_argv[ppsz_argc++] = "--no-media-library";
+        ppsz_argv[ppsz_argc++] = "--ignore-config";
         ppsz_argv[ppsz_argc++] = "--intf=dummy";
 
         // loop mode is a configuration option only
         if( _b_autoloop )
             ppsz_argv[ppsz_argc++] = "--loop";
 
-        _p_libvlc = libvlc_new(ppsz_argc, ppsz_argv, NULL);
-        if( NULL == _p_libvlc )
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        _p_libvlc = libvlc_new(ppsz_argc, ppsz_argv, &ex);
+        if( libvlc_exception_raised(&ex) )
         {
             *pp_libvlc = NULL;
+            libvlc_exception_clear(&ex);
             return E_FAIL;
         }
 
@@ -668,7 +658,8 @@ HRESULT VLCPlugin::onClose(DWORD dwSaveOption)
         _p_libvlc = NULL;
         vlcDataObject->onClose();
 
-        libvlc_release(p_libvlc);
+        if( p_libvlc )
+            libvlc_release(p_libvlc);
     }
     return S_OK;
 };
index 7e6c0e770c010e3c47c15a0d51631216969a9ebc..62c4b18bfeb7333684e01fea2133d422d812af1b 100644 (file)
@@ -27,7 +27,6 @@
 #include <olectl.h>
 
 #include <vlc/vlc.h>
-#include <vlc/libvlc.h>
 
 extern "C" const GUID CLSID_VLCPlugin;
 extern "C" const GUID CLSID_VLCPlugin2;
@@ -194,7 +193,6 @@ public:
     inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
 
     inline BOOL isRunning(void) { return NULL != _p_libvlc; };
-    HRESULT getVLCObject(int *i_vlc);
     HRESULT getVLC(libvlc_instance_t** p_vlc);
     void setErrorInfo(REFIID riid, const char *description);
 
index ea972919bf78eba08414bbcc5beac055f1200057..8d7509ee6f899aa19bb0369a65c6af45186880bb 100644 (file)
@@ -123,8 +123,8 @@ STDMETHODIMP VLCControl::put_Visible(VARIANT_BOOL isVisible)
 
 STDMETHODIMP VLCControl::play(void)
 {
-    int i_vlc;
-    HRESULT result = _p_instance->getVLCObject(&i_vlc);
+    libvlc_instance_t *p_libvlc;
+    HRESULT result = _p_instance->getVLC(&p_libvlc);
     if( SUCCEEDED(result) )
     {
         VLC_Play(i_vlc);
@@ -135,8 +135,8 @@ STDMETHODIMP VLCControl::play(void)
 
 STDMETHODIMP VLCControl::pause(void)
 {
-    int i_vlc;
-    HRESULT result = _p_instance->getVLCObject(&i_vlc);
+    libvlc_instance_t *p_libvlc;
+    HRESULT result = _p_instance->getVLC(&p_libvlc);
     if( SUCCEEDED(result) )
     {
         VLC_Pause(i_vlc);
@@ -147,8 +147,8 @@ STDMETHODIMP VLCControl::pause(void)
 
 STDMETHODIMP VLCControl::stop(void)
 {
-    int i_vlc;
-    HRESULT result = _p_instance->getVLCObject(&i_vlc);
+    libvlc_instance_t *p_libvlc;
+    HRESULT result = _p_instance->getVLC(&p_libvlc);
     if( SUCCEEDED(result) )
     {
         VLC_Stop(i_vlc);
@@ -165,11 +165,14 @@ STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)
     HRESULT result = NOERROR;
     if( _p_instance->isRunning() )
     {
-        int i_vlc;
-        result = _p_instance->getVLCObject(&i_vlc);
+        libvlc_instance_t *p_libvlc;
+        result = _p_instance->getVLC(&p_libvlc);
         if( SUCCEEDED(result) )
         {
-            *isPlaying = VLC_IsPlaying(i_vlc) ? VARIANT_TRUE : VARIANT_FALSE;
+            if( libvlc_playlist_isplaying(p_libvlc, NULL) )
+                *isPlaying = VARIANT_TRUE;
+            else
+                *isPlaying = VARIANT_FALSE;
             return NOERROR;
         }
     }
@@ -185,8 +188,8 @@ STDMETHODIMP VLCControl::get_Position(float *position)
     HRESULT result = E_UNEXPECTED;
     if( _p_instance->isRunning() )
     {
-        int i_vlc;
-        result = _p_instance->getVLCObject(&i_vlc);
+        libvlc_instance_t *p_libvlc;
+        result = _p_instance->getVLC(&p_libvlc);
         if( SUCCEEDED(result) )
         {
             *position = VLC_PositionGet(i_vlc);
@@ -202,8 +205,8 @@ STDMETHODIMP VLCControl::put_Position(float position)
     HRESULT result = E_UNEXPECTED;
     if( _p_instance->isRunning() )
     {
-        int i_vlc;
-        result = _p_instance->getVLCObject(&i_vlc);
+        libvlc_instance_t *p_libvlc;
+        result = _p_instance->getVLC(&p_libvlc);
         if( SUCCEEDED(result) )
         {
             VLC_PositionSet(i_vlc, position);
@@ -220,8 +223,8 @@ STDMETHODIMP VLCControl::get_Time(int *seconds)
     HRESULT result = NOERROR;
     if( _p_instance->isRunning() )
     {
-        int i_vlc;
-        result = _p_instance->getVLCObject(&i_vlc);
+        libvlc_instance_t *p_libvlc;
+        result = _p_instance->getVLC(&p_libvlc);
         if( SUCCEEDED(result) )
         {
             *seconds = VLC_TimeGet(i_vlc);
@@ -245,8 +248,8 @@ STDMETHODIMP VLCControl::shuttle(int seconds)
     HRESULT result = E_UNEXPECTED;
     if( _p_instance->isRunning() )
     {
-        int i_vlc;
-        result = _p_instance->getVLCObject(&i_vlc);
+        libvlc_instance_t *p_libvlc;
+        result = _p_instance->getVLC(&p_libvlc);
         if( SUCCEEDED(result) )
         {
             VLC_TimeSet(i_vlc, seconds, true);
@@ -260,11 +263,20 @@ STDMETHODIMP VLCControl::fullscreen(void)
     HRESULT result = E_UNEXPECTED;
     if( _p_instance->isRunning() )
     {
-        int i_vlc;
-        result = _p_instance->getVLCObject(&i_vlc);
+        libvlc_instance_t *p_libvlc;
+        result = _p_instance->getVLC(&p_libvlc);
         if( SUCCEEDED(result) )
         {
-            VLC_FullScreen(i_vlc);
+            if( libvlc_playlist_isplaying(p_libvlc, NULL) )
+            {
+                libvlc_media_player_t *p_md =
+                    libvlc_playlist_get_media_player(p_libvlc, NULL);
+                if( p_md )
+                {
+                    libvlc_toggle_fullscreen(p_md, NULL);
+                    libvlc_media_player_release(p_md);
+                }
+            }
         }
     }
     return result;
@@ -278,8 +290,8 @@ STDMETHODIMP VLCControl::get_Length(int *seconds)
     HRESULT result = NOERROR;
     if( _p_instance->isRunning() )
     {
-        int i_vlc;
-        result = _p_instance->getVLCObject(&i_vlc);
+        libvlc_instance_t *p_libvlc;
+        result = _p_instance->getVLC(&p_libvlc);
         if( SUCCEEDED(result) )
         {
             *seconds = VLC_LengthGet(i_vlc);
@@ -295,8 +307,8 @@ STDMETHODIMP VLCControl::playFaster(void)
     HRESULT result = E_UNEXPECTED;
     if( _p_instance->isRunning() )
     {
-        int i_vlc;
-        result = _p_instance->getVLCObject(&i_vlc);
+        libvlc_instance_t *p_libvlc;
+        result = _p_instance->getVLC(&p_libvlc);
         if( SUCCEEDED(result) )
         {
             VLC_SpeedFaster(i_vlc);
@@ -310,8 +322,8 @@ STDMETHODIMP VLCControl::playSlower(void)
     HRESULT result = E_UNEXPECTED;
     if( _p_instance->isRunning() )
     {
-        int i_vlc;
-        result = _p_instance->getVLCObject(&i_vlc);
+        libvlc_instance_t *p_libvlc;
+        result = _p_instance->getVLC(&p_libvlc);
         if( SUCCEEDED(result) )
         {
             VLC_SpeedSlower(i_vlc);
@@ -337,8 +349,8 @@ STDMETHODIMP VLCControl::put_Volume(int volume)
 
 STDMETHODIMP VLCControl::toggleMute(void)
 {
-    int i_vlc;
-    HRESULT result = _p_instance->getVLCObject(&i_vlc);
+    libvlc_instance_t *p_libvlc;
+    HRESULT result = _p_instance->getVLC(&p_libvlc);
     if( SUCCEEDED(result) )
     {
         VLC_VolumeMute(i_vlc);
@@ -351,8 +363,8 @@ STDMETHODIMP VLCControl::setVariable(BSTR name, VARIANT value)
     if( 0 == SysStringLen(name) )
         return E_INVALIDARG;
 
-    int i_vlc;
-    HRESULT hr = _p_instance->getVLCObject(&i_vlc);
+    libvlc_instance_t *p_libvlc;
+    HRESULT result = _p_instance->getVLC(&p_libvlc);
     if( SUCCEEDED(hr) )
     {
         int codePage = _p_instance->getCodePage();
@@ -466,8 +478,8 @@ STDMETHODIMP VLCControl::getVariable( BSTR name, VARIANT *value)
     if( 0 == SysStringLen(name) )
         return E_INVALIDARG;
 
-    int i_vlc;
-    HRESULT hr = _p_instance->getVLCObject(&i_vlc);
+    libvlc_instance_t *p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
     if( SUCCEEDED(hr) )
     {
         UINT codePage = _p_instance->getCodePage();
@@ -853,8 +865,8 @@ STDMETHODIMP VLCControl::addTarget( BSTR uri, VARIANT options, enum VLCPlaylistM
     if( 0 == SysStringLen(uri) )
         return E_INVALIDARG;
 
-    int i_vlc;
-    HRESULT hr = _p_instance->getVLCObject(&i_vlc);
+    libvlc_instance_t *p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
     if( SUCCEEDED(hr) )
     {
         char *cUri = CStrFromBSTR(CP_UTF8, uri);
@@ -891,8 +903,8 @@ STDMETHODIMP VLCControl::get_PlaylistIndex(int *index)
     if( NULL == index )
         return E_POINTER;
 
-    int i_vlc;
-    HRESULT result = _p_instance->getVLCObject(&i_vlc);
+    libvlc_instance_t *p_libvlc;
+    HRESULT result = _p_instance->getVLC(&p_libvlc);
     if( SUCCEEDED(result) )
     {
         *index = VLC_PlaylistIndex(i_vlc);
@@ -904,8 +916,8 @@ STDMETHODIMP VLCControl::get_PlaylistIndex(int *index)
 
 STDMETHODIMP VLCControl::get_PlaylistCount(int *count)
 {
-    int i_vlc;
-    HRESULT result = _p_instance->getVLCObject(&i_vlc);
+    libvlc_instance_t *p_libvlc;
+    HRESULT result = _p_instance->getVLC(&p_libvlc);
     if( SUCCEEDED(result) )
     {
         *count = VLC_PlaylistNumberOfItems(i_vlc);
@@ -917,8 +929,8 @@ STDMETHODIMP VLCControl::get_PlaylistCount(int *count)
 
 STDMETHODIMP VLCControl::playlistNext(void)
 {
-    int i_vlc;
-    HRESULT result = _p_instance->getVLCObject(&i_vlc);
+    libvlc_instance_t *p_libvlc;
+    HRESULT result = _p_instance->getVLC(&p_libvlc);
     if( SUCCEEDED(result) )
     {
         VLC_PlaylistNext(i_vlc);
@@ -929,8 +941,8 @@ STDMETHODIMP VLCControl::playlistNext(void)
 
 STDMETHODIMP VLCControl::playlistPrev(void)
 {
-    int i_vlc;
-    HRESULT result = _p_instance->getVLCObject(&i_vlc);
+    libvlc_instance_t *p_libvlc;
+    HRESULT result = _p_instance->getVLC(&p_libvlc);
     if( SUCCEEDED(result) )
     {
         VLC_PlaylistPrev(i_vlc);
@@ -941,8 +953,8 @@ STDMETHODIMP VLCControl::playlistPrev(void)
 
 STDMETHODIMP VLCControl::playlistClear(void)
 {
-    int i_vlc;
-    HRESULT result = _p_instance->getVLCObject(&i_vlc);
+    libvlc_instance_t *p_libvlc;
+    HRESULT result = _p_instance->getVLC(&p_libvlc);
     if( SUCCEEDED(result) )
     {
         VLC_PlaylistClear(i_vlc);
@@ -956,11 +968,11 @@ STDMETHODIMP VLCControl::get_VersionInfo(BSTR *version)
     if( NULL == version )
         return E_POINTER;
 
-    const char *versionStr = VLC_Version();
+    const char *versionStr = libvlc_get_version();
     if( NULL != versionStr )
     {
         *version = BSTRFromCStr(CP_UTF8, versionStr);
+
         return NULL == *version ? E_OUTOFMEMORY : NOERROR;
     }
     *version = NULL;