return (NULL != *ppEnum ) ? S_OK : E_OUTOFMEMORY;
};
-void VLCConnectionPoint::fireEvent(DISPID dispId, DISPPARAMS* pDispParams)
+void VLCConnectionPoint::fireEvent(DISPID dispId, DISPPARAMS *pDispParams)
{
vector<CONNECTDATA>::iterator end = _connections.end();
vector<CONNECTDATA>::iterator iter = _connections.begin();
while( ! _q_events.empty() )
{
VLCDispatchEvent *ev = _q_events.front();
+ _q_events.pop();
_p_events->fireEvent(ev->_dispId, &ev->_dispParams);
delete ev;
- _q_events.pop();
}
}
_b_freeze = freeze;
void VLCConnectionPointContainer::fireEvent(DISPID dispId, DISPPARAMS* pDispParams)
{
- VLCDispatchEvent *evt = new VLCDispatchEvent(dispId, *pDispParams);
if( _b_freeze )
{
// queue event for later use when container is ready
- _q_events.push(evt);
+ _q_events.push(new VLCDispatchEvent(dispId, *pDispParams));
if( _q_events.size() > 10 )
{
// too many events in queue, get rid of older one
else
{
_p_events->fireEvent(dispId, pDispParams);
- delete evt;
}
};
{
if( 0 == _i_vlc )
{
-#ifdef ACTIVEX_DEBUG
- char *ppsz_argv[] = { "vlc", "-vv", "--fast-mutex", "--win9x-cv-method=1" };
-#else
- char *ppsz_argv[] = { "vlc", "-vv" };
-#endif
+ _i_vlc = VLC_Create();
+ if( _i_vlc < 0 )
+ {
+ _i_vlc = 0;
+ return E_FAIL;
+ }
+
+ /*
+ ** default initialization options
+ */
+ char *ppsz_argv[10] = { "vlc", "-vv" };
+ int ppsz_argc = 2;
+
HKEY h_key;
DWORD i_type, i_data = MAX_PATH + 1;
char p_data[MAX_PATH + 1];
RegCloseKey( h_key );
}
-#if 0
+#if 1
ppsz_argv[0] = "C:\\cygwin\\home\\Damien_Fouilleul\\dev\\videolan\\vlc-trunk\\vlc";
#endif
- _i_vlc = VLC_Create();
- if( _i_vlc < 0 )
+ if( IsDebuggerPresent() )
{
- _i_vlc = 0;
- return E_FAIL;
+ /*
+ ** VLC default threading mechanism is designed to be as compatible
+ ** with POSIX as possible, however when debugged on win32, threads
+ ** lose signals and eventually VLC get stuck during initialization.
+ ** threading support can be configured to be more debugging friendly
+ ** but it will be less compatible with POSIX.
+ ** This is done by initializing with the following options
+ */
+ ppsz_argv[ppsz_argc++] = "--fast-mutex";
+ ppsz_argv[ppsz_argc++] = "--win9x-cv-method=1";
}
- if( VLC_Init(_i_vlc, sizeof(ppsz_argv)/sizeof(char*), ppsz_argv) )
+ if( VLC_Init(_i_vlc, ppsz_argc, ppsz_argv) )
{
VLC_Destroy(_i_vlc);
_i_vlc = 0;
}
VariantInit(&v);
V_VT(&v) = VT_I4;
- if( SUCCEEDED(GetObjectProperty(pContainer, dispID, v)) )
+ if( SUCCEEDED(GetObjectProperty(pContainer, DISPID_AMBIENT_CODEPAGE, v)) )
{
setCodePage(V_I4(&v));
+ VariantClear(&v);
}
break;
}
void setFocus(BOOL fFocus);
inline UINT getCodePage(void) { return _i_codepage; };
- inline void setCodePage(UINT cp) { _i_codepage = cp; };
+ inline void setCodePage(UINT cp)
+ {
+ // accept new codepage only if it works on this system
+ size_t mblen = WideCharToMultiByte(cp,
+ 0, L"test", -1, NULL, 0, NULL, NULL);
+ if( mblen > 0 )
+ _i_codepage = cp;
+ };
inline BOOL isUserMode(void) { return _b_usermode; };
inline void setUserMode(BOOL um) { _b_usermode = um; };
using namespace std;
-char *CStrFromBSTR(int codePage, BSTR bstr)
+char *CStrFromBSTR(UINT codePage, BSTR bstr)
{
UINT len = SysStringLen(bstr);
if( len > 0 )
return NULL;
};
-BSTR BSTRFromCStr(int codePage, const char *s)
+BSTR BSTRFromCStr(UINT codePage, LPCSTR s)
{
int wideLen = MultiByteToWideChar(codePage, 0, s, -1, NULL, 0);
if( wideLen > 0 )
#include <vector>
// utilities
-extern char *CStrFromBSTR(int codePage, BSTR bstr);
-extern BSTR BSTRFromCStr(int codePage, const char *s);
+extern char *CStrFromBSTR(UINT codePage, BSTR bstr);
+extern BSTR BSTRFromCStr(UINT codePage, LPCSTR s);
// properties
extern HRESULT GetObjectProperty(LPUNKNOWN object, DISPID dispID, VARIANT& v);
STDMETHODIMP VLCControl::getVariable( BSTR name, VARIANT *value)
{
- if( 0 == SysStringLen(name) )
- return E_INVALIDARG;
-
if( NULL == value )
return E_POINTER;
+ VariantInit(value);
+
+ if( 0 == SysStringLen(name) )
+ return E_INVALIDARG;
+
int i_vlc = _p_instance->getVLCObject();
if( i_vlc )
{
- int codePage = _p_instance->getCodePage();
+ UINT codePage = _p_instance->getCodePage();
char *psz_varname = CStrFromBSTR(codePage, name);
if( NULL == psz_varname )
return E_OUTOFMEMORY;
case VLC_VAR_VARIABLE:
V_VT(value) = VT_BSTR;
V_BSTR(value) = BSTRFromCStr(codePage, val.psz_string);
- CoTaskMemFree(val.psz_string);
+ if( NULL != val.psz_string)
+ free(val.psz_string);
break;
case VLC_VAR_TIME: