Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Speech / Src / Internal / SapiInterop / SpStreamWrapper.cs / 1 / SpStreamWrapper.cs
//------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // // // // Description: // Maps an audio stream the SAPI ISpStreamFormat // // History: // 7/10/2005 [....] //----------------------------------------------------------------- using System; using System.IO; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using System.Speech.AudioFormat; using System.Speech.Internal.SapiInterop; using System.Speech.Internal.Synthesis; #pragma warning disable 1634, 1691 // Allows suppression of certain PreSharp messages. using STATSTG = System.Runtime.InteropServices.ComTypes.STATSTG; namespace System.Speech.Internal.SapiInterop { internal class SpStreamWrapper : IStream, IDisposable { //******************************************************************* // // Constructors // //******************************************************************* #region Constructors internal SpStreamWrapper (Stream stream) { _stream = stream; _endOfStreamPosition = stream.Length; } ////// /// public void Dispose () { _stream.Dispose (); GC.SuppressFinalize (this); } #endregion //******************************************************************** // // Public Methods // //******************************************************************* #region public Methods #region ISpStreamFormat interface implementation public void Read (byte [] pv, int cb, IntPtr pcbRead) { if (_endOfStreamPosition >= 0 && _stream.Position + cb > _endOfStreamPosition) { cb = (int) (_endOfStreamPosition - _stream.Position); } int read = 0; try { read = _stream.Read (pv, 0, cb); } catch (EndOfStreamException) { read = 0; } if (pcbRead != IntPtr.Zero) { Marshal.WriteIntPtr (pcbRead, new IntPtr (read)); } } public void Write (byte [] pv, int cb, IntPtr pcbWritten) { throw new NotSupportedException (); } public void Seek (long offset, int seekOrigin, IntPtr plibNewPosition) { _stream.Seek (offset, (SeekOrigin) seekOrigin); if (plibNewPosition != IntPtr.Zero) { Marshal.WriteIntPtr (plibNewPosition, new IntPtr (_stream.Position)); } } public void SetSize (long libNewSize) { throw new NotSupportedException (); } public void CopyTo (IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten) { throw new NotSupportedException (); } public void Commit (int grfCommitFlags) { _stream.Flush (); } public void Revert () { throw new NotSupportedException (); } public void LockRegion (long libOffset, long cb, int dwLockType) { throw new NotSupportedException (); } public void UnlockRegion (long libOffset, long cb, int dwLockType) { throw new NotSupportedException (); } public void Stat (out STATSTG pstatstg, int grfStatFlag) { pstatstg = new STATSTG (); pstatstg.cbSize = _stream.Length; } public void Clone (out IStream ppstm) { throw new NotSupportedException (); } #endregion #endregion //******************************************************************** // // Private Fields // //******************************************************************** #region Private Fields private Stream _stream; protected long _endOfStreamPosition = -1; #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- NonSerializedAttribute.cs
- SSmlParser.cs
- CssStyleCollection.cs
- SqlProviderManifest.cs
- MultipartContentParser.cs
- BitmapEditor.cs
- ValidationRuleCollection.cs
- Expression.cs
- ListViewCommandEventArgs.cs
- TextBox.cs
- TraceUtility.cs
- AutoResetEvent.cs
- NaturalLanguageHyphenator.cs
- WorkflowMarkupElementEventArgs.cs
- HtmlSelect.cs
- AddDataControlFieldDialog.cs
- activationcontext.cs
- PerfCounterSection.cs
- WaitHandle.cs
- EntityException.cs
- Int64AnimationBase.cs
- WebConfigurationFileMap.cs
- _NegoStream.cs
- RowSpanVector.cs
- MimeFormatter.cs
- MissingMethodException.cs
- linebase.cs
- SqlColumnizer.cs
- TableHeaderCell.cs
- BufferedWebEventProvider.cs
- TrackingStringDictionary.cs
- WebBrowserBase.cs
- Light.cs
- ContentValidator.cs
- SafeHandles.cs
- DiagnosticTraceSource.cs
- SystemUnicastIPAddressInformation.cs
- RichTextBoxConstants.cs
- DataColumnChangeEvent.cs
- ProcessHost.cs
- Splitter.cs
- StrongNameMembershipCondition.cs
- BitmapEncoder.cs
- OutgoingWebRequestContext.cs
- JulianCalendar.cs
- FlowDocumentPaginator.cs
- CommunicationObjectManager.cs
- SrgsDocument.cs
- tibetanshape.cs
- FixedSOMSemanticBox.cs
- HttpListenerException.cs
- WebPartUtil.cs
- FeatureSupport.cs
- HttpDictionary.cs
- LinqDataSourceDeleteEventArgs.cs
- BuildDependencySet.cs
- QuaternionValueSerializer.cs
- PartialArray.cs
- MonthChangedEventArgs.cs
- InternalTypeHelper.cs
- DataSetSchema.cs
- EntityKeyElement.cs
- VersionPair.cs
- EffectiveValueEntry.cs
- GlobalizationAssembly.cs
- Signature.cs
- DecimalStorage.cs
- GridViewRowCollection.cs
- Evidence.cs
- CodeMemberField.cs
- CssStyleCollection.cs
- CollectionEditVerbManager.cs
- PersonalizationProvider.cs
- HtmlInputText.cs
- Int16AnimationBase.cs
- SetterBaseCollection.cs
- EmptyElement.cs
- CredentialCache.cs
- RelationshipManager.cs
- AttributeCollection.cs
- TextEffectResolver.cs
- COSERVERINFO.cs
- BevelBitmapEffect.cs
- FacetDescriptionElement.cs
- CategoryAttribute.cs
- SystemDiagnosticsSection.cs
- SetterBase.cs
- RowCache.cs
- Geometry3D.cs
- Inline.cs
- TraceProvider.cs
- OutputCacheSettingsSection.cs
- NullableIntSumAggregationOperator.cs
- EntityModelBuildProvider.cs
- LoginStatusDesigner.cs
- ListDictionary.cs
- DataGridViewRowStateChangedEventArgs.cs
- TemplateManager.cs
- SignedXmlDebugLog.cs
- HttpBindingExtension.cs