Exemplo n.º 1
0
        public unsafe override bool Start(ENCODEPROC proc, IntPtr user, bool paused)
        {
            if (base.EncoderHandle != 0 || (proc != null && !this.SupportsSTDOUT))
            {
                return(false);
            }
            if (this.ACM_Codec == null)
            {
                this.ACM_Codec = new ACMFORMAT();
            }
            int num = base.ChannelHandle;

            if (base.InputFile != null)
            {
                num = Bass.BASS_StreamCreateFile(base.InputFile, 0L, 0L, BASSFlag.BASS_STREAM_DECODE);
                if (num == 0)
                {
                    return(false);
                }
            }
            BASSEncode bassencode = BASSEncode.BASS_ENCODE_DEFAULT;

            if (paused && base.InputFile == null)
            {
                bassencode |= BASSEncode.BASS_ENCODE_PAUSE;
            }
            if (base.NoLimit)
            {
                bassencode |= BASSEncode.BASS_ENCODE_CAST_NOLIMIT;
            }
            if (base.UseAsyncQueue)
            {
                bassencode |= BASSEncode.BASS_ENCODE_QUEUE;
            }

            fixed(byte *ptr = this.acmCodecToByteArray())
            {
                if (base.OutputFile == null)
                {
                    base.EncoderHandle = BassEnc.BASS_Encode_StartACM(num, (IntPtr)((void *)ptr), bassencode, proc, user);
                }
                else
                {
                    if (base.OutputFile == null || this.ACM_EncoderType != BASSChannelType.BASS_CTYPE_STREAM_WAV || !this.ACM_WriteWaveHeader)
                    {
                        bassencode |= BASSEncode.BASS_ENCODE_NOHEAD;
                    }
                    base.EncoderHandle = BassEnc.BASS_Encode_StartACMFile(num, (IntPtr)((void *)ptr), bassencode, base.OutputFile);
                }
            }

            if (base.InputFile != null)
            {
                Utils.DecodeAllData(num, true);
            }
            return(base.EncoderHandle != 0);
        }