Commit 3306321e authored by JP Dinger's avatar JP Dinger Committed by Jean-Baptiste Kempf

De-deprecate activex plugin.

Signed-off-by: Rémi Denis-Courmont's avatarRémi Denis-Courmont <remi@remlab.net>
parent 37b1f6f2
......@@ -206,6 +206,9 @@ VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) :
_p_class(p_class),
_i_ref(1UL),
_p_libvlc(NULL),
_p_mlist(NULL),
_p_mplayer(NULL),
_i_midx(-1),
_i_codepage(CP_ACP),
_b_usermode(TRUE)
{
......@@ -267,6 +270,10 @@ VLCPlugin::~VLCPlugin()
SysFreeString(_bstr_mrl);
SysFreeString(_bstr_baseurl);
if( _p_mplayer ) { libvlc_media_player_release(_p_mplayer); _p_mplayer=NULL; }
if( _p_mlist ) { libvlc_media_list_release(_p_mlist); _p_mlist=NULL; }
if( _p_libvlc ) { libvlc_release(_p_libvlc); _p_libvlc=NULL; }
_p_class->Release();
};
......@@ -411,12 +418,11 @@ HRESULT VLCPlugin::onLoad(void)
return S_OK;
};
HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
void VLCPlugin::initVLC()
{
extern HMODULE DllGetModule();
if( ! isRunning() )
{
/*
** default initialization options
*/
......@@ -482,11 +488,14 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
libvlc_exception_init(&ex);
_p_libvlc = libvlc_new(ppsz_argc, ppsz_argv, &ex);
if( libvlc_exception_raised(&ex) )
return;
_p_mlist = libvlc_media_list_new(_p_libvlc, &ex);
if( libvlc_exception_raised(&ex) )
{
*pp_libvlc = NULL;
libvlc_exception_clear(&ex);
return E_FAIL;
libvlc_release(_p_libvlc);
return;
}
// initial volume setting
......@@ -536,13 +545,10 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
options[i_options++] = timeBuffer;
}
// add default target to playlist
libvlc_playlist_add_extended_untrusted(_p_libvlc, psz_mrl, NULL, i_options, options, NULL);
playlist_add_extended_untrusted(psz_mrl, i_options, options, NULL);
CoTaskMemFree(psz_mrl);
}
}
}
*pp_libvlc = _p_libvlc;
return S_OK;
};
void VLCPlugin::setErrorInfo(REFIID riid, const char *description)
......@@ -729,17 +735,11 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc
libvlc_video_set_parent(p_libvlc,
reinterpret_cast<libvlc_drawable_t>(_inplacewnd), NULL);
if( _b_autoplay )
{
libvlc_playlist_lock(p_libvlc);
unsigned count = libvlc_playlist_items_count(p_libvlc, &ex);
if( count > 0 )
if( _b_autoplay && playlist_select(0,NULL) )
{
libvlc_playlist_play(p_libvlc, 0, 0, NULL, NULL);
libvlc_media_player_play(_p_mplayer,NULL);
fireOnPlayEvent();
}
libvlc_playlist_unlock(p_libvlc);
}
}
if( isVisible() )
......@@ -750,9 +750,9 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc
HRESULT VLCPlugin::onInPlaceDeactivate(void)
{
if( isRunning() )
if( isPlaying(NULL) )
{
libvlc_playlist_stop(_p_libvlc, NULL);
playlist_stop(NULL);
fireOnStopEvent();
}
......@@ -817,14 +817,9 @@ void VLCPlugin::setTime(int seconds)
if( seconds != _i_time )
{
setStartTime(_i_time);
if( isRunning() )
{
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(_p_libvlc, NULL);
if( NULL != p_md )
if( NULL != _p_mplayer )
{
libvlc_media_player_set_time(p_md, _i_time, NULL);
libvlc_media_player_release(p_md);
}
libvlc_media_player_set_time(_p_mplayer, _i_time, NULL);
}
}
};
......@@ -1036,3 +1031,77 @@ void VLCPlugin::fireOnStopEvent(void)
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
vlcConnectionPointContainer->fireEvent(DISPID_StopEvent, &dispparamsNoArgs);
};
bool VLCPlugin::playlist_select( int idx, libvlc_exception_t *ex )
{
libvlc_media_t *p_m = NULL;
libvlc_media_list_lock(_p_mlist);
int count = libvlc_media_list_count(_p_mlist,ex);
if( libvlc_exception_raised(ex) )
goto bad_unlock;
if( idx<0||idx>=count )
goto bad_unlock;
_i_midx = idx;
p_m = libvlc_media_list_item_at_index(_p_mlist,_i_midx,ex);
libvlc_media_list_unlock(_p_mlist);
if( libvlc_exception_raised(ex) )
return false;
if( _p_mplayer )
{
libvlc_media_player_release( _p_mplayer );
_p_mplayer = NULL;
}
_p_mplayer = libvlc_media_player_new_from_media(p_m,ex);
if( _p_mplayer )
set_player_window(ex);
libvlc_media_release( p_m );
return !libvlc_exception_raised(ex);
bad_unlock:
libvlc_media_list_unlock(_p_mlist);
return false;
}
void VLCPlugin::set_player_window(libvlc_exception_t *ex)
{
// XXX FIXME no idea if this is correct or not
libvlc_media_player_set_hwnd(_p_mplayer,getInPlaceWindow(),ex);
}
int VLCPlugin::playlist_add_extended_untrusted(const char *mrl, int optc, const char **optv, libvlc_exception_t *ex)
{
int item = -1;
libvlc_media_t *p_m = libvlc_media_new(_p_libvlc,mrl,ex);
if( libvlc_exception_raised(ex) )
return -1;
for( int i = 0; i < optc; ++i )
{
libvlc_media_add_option_untrusted(p_m, optv[i],ex);
if( libvlc_exception_raised(ex) )
{
libvlc_media_release(p_m);
return -1;
}
}
libvlc_media_list_lock(_p_mlist);
libvlc_media_list_add_media(_p_mlist,p_m,ex);
if( !libvlc_exception_raised(ex) )
item = libvlc_media_list_count(_p_mlist,ex)-1;
libvlc_media_list_unlock(_p_mlist);
libvlc_media_release(p_m);
return item;
}
......@@ -193,7 +193,20 @@ public:
inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
inline BOOL isRunning(void) { return NULL != _p_libvlc; };
HRESULT getVLC(libvlc_instance_t** p_vlc);
HRESULT getVLC(libvlc_instance_t** pp_libvlc)
{
if( !isRunning() )
initVLC();
*pp_libvlc = _p_libvlc;
return _p_libvlc?S_OK:E_FAIL;
}
HRESULT getMD(libvlc_media_player_t **pp_md)
{
*pp_md = _p_mplayer;
return _p_mplayer?S_OK:E_FAIL;
}
void setErrorInfo(REFIID riid, const char *description);
// control geometry within container
......@@ -227,11 +240,81 @@ public:
// controlling IUnknown interface
LPUNKNOWN pUnkOuter;
/*
** libvlc interface
*/
bool isPlaying(libvlc_exception_t *ex)
{
return _p_mplayer && libvlc_media_player_is_playing(_p_mplayer,ex);
}
int playlist_get_current_index(libvlc_exception_t *) { return _i_midx; }
int playlist_add_extended_untrusted(const char *, int, const char **, libvlc_exception_t *);
void playlist_delete_item(int idx, libvlc_exception_t *ex)
{
if( _p_mlist )
libvlc_media_list_remove_index(_p_mlist,idx,ex);
}
void playlist_clear(libvlc_exception_t *ex)
{
if( !_p_libvlc )
return;
if( _p_mlist )
libvlc_media_list_release(_p_mlist);
_p_mlist = libvlc_media_list_new(_p_libvlc,ex);
}
int playlist_count(libvlc_exception_t *ex)
{
int r = 0;
if( !_p_mlist )
return 0;
libvlc_media_list_lock(_p_mlist);
r = libvlc_media_list_count(_p_mlist,ex);
libvlc_media_list_unlock(_p_mlist);
return r;
}
void playlist_pause(libvlc_exception_t *ex)
{
if( isPlaying(ex) )
libvlc_media_player_pause(_p_mplayer,ex);
}
void playlist_play(libvlc_exception_t *ex)
{
if( !_p_libvlc )
initVLC();
if( _p_mplayer||playlist_select(0,ex) )
libvlc_media_player_play(_p_mplayer,ex);
}
void playlist_play_item(int idx,libvlc_exception_t *ex)
{
if( !_p_libvlc )
initVLC();
if( playlist_select(idx,ex) )
libvlc_media_player_play(_p_mplayer,ex);
}
void playlist_stop(libvlc_exception_t *ex)
{
if( _p_mplayer )
libvlc_media_player_stop(_p_mplayer,ex);
}
void playlist_next(libvlc_exception_t *ex)
{
if( playlist_select( _i_midx+1, ex) )
libvlc_media_player_play(_p_mplayer,ex);
}
void playlist_prev(libvlc_exception_t *ex)
{
if( playlist_select( _i_midx-1, ex) )
libvlc_media_player_play(_p_mplayer,ex);
}
protected:
virtual ~VLCPlugin();
private:
void initVLC();
bool playlist_select(int i,libvlc_exception_t *);
void set_player_window(libvlc_exception_t *);
//implemented interfaces
class VLCOleObject *vlcOleObject;
......@@ -256,7 +339,11 @@ private:
VLCPluginClass* _p_class;
ULONG _i_ref;
libvlc_instance_t* _p_libvlc;
libvlc_instance_t *_p_libvlc;
libvlc_media_list_t *_p_mlist;
libvlc_media_player_t *_p_mplayer;
int _i_midx;
UINT _i_codepage;
BOOL _b_usermode;
RECT _posRect;
......
......@@ -124,14 +124,10 @@ STDMETHODIMP VLCControl::put_Visible(VARIANT_BOOL isVisible)
STDMETHODIMP VLCControl::play(void)
{
libvlc_instance_t* p_libvlc;
HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_playlist_play(p_libvlc, -1, 0, NULL, &ex);
_p_instance->playlist_play(&ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCControl,
......@@ -141,20 +137,18 @@ STDMETHODIMP VLCControl::play(void)
}
_p_instance->fireOnPlayEvent();
return NOERROR;
}
return result;
};
STDMETHODIMP VLCControl::pause(void)
{
libvlc_instance_t* p_libvlc;
HRESULT result = _p_instance->getVLC(&p_libvlc);
libvlc_media_player_t* p_md;
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_playlist_pause(p_libvlc, &ex);
libvlc_media_player_pause(p_md, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCControl,
......@@ -170,14 +164,14 @@ STDMETHODIMP VLCControl::pause(void)
STDMETHODIMP VLCControl::stop(void)
{
libvlc_instance_t* p_libvlc;
HRESULT result = _p_instance->getVLC(&p_libvlc);
libvlc_media_player_t *p_md;
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_playlist_stop(p_libvlc, &ex);
libvlc_media_player_stop(p_md, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCControl,
......@@ -196,22 +190,14 @@ STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)
if( NULL == isPlaying )
return E_POINTER;
HRESULT result = NOERROR;
if( _p_instance->isRunning() )
{
libvlc_instance_t *p_libvlc;
result = _p_instance->getVLC(&p_libvlc);
libvlc_media_player_t *p_md;
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{
libvlc_playlist_lock( p_libvlc );
if( libvlc_playlist_isplaying(p_libvlc, NULL) )
*isPlaying = VARIANT_TRUE;
else
*isPlaying = VARIANT_FALSE;
libvlc_playlist_unlock( p_libvlc );
*isPlaying = libvlc_media_player_is_playing(p_md, NULL) ?
VARIANT_TRUE : VARIANT_FALSE;
return NOERROR;
}
}
*isPlaying = VARIANT_FALSE;
return result;
};
......@@ -222,25 +208,18 @@ STDMETHODIMP VLCControl::get_Position(float *position)
return E_POINTER;
*position = 0.0f;
libvlc_instance_t* p_libvlc;
HRESULT result = E_UNEXPECTED;
result = _p_instance->getVLC(&p_libvlc);
libvlc_media_player_t *p_md;
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_t *p_md;
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( !libvlc_exception_raised(&ex) )
{
*position = libvlc_media_player_get_position(p_md, &ex);
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCControl,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
......@@ -251,25 +230,18 @@ STDMETHODIMP VLCControl::get_Position(float *position)
STDMETHODIMP VLCControl::put_Position(float position)
{
HRESULT result = E_UNEXPECTED;
libvlc_instance_t* p_libvlc;
result = _p_instance->getVLC(&p_libvlc);
libvlc_media_player_t *p_md;
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_t *p_md;
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) )
{
libvlc_media_player_set_position(p_md, position, &ex);
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCControl,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
......@@ -284,24 +256,18 @@ STDMETHODIMP VLCControl::get_Time(int *seconds)
return E_POINTER;
*seconds = 0;
libvlc_instance_t* p_libvlc;
HRESULT result = _p_instance->getVLC(&p_libvlc);
libvlc_media_player_t *p_md;
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_t *p_md;
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) )
{
*seconds = libvlc_media_player_get_time(p_md, &ex);
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCControl,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
......@@ -319,25 +285,19 @@ STDMETHODIMP VLCControl::put_Time(int seconds)
STDMETHODIMP VLCControl::shuttle(int seconds)
{
libvlc_instance_t* p_libvlc;
HRESULT result = _p_instance->getVLC(&p_libvlc);
libvlc_media_player_t *p_md;
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_t *p_md;
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) )
{
if( seconds < 0 ) seconds = 0;
libvlc_media_player_set_time(p_md, (int64_t)seconds, &ex);
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCControl,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
......@@ -349,27 +309,13 @@ STDMETHODIMP VLCControl::shuttle(int seconds)
STDMETHODIMP VLCControl::fullscreen(void)
{
HRESULT result = E_UNEXPECTED;
if( _p_instance->isRunning() )
{
libvlc_instance_t *p_libvlc;
result = _p_instance->getVLC(&p_libvlc);
libvlc_media_player_t *p_md;
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{
bool b_playing;
libvlc_playlist_lock( p_libvlc );
b_playing = libvlc_playlist_isplaying(p_libvlc, NULL);
libvlc_playlist_unlock( p_libvlc );
if( b_playing )
{
libvlc_media_player_t *p_md =
libvlc_playlist_get_media_player(p_libvlc, NULL);
if( p_md )
if( libvlc_media_player_is_playing(p_md, NULL) )
{
libvlc_toggle_fullscreen(p_md, NULL);
libvlc_media_player_release(p_md);
}
}
}
}
return result;
......@@ -381,24 +327,18 @@ STDMETHODIMP VLCControl::get_Length(int *seconds)
return E_POINTER;
*seconds = 0;
libvlc_instance_t* p_libvlc;
HRESULT result = _p_instance->getVLC(&p_libvlc);
libvlc_media_player_t *p_md;
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_t *p_md;
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) )
{
*seconds = (double)libvlc_media_player_get_length(p_md, &ex);
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCControl,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
......@@ -412,23 +352,17 @@ STDMETHODIMP VLCControl::playFaster(void)
{
int32_t rate = 2;
HRESULT result = E_UNEXPECTED;
if( !_p_instance->isRunning() )
return result;
libvlc_media_player_t *p_md;
HRESULT result = _p_instance->getMD(&p_md);
libvlc_instance_t* p_libvlc;
result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_t *p_md;
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) )
{
libvlc_media_player_set_rate(p_md, rate, &ex);
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
......@@ -446,28 +380,18 @@ STDMETHODIMP VLCControl::playSlower(void)
{
float rate = 0.5;
HRESULT result = E_UNEXPECTED;
if( !_p_instance->isRunning() )
return result;
libvlc_instance_t* p_libvlc;
result = _p_instance->getVLC(&p_libvlc);
libvlc_media_player_t *p_md;
HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_t *p_md;
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) )
{
libvlc_media_player_set_rate(p_md, rate, &ex);
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCControl,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
......@@ -880,10 +804,8 @@ STDMETHODIMP VLCControl::addTarget(BSTR uri, VARIANT options, enum VLCPlaylistMo
libvlc_exception_t ex;
libvlc_exception_init(&ex);
position = libvlc_playlist_add_extended(p_libvlc, cUri, cUri,
cOptionsCount,
const_cast<const char**>(cOptions),
&ex);
position = _p_instance->playlist_add_extended_untrusted(cUri,
cOptionsCount, const_cast<const char**>(cOptions), &ex);
FreeTargetOptions(cOptions, cOptionsCount);
CoTaskMemFree(cUri);
......@@ -919,7 +841,7 @@ STDMETHODIMP VLCControl::get_PlaylistIndex(int *index)
libvlc_exception_t ex;
libvlc_exception_init(&ex);
*index = libvlc_playlist_get_current_index(p_libvlc, &ex);
*index = _p_instance->playlist_get_current_index(&ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCControl,
......@@ -937,17 +859,10 @@ STDMETHODIMP VLCControl::get_PlaylistCount(int *count)
if( NULL == count )
return E_POINTER;
*count = 0;
libvlc_instance_t* p_libvlc;
HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_playlist_lock(p_libvlc);
*count = libvlc_playlist_items_count(p_libvlc, &ex);
libvlc_playlist_unlock(p_libvlc);
*count = _p_instance->playlist_count(&ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCControl,
......@@ -956,8 +871,6 @@ STDMETHODIMP VLCControl::get_PlaylistCount(int *count)
return E_FAIL;
}
return NOERROR;
}
return result;
};
STDMETHODIMP VLCControl::playlistNext(void)
......@@ -969,7 +882,7 @@ STDMETHODIMP VLCControl::playlistNext(void)
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_playlist_next(p_libvlc, &ex);
_p_instance->playlist_next(&ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCControl,
......@@ -991,7 +904,7 @@ STDMETHODIMP VLCControl::playlistPrev(void)
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_playlist_prev(p_libvlc, &ex);
_p_instance->playlist_prev(&ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCControl,
......@@ -1013,7 +926,7 @@ STDMETHODIMP VLCControl::playlistClear(void)
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_playlist_clear(p_libvlc, &ex);
_p_instance->playlist_clear(&ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCControl,
......
......@@ -211,17 +211,14 @@ STDMETHODIMP VLCAudio::get_track(long* track)
if( NULL == track )
return E_POINTER;
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
libvlc_media_player_t* p_md;
HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_t *p_md;
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
*track = libvlc_audio_get_track(p_md, &ex);
libvlc_media_player_release(p_md);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCAudio,
......@@ -236,17 +233,14 @@ STDMETHODIMP VLCAudio::get_track(long* track)
STDMETHODIMP VLCAudio::put_track(long track)
{
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_t *p_md;
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
libvlc_audio_set_track(p_md, track, &ex);
libvlc_media_player_release(p_md);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCAudio,
......@@ -413,24 +407,18 @@ STDMETHODIMP VLCInput::get_length(double* length)
return E_POINTER;
*length = 0;
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_media_player_t *p_md;
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) )
{
*length = (double)libvlc_media_player_get_length(p_md, &ex);
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCInput,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
......@@ -445,24 +433,18 @@ STDMETHODIMP VLCInput::get_position(double* position)