Esempio n. 1
0
        public async Task <IBassStream> CreateStream(PlaylistItem playlistItem, bool immidiate, BassFlags flags)
        {
#if NET40
            this.Semaphore.Wait();
#else
            await this.Semaphore.WaitAsync().ConfigureAwait(false);
#endif
            try
            {
                foreach (var provider in this.Providers.Values)
                {
                    if (!provider.CanCreateStream(playlistItem))
                    {
                        continue;
                    }
                    var channelHandle = await provider.CreateStream(playlistItem, flags).ConfigureAwait(false);

                    if (channelHandle != 0)
                    {
                        return(new BassStream(provider, channelHandle));
                    }
                    else
                    {
                        return(BassStream.Error(Bass.LastError));
                    }
                }
            }
            finally
            {
                this.Semaphore.Release();
            }
            return(BassStream.Empty);
        }
Esempio n. 2
0
        protected virtual IBassStream CreateBasicStream(int channelHandle, IEnumerable <IBassStreamAdvice> advice, BassFlags flags)
        {
            if (channelHandle == 0)
            {
                Logger.Write(this, LogLevel.Debug, "Failed to create stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError));
                return(BassStream.Error(Bass.LastError));
            }
            var stream = default(IBassStream);

            foreach (var advisory in advice)
            {
                if (advisory.Wrap(this, channelHandle, advice, flags, out stream))
                {
                    break;
                }
            }
            if (stream == null)
            {
                stream = new BassStream(this, channelHandle, Bass.ChannelGetLength(channelHandle, PositionFlags.Bytes), advice, flags);
            }
            return(stream);
        }