public CUstream CreateStream(StreamFlags flags) { CUstream phStream = new CUstream(); this.LastError = CUDADriver.cuStreamCreate(ref phStream, (uint)flags); return(phStream); }
/// <summary cref="CudaAPI.CreateStreamWithPriority(out IntPtr, StreamFlags, int)"/> internal override CudaError CreateStreamWithPriority( out IntPtr stream, StreamFlags flags, int priority) { throw new NotSupportedException(RuntimeErrorMessages.CudaNotSupported); }
/// <summary cref="CudaAPI.CreateStreamWithPriority(out IntPtr, StreamFlags, int)"/> internal override CudaError CreateStreamWithPriority( out IntPtr stream, StreamFlags flags, int priority) { return(cuStreamCreateWithPriority(out stream, flags, priority)); }
/// <summary> /// Constructs a new Cuda stream with given <see cref="StreamFlags"/>. /// </summary> /// <param name="accelerator">The associated accelerator.</param> /// <param name="flag"> /// Stream flag to use. Allows blocking and non-blocking streams. /// </param> internal CudaStream(Accelerator accelerator, StreamFlags flag) : base(accelerator) { CudaException.ThrowIfFailed( CurrentAPI.CreateStream( out streamPtr, flag)); responsibleForHandle = true; }
/////////////////////////////////////////////////////////////////////////////////////////////// #region Internal Constructors #if NETWORK internal ChannelStream( TcpListener listener, ChannelType channelType, OptionDictionary options, StreamFlags flags ) : this() { this.listener = listener; this.channelType = channelType; this.options = options; this.flags = flags; }
/////////////////////////////////////////////////////////////////////////////////////////////// public virtual StreamFlags SetFlags(StreamFlags flags, bool set) { CheckDisposed(); if (set) { return(this.flags |= flags); } else { return(this.flags &= ~flags); } }
/////////////////////////////////////////////////////////////////////////////////////////////// #region Stream Flags Members public virtual bool HasFlags(StreamFlags flags, bool all) { CheckDisposed(); if (all) { return((this.flags & flags) == flags); } else { return((this.flags & flags) != StreamFlags.None); } }
public override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamFlags = StreamFlags.None) { switch (access) { case VirtualFileAccess.Write: return new NetworkWriteStream(socketMessageLayer, RemoteUrl + url); case VirtualFileAccess.Read: var downloadFileAnswer = (DownloadFileAnswer)socketMessageLayer.SendReceiveAsync(new DownloadFileQuery { Url = RemoteUrl + url }).Result; return new MemoryStream(downloadFileAnswer.Data); default: throw new NotSupportedException(); } }
/// <summary> /// Initializes the Audio Client /// </summary> /// <param name="shareMode">Share Mode</param> /// <param name="streamFlags">Stream Flags</param> /// <param name="bufferDuration">Buffer Duration</param> /// <param name="periodicity">Periodicity</param> /// <param name="waveFormat">Wave Format</param> /// <param name="audioSessionGuid">Audio Session GUID (can be null)</param> public int Initialize(ShareMode shareMode, StreamFlags streamFlags, long bufferDuration, long periodicity, WaveFormat waveFormat, Guid audioSessionGuid) { this.shareMode = shareMode; int hret = audioClientInterface.Initialize(shareMode, streamFlags, bufferDuration, periodicity, waveFormat, ref audioSessionGuid); mixFormat = null; return(hret); }
/// <inheritdoc/> public override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamFlags = StreamFlags.None) { if (localBasePath != null && url.Split(VirtualFileSystem.DirectorySeparatorChar, VirtualFileSystem.AltDirectorySeparatorChar).Contains("..")) throw new InvalidOperationException("Relative path is not allowed in FileSystemProvider."); var rawAccess = (NativeFileAccess) 0; if ((access & VirtualFileAccess.Read) != 0) rawAccess |= NativeFileAccess.Read; if ((access & VirtualFileAccess.Write) != 0) rawAccess |= NativeFileAccess.Write; return new NativeFileStream(ConvertUrlToFullPath(url), (NativeFileMode)mode, rawAccess); }
/// <inheritdoc/> public override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamType = StreamFlags.None) { if (localBasePath != null && url.Split(VirtualFileSystem.DirectorySeparatorChar, VirtualFileSystem.AltDirectorySeparatorChar).Contains("..")) throw new InvalidOperationException("Relative path is not allowed in FileSystemProvider."); var filename = ConvertUrlToFullPath(url); var result = new FileStream(filename, (FileMode)mode, (FileAccess)access, (FileShare)share); #if SILICONSTUDIO_PLATFORM_IOS if (AutoSetSkipBackupAttribute && (mode == VirtualFileMode.CreateNew || mode == VirtualFileMode.Create || mode == VirtualFileMode.OpenOrCreate)) { MonoTouch.Foundation.NSFileManager.SetSkipBackupAttribute(filename, true); } #endif return result; }
/////////////////////////////////////////////////////////////////////////////////////////////// #if NETWORK public Channel( TcpListener listener, ChannelType channelType, OptionDictionary options, StreamFlags flags, IClientData clientData ) : this() { this.stream = new ChannelStream( listener, channelType, options, flags); this.encoding = null; this.appendMode = false; this.autoFlush = false; this.clientData = clientData; }
/// <inheritdoc/> public override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamFlags = StreamFlags.None) { // Open or create the file through the underlying (IContentIndexMap, IOdbBackend) couple. // Also read/write a ObjectHeader. if (mode == VirtualFileMode.Open) { ObjectId objectId; if (url.StartsWith(ObjectIdUrl)) ObjectId.TryParse(url.Substring(ObjectIdUrl.Length), out objectId); else if (!contentIndexMap.TryGetValue(url, out objectId)) throw new FileNotFoundException(string.Format("Unable to find the file [{0}]", url)); var result = objectDatabase.OpenStream(objectId, mode, access, share); // copy the stream into a memory stream in order to make it seek-able if (streamFlags == StreamFlags.Seekable && !result.CanSeek) { var buffer = new byte[result.Length - result.Position]; result.Read(buffer, 0, buffer.Length); return new DatabaseReadFileStream(objectId, new MemoryStream(buffer), 0); } return new DatabaseReadFileStream(objectId, result, result.Position); } if (mode == VirtualFileMode.Create) { if (url.StartsWith(ObjectIdUrl)) throw new NotSupportedException(); var stream = objectDatabase.CreateStream(); // Header will be written by DatabaseWriteFileStream var result = new DatabaseWriteFileStream(stream, stream.Position); stream.Disposed += x => { // Commit index changes contentIndexMap[url] = x.CurrentHash; }; return result; } throw new ArgumentException("mode"); }
/////////////////////////////////////////////////////////////////////////////////////////////// #region Public Constructors public ChannelStream( Stream stream, ChannelType channelType, OptionDictionary options, StreamFlags flags, StreamTranslation inTranslation, StreamTranslation outTranslation ) : this() { this.stream = stream; this.channelType = channelType; this.options = options; this.flags = flags; this.inTranslation = inTranslation; this.outTranslation = outTranslation; }
public override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamType = StreamFlags.None) { // For now, block multithreading (not sure it can work or not) lock (fileSystemProvider) { if (!fileSystemProvider.FileExists(url)) { // Ensure top directory exists fileSystemProvider.CreateDirectory(VirtualFileSystem.GetParentFolder(url)); using (var asset = PlatformAndroid.Context.Assets.Open(assetRoot + url)) using (var output = fileSystemProvider.OpenStream(url, VirtualFileMode.CreateNew, VirtualFileAccess.Write, share, streamType)) asset.CopyTo(output); } } return fileSystemProvider.OpenStream(url, mode, access); }
public Wasapi(MMDevice device, StreamFlags streamFlags, ShareMode shareMode, bool eventSync, int durationMillisecond) { audioClient = device.AudioClient; if (shareMode == ShareMode.Exclusive) { eventSync = true; } this.streamFlags = streamFlags; this.device = device; this.shareMode = shareMode; this.eventSync = eventSync; this.durationMillisecond = durationMillisecond; if (eventSync) { this.streamFlags |= StreamFlags.StreamFlagsEventCallback; } }
/////////////////////////////////////////////////////////////////////////////////////////////// internal ChannelStream( Socket socket, int timeout, ChannelType channelType, OptionDictionary options, StreamFlags flags, StreamTranslation inTranslation, StreamTranslation outTranslation ) : this() { this.socket = socket; this.timeout = timeout; this.channelType = channelType; this.options = options; this.flags = flags; this.inTranslation = inTranslation; this.outTranslation = outTranslation; }
public override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamFlags = StreamFlags.None) { if (share != VirtualFileShare.Read) throw new NotImplementedException(); lock (files) { FileInfo fileInfo; bool exists = files.TryGetValue(url, out fileInfo); bool write = access != VirtualFileAccess.Read; switch (mode) { case VirtualFileMode.CreateNew: if (exists) throw new IOException("File already exists."); files.Add(url, fileInfo = new FileInfo()); return new MemoryFileStream(this, fileInfo, write); case VirtualFileMode.Create: files.Remove(url); files.Add(url, fileInfo = new FileInfo()); return new MemoryFileStream(this, fileInfo, write); case VirtualFileMode.Truncate: if (!exists) throw new IOException("File doesn't exists."); files.Remove(url); return new MemoryStream(); case VirtualFileMode.Open: if (!exists) throw new FileNotFoundException(); if (write) throw new NotImplementedException(); return new MemoryFileStream(this, fileInfo, false, fileInfo.Data); case VirtualFileMode.OpenOrCreate: throw new NotImplementedException(); } } return null; }
/////////////////////////////////////////////////////////////////////////////////////////////// public Channel( Stream stream, ChannelType channelType, OptionDictionary options, StreamFlags flags, StreamTranslation inTranslation, StreamTranslation outTranslation, Encoding encoding, bool appendMode, bool autoFlush, IClientData clientData ) : this() { this.stream = new ChannelStream( stream, channelType, options, flags, inTranslation, outTranslation); this.encoding = encoding; this.appendMode = appendMode; this.autoFlush = autoFlush; this.clientData = clientData; }
public override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamType = StreamFlags.None) { ZipFileEntry zipFileEntry; if (!zipFileEntries.TryGetValue(url, out zipFileEntry)) throw new FileNotFoundException("File not found inside ZIP archive."); if (mode != VirtualFileMode.Open || access != VirtualFileAccess.Read) throw new UnauthorizedAccessException("ZIP archive are read-only."); lock (zipFile) { if (zipFileEntry.Method == Compression.Store) { // Open a VirtualFileStream on top of Zip FileStream return new VirtualFileStream(new FileStream(zipFileEntry.ZipFileName, FileMode.Open, FileAccess.Read), zipFileEntry.FileOffset, zipFileEntry.FileOffset + zipFileEntry.FileSize); } // Decompress it into a MemoryStream var buffer = new byte[zipFileEntry.FileSize]; zipFile.ExtractFile(zipFileEntry, buffer); return new MemoryStream(buffer); } }
/// <inheritdoc/> public override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamFlags = StreamFlags.None) { // Open or create the file through the underlying (IContentIndexMap, IOdbBackend) couple. // Also read/write a ObjectHeader. if (mode == VirtualFileMode.Open) { ObjectId objectId; if (url.StartsWith(ObjectIdUrl)) { ObjectId.TryParse(url.Substring(ObjectIdUrl.Length), out objectId); } else if (!contentIndexMap.TryGetValue(url, out objectId)) { throw new FileNotFoundException(string.Format("Unable to find the file [{0}]", url)); } var result = objectDatabase.OpenStream(objectId, mode, access, share); // copy the stream into a memory stream in order to make it seek-able if (streamFlags == StreamFlags.Seekable && !result.CanSeek) { var buffer = new byte[result.Length - result.Position]; result.Read(buffer, 0, buffer.Length); return(new DatabaseReadFileStream(objectId, new MemoryStream(buffer), 0)); } return(new DatabaseReadFileStream(objectId, result, result.Position)); } if (mode == VirtualFileMode.Create) { if (url.StartsWith(ObjectIdUrl)) { throw new NotSupportedException(); } var stream = objectDatabase.CreateStream(); // Header will be written by DatabaseWriteFileStream var result = new DatabaseWriteFileStream(stream, stream.Position); stream.Disposed += x => { // Commit index changes contentIndexMap[url] = x.CurrentHash; }; return(result); } throw new ArgumentException("mode"); }
public override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamFlags = StreamFlags.None) { switch (access) { case VirtualFileAccess.Write: return(new NetworkWriteStream(socketMessageLayer, RemoteUrl + url)); case VirtualFileAccess.Read: var downloadFileAnswer = (DownloadFileAnswer)socketMessageLayer.SendReceiveAsync(new DownloadFileQuery { Url = RemoteUrl + url }).Result; return(new MemoryStream(downloadFileAnswer.Data)); default: throw new NotSupportedException(); } }
/// <inheritdoc/> public abstract Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamFlags = StreamFlags.None);
/// <summary> /// Opens the specified URL as a stream used for custom raw asset loading. /// </summary> /// <param name="content">The <see cref="IContentManager"/>.</param> /// <param name="urlReference">The URL to the raw asset.</param> /// <param name="streamFlags">The type of stream needed</param> /// <returns>A stream to the raw asset.</returns> /// <exception cref="ArgumentNullException">If <paramref name="urlReference"/> is <c>null</c> or <c>empty</c>. Or <paramref name="content"/> is <c>null</c>.</exception> public static Stream OpenAsStream(this IContentManager content, UrlReference urlReference, StreamFlags streamFlags = StreamFlags.None) { CheckArguments(content, urlReference); return(content.OpenAsStream(urlReference.Url, streamFlags)); }
/// <summary cref="CudaAPI.CreateStream(out IntPtr, StreamFlags)"/> internal override CudaError CreateStream(out IntPtr stream, StreamFlags flags) { return(cuStreamCreate(out stream, flags)); }
public bool HasFlag(StreamFlags flags) { return((this.flags & (ushort)flags) == (ushort)flags); }
//not properly implemented yet /// <summary> /// Create a user sample stream. /// </summary> /// <param name="freq">BassStream playback rate</param> /// <param name="flags">StreamFlags</param> /// <param name="proc">StreamCallBack delegate</param> /// <param name="user">The "user" value passed to the callback function</param> /// <returns></returns> private BassStream CreateStream(int freq, StreamFlags flags, StreamCallBack proc, int user) { if (_disposed) throw new ObjectDisposedException("BASSEngine"); IntPtr handle = _CreateStream(freq, (int) flags, proc, user); if (handle == IntPtr.Zero) throw new BASSException(); var output = new BassStream(handle); output.Owner = this; return output; }
/// <summary> /// Create a sample stream from an MP3/MP2/MP1/OGG or WAV file. /// </summary> /// <param name="mem">BassStream file from memory</param> /// <param name="filename">Filename or memory location</param> /// <param name="offset">File offset of the stream data</param> /// <param name="length">File length (0=use whole file)</param> /// <param name="flags">StreamFlags</param> /// <returns></returns> public BassStream LoadStream(bool mem, string filename, int offset, int length, StreamFlags flags) { if (_disposed) throw new ObjectDisposedException("BASSEngine"); IntPtr handle = _CreateStreamFile(Helper.Bool2Int(mem), Marshal.StringToHGlobalAnsi(filename), offset, length, (int) flags); if (handle == IntPtr.Zero) throw new BASSException(); var output = new BassStream(handle); output.Owner = this; return output; }
/// <summary> /// Create a sample stream from an MP3/MP2/MP1/OGG or WAV file on the internet. /// </summary> /// <param name="url">The URL (beginning with "http://" or "ftp://")</param> /// <param name="offset">File offset of start streaming from</param> /// <param name="flags">StreamFlags</param> /// <param name="savefile">Filename to save the streamed file as locally (""=don//t save)</param> /// <returns></returns> public BassStream CreateStreamFromURL(string url, int offset, StreamFlags flags, string savefile) { if (_disposed) throw new ObjectDisposedException("BASSEngine"); IntPtr handle = _CreateStreamURL(url, offset, (int) flags, savefile); if (handle == IntPtr.Zero) throw new BASSException(); var output = new BassStream(handle); output.Owner = this; return output; }
public override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamFlags = StreamFlags.None) { if (share != VirtualFileShare.Read) { throw new NotImplementedException(); } lock (files) { FileInfo fileInfo; bool exists = files.TryGetValue(url, out fileInfo); bool write = access != VirtualFileAccess.Read; switch (mode) { case VirtualFileMode.CreateNew: if (exists) { throw new IOException("File already exists."); } files.Add(url, fileInfo = new FileInfo()); return(new MemoryFileStream(this, fileInfo, write)); case VirtualFileMode.Create: files.Remove(url); files.Add(url, fileInfo = new FileInfo()); return(new MemoryFileStream(this, fileInfo, write)); case VirtualFileMode.Truncate: if (!exists) { throw new IOException("File doesn't exists."); } files.Remove(url); return(new MemoryStream()); case VirtualFileMode.Open: if (!exists) { throw new FileNotFoundException(); } if (write) { throw new NotImplementedException(); } return(new MemoryFileStream(this, fileInfo, false, fileInfo.Data)); case VirtualFileMode.OpenOrCreate: throw new NotImplementedException(); } } return(null); }
/// <summary> /// Creates a new accelerator stream. /// </summary> /// <param name="stream">The created stream.</param> /// <param name="flags">The flags to use.</param> /// <param name="priority">The priority to use.</param> /// <returns>The error status.</returns> internal abstract CudaError CreateStreamWithPriority( out IntPtr stream, StreamFlags flags, int priority);
/// <summary> /// Creates a new accelerator stream. /// </summary> /// <param name="stream">The created stream.</param> /// <param name="flags">The flags to use.</param> /// <returns>The error status.</returns> internal abstract CudaError CreateStream( out IntPtr stream, StreamFlags flags);
public override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamFlags = StreamFlags.None) { return ThreadLocal.Value.OpenStream(url, mode, access, share, streamFlags); }
/// <summary cref="CudaAPI.CreateStream(out IntPtr, StreamFlags)"/> internal override CudaError CreateStream( out IntPtr stream, StreamFlags flags) => throw new NotSupportedException(RuntimeErrorMessages.CudaNotSupported);
public static extern CudaResult cudaStreamCreateWithFlags(ref IntPtr phStream, StreamFlags Flags);
public override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamType = StreamFlags.None) { if (!zipFileEntries.TryGetValue(url, out var zipFileEntry)) { throw new FileNotFoundException("File not found inside ZIP archive."); } if (mode != VirtualFileMode.Open || access != VirtualFileAccess.Read) { throw new UnauthorizedAccessException("ZIP archive are read-only."); } lock (zipFile) { if (zipFileEntry.Method == Compression.Store) { // Open a VirtualFileStream on top of Zip FileStream return(new VirtualFileStream(new FileStream(zipFileEntry.ZipFileName, FileMode.Open, FileAccess.Read), zipFileEntry.FileOffset, zipFileEntry.FileOffset + zipFileEntry.FileSize)); } // Decompress it into a MemoryStream var buffer = new byte[zipFileEntry.FileSize]; zipFile.ExtractFile(zipFileEntry, buffer); return(new MemoryStream(buffer)); } }
public static extern CudaResult cudaStreamCreateWithPriority(ref IntPtr phStream, StreamFlags Flags, int priority);
/// <summary> /// Creates a new accelerator stream. /// </summary> /// <param name="stream">The created stream.</param> /// <param name="flags">The flags to use.</param> /// <returns>The error status.</returns> internal CudaError CreateStream( out IntPtr stream, StreamFlags flags) => cuStreamCreate(out stream, flags);
/// <inheritdoc/> public override Stream OpenStream(string url, VirtualFileMode mode, VirtualFileAccess access, VirtualFileShare share = VirtualFileShare.Read, StreamFlags streamFlags = StreamFlags.None) { if (localBasePath != null && url.Split(VirtualFileSystem.DirectorySeparatorChar, VirtualFileSystem.AltDirectorySeparatorChar).Contains("..")) { throw new InvalidOperationException("Relative path is not allowed in FileSystemProvider."); } var rawAccess = (NativeFileAccess)0; if ((access & VirtualFileAccess.Read) != 0) { rawAccess |= NativeFileAccess.Read; } if ((access & VirtualFileAccess.Write) != 0) { rawAccess |= NativeFileAccess.Write; } return(new NativeFileStream(ConvertUrlToFullPath(url), (NativeFileMode)mode, rawAccess)); }