//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); } } }