AudioFileReader / SPI / unrecognized formats

  • Thread starter Andrew Thompson
  • Start date
A

Andrew Thompson

What should an AudioFileReader.getAudioInputStream(InputStream)*
do/throw when it encounters an unrecognized stream?

The JavaDocs declare that it throws an UnsupportedAudioFileException.

* <http://java.sun.com/javase/6/docs/api/javax/sound/sampled/spi/
AudioFileReader.html#getAudioInputStream(java.io.InputStream)>

I am developing a new sound format. After some months of wrangling
with the build tools to get an app. that correctly registers a new
audio
type via the ServiceProvider interface (fixed in the end, by upgrading
to
the latest version of Ant), I am now puzzling over what to do when
the
new class is handed an audio stream that is handled by one of the
*pre-existing* formats.

If I throw an UnsupportedAudioFileException when handed a format
that is not the new one, the app. can no longer read existing formats.
If I fail to throw an UAFE, my class is left trying to deal with data
for which it was not designed, and cannot cope.

Anybody encountered this before / have any tips on how to proceed?
 
M

Michael Rauscher

Hi Andrew,

Andrew said:
What should an AudioFileReader.getAudioInputStream(InputStream)*
do/throw when it encounters an unrecognized stream? ....
the latest version of Ant), I am now puzzling over what to do when
the
new class is handed an audio stream that is handled by one of the
*pre-existing* formats.

If I throw an UnsupportedAudioFileException when handed a format
that is not the new one, the app. can no longer read existing formats.

I haven't tried it, but I'd expect AudioSystem to try-catch-iterate over
the registered providers (at least, if a File, URL or InputStream is given).

Bye
Michael
 
A

Andrew Thompson

I haven't tried it, but I'd expect AudioSystem to try-catch-iterate over
the registered providers (at least, if a File, URL or InputStream is given).

I'd have thought so as well, but throwing
an UAFE within my own reader stops the
process, whatever that process is.

...Now I look at the source for
AudioSystem.getAudioInputStream(InputStream)
it supports what you are saying, it iterates
a list of the AudioFileReaders, try/catching
on UAFE!

I'll think some more on where /I/ am going
wrong with that process..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top