示例#1
0
        void CloseFile()
        {
            if (curr_track != null)
            {
                //flag this track as the final one in the file
                curr_track.IsFinalInFile = true;
            }

            curr_file = null;
        }
示例#2
0
        void OpenFile(CUE_File.Command.FILE f)
        {
            if (curr_file != null)
            {
                CloseFile();
            }

            curr_blobIndex++;
            curr_fileHasTrack = false;

            var Resolver = IN_CueContext.Resolver;

            //TODO - smart audio file resolving only for AUDIO types. not BINARY or MOTOROLA or AIFF or ECM or what have you

            var    options = Resolver.Resolve(f.Path);
            string choice  = null;

            if (options.Count == 0)
            {
                Error(string.Format("Couldn't resolve referenced cue file: {0} ; you can commonly repair the cue file yourself, or a file might be missing", f.Path));
                //add a null entry to keep the count from being wrong later (quiets a warning)
                OUT_CompiledCueFiles.Add(null);
                return;
            }
            else
            {
                choice = options[0];
                if (options.Count > 1)
                {
                    Warn("Multiple options resolving referenced cue file; choosing: " + Path.GetFileName(choice));
                }
            }

            var cfi = new CompiledCueFile();

            curr_file = cfi;
            OUT_CompiledCueFiles.Add(cfi);

            cfi.FullPath = choice;

            //determine the CueFileInfo's type, based on extension and extra checking
            //TODO - once we reorganize the file ID stuff, do legit checks here (this is completely redundant with the fileID system
            //TODO - decode vs stream vs unpossible policies in input policies object (including ffmpeg availability-checking callback (results can be cached))
            string blobPathExt = Path.GetExtension(choice).ToUpperInvariant();

            if (blobPathExt == ".BIN" || blobPathExt == ".IMG")
            {
                cfi.Type = CompiledCueFileType.BIN;
            }
            else if (blobPathExt == ".ISO")
            {
                cfi.Type = CompiledCueFileType.BIN;
            }
            else if (blobPathExt == ".WAV")
            {
                //quickly, check the format. turn it to DecodeAudio if it can't be supported
                //TODO - fix exception-throwing inside
                //TODO - verify stream-disposing semantics
                var fs = File.OpenRead(choice);
                using (var blob = new Disc.Blob_WaveFile())
                {
                    try
                    {
                        blob.Load(fs);
                        cfi.Type = CompiledCueFileType.WAVE;
                    }
                    catch
                    {
                        cfi.Type = CompiledCueFileType.DecodeAudio;
                    }
                }
            }
            else if (blobPathExt == ".APE")
            {
                cfi.Type = CompiledCueFileType.DecodeAudio;
            }
            else if (blobPathExt == ".MP3")
            {
                cfi.Type = CompiledCueFileType.DecodeAudio;
            }
            else if (blobPathExt == ".MPC")
            {
                cfi.Type = CompiledCueFileType.DecodeAudio;
            }
            else if (blobPathExt == ".FLAC")
            {
                cfi.Type = CompiledCueFileType.DecodeAudio;
            }
            else if (blobPathExt == ".ECM")
            {
                cfi.Type = CompiledCueFileType.ECM;
                if (!Disc.Blob_ECM.IsECM(choice))
                {
                    Error("an ECM file was specified or detected, but it isn't a valid ECM file: " + Path.GetFileName(choice));
                    cfi.Type = CompiledCueFileType.Unknown;
                }
            }
            else
            {
                Error("Unknown cue file type. Since it's likely an unsupported compression, this is an error: ", Path.GetFileName(choice));
                cfi.Type = CompiledCueFileType.Unknown;
            }

            //TODO - check for mismatches between track types and file types, or is that best done when interpreting the commands?
        }