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

Commit c4f1b2f8 authored by Kevin Rocard's avatar Kevin Rocard
Browse files

Audio HAL VTS: setGain allow -0.0



Previously -0.0 was consider an invalid value as not in the range [0,1].
But it is quite difficult in C++ to differentiate -0.0 and 0.0 as -0.0 == 0.0
and such difference has no impact in practice.

Thus leave the implementation support or not -0.0.

Test: vts-tradefed run vts --module VtsHalAudioV2_0Target
Test: call/play music/record/video...
Bug: 36311550
Change-Id: Ia0ebcb325f77adcf8471620f418da1cbe8995e36
Signed-off-by: default avatarKevin Rocard <krocard@google.com>
parent 98390a6c
Loading
Loading
Loading
Loading
+8 −7
Original line number Original line Diff line number Diff line
@@ -1029,12 +1029,8 @@ TEST_P(InputStreamTest, GetAudioSource) {
}
}


static void testUnitaryGain(std::function<Return<Result>(float)> setGain) {
static void testUnitaryGain(std::function<Return<Result>(float)> setGain) {
    for (float value : {0.0, 0.01, 0.5, 0.09, 1.0}) {
    for (float value :
        SCOPED_TRACE("value=" + to_string(value));
         (float[]){-INFINITY, -1.0, 1.0 + std::numeric_limits<float>::epsilon(),
        ASSERT_OK(setGain(value));
    }
    for (float value : (float[]){-INFINITY, -1.0, -0.0,
                                 1.0 + std::numeric_limits<float>::epsilon(),
                   2.0, INFINITY, NAN}) {
                   2.0, INFINITY, NAN}) {
        SCOPED_TRACE("value=" + to_string(value));
        SCOPED_TRACE("value=" + to_string(value));
        // FIXME: NAN should never be accepted
        // FIXME: NAN should never be accepted
@@ -1042,6 +1038,11 @@ static void testUnitaryGain(std::function<Return<Result>(float)> setGain) {
        // outside [0,1] ?
        // outside [0,1] ?
        ASSERT_RESULT(Result::INVALID_ARGUMENTS, setGain(value));
        ASSERT_RESULT(Result::INVALID_ARGUMENTS, setGain(value));
    }
    }
    // Do not consider -0.0 as an invalid value as it is == with 0.0
    for (float value : {-0.0, 0.0, 0.01, 0.5, 0.09, 1.0 /* Restore volume*/}) {
        SCOPED_TRACE("value=" + to_string(value));
        ASSERT_OK(setGain(value));
    }
}
}


static void testOptionalUnitaryGain(
static void testOptionalUnitaryGain(