/// <summary> /// 次のストリームを準備する /// </summary> private static bool PrepareNextStream(int index, List <KeyValuePair <string, object> > tags = null) { lock (PrepareMutex) { LastPreparedIndex = index; if (PreparedStream != null) { return(false); } if (index == -1) { PreparedStream = new StopperInputStream(); return(true); } if (index >= CurrentPlaylistRows || index < 0) { return(false); } object[] row = Controller.GetPlaylistRow(index); string filename = (string)row[Controller.GetColumnIndexByName(LibraryDBColumnTextMinimum.file_name)]; try { int tr = Util.Util.GetTrackNumberInt(row[Controller.GetColumnIndexByName("tagTracknumber")].ToString(), 1); PullSoundStreamBase nextStream = DecodeStreamFactory.CreateFileStream(filename, tr, MyCoreComponent.UsePrescan, tags); if (nextStream == null) { return(false); } if (nextStream.Chans == 1) { nextStream = new Mono2StereoFilter(nextStream); } //if (nextStream.Freq == 96000) //{ // nextStream = new FreqConvertFilter(nextStream); //} // prepareにsyncを設定 var inStream = new InputStream(nextStream, row); inStream.Ready = !OutputDeviceFactory.RebuildRequired(OutputDevice, nextStream.Freq, nextStream.Chans, true); inStream.SetEvent(on80Percent, nextStream.LengthSec * 0.80); inStream.SetEvent(onPreFinish, Math.Max(nextStream.LengthSec * 0.90, nextStream.LengthSec - 5)); PreparedStream = inStream; } catch (Exception e) { Logger.Log(e.ToString()); return(false); } } return(true); }
internal static Boolean QueuePlaylistItem(int index) { lock (PrepareMutex) { DisposePreparedStream(); switch (index) { case QUEUE_CLEAR: return(true); case QUEUE_STOP: PreparedStream = new StopperInputStream(); return(true); default: return(PrepareNextStream(index)); } } }