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

Commit a65262e9 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 am: 50103561

am: 45309a4a

* commit '45309a4a':
  Fix AudioTrack and AudioRecord documentation

Change-Id: I9da5a69426b790bbf4a0c6a22ae894b7f1258220
parents 95dbbac8 45309a4a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -19882,6 +19882,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
@@ -20004,6 +20005,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
@@ -21398,6 +21398,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
@@ -21522,6 +21523,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
@@ -19952,6 +19952,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
@@ -20074,6 +20075,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
@@ -608,6 +608,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,
@@ -630,11 +642,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