private static void ConnectTransport() { if (IsTransportConnected) { throw new System.InvalidOperationException(SR.Get(SRID.MediaSystem_OutOfOrderConnectOrDisconnect)); } // // Create a default transport to be used by this media system. // If creation fails, fall back to a local transport. // HRESULT.Check(UnsafeNativeMethods.WgxConnection_Create( false, // false means asynchronous transport out s_pConnection)); // Create service channel used by global glyph cache. This channel is // the first channel created for the app, and by creating it with // a null channel reference it creates a new partition. // All subsequent channel creates will pass in a reference to this // channel thus using its partition. s_serviceChannel = new DUCE.Channel( null, false, // not out of band s_pConnection, false); IsTransportConnected = true; }
internal DUCE.Channel AllocateSyncChannel() { DUCE.Channel syncChannel; if (_pSyncConnection == IntPtr.Zero) { HRESULT.Check(UnsafeNativeMethods.WgxConnection_Create( true, // true means synchronous transport out _pSyncConnection)); } if (_freeSyncChannels == null) { // // Ensure the free sync channels queue... // _freeSyncChannels = new Queue <DUCE.Channel>(3); } if (_freeSyncChannels.Count > 0) { // // If there is a free sync channel in the queue, we're done: // return(_freeSyncChannels.Dequeue()); } else { // // Otherwise, create a new channel. We will try to cache it // when the ReleaseSyncChannel call is made. Also ensure the // synchronous service channel and glyph cache. // if (_syncServiceChannel == null) { _syncServiceChannel = new DUCE.Channel( null, false, // not out of band _pSyncConnection, true // synchronous ); } syncChannel = new DUCE.Channel( _syncServiceChannel, false, // not out of band _pSyncConnection, true // synchronous ); return(syncChannel); } }
internal static void NotifyRedirectionEnvironmentChanged() { using (CompositionEngineLock.Acquire()) { // Check to see if we need to force software for the Vista Magnifier s_forceSoftareForGraphicsStreamMagnifier = UnsafeNativeMethods.WgxConnection_ShouldForceSoftwareForGraphicsStreamClient(); foreach (MediaContext mc in _mediaContexts) { mc.PostInvalidateRenderMode(); } } }
private static void DisconnectTransport() { if (!IsTransportConnected) { return; } // Close global glyph cache channel. s_serviceChannel.Close(); HRESULT.Check(UnsafeNativeMethods.WgxConnection_Disconnect(s_pConnection)); // Release references to global glyph cache and service channel. s_serviceChannel = null; s_pConnection = IntPtr.Zero; IsTransportConnected = false; }
public static bool Startup(MediaContext mc) { // // Note to stress triagers: // // This call will fail if PresentationCore.dll and milcore.dll have mismatched // versions -- please make sure that both binaries have been properly built // and deployed. // // *** Failure here does NOT indicate a bug in MediaContext.Startup! *** // HRESULT.Check(UnsafeNativeMethods.MilVersionCheck(MS.Internal.Composition.Version.MilSdkVersion)); using (CompositionEngineLock.Acquire()) { _mediaContexts.Add(mc); //Is this the first startup? if (0 == s_refCount) { HRESULT.Check(SafeNativeMethods.MilCompositionEngine_InitializePartitionManager( 0 // THREAD_PRIORITY_NORMAL )); s_forceSoftareForGraphicsStreamMagnifier = UnsafeNativeMethods.WgxConnection_ShouldForceSoftwareForGraphicsStreamClient(); ConnectTransport(); // Read a flag from the registry to determine whether we should run // animation smoothing code. ReadAnimationSmoothingSetting(); } s_refCount++; } // Consider making MediaSystem.ConnectTransport return the state of transport connectedness so // that we can initialize the media system to a disconnected state. return(true); }
internal void RemoveChannels() { if (_asyncChannel != null) { _asyncChannel.Close(); _asyncChannel = null; } if (_asyncOutOfBandChannel != null) { _asyncOutOfBandChannel.Close(); _asyncOutOfBandChannel = null; } RemoveSyncChannels(); if (_pSyncConnection != IntPtr.Zero) { HRESULT.Check(UnsafeNativeMethods.WgxConnection_Disconnect(_pSyncConnection)); _pSyncConnection = IntPtr.Zero; } }