private static void errorCallbackFromNative(int error) { ErrorCallback errorCallback = null; synchronized (AudioSystem.class) { if (mErrorCallback != null) { errorCallback = mErrorCallback; } } if (errorCallback != null) { errorCallback.onError(error); } }
/** * Triggers an error for the Future * * @param error The error */ public void triggerError(Throwable error) { synchronized (mErrorLock) { if (mErrorCallback.size() > 0) { for (ErrorCallback handler : mErrorCallback) { handler.onError(error); } } else { mErrorQueue.add(error); } mError = error; mResultSemaphore.release(); } }
/* * Registers a callback to be invoked when an error occurs. * @param cb the callback to run */ public static void setErrorCallback(ErrorCallback cb) { synchronized (AudioSystem.class) { mErrorCallback = cb; if (cb != null) { cb.onError(checkAudioFlinger()); } } }
/** * Handles error during the execution of the Future. If it's the first time the method is invoked * on the object and errors were already triggered, the handler will be called once per error, * right away. * * @param errorCallback The handler */ public OfficeFuture<V> onError(ErrorCallback errorCallback) { synchronized (mErrorLock) { mErrorCallback.add(errorCallback); while (!mErrorQueue.isEmpty()) { // Only the first error handler will get the queued errors if (errorCallback != null) { errorCallback.onError(mErrorQueue.poll()); } } } return this; }
@Override public void fileErrorCallback(FileError fileError) { callback.onError(message, fileError); }