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

Commit a3033569 authored by Eric Laurent's avatar Eric Laurent Committed by android-build-merger
Browse files

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

am: b143e3de

* commit 'b143e3de':
  Fix AudioTrack and AudioRecord documentation

Change-Id: I861c0047b33730465c3ceeae1c4072f17b29d804
parents d2b0d2e2 b143e3de
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -19877,6 +19877,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
@@ -19999,6 +20000,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
@@ -21393,6 +21393,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
@@ -21517,6 +21518,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
@@ -19947,6 +19947,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
@@ -20069,6 +20070,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