bool CVideoRenderer::Initialize ( const WCHAR * fileName ) { HRESULT hr; #define EIF( _x ) if( FAILED( hr=_x ) ) goto error // --- check for a valid device if ( !m_pDevice ) return false; Lock (); // --- create the filter graph EIF( CoCreateInstance( CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void **)&m_pGraph ) ); m_pFilter = CreateTextureRenderer ( &hr, m_pDevice, this ); EIF( hr ); // --- add our texture filter and set up the graph to render to this filter m_pGraph->AddFilter( m_pFilter, L"Texture renderer" ); EIF( RenderFileToVideoRenderer( m_pGraph, fileName, FALSE ) ); #ifdef _DEBUG // --- register this graph for use with graphedt if( FAILED( hr = AddGraphToRot( m_pGraph, &m_dwGraphRegister ) ) ) { // ACHTUNG: failure, report and move on } #endif // --- get some interfaces m_pGraph->QueryInterface( IID_IMediaSeeking, (void**)&m_pMediaSeeking ); m_pGraph->QueryInterface( IID_IMediaControl, (void**)&m_pMediaControl ); m_pGraph->QueryInterface( IID_IBasicAudio, (void**)&m_pBasicAudio ); m_pBasicAudio->get_Volume ( &lDefaultVolume ); // --- clean up m_pGraph->Release (); m_pGraph = NULL; // --- unlock the mutex Unlock (); return true; error: // --- failure occurred hr = hr; return false; }
static DWORD str_to_charset(const char *str) { if(!str || !*str) return DEFAULT_CHARSET; #define EIF(s) else if(!strcmp(str, s)) return if(strstr(str, "8859")) return ANSI_CHARSET; //Return ANSI for ISO8859-* ? EIF("Ansi") ANSI_CHARSET; EIF("Baltic") BALTIC_CHARSET; EIF("Chinese Big5") CHINESEBIG5_CHARSET; EIF("Eastern Europe") EASTEUROPE_CHARSET; EIF("Gb2312") GB2312_CHARSET; EIF("Greek") GREEK_CHARSET; #ifndef _WIN32_WCE EIF("Hangul") HANGUL_CHARSET; #endif EIF("MAC") MAC_CHARSET; EIF("OEM") OEM_CHARSET; EIF("Russian") RUSSIAN_CHARSET; EIF("Shift Jis") SHIFTJIS_CHARSET; EIF("Symbol") SYMBOL_CHARSET; EIF("Turkish") TURKISH_CHARSET; EIF("Vietnamese") VIETNAMESE_CHARSET; EIF("Johab") JOHAB_CHARSET; EIF("Arabic") ARABIC_CHARSET; EIF("Hebrew") HEBREW_CHARSET; EIF("Thai") THAI_CHARSET; return DEFAULT_CHARSET; }