Decoder
public Player(System.IO.Stream stream, AudioDevice device) { bitstream = new Bitstream(stream); decoder = new Decoder(); if (device != null) { audio = device; } else { FactoryRegistry r = FactoryRegistry.systemRegistry(); audio = r.createAudioDevice(); } audio.open(decoder); }
//UPGRADE_NOTE: Synchronized keyword was removed from method 'convert'. Lock expression was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1027"' public virtual void convert(System.IO.Stream sourceStream, System.String destName, ProgressListener progressListener, Decoder.Params decoderParams) { lock (this) { if (progressListener == null) progressListener = PrintWriterProgressListener.newStdOut(PrintWriterProgressListener.NO_DETAIL); try { if (!(sourceStream is System.IO.BufferedStream)) sourceStream = new System.IO.BufferedStream(sourceStream); int frameCount = - 1; //UPGRADE_ISSUE: Method 'java.io.InputStream.markSupported' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaioInputStreammarkSupported"' if (sourceStream.markSupported()) { //UPGRADE_ISSUE: Method 'java.io.InputStream.mark' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaioInputStreammark_int"' sourceStream.mark(- 1); frameCount = countFrames(sourceStream); //UPGRADE_ISSUE: Method 'java.io.InputStream.reset' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaioInputStreamreset"' sourceStream.reset(); } progressListener.converterUpdate(javazoom.jl.converter.Converter.ProgressListener_Fields.UPDATE_FRAME_COUNT, frameCount, 0); Obuffer output = null; Decoder decoder = new Decoder(decoderParams); Bitstream stream = new Bitstream(sourceStream); if (frameCount == - 1) frameCount = System.Int32.MaxValue; int frame = 0; long startTime = (System.DateTime.Now.Ticks - 621355968000000000) / 10000; try { for (; frame < frameCount; frame++) { try { Header header = stream.readFrame(); if (header == null) break; progressListener.readFrame(frame, header); if (output == null) { // REVIEW: Incorrect functionality. // the decoder should provide decoded // frequency and channels output as it may differ from // the source (e.g. when downmixing stereo to mono.) int channels = (header.mode() == Header.SINGLE_CHANNEL)?1:2; int freq = header.frequency(); output = new WaveFileObuffer(channels, freq, destName); decoder.OutputBuffer = output; } Obuffer decoderOutput = decoder.decodeFrame(header, stream); // REVIEW: the way the output buffer is set // on the decoder is a bit dodgy. Even though // this exception should never happen, we test to be sure. if (decoderOutput != output) throw new System.ApplicationException("Output buffers are different."); progressListener.decodedFrame(frame, header, output); stream.closeFrame(); } catch (System.Exception ex) { bool stop = !progressListener.converterException(ex); if (stop) { throw new JavaLayerException(ex.Message, ex); } } } } finally { if (output != null) output.close(); } int time = (int) ((System.DateTime.Now.Ticks - 621355968000000000) / 10000 - startTime); progressListener.converterUpdate(javazoom.jl.converter.Converter.ProgressListener_Fields.UPDATE_CONVERT_COMPLETE, time, frame); } catch (System.IO.IOException ex) { throw new JavaLayerException(ex.Message, ex); } } }
//UPGRADE_NOTE: Synchronized keyword was removed from method 'open'. Lock expression was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1027"' /// <summary> Opens this audio device. /// /// </summary> /// <param name="decoder The">decoder that will provide audio data /// to this audio device. /// /// </param> public virtual void open(Decoder decoder) { lock (this) { if (!Open) { this.decoder = decoder; openImpl(); Open = true; } } }
public virtual void convert(System.String sourceName, System.String destName, ProgressListener progressListener, Decoder.Params decoderParams) { if (destName.Length == 0) destName = null; try { System.IO.Stream in_Renamed = openInput(sourceName); convert(in_Renamed, destName, progressListener, decoderParams); in_Renamed.Close(); } catch (System.IO.IOException ioe) { throw new JavaLayerException(ioe.Message, ioe); } }
//UPGRADE_NOTE: Synchronized keyword was removed from method 'close'. Lock expression was added. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1027"' /// <summary> Closes this audio device. If the device is currently playing /// audio, playback is stopped immediately without flushing /// any buffered audio data. /// </summary> public virtual void close() { lock (this) { if (Open) { closeImpl(); Open = false; decoder = null; } } }