Skip to content

Commit b7b5803

Browse files
committed
removing ResettableStream.
The only safe stream to reset is ByteArrayInputStream, and it already has a reset() method.
1 parent cac58c0 commit b7b5803

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

sources/net.sf.j2s.java.core/src/javajs/api/ResettableStream.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

sources/net.sf.j2s.java.core/src/swingjs/JSAudio.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import javax.sound.sampled.Line;
1414
import javax.sound.sampled.UnsupportedAudioFileException;
1515

16-
import javajs.api.ResettableStream;
1716
import javajs.util.BC;
1817
import javajs.util.Base64;
1918
import javajs.util.OC;
@@ -370,10 +369,9 @@ private static AudioFormat getAudioFormatForStreamOrBytes(
370369

371370
Map<String, Object> props = new Hashtable<String, Object>();
372371
String fmt = (stream == null ? getAudioTypeForBytes(header) : getAudioTypeForStream(stream));
373-
ResettableStream jsstream = (ResettableStream) stream;
374372
props.put("fileFormat", fmt);
375373
if (stream != null)
376-
jsstream.resetStream();
374+
stream.reset();
377375
Encoding encoding = null;
378376
float sampleRate = -1;
379377
int sampleSizeInBits = -1;
@@ -423,23 +421,22 @@ private static AudioFormat getAudioFormatForStreamOrBytes(
423421
} catch (Throwable e) {
424422
} finally {
425423
if (stream != null)
426-
jsstream.resetStream();
424+
stream.reset();
427425
}
428426
return new AudioFormat(encoding, sampleRate, sampleSizeInBits, channels,
429427
frameSize, frameRate, bigEndian, props);
430428
}
431429

432430

433431
private static String getAudioTypeForStream(ByteArrayInputStream stream) throws UnsupportedAudioFileException {
434-
ResettableStream jsstream = (ResettableStream) (Object) stream;
435-
jsstream.resetStream();
432+
stream.reset();
436433
byte[] b = new byte[12];
437434
try {
438435
stream.read(b);
439436
} catch (IOException e) {
440437
// no problem
441438
}
442-
jsstream.resetStream();
439+
stream.reset();
443440
return getAudioTypeForBytes(b);
444441
}
445442

0 commit comments

Comments
 (0)