コード例 #1
0
        /// <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);
        }
コード例 #2
0
 public InputStream(PullSoundStreamBase audioStream, object[] metaDataRow)
     : base(audioStream)
 {
     this.meta = metaDataRow;
 }