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: William Stewart <email@hidden>
- Date: Thu, 8 Jan 2004 17:12:49 -0800
On 19/12/2003, at 12:51 AM, Hugues Pisapia wrote:
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...
No, for the Java side this is correct.
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
No - zero-sized data buffers as doug describes below (Essentially its
the same logic - return an error and zero data buffers, its just that
in Java the error is signalled through throwing an exception)...
When you are done (ie. you are at the end of your input stream, then
you do return a zero sized data buffer AND no Error (ie. in Java don't
throw an exception)
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?
That's why the non-zero result code that you return from your Audio
Converter's Input Proc is propogated back to the caller of
AudioConverterFill*** calls
You can see this yourself as all of the CAJava sources are now in the
SDK.
In the wrapped call in the CAJava API. if an exception is generated
from the call to FillBuffer a CAException is thrown to the caller of
the java fillBuffer- which you'd need to catch of course, then look at
the numeric result code. If there's no error, then the result of the
java fillBuffer call is the number of bytes converted.
Bill
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.
--
mailto:email@hidden
tel: +1 408 974 4056
________________________________________________________________________
__
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
________________________________________________________________________
__
_______________________________________________
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.