Commit c7acc9f3 authored by JP Dinger's avatar JP Dinger

activex plugin: Replace duplicated get_object methods with calls to

a templated helper. The holder variables are not otherwise used so a
pointer to the (virtual) interface classes works fine.
parent f61d8c9f
......@@ -76,6 +76,21 @@ BIND_INTERFACE( VLCSubtitle )
#undef BIND_INTERFACE
template<class I> static inline
HRESULT object_get(I **dst, I *src)
{
if( NULL == dst )
return E_POINTER;
*dst = src;
if( NULL != src )
{
src->AddRef();
return NOERROR;
}
return E_OUTOFMEMORY;
}
// ---------
......@@ -1663,30 +1678,12 @@ STDMETHODIMP VLCVideo::toggleTeletext()
STDMETHODIMP VLCVideo::get_marquee(IVLCMarquee** obj)
{
if( NULL == obj )
return E_POINTER;
*obj = _p_vlcmarquee;
if( NULL != _p_vlcmarquee )
{
_p_vlcmarquee->AddRef();
return NOERROR;
}
return E_OUTOFMEMORY;
};
return object_get(obj,_p_vlcmarquee);
}
STDMETHODIMP VLCVideo::get_logo(IVLCLogo** obj)
{
if( NULL == obj )
return E_POINTER;
*obj = _p_vlclogo;
if( NULL != _p_vlclogo )
{
_p_vlclogo->AddRef();
return NOERROR;
}
return E_OUTOFMEMORY;
return object_get(obj,_p_vlclogo);
}
......@@ -2048,84 +2045,30 @@ STDMETHODIMP VLCControl2::put_BackColor(OLE_COLOR backcolor)
STDMETHODIMP VLCControl2::get_audio(IVLCAudio** obj)
{
if( NULL == obj )
return E_POINTER;
*obj = _p_vlcaudio;
if( NULL != _p_vlcaudio )
{
_p_vlcaudio->AddRef();
return NOERROR;
}
return E_OUTOFMEMORY;
};
return object_get(obj,_p_vlcaudio);
}
STDMETHODIMP VLCControl2::get_input(IVLCInput** obj)
{
if( NULL == obj )
return E_POINTER;
*obj = _p_vlcinput;
if( NULL != _p_vlcinput )
{
_p_vlcinput->AddRef();
return NOERROR;
}
return E_OUTOFMEMORY;
};
return object_get(obj,_p_vlcinput);
}
STDMETHODIMP VLCControl2::get_log(IVLCLog** obj)
{
if( NULL == obj )
return E_POINTER;
*obj = _p_vlclog;
if( NULL != _p_vlclog )
{
_p_vlclog->AddRef();
return NOERROR;
}
return E_OUTOFMEMORY;
};
return object_get(obj,_p_vlclog);
}
STDMETHODIMP VLCControl2::get_playlist(IVLCPlaylist** obj)
{
if( NULL == obj )
return E_POINTER;
*obj = _p_vlcplaylist;
if( NULL != _p_vlcplaylist )
{
_p_vlcplaylist->AddRef();
return NOERROR;
}
return E_OUTOFMEMORY;
};
return object_get(obj,_p_vlcplaylist);
}
STDMETHODIMP VLCControl2::get_subtitle(IVLCSubtitle** obj)
{
if( NULL == obj )
return E_POINTER;
*obj = _p_vlcsubtitle;
if( NULL != _p_vlcsubtitle )
{
_p_vlcsubtitle->AddRef();
return NOERROR;
}
return E_OUTOFMEMORY;
};
return object_get(obj,_p_vlcsubtitle);
}
STDMETHODIMP VLCControl2::get_video(IVLCVideo** obj)
{
if( NULL == obj )
return E_POINTER;
*obj = _p_vlcvideo;
if( NULL != _p_vlcvideo )
{
_p_vlcvideo->AddRef();
return NOERROR;
}
return E_OUTOFMEMORY;
};
return object_get(obj,_p_vlcvideo);
}
......@@ -277,7 +277,7 @@ public:
protected:
libvlc_log_t *_p_log;
VLCMessages* _p_vlcmessages;
IVLCMessages *_p_vlcmessages;
};
class VLCMarquee: public VLCInterface<VLCMarquee,IVLCMarquee>
......@@ -425,8 +425,8 @@ public:
STDMETHODIMP toggleTeletext();
private:
VLCMarquee* _p_vlcmarquee;
VLCLogo* _p_vlclogo;
IVLCMarquee *_p_vlcmarquee;
IVLCLogo *_p_vlclogo;
};
class VLCControl2 : public IVLCControl2
......@@ -493,15 +493,15 @@ protected:
HRESULT loadTypeInfo();
private:
VLCPlugin* _p_instance;
ITypeInfo* _p_typeinfo;
VLCAudio* _p_vlcaudio;
VLCInput* _p_vlcinput;
VLCLog * _p_vlclog;
VLCPlaylist* _p_vlcplaylist;
VLCSubtitle* _p_vlcsubtitle;
VLCVideo* _p_vlcvideo;
VLCPlugin *_p_instance;
ITypeInfo *_p_typeinfo;
IVLCAudio *_p_vlcaudio;
IVLCInput *_p_vlcinput;
IVLCLog *_p_vlclog;
IVLCPlaylist *_p_vlcplaylist;
IVLCSubtitle *_p_vlcsubtitle;
IVLCVideo *_p_vlcvideo;
};
#endif
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