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

Commit 81833e3b authored by android-build-team Robot's avatar android-build-team Robot
Browse files

release-request-e81235f1-b2b4-4de1-b974-255760176f06-for-git_oc-mr1-release-40...

release-request-e81235f1-b2b4-4de1-b974-255760176f06-for-git_oc-mr1-release-4040405 snap-temp-L68200000067456736

Change-Id: Ifdbcdb8e33ec2f781b6bcd6b33e8b8008df8852a
parents f2ed2618 731f512b
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -44,8 +44,20 @@ Stream::~Stream() {
}

// static
Result Stream::analyzeStatus(const char* funcName, int status, int ignoreError, int ignoreError2) {
    if (status != 0 && status != -ignoreError && status != -ignoreError2) {
Result Stream::analyzeStatus(const char* funcName, int status) {
    static const std::vector<int> empty;
    return analyzeStatus(funcName, status, empty);
}

template <typename T>
inline bool element_in(T e, const std::vector<T>& v) {
    return std::find(v.begin(), v.end(), e) != v.end();
}

// static
Result Stream::analyzeStatus(const char* funcName, int status,
                             const std::vector<int>& ignoreErrors) {
    if (status != 0 && (ignoreErrors.empty() || !element_in(-status, ignoreErrors))) {
        ALOGW("Error from HAL stream in function %s: %s", funcName, strerror(-status));
    }
    switch (status) {
+6 −3
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
#ifndef ANDROID_HARDWARE_AUDIO_V2_0_STREAM_H
#define ANDROID_HARDWARE_AUDIO_V2_0_STREAM_H

#include <vector>

#include <android/hardware/audio/2.0/IStream.h>
#include <hardware/audio.h>
#include <hidl/Status.h>
@@ -79,8 +81,9 @@ struct Stream : public IStream, public ParametersUtil {
    Return<Result> close()  override;

    // Utility methods for extending interfaces.
    static Result analyzeStatus(
            const char* funcName, int status, int ignoreError = OK, int ignoreError2 = OK);
    static Result analyzeStatus(const char* funcName, int status);
    static Result analyzeStatus(const char* funcName, int status,
                                const std::vector<int>& ignoreErrors);

   private:
    audio_stream_t *mStream;
+6 −6
Original line number Diff line number Diff line
@@ -416,15 +416,15 @@ Return<uint32_t> StreamIn::getInputFramesLost() {
// static
Result StreamIn::getCapturePositionImpl(audio_stream_in_t* stream,
                                        uint64_t* frames, uint64_t* time) {
    // HAL may have a stub function, always returning ENOSYS, don't
    // spam the log in this case.
    static const std::vector<int> ignoredErrors{ENOSYS};
    Result retval(Result::NOT_SUPPORTED);
    if (stream->get_capture_position != NULL) return retval;
    int64_t halFrames, halTime;
    retval = Stream::analyzeStatus(
        "get_capture_position",
    retval = Stream::analyzeStatus("get_capture_position",
                                   stream->get_capture_position(stream, &halFrames, &halTime),
        // HAL may have a stub function, always returning ENOSYS, don't
        // spam the log in this case.
        ENOSYS);
                                   ignoredErrors);
    if (retval == Result::OK) {
        *frames = halFrames;
        *time = halTime;
+8 −7
Original line number Diff line number Diff line
@@ -487,16 +487,17 @@ Return<Result> StreamOut::flush() {
Result StreamOut::getPresentationPositionImpl(audio_stream_out_t* stream,
                                              uint64_t* frames,
                                              TimeSpec* timeStamp) {
    // Don't logspam on EINVAL--it's normal for get_presentation_position
    // to return it sometimes. EAGAIN may be returned by A2DP audio HAL
    // implementation. ENODATA can also be reported while the writer is
    // continuously querying it, but the stream has been stopped.
    static const std::vector<int> ignoredErrors{EINVAL, EAGAIN, ENODATA};
    Result retval(Result::NOT_SUPPORTED);
    if (stream->get_presentation_position == NULL) return retval;
    struct timespec halTimeStamp;
    retval = Stream::analyzeStatus(
        "get_presentation_position",
    retval = Stream::analyzeStatus("get_presentation_position",
                                   stream->get_presentation_position(stream, frames, &halTimeStamp),
        // Don't logspam on EINVAL--it's normal for get_presentation_position
        // to return it sometimes. EAGAIN may be returned by A2DP audio HAL
        // implementation.
        EINVAL, EAGAIN);
                                   ignoredErrors);
    if (retval == Result::OK) {
        timeStamp->tvSec = halTimeStamp.tv_sec;
        timeStamp->tvNSec = halTimeStamp.tv_nsec;
+4 −12
Original line number Diff line number Diff line
@@ -746,12 +746,12 @@ TEST_IO_STREAM(
TEST_IO_STREAM(
    GetSampleRate,
    "Check that the stream sample rate == the one it was opened with",
    ASSERT_EQ(audioConfig.sampleRateHz, extract(stream->getSampleRate())))
    stream->getSampleRate())

TEST_IO_STREAM(
    GetChannelMask,
    "Check that the stream channel mask == the one it was opened with",
    ASSERT_EQ(audioConfig.channelMask, extract(stream->getChannelMask())))
    stream->getChannelMask())

TEST_IO_STREAM(GetFormat,
               "Check that the stream format == the one it was opened with",
@@ -853,25 +853,17 @@ TEST_IO_STREAM(
    areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported")
                               : testSetDevice(stream.get(), address))

static void testGetAudioProperties(IStream* stream,
                                   AudioConfig expectedConfig) {
static void testGetAudioProperties(IStream* stream) {
    uint32_t sampleRateHz;
    AudioChannelMask mask;
    AudioFormat format;

    stream->getAudioProperties(returnIn(sampleRateHz, mask, format));

    // FIXME: the qcom hal it does not currently negotiate the sampleRate &
    // channel mask
    EXPECT_EQ(expectedConfig.sampleRateHz, sampleRateHz);
    EXPECT_EQ(expectedConfig.channelMask, mask);
    EXPECT_EQ(expectedConfig.format, format);
}

TEST_IO_STREAM(
    GetAudioProperties,
    "Check that the stream audio properties == the ones it was opened with",
    testGetAudioProperties(stream.get(), audioConfig))
    testGetAudioProperties(stream.get()))

static void testConnectedState(IStream* stream) {
    DeviceAddress address = {};
Loading