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

Commit 53c7ddc8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "aaudio examples: allow -n0 for minimum buffer size"

parents 662f25f1 bad0f578
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -40,7 +40,8 @@
// V0.4.01 = add -h hang option
//           fix -n option to set output buffer for -tm
//           plot first glitch
#define APP_VERSION             "0.4.01"
// V0.4.02 = allow -n0 for minimal buffer size
#define APP_VERSION             "0.4.02"

// Tag for machine readable results as property = value pairs
#define RESULT_TAG              "RESULT: "
@@ -535,7 +536,7 @@ int main(int argc, const char **argv)
    printf("INPUT  stream ----------------------------------------\n");
    // Use different parameters for the input.
    argParser.setDeviceId(requestedInputDeviceId);
    argParser.setNumberOfBursts(AAUDIO_UNSPECIFIED);
    argParser.setNumberOfBursts(AAudioParameters::kDefaultNumberOfBursts);
    argParser.setFormat(requestedInputFormat);
    argParser.setPerformanceMode(inputPerformanceLevel);
    argParser.setChannelCount(requestedInputChannelCount);
+19 −6
Original line number Diff line number Diff line
@@ -251,6 +251,8 @@ public:
        }
    }

    static constexpr int32_t   kDefaultNumberOfBursts = 2;

private:
    int32_t                    mChannelCount    = AAUDIO_UNSPECIFIED;
    aaudio_format_t            mFormat          = AAUDIO_FORMAT_UNSPECIFIED;
@@ -266,7 +268,7 @@ private:
    aaudio_input_preset_t      mInputPreset     = AAUDIO_UNSPECIFIED;
    aaudio_allowed_capture_policy_t mAllowedCapturePolicy     = AAUDIO_UNSPECIFIED;

    int32_t                    mNumberOfBursts  = AAUDIO_UNSPECIFIED;
    int32_t                    mNumberOfBursts  = kDefaultNumberOfBursts;
    int32_t                    mFramesPerCallback = AAUDIO_UNSPECIFIED;
};

@@ -386,7 +388,7 @@ public:
        printf("          1 = _NEVER, never use MMAP\n");
        printf("          2 = _AUTO, use MMAP if available, default for -m with no number\n");
        printf("          3 = _ALWAYS, use MMAP or fail\n");
        printf("      -n{numberOfBursts} for setBufferSize\n");
        printf("      -n{numberOfBursts} for setBufferSize, default %d\n", kDefaultNumberOfBursts);
        printf("      -p{performanceMode} set output AAUDIO_PERFORMANCE_MODE*, default NONE\n");
        printf("          n for _NONE\n");
        printf("          l for _LATENCY\n");
@@ -460,17 +462,28 @@ public:
               getFormat(), AAudioStream_getFormat(stream));

        int32_t framesPerBurst = AAudioStream_getFramesPerBurst(stream);
        int32_t sizeFrames = AAudioStream_getBufferSizeInFrames(stream);
        printf("  Buffer:       burst     = %d\n", framesPerBurst);

        int32_t sizeFrames = AAudioStream_getBufferSizeInFrames(stream);
        if (framesPerBurst > 0) {
            printf("  Buffer:       size      = %d = (%d * %d) + %d\n",
            int32_t requestedSize = getNumberOfBursts() * framesPerBurst;
            printf("  BufferSize:   requested = %4d, actual = %4d = (%d * %d) + %d\n",
                   requestedSize,
                   sizeFrames,
                   (sizeFrames / framesPerBurst),
                   framesPerBurst,
                   (sizeFrames % framesPerBurst));
        } else {
             printf("  BufferSize:    %d\n", sizeFrames);
        }
        printf("  Capacity:     requested = %d, actual = %d\n", getBufferCapacity(),
               AAudioStream_getBufferCapacityInFrames(stream));

        int32_t capacityFrames = AAudioStream_getBufferCapacityInFrames(stream);
        printf("  Capacity:     requested = %4d, actual = %4d = (%d * %d) + %d\n",
               getBufferCapacity(),
               capacityFrames,
               (capacityFrames / framesPerBurst),
               framesPerBurst,
               (capacityFrames % framesPerBurst));

        printf("  CallbackSize: requested = %d, actual = %d\n", getFramesPerCallback(),
               AAudioStream_getFramesPerDataCallback(stream));
+3 −4
Original line number Diff line number Diff line
@@ -120,10 +120,9 @@ public:

        if (result == AAUDIO_OK) {
            int32_t sizeInBursts = parameters.getNumberOfBursts();
            if (sizeInBursts > 0) {
            int32_t framesPerBurst = AAudioStream_getFramesPerBurst(mStream);
                AAudioStream_setBufferSizeInFrames(mStream, sizeInBursts * framesPerBurst);
            }
            int32_t bufferSizeFrames = sizeInBursts * framesPerBurst;
            AAudioStream_setBufferSizeInFrames(mStream, bufferSizeFrames);
        }

        AAudioStreamBuilder_delete(builder);
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@
#include "AAudioSimplePlayer.h"
#include "AAudioArgsParser.h"

#define APP_VERSION  "0.1.6"
#define APP_VERSION  "0.1.7"

constexpr int32_t kDefaultHangTimeMSec = 10;