Пример #1
0
        void OpenTrack(CUE_File.Command.TRACK trackCommand)
        {
            //assert that a file is open
            if (curr_file == null)
            {
                Error("Track command encountered with no active file");
                throw new DiscJobAbortException();
            }

            curr_track = new CompiledCueTrack();

            //spill cdtext data into this track
            curr_cdtext = curr_track.CDTextData;

            curr_track.BlobIndex = curr_blobIndex;
            curr_track.Number    = trackCommand.Number;
            curr_track.TrackType = trackCommand.Type;

            //default flags
            if (curr_track.TrackType != CueTrackType.Audio)
            {
                curr_track.Flags = CueTrackFlags.DATA;
            }

            if (!curr_fileHasTrack)
            {
                curr_fileHasTrack = curr_track.IsFirstInFile = true;
            }

            UpdateDiscInfo(trackCommand);
        }
Пример #2
0
        public void Run()
        {
            //in params
            var cue = IN_CueFile;

            //output state
            OUT_GlobalCDText      = new CompiledCDText();
            OUT_CompiledDiscInfo  = new CompiledDiscInfo();
            OUT_CompiledCueFiles  = new List <CompiledCueFile>();
            OUT_CompiledCueTracks = new List <CompiledCueTrack>();

            //add a track 0, for addressing convenience.
            //note: for future work, track 0 may need emulation (accessible by very negative LBA--the TOC is stored there)
            var track0 = new CompiledCueTrack()
            {
                Number = 0,
            };

            OUT_CompiledCueTracks.Add(track0);

            //global cd text will acquire the cdtext commands set before track commands
            curr_cdtext = OUT_GlobalCDText;

            for (int i = 0; i < cue.Commands.Count; i++)
            {
                var cmd = cue.Commands[i];

                //these commands get dealt with globally. nothing to be done here
                //(but in the future we need to accumulate them into the compile pass output)
                if (cmd is CUE_File.Command.CATALOG || cmd is CUE_File.Command.CDTEXTFILE)
                {
                    continue;
                }

                //nothing to be done for comments
                if (cmd is CUE_File.Command.REM)
                {
                    continue;
                }
                if (cmd is CUE_File.Command.COMMENT)
                {
                    continue;
                }

                //CD-text and related
                if (cmd is CUE_File.Command.PERFORMER)
                {
                    curr_cdtext.Performer = (cmd as CUE_File.Command.PERFORMER).Value;
                }
                if (cmd is CUE_File.Command.SONGWRITER)
                {
                    curr_cdtext.Songwriter = (cmd as CUE_File.Command.SONGWRITER).Value;
                }
                if (cmd is CUE_File.Command.TITLE)
                {
                    curr_cdtext.Title = (cmd as CUE_File.Command.TITLE).Value;
                }
                if (cmd is CUE_File.Command.ISRC)
                {
                    curr_cdtext.ISRC = (cmd as CUE_File.Command.ISRC).Value;
                }

                //flags can only be set when a track command is running
                if (cmd is CUE_File.Command.FLAGS)
                {
                    if (curr_track == null)
                    {
                        Warn("Ignoring invalid flag commands outside of a track command");
                    }
                    else
                    {
                        //take care to |= it here, so the data flag doesn't get cleared
                        curr_track.Flags |= (cmd as CUE_File.Command.FLAGS).Flags;
                    }
                }

                if (cmd is CUE_File.Command.TRACK)
                {
                    CloseTrack();
                    OpenTrack(cmd as CUE_File.Command.TRACK);
                }

                if (cmd is CUE_File.Command.FILE)
                {
                    CloseFile();
                    OpenFile(cmd as CUE_File.Command.FILE);
                }

                if (cmd is CUE_File.Command.INDEX)
                {
                    //todo - validate no postgap specified
                    AddIndex(cmd as CUE_File.Command.INDEX);
                }

                if (cmd is CUE_File.Command.PREGAP)
                {
                    //validate track open
                    //validate no indexes
                    curr_track.PregapLength = (cmd as CUE_File.Command.PREGAP).Length;
                }

                if (cmd is CUE_File.Command.POSTGAP)
                {
                    curr_track.PostgapLength = (cmd as CUE_File.Command.POSTGAP).Length;
                }
            }

            //it's a bit odd to close the file before closing the track, but...
            //we need to be sure to CloseFile first to make sure the track is marked as the final one in the file
            CloseFile();
            CloseTrack();

            CreateTrack1Pregap();
            FinalAnalysis();

            FinishLog();
        } //Run()