Exemplo n.º 1
0
        public override IBassStream CreateInteractiveStream(PlaylistItem playlistItem, IEnumerable <IBassStreamAdvice> advice, BassFlags flags)
        {
            flags |= BassFlags.DSDRaw;
            var fileName      = this.GetFileName(playlistItem, advice);
            var channelHandle = default(int);

            if (this.Output != null && this.Output.PlayFromMemory)
            {
                channelHandle = BassDsdInMemoryHandler.CreateStream(fileName, 0, 0, flags);
                if (channelHandle == 0)
                {
                    Logger.Write(this, LogLevel.Warn, "Failed to load file into memory: {0}", fileName);
                    channelHandle = BassDsd.CreateStream(fileName, 0, 0, flags);
                }
            }
            else
            {
                channelHandle = BassDsd.CreateStream(fileName, 0, 0, flags);
            }
            if (channelHandle != 0 && !this.IsFormatSupported(playlistItem, channelHandle))
            {
                this.FreeStream(playlistItem, channelHandle);
                channelHandle = 0;
            }
            return(this.CreateInteractiveStream(channelHandle, advice, flags));
        }
Exemplo n.º 2
0
        public override async Task <int> CreateStream(PlaylistItem playlistItem, BassFlags flags)
#endif
        {
            if (!flags.HasFlag(BassFlags.DSDRaw))
            {
#if NET40
                return(base.CreateStream(playlistItem, flags));
#else
                return(await base.CreateStream(playlistItem, flags).ConfigureAwait(false));
#endif
            }
#if NET40
            this.Semaphore.Wait();
#else
            await this.Semaphore.WaitAsync().ConfigureAwait(false);
#endif
            try
            {
                var channelHandle = default(int);
                if (this.Output != null && this.Output.PlayFromMemory)
                {
                    channelHandle = BassDsdInMemoryHandler.CreateStream(playlistItem.FileName, 0, 0, flags);
                    if (channelHandle == 0)
                    {
                        Logger.Write(this, LogLevel.Warn, "Failed to load file into memory: {0}", playlistItem.FileName);
                    }
                }
                else
                {
                    channelHandle = BassDsd.CreateStream(playlistItem.FileName, 0, 0, flags);
                }
                if (channelHandle != 0)
                {
                    var query    = this.BassStreamPipelineFactory.QueryPipeline();
                    var channels = BassUtils.GetChannelCount(channelHandle);
                    var rate     = BassUtils.GetChannelDsdRate(channelHandle);
                    if (query.OutputChannels < channels || !query.OutputRates.Contains(rate))
                    {
                        Logger.Write(this, LogLevel.Warn, "DSD format {0}:{1} is unsupported, the stream will be unloaded. This warning is expensive, please don't attempt to play unsupported DSD.", rate, channels);
                        this.FreeStream(playlistItem, channelHandle);
                        channelHandle = 0;
                    }
                }
#if NET40
                return(TaskEx.FromResult(channelHandle));
#else
                return(channelHandle);
#endif
            }
            finally
            {
                this.Semaphore.Release();
            }
        }
Exemplo n.º 3
0
        public override IBassStream CreateBasicStream(PlaylistItem playlistItem, IEnumerable <IBassStreamAdvice> advice, BassFlags flags)
        {
            flags |= BassFlags.DSDRaw;
            var fileName      = this.GetFileName(playlistItem, advice);
            var channelHandle = BassDsd.CreateStream(fileName, 0, 0, flags);

            if (channelHandle != 0 && !this.IsFormatSupported(playlistItem, channelHandle))
            {
                this.FreeStream(playlistItem, channelHandle);
                channelHandle = 0;
            }
            return(this.CreateInteractiveStream(channelHandle, advice, flags));
        }