This content has been marked as final. Show 10 replies
ptoye wrote:I expect the problem is the Java 7 JRE. Why not raise a bug report and see what Oracle has to say on the matter?
I have a program which works fine under Java 6. But under Java 7 it fails when calling getAudioInputStream. The failure is an I/O exception saying that Mark/Reset is not available for the stream (which is true under both Javas 6 & 7).
Has getAudioInputStream changed between Java versions?
And how to mend the program? ..One potential fix is to read the input stream and write the bytes into a <tt>ByteArrayOutputStream</tt>, when they are loaded, call <tt>getBytes()</tt> and use that to construct a <tt>ByteArrayInputStream</tt>. Use the BAIS for <tt>getAudioInputStream(InputStream)</tt>. The BAIS is definitely positionable.
Thanks Andrew. This isn't the first problem I've had with Java 7 being incompatible with 6.
I don't actually need to rewind the stream (it wouldn't have worked under 6 if I did). At the moment I think I'll stick with 6.
One further question - how does one actually submit a bug report to Oracle? I can't see anything on the Oracle.com web site which even hints that such a thing might be possible.
Edited by: ptoye on 25-Sep-2011 11:15
I just got the same error. Unfortunately I don't have Java 7 and can't test if the following fix works!
I was using this form to get a new AudioInputStream:
This syntax uses InputStream as an argument, and InputStream requires that a stream be "markable". Maybe this was a "grey area" and previously worked but with Java 7 is now more rigorously enforced?
AudioInputStream ais = AudioSystem.getAudioInputStream(AudioMixer.class.getResourceAsStream(fileName));
So, I am trying this form, which doesn't mention checking for "mark/reset" in the api.
I haven't been able to verify if this works yet!
URL url = AudioMixer.class.getResource(fileName); AudioInputStream ais = AudioSystem.getAudioInputStream(url);
It would be great to have someone who runs Java 7 give my Applet a try. It is a demo of an audio mixing program in development, to funnel all audio into a single SourceDataLine.
I'd appreciate a note if the top row buttons are working or not. They rely upon the one-time loading of an AudioInputStream.
Edited by: 807197 on Nov 10, 2011 2:38 PM
The Java 7 user who reported this problem to me just let me know that the above solution works.
I would like to suggest the previous post as a possible "work around" for those of you who are involved in the bug report. I'll try to make a note on the bug report itself, if there is a place for comments, but it is rather difficult to navigate in that area.
It seems to me, in fact, that it might be more correct to use a parameter other than InputStream, given that InputStream's specification indicates it checks for markability. Unfortunately, due to this being a "gray area" and working in the past (see explanation in the Bug Report response!), backwards compatibility issues do arise. Fortunately, the required recoding is straightforward.