Пример #1
0
        }// -----------------------------------------

        // --
        public override void start()
        {
            base.start();

            p = (RestoreParams)jobData;

            log("Restoring track -" + track.storedFileName);

            // --
            crushedTrackPath = Path.Combine(p.tempDir, track.storedFileName);
            // Set the final track pathname now, I need this for later.
            track.workingFile = Path.Combine(p.tempDir, track.getFilenameRaw());

            // --
            if (track.isData)
            {
                var ecm = new EcmTools(CDCRUSH.TOOLS_PATH);
                ecm.onComplete = (s) => {
                    if (s)
                    {
                        deleteOldFile();
                        if (!checkTrackMD5())
                        {
                            fail(msg: "MD5 checksum is wrong!");
                            return;
                        }
                        complete();
                    }
                    else
                    {
                        fail(msg: ecm.ERROR);
                    }
                };
                ecm.unecm(crushedTrackPath);
                killExtra = () => ecm.kill();
            }
            else
            {
                if (Path.GetExtension(track.storedFileName) == ".ogg")
                {
                    isOgg = true;
                }
                else
                {
                    isFlac = true;             // must be flac
                }

                var ffmp = new FFmpeg(CDCRUSH.FFMPEG_PATH);
                ffmp.onComplete = (s) => {
                    if (s)
                    {
                        deleteOldFile();                 // Don't need it
                        if (isOgg)
                        {
                            correctPCMSize();
                        }
                        if (isFlac)
                        {
                            if (!checkTrackMD5())
                            {
                                fail(msg: "MD5 checksum is wrong!");
                                return;
                            }
                        }
                        complete();
                    }
                    else
                    {
                        fail(msg: ffmp.ERROR);
                    }
                };

                ffmp.audioToPCM(crushedTrackPath);
                killExtra = () => ffmp.kill();
            }
        }// -----------------------------------------
Пример #2
0
        }// -----------------------------------------

        // --
        public override void start()
        {
            base.start();

            p = (RestoreParams)jobData;

            // --
            crushedTrackPath = Path.Combine(p.tempDir, track.storedFileName);
            // Set the final track pathname now, I need this for later.
            track.workingFile = Path.Combine(p.tempDir, track.getFilenameRaw());

            // --
            if (track.isData)
            {
                var ecm = new EcmTools(CDCRUSH.TOOLS_PATH);
                ecm.onComplete = (s) => {
                    ecm.onProgress = handleProgress;
                    if (s)
                    {
                        deleteOldFile();
                        if (!checkTrackMD5())
                        {
                            fail(msg: "MD5 checksum is wrong!");
                            return;
                        }
                        complete();
                    }
                    else
                    {
                        fail(msg: ecm.ERROR);
                    }
                };
                ecm.unecm(crushedTrackPath);
                killExtra = () => ecm.kill();
            }
            else
            {
                // No need to convert back
                if (p.flag_encCue)
                {
                    // Fix current file
                    track.workingFile = crushedTrackPath;
                    complete();
                    return;
                }

                // --
                isFlac = (Path.GetExtension(track.storedFileName) == ".flac");

                var ffmp = new FFmpeg(CDCRUSH.FFMPEG_PATH);
                ffmp.onProgress = handleProgress;
                ffmp.onComplete = (s) => {
                    if (s)
                    {
                        deleteOldFile();                 // Don't need it
                        if (!isFlac)
                        {
                            // OGG and MP3 don't restore to the exact byte length
                            correctPCMSize();
                        }
                        else
                        {
                            // FLAC restores to exact bytes
                            if (!checkTrackMD5())
                            {
                                fail(msg: "MD5 checksum is wrong!");
                                return;
                            }
                        }
                        complete();
                    }
                    else
                    {
                        fail(msg: ffmp.ERROR);
                    }
                };

                ffmp.audioToPCM(crushedTrackPath);
                killExtra = () => ffmp.kill();
            }

            log("Restoring track -" + track.storedFileName);
        }// -----------------------------------------