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

Commit 304b6c81 authored by Kevin Rocard's avatar Kevin Rocard
Browse files

Audio HAL VTS: stopped stream state getters may return INVALID_STATE



A never started stream should have its render position and next write
timestamp at 0 or indicate that the state is invalid.

Test: vts-tradefed run vts --module VtsHalAudioV2_0Target
Test: call/play music/record/video...
Bug: 36311550
Change-Id: I62e16066bb22101ee8f75154fc6c85a66be2f402
Signed-off-by: default avatarKevin Rocard <krocard@google.com>
parent c4f1b2f8
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -1182,27 +1182,39 @@ TEST_P(OutputStreamTest, SupportsPauseAndResumeAndDrain) {
    Capability(stream.get());
}

template <class Value>
static void checkInvalidStateOr0(Result res, Value value) {
    switch (res) {
        case Result::INVALID_STATE:
            break;
        case Result::OK:
            ASSERT_EQ(0U, value);
            break;
        default:
            FAIL() << "Unexpected result " << toString(res);
    }
}

TEST_P(OutputStreamTest, GetRenderPosition) {
    doc::test("The render position should be 0 on a not started");
    doc::test("A new stream render position should be 0 or INVALID_STATE");
    uint32_t dspFrames;
    ASSERT_OK(stream->getRenderPosition(returnIn(res, dspFrames)));
    if (res == Result::NOT_SUPPORTED) {
        doc::partialTest("getRenderPosition is not supported");
        return;
    }
    ASSERT_OK(res);
    ASSERT_EQ(0U, dspFrames);
    checkInvalidStateOr0(res, dspFrames);
}

TEST_P(OutputStreamTest, GetNextWriteTimestamp) {
    doc::test("The render position of a stream just created should be 0");
    doc::test("A new stream next write timestamp should be 0 or INVALID_STATE");
    uint64_t timestampUs;
    ASSERT_OK(stream->getNextWriteTimestamp(returnIn(res, timestampUs)));
    if (res == Result::NOT_SUPPORTED) {
        doc::partialTest("getNextWriteTimestamp is not supported");
        return;
    }
    ASSERT_EQ(Result::INVALID_STATE, res);
    checkInvalidStateOr0(res, timestampUs);
}

/** Stub implementation of out stream callback. */