Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b143e3de authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "Fix AudioTrack and AudioRecord documentation" into nyc-dev

parents d4a45e0c 219de73d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -19776,6 +19776,7 @@ package android.media {
    method public void stop() throws java.lang.IllegalStateException;
    field public static final int ERROR = -1; // 0xffffffff
    field public static final int ERROR_BAD_VALUE = -2; // 0xfffffffe
    field public static final int ERROR_DEAD_OBJECT = -6; // 0xfffffffa
    field public static final int ERROR_INVALID_OPERATION = -3; // 0xfffffffd
    field public static final int READ_BLOCKING = 0; // 0x0
    field public static final int READ_NON_BLOCKING = 1; // 0x1
@@ -19898,6 +19899,7 @@ package android.media {
    method public int write(java.nio.ByteBuffer, int, int, long);
    field public static final int ERROR = -1; // 0xffffffff
    field public static final int ERROR_BAD_VALUE = -2; // 0xfffffffe
    field public static final int ERROR_DEAD_OBJECT = -6; // 0xfffffffa
    field public static final int ERROR_INVALID_OPERATION = -3; // 0xfffffffd
    field public static final int MODE_STATIC = 0; // 0x0
    field public static final int MODE_STREAM = 1; // 0x1
+2 −0
Original line number Diff line number Diff line
@@ -21292,6 +21292,7 @@ package android.media {
    method public void stop() throws java.lang.IllegalStateException;
    field public static final int ERROR = -1; // 0xffffffff
    field public static final int ERROR_BAD_VALUE = -2; // 0xfffffffe
    field public static final int ERROR_DEAD_OBJECT = -6; // 0xfffffffa
    field public static final int ERROR_INVALID_OPERATION = -3; // 0xfffffffd
    field public static final int READ_BLOCKING = 0; // 0x0
    field public static final int READ_NON_BLOCKING = 1; // 0x1
@@ -21416,6 +21417,7 @@ package android.media {
    method public int write(java.nio.ByteBuffer, int, int, long);
    field public static final int ERROR = -1; // 0xffffffff
    field public static final int ERROR_BAD_VALUE = -2; // 0xfffffffe
    field public static final int ERROR_DEAD_OBJECT = -6; // 0xfffffffa
    field public static final int ERROR_INVALID_OPERATION = -3; // 0xfffffffd
    field public static final int MODE_STATIC = 0; // 0x0
    field public static final int MODE_STREAM = 1; // 0x1
+2 −0
Original line number Diff line number Diff line
@@ -19845,6 +19845,7 @@ package android.media {
    method public void stop() throws java.lang.IllegalStateException;
    field public static final int ERROR = -1; // 0xffffffff
    field public static final int ERROR_BAD_VALUE = -2; // 0xfffffffe
    field public static final int ERROR_DEAD_OBJECT = -6; // 0xfffffffa
    field public static final int ERROR_INVALID_OPERATION = -3; // 0xfffffffd
    field public static final int READ_BLOCKING = 0; // 0x0
    field public static final int READ_NON_BLOCKING = 1; // 0x1
@@ -19967,6 +19968,7 @@ package android.media {
    method public int write(java.nio.ByteBuffer, int, int, long);
    field public static final int ERROR = -1; // 0xffffffff
    field public static final int ERROR_BAD_VALUE = -2; // 0xfffffffe
    field public static final int ERROR_DEAD_OBJECT = -6; // 0xfffffffa
    field public static final int ERROR_INVALID_OPERATION = -3; // 0xfffffffd
    field public static final int MODE_STATIC = 0; // 0x0
    field public static final int MODE_STREAM = 1; // 0x1
+6 −10
Original line number Diff line number Diff line
@@ -479,17 +479,13 @@ void envReleaseArrayElements(JNIEnv *env, jfloatArray array, jfloat *elems, jint

static inline
jint interpretReadSizeError(ssize_t readSize) {
    ALOGE_IF(readSize != WOULD_BLOCK, "Error %zd during AudioRecord native read", readSize);
    switch (readSize) {
    case WOULD_BLOCK:
    if (readSize == WOULD_BLOCK) {
        return (jint)0;
    case BAD_VALUE:
        return (jint)AUDIO_JAVA_BAD_VALUE;
    default:
        // may be possible for other errors such as
        // NO_INIT to happen if restoreRecord_l fails.
    case INVALID_OPERATION:
        return (jint)AUDIO_JAVA_INVALID_OPERATION;
    } else if (readSize == NO_INIT) {
        return AUDIO_JAVA_DEAD_OBJECT;
    } else {
        ALOGE("Error %zd during AudioRecord native read", readSize);
        return nativeToJavaStatus(readSize);
    }
}

+14 −3
Original line number Diff line number Diff line
@@ -606,6 +606,18 @@ void envReleaseArrayElements(JNIEnv *env, jfloatArray array, jfloat *elems, jint
    env->ReleaseFloatArrayElements(array, elems, mode);
}

static inline
jint interpretWriteSizeError(ssize_t writeSize) {
    if (writeSize == WOULD_BLOCK) {
        return (jint)0;
    } else if (writeSize == NO_INIT) {
        return AUDIO_JAVA_DEAD_OBJECT;
    } else {
        ALOGE("Error %zd during AudioTrack native read", writeSize);
        return nativeToJavaStatus(writeSize);
    }
}

// ----------------------------------------------------------------------------
template <typename T>
static jint writeToTrack(const sp<AudioTrack>& track, jint audioFormat, const T *data,
@@ -628,11 +640,10 @@ static jint writeToTrack(const sp<AudioTrack>& track, jint audioFormat, const T
        memcpy(track->sharedBuffer()->pointer(), data + offsetInSamples, sizeInBytes);
        written = sizeInBytes;
    }
    if (written > 0) {
    if (written >= 0) {
        return written / sizeof(T);
    }
    // for compatibility, error codes pass through unchanged
    return written;
    return interpretWriteSizeError(written);
}

// ----------------------------------------------------------------------------
Loading