Re: What exception to launch when AudioConverterDataSupplier fails?
Re: What exception to launch when AudioConverterDataSupplier fails?
- Subject: Re: What exception to launch when AudioConverterDataSupplier fails?
- From: Hugues Pisapia <email@hidden>
- Date: Fri, 19 Dec 2003 09:51:12 +0100
Thanks for your answer Doug,
I am sorry I wasn't clear: I am using the Java interface. It appears to
me that the Exception mecanism in the Java API is the way to pass the
OSStatus to the caller.
The AudioConverterDataSupplier.execute call does not return the OSStatus
but returns an AudioConverterData object containing the data for the AC.
My understanding was then to give the error OSStatus through an Exception.
Apparently I was wrong...
Then now, I understand the following: when my InputStream (in C/C++ it
can be a call to read() in a file descriptor) throws an IOException (or
the call to read() returns a IO error code), I have to return zero-sized
data buffers for this and any subsequent callbacks to let the AC know
that there is no more thing to read. Is that right? OK, but how do I
inform the caller of the AC about the I/O error?
Hugues
Doug Wyatt wrote:
We use C++ exceptions in the sample code and internally -- but (and
this applies equally to Java) one should never throw an exception
beyond a link-module boundary. In this case, your AudioConverter
callback should catch all exceptions and return an OSStatus. I'm
sorry, I don't know the particulars of the Java interface to the AC.
What you should do when there is no data available is to return any
non-zero value from your callback -- and no data (it would be
ignored). This tells the AudioConverter to stop everything it's doing,
and return whatever data has been produced so far (if any). It will
also return your same non-zero return code to the caller of
AudioConverterFillComplexBuffer (and related functions)
Doug
On Dec 17, 2003, at 13:55, Hugues Pisapia wrote:
Hi there,
I am implementing the com.apple.toolbox.AudioConverterDataSupplier
interface to feed an AudioConverter with data comming from a
java.io.InputStream.
When some Exception occurs while reading in this InputStream, I
though that throwing a 'new CAException(myExc.toString())' would make
the AudioConverter informed of my problem... However, it resulted
with a complete crash of the application :-(
I went into the documentation and found QA1317 talking about how to
inform the AC that no more data is available. But I did not find
anything about what to return... Can someone tell me about that? I
preferred not my application to crash when something like that occur.
Thanks,
Hugues
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.