public virtual Task <int> CreateStream(PlaylistItem playlistItem, BassFlags flags)
public LoadOutputStreamTask(PlaylistItem playlistItem, bool immediate) : base(ID) { this.PlaylistItem = playlistItem; this.Immediate = immediate; }
public PlaylistItemScriptRunner(IPlaybackManager playbackManager, IScriptingContext scriptingContext, PlaylistItem playlistItem, string script) { this.PlaybackManager = playbackManager; this.ScriptingContext = scriptingContext; this.PlaylistItem = playlistItem; this.Script = script; }
public BassOutputStream(IBassOutput output, IBassStreamPipelineManager manager, IBassStream stream, PlaylistItem playlistItem) : base(playlistItem) { this.Output = output; this.Manager = manager; this.Stream = stream; }
public abstract Task <IOutputStream> Load(PlaylistItem playlistItem, bool immidiate);
public virtual void FreeStream(PlaylistItem playlistItem, int channelHandle) { Logger.Write(this, LogLevel.Debug, "Freeing stream: {0}", channelHandle); Bass.StreamFree(channelHandle); //Not checking result code as it contains an error if the application is shutting down. }
public override Task <int> CreateStream(PlaylistItem playlistItem) { var flags = BassFlags.Decode | BassFlags.DSDRaw; return(this.CreateStream(playlistItem, flags)); }
public UpdatePlaylistPlayCountTask(PlaylistItem playlistItem) : base(ID) { this.PlaylistItem = playlistItem; }
public BassOutputStream(IBassOutput output, IBassStreamPipelineManager manager, IBassStreamProvider provider, PlaylistItem playlistItem, int channelHandle) : base(playlistItem) { this.Output = output; this.Manager = manager; this.Provider = provider; this.ChannelHandle = channelHandle; if (!ActiveStreams.TryAdd(playlistItem, this)) { //TODO: Warn. } }
protected virtual bool TryCalculateSilence(IBassStreamProvider provider, PlaylistItem playlistItem, IEnumerable <IBassStreamAdvice> advice, out TimeSpan leadIn, out TimeSpan leadOut) { if (provider.Flags.HasFlag(BassStreamProviderFlags.Serial)) { Logger.Write(this, LogLevel.Debug, "Cannot calculate lead in/out for file \"{0}\": The provider does not support this action.", playlistItem.FileName); leadIn = default(TimeSpan); leadOut = default(TimeSpan); return(false); } Logger.Write(this, LogLevel.Debug, "Attempting to calculate lead in/out for file \"{0}\".", playlistItem.FileName); var stream = provider.CreateBasicStream(playlistItem, advice, BassFlags.Decode | BassFlags.Byte); if (stream.IsEmpty) { Logger.Write(this, LogLevel.Warn, "Failed to create stream for file \"{0}\": {1}", playlistItem.FileName, Enum.GetName(typeof(Errors), Bass.LastError)); leadIn = default(TimeSpan); leadOut = default(TimeSpan); return(false); } try { var leadInBytes = this.GetLeadIn(stream, this.Behaviour.Threshold); if (leadInBytes == -1) { Logger.Write(this, LogLevel.Warn, "Failed to calculate lead in for file \"{0}\": Track was considered silent.", playlistItem.FileName); leadIn = default(TimeSpan); leadOut = default(TimeSpan); return(false); } var leadOutBytes = this.GetLeadOut(stream, this.Behaviour.Threshold); if (leadOutBytes == -1) { Logger.Write(this, LogLevel.Warn, "Failed to calculate lead out for file \"{0}\": Track was considered silent.", playlistItem.FileName); leadIn = default(TimeSpan); leadOut = default(TimeSpan); return(false); } leadIn = TimeSpan.FromSeconds( Bass.ChannelBytes2Seconds( stream.ChannelHandle, leadInBytes ) ); leadOut = TimeSpan.FromSeconds( Bass.ChannelBytes2Seconds( stream.ChannelHandle, leadOutBytes ) ); Logger.Write(this, LogLevel.Debug, "Successfully calculated lead in/out for file \"{0}\": {1}/{2}", playlistItem.FileName, leadIn, leadOut); return(true); } finally { provider.FreeStream(playlistItem, stream.ChannelHandle); } }
protected virtual bool TryGetMetaData(BassSkipSilenceStreamAdvisorBehaviour behaviour, PlaylistItem playlistItem, out TimeSpan leadIn, out TimeSpan leadOut) { if (playlistItem.MetaDatas == null) { //This shouldn't happen. leadIn = default(TimeSpan); leadOut = default(TimeSpan); return(false); } Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Debug, "Attempting to fetch lead in/out for file \"{0}\" from meta data.", playlistItem.FileName); var leadInMetaDataItem = default(MetaDataItem); var leadOutMetaDataItem = default(MetaDataItem); lock (playlistItem.MetaDatas) { var metaDatas = playlistItem.MetaDatas.ToDictionary( metaDataItem => metaDataItem.Name, StringComparer.OrdinalIgnoreCase ); metaDatas.TryGetValue(CustomMetaData.LeadIn, out leadInMetaDataItem); metaDatas.TryGetValue(CustomMetaData.LeadOut, out leadOutMetaDataItem); if (leadInMetaDataItem == null && leadOutMetaDataItem == null) { Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Debug, "Lead in/out meta data does not exist for file \"{0}\".", playlistItem.FileName); leadIn = default(TimeSpan); leadOut = default(TimeSpan); return(false); } } if (leadInMetaDataItem == null) { leadIn = TimeSpan.Zero; } else if (!this.TryParseDuration(behaviour, leadInMetaDataItem.Value, out leadIn)) { Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Debug, "Lead in meta data value \"{0}\" for file \"{1}\" is not valid.", leadInMetaDataItem.Value, playlistItem.FileName); leadIn = default(TimeSpan); leadOut = default(TimeSpan); return(false); } if (leadOutMetaDataItem == null) { leadOut = TimeSpan.Zero; } else if (!this.TryParseDuration(behaviour, leadOutMetaDataItem.Value, out leadOut)) { Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Debug, "Lead out meta data value \"{0}\" for file \"{1}\" is not valid.", leadOutMetaDataItem.Value, playlistItem.FileName); leadIn = default(TimeSpan); leadOut = default(TimeSpan); return(false); } Logger.Write(typeof(BassSkipSilenceStreamAdvisor), LogLevel.Debug, "Successfully fetched lead in/out from meta data for file \"{0}\": {1}/{2}", playlistItem.FileName, leadIn, leadOut); return(true); }
protected abstract PlaylistItem GetPrevious(Playlist playlist, PlaylistItem playlistItem);
protected abstract PlaylistItem GetNext(Playlist playlist, PlaylistItem playlistItem);
public PlaylistItemScriptRunner(IScriptingContext scriptingContext, PlaylistItem playlistItem, string script) : this(null, scriptingContext, playlistItem, script) { }
public bool IsQueued(PlaylistItem playlistItem) { return(this.Queue.ContainsKey(playlistItem)); }
private Task SetCurrentItem(PlaylistItem value) { this._CurrentItem = value; return(this.OnCurrentItemChanged()); }
public abstract void Advise(IBassStreamProvider provider, PlaylistItem playlistItem, IList <IBassStreamAdvice> advice);
public IEnumerable <IBassStreamAdvice> GetAdvice(IBassStreamProvider provider, PlaylistItem playlistItem) { var advice = new List <IBassStreamAdvice>(); foreach (var advisor in this.Advisors) { advisor.Advise(provider, playlistItem, advice); } return(advice.ToArray()); }
public virtual bool CanCreateStream(PlaylistItem playlistItem) { return(true); }
public Playlist GetPlaylist(PlaylistItem playlistItem) { return(this.GetPlaylists().FirstOrDefault(playlist => playlist.Id == playlistItem.Playlist_Id)); }
public override Task <int> CreateStream(PlaylistItem playlistItem, BassFlags flags)
public PlaylistItem GetNextItem(PlaylistItem playlistItem) { return(this.NavigationStrategy.GetNext(playlistItem)); }
public PlaylistItemScriptRunner(IScriptingContext scriptingContext, PlaylistItem playlistItem, string script) { this.ScriptingContext = scriptingContext; this.PlaylistItem = playlistItem; this.Script = script; }
public PlaylistItem GetPreviousItem(PlaylistItem playlistItem) { return(this.NavigationStrategy.GetPrevious(playlistItem)); }
protected OutputStream(PlaylistItem playlistItem) { this.PlaylistItem = playlistItem; }
protected virtual async Task Create(IntPtr archive, List <PlaylistItem> playlistItems) { var count = default(int); var directoryName = Path.GetDirectoryName(this.FileName); var metaDataSource = this.MetaDataSourceFactory.Create(); if (Archive.GetEntryCount(archive, out count)) { for (var a = 0; a < count; a++) { var entry = default(Archive.ArchiveEntry); if (Archive.GetEntry(archive, out entry, a)) { if (!this.Output.IsSupported(entry.path)) { continue; } var fileName = ArchiveUtils.CreateUrl(this.FileName, entry.path); var playlistItem = new PlaylistItem() { DirectoryName = directoryName, FileName = fileName }; if (this.MetaData.Value) { try { retry: using (var fileAbstraction = ArchiveFileAbstraction.Create(this.FileName, entry.path, a)) { if (fileAbstraction.IsOpen) { playlistItem.MetaDatas = ( await metaDataSource.GetMetaData(fileAbstraction).ConfigureAwait(false) ).ToList(); switch (fileAbstraction.Result) { case ArchiveEntry.RESULT_PASSWORD_REQUIRED: Logger.Write(this, LogLevel.Warn, "Invalid password for \"{0}\".", this.FileName); if (this.PasswordBehaviour != null && !this.PasswordBehaviour.WasCancelled(this.FileName)) { this.PasswordBehaviour.Reset(this.FileName); goto retry; } break; } } } } catch (Exception e) { Logger.Write(this, LogLevel.Debug, "Failed to read meta data from file \"{0}\": {1}", this.FileName, e.Message); } } this.EnsureMetaData(a, entry, playlistItem); playlistItems.Add(playlistItem); } else { //TODO: Warn. } } } else { //TODO: Warn. } }
public IEnumerable <IBassStreamProvider> GetProviders(PlaylistItem playlistItem) { return(this.Providers.Values.Where(provider => provider.CanCreateStream(playlistItem))); }
public BassOutputStream(IBassOutput output, IBassStreamPipelineManager manager, IBassStream stream, PlaylistItem playlistItem) : base(playlistItem) { this.Output = output; this.Manager = manager; this.Stream = stream; if (!BassOutputStreams.Add(this)) { //TODO: Warn. } }