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

Commit 1f1abe82 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Check Visualizer.getWaveForm input array size" into udc-qpr-dev am: e7db2457

parents 644dbf5b e7db2457
Loading
Loading
Loading
Loading
+9 −1
Original line number Original line Diff line number Diff line
@@ -455,11 +455,13 @@ public class Visualizer {
     * a number of consecutive 8-bit (unsigned) mono PCM samples equal to the capture size returned
     * a number of consecutive 8-bit (unsigned) mono PCM samples equal to the capture size returned
     * by {@link #getCaptureSize()}.
     * by {@link #getCaptureSize()}.
     * <p>This method must be called when the Visualizer is enabled.
     * <p>This method must be called when the Visualizer is enabled.
     * @param waveform array of bytes where the waveform should be returned
     * @param waveform array of bytes where the waveform should be returned, array length must be
     * at least equals to the capture size returned by {@link #getCaptureSize()}.
     * @return {@link #SUCCESS} in case of success,
     * @return {@link #SUCCESS} in case of success,
     * {@link #ERROR_NO_MEMORY}, {@link #ERROR_INVALID_OPERATION} or {@link #ERROR_DEAD_OBJECT}
     * {@link #ERROR_NO_MEMORY}, {@link #ERROR_INVALID_OPERATION} or {@link #ERROR_DEAD_OBJECT}
     * in case of failure.
     * in case of failure.
     * @throws IllegalStateException
     * @throws IllegalStateException
     * @throws IllegalArgumentException
     */
     */
    public int getWaveForm(byte[] waveform)
    public int getWaveForm(byte[] waveform)
    throws IllegalStateException {
    throws IllegalStateException {
@@ -467,6 +469,12 @@ public class Visualizer {
            if (mState != STATE_ENABLED) {
            if (mState != STATE_ENABLED) {
                throw(new IllegalStateException("getWaveForm() called in wrong state: "+mState));
                throw(new IllegalStateException("getWaveForm() called in wrong state: "+mState));
            }
            }
            int captureSize = getCaptureSize();
            if (captureSize > waveform.length) {
                throw(new IllegalArgumentException("getWaveForm() called with illegal size: "
                                                   + waveform.length + " expecting at least "
                                                   + captureSize + " bytes"));
            }
            return native_getWaveForm(waveform);
            return native_getWaveForm(waveform);
        }
        }
    }
    }