Esempio n. 1
0
        }// -----------------------------------------

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

            p = (RestoreParams)jobData;

            INPUT             = Path.Combine(p.tempDir, track.storedFileName);
            OUTPUT            = Path.Combine(p.tempDir, track.getFilenameRaw());
            track.workingFile = OUTPUT;     // Point to the new file

            // -
            var fileExt = Path.GetExtension(track.storedFileName);

            requirePostSizeFix = AudioMaster.isLossyByExt(fileExt);

            // --
            if (track.isData)
            {
                var ecm = new EcmTools(CDCRUSH.TOOLS_PATH);
                setupHandlers(ecm);
                ecm.unecm(INPUT);
            }
            else
            {
                // No need to convert back, end the task
                if (p.mode == 2)
                {
                    // Point to correct file
                    track.workingFile = INPUT;
                    complete();
                    return;
                }

                var ffmp = new FFmpeg(CDCRUSH.FFMPEG_PATH);

                if (fileExt.ToLower() == ".tak")
                {
                    var tak = new Tak(CDCRUSH.TOOLS_PATH);
                    setupHandlers(tak);

                    tak.decodeToStream(INPUT, (_out) => {
                        ffmp.convertWavStreamToPCM(OUTPUT, (_in) => {
                            _out.CopyTo(_in);
                            _in.Close();
                        });
                    });
                }
                else
                {
                    setupHandlers(ffmp);
                    ffmp.audioToPCM(INPUT, track.workingFile);
                }
            }

            log("Restoring track -" + track.storedFileName);
        }// -----------------------------------------
Esempio n. 2
0
        }// -----------------------------------------

        // --
        // Gets called regardless of number of tracks:
        public override void start()
        {
            base.start();

            // Get the global cd object
            cd.CDInfos CD = jobData.cd;
            input = (CD.tracks[0] as cd.CDTrack).workingFile;

            // No need to cut an already cut CD
            // Multifiles `workingfile` is already set to proper
            if (CD.MULTIFILE)
            {
                complete();
                return;
            }

            // No need to copy the bytes to the temp folder, just work from the source
            if (CD.tracks.length == 1)
            {
                complete();
                return;
            }


            int progressStep = (int)Math.Round((double)(100 / CD.tracks.length));

            // -- Cut the tracks ::

            FileStream inStr = new FileStream(input, FileMode.Open, FileAccess.Read);

            for (int i = 0; i < CD.tracks.length; i++)
            {
                cd.CDTrack track = (CD.tracks[i] as cd.CDTrack);

                int byteStart = track.sectorStart * CD.SECTOR_SIZE;
                int byteLen   = track.sectorSize * CD.SECTOR_SIZE;

                // New filename for the tracks
                track.workingFile = Path.Combine(jobData.tempDir, track.getFilenameRaw());
                FileStream outStr = new FileStream(track.workingFile, FileMode.CreateNew, FileAccess.Write);
                copyStream(inStr, outStr, byteStart, byteLen);
                outStr.Dispose();
                PROGRESS += progressStep;
            }    // --

            inStr.Dispose();

            complete();
        }// -----------------------------------------