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

Commit 05e6b175 authored by Phil Burk's avatar Phil Burk
Browse files

aaudio_loopback: fix -n for sine test

Allow -n to specify buffer size for -tm test.
It was being forced to the size of the input buffer.

Test: aaudio_loopback -tm -s20 -n2
Change-Id: I4b71238f17bb87c22602bf86e2b91cfa41e3ae55
parent ffb2516c
Loading
Loading
Loading
Loading
+13 −7
Original line number Original line Diff line number Diff line
@@ -36,8 +36,11 @@
#include "LoopbackAnalyzer.h"
#include "LoopbackAnalyzer.h"
#include "../../utils/AAudioExampleUtils.h"
#include "../../utils/AAudioExampleUtils.h"


// V0.4.00 = rectify and low-pass filter the echos, use auto-correlation on entire echo
// V0.4.00 = rectify and low-pass filter the echos, auto-correlate entire echo
#define APP_VERSION             "0.4.00"
// 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"


// Tag for machine readable results as property = value pairs
// Tag for machine readable results as property = value pairs
#define RESULT_TAG              "RESULT: "
#define RESULT_TAG              "RESULT: "
@@ -476,6 +479,8 @@ int main(int argc, const char **argv)
    int32_t timeMillis = 0;
    int32_t timeMillis = 0;
    int32_t recordingDuration = std::min(60 * 5, requestedDuration);
    int32_t recordingDuration = std::min(60 * 5, requestedDuration);


    int32_t requestedOutputBursts = argParser.getNumberOfBursts();

    switch(testMode) {
    switch(testMode) {
        case TEST_SINE_MAGNITUDE:
        case TEST_SINE_MAGNITUDE:
            loopbackData.loopbackProcessor = &loopbackData.sineAnalyzer;
            loopbackData.loopbackProcessor = &loopbackData.sineAnalyzer;
@@ -541,20 +546,19 @@ int main(int argc, const char **argv)
    }
    }
    inputStream = loopbackData.inputStream = recorder.getStream();
    inputStream = loopbackData.inputStream = recorder.getStream();


    argParser.compareWithStream(inputStream);

    {
    {
        int32_t actualCapacity = AAudioStream_getBufferCapacityInFrames(inputStream);
        int32_t actualCapacity = AAudioStream_getBufferCapacityInFrames(inputStream);
        (void) AAudioStream_setBufferSizeInFrames(inputStream, actualCapacity);
        (void) AAudioStream_setBufferSizeInFrames(inputStream, actualCapacity);


        if (testMode == TEST_SINE_MAGNITUDE) {
        if (testMode == TEST_SINE_MAGNITUDE
                && requestedOutputBursts == AAUDIO_UNSPECIFIED) {
            result = AAudioStream_setBufferSizeInFrames(outputStream, actualCapacity);
            result = AAudioStream_setBufferSizeInFrames(outputStream, actualCapacity);
            if (result < 0) {
            if (result < 0) {
                fprintf(stderr, "ERROR -  AAudioStream_setBufferSizeInFrames(output) returned %d\n",
                fprintf(stderr, "ERROR -  AAudioStream_setBufferSizeInFrames(output) returned %d\n",
                        result);
                        result);
                goto finish;
                goto finish;
            } else {
            } else {
                printf("Output buffer size set to match input capacity = %d frames.\n", result);
                printf("Output buffer size set to match input capacity = %d frames!\n", result);
            }
            }
        }
        }


@@ -565,6 +569,8 @@ int main(int argc, const char **argv)
        }
        }
    }
    }


    argParser.compareWithStream(inputStream);

    // ------- Setup loopbackData -----------------------------
    // ------- Setup loopbackData -----------------------------
    loopbackData.actualInputFormat = AAudioStream_getFormat(inputStream);
    loopbackData.actualInputFormat = AAudioStream_getFormat(inputStream);