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

Commit 72e50e2e authored by Kevin Rocard's avatar Kevin Rocard
Browse files

Audio HAL VTS: Fix style on modified files

In order to avoid style inconsistency as well as non functional
modification in following patches,
fix the style of all files modified for the fix of the VTS tests.

Patch generated with:
$ clang-format -i --style file -- <file list>

Bug: 36311550
Test: compile
Change-Id: I53dbcdabf959a6100e34a2ee4d0f951d525049cb
parent eca8d114
Loading
Loading
Loading
Loading
+114 −104
Original line number Diff line number Diff line
@@ -92,7 +92,8 @@ Device::Device(audio_hw_device_t* device, const char* type)

Device::~Device() {
    int status = audio_hw_device_close(mDevice);
    ALOGW_IF(status, "Error closing audio hw device %p: %s", mDevice, strerror(-status));
    ALOGW_IF(status, "Error closing audio hw device %p: %s", mDevice,
             strerror(-status));
    mDevice = nullptr;
}

@@ -101,12 +102,18 @@ Result Device::analyzeStatus(const char* funcName, int status) {
        ALOGW("Device %p %s: %s", mDevice, funcName, strerror(-status));
    }
    switch (status) {
        case 0: return Result::OK;
        case -EINVAL: return Result::INVALID_ARGUMENTS;
        case -ENODATA: return Result::INVALID_STATE;
        case -ENODEV: return Result::NOT_INITIALIZED;
        case -ENOSYS: return Result::NOT_SUPPORTED;
        default: return Result::INVALID_STATE;
        case 0:
            return Result::OK;
        case -EINVAL:
            return Result::INVALID_ARGUMENTS;
        case -ENODATA:
            return Result::INVALID_STATE;
        case -ENODEV:
            return Result::NOT_INITIALIZED;
        case -ENOSYS:
            return Result::NOT_SUPPORTED;
        default:
            return Result::INVALID_STATE;
    }
}

@@ -136,7 +143,8 @@ Return<Result> Device::initCheck() {
Return<Result> Device::setMasterVolume(float volume) {
    Result retval(Result::NOT_SUPPORTED);
    if (mDevice->set_master_volume != NULL) {
        retval = analyzeStatus("set_master_volume", mDevice->set_master_volume(mDevice, volume));
        retval = analyzeStatus("set_master_volume",
                               mDevice->set_master_volume(mDevice, volume));
    }
    return retval;
}
@@ -145,7 +153,8 @@ Return<void> Device::getMasterVolume(getMasterVolume_cb _hidl_cb) {
    Result retval(Result::NOT_SUPPORTED);
    float volume = 0;
    if (mDevice->get_master_volume != NULL) {
        retval = analyzeStatus("get_master_volume", mDevice->get_master_volume(mDevice, &volume));
        retval = analyzeStatus("get_master_volume",
                               mDevice->get_master_volume(mDevice, &volume));
    }
    _hidl_cb(retval, volume);
    return Void();
@@ -157,7 +166,8 @@ Return<Result> Device::setMicMute(bool mute) {

Return<void> Device::getMicMute(getMicMute_cb _hidl_cb) {
    bool mute = false;
    Result retval = analyzeStatus("get_mic_mute", mDevice->get_mic_mute(mDevice, &mute));
    Result retval =
        analyzeStatus("get_mic_mute", mDevice->get_mic_mute(mDevice, &mute));
    _hidl_cb(retval, mute);
    return Void();
}
@@ -165,7 +175,8 @@ Return<void> Device::getMicMute(getMicMute_cb _hidl_cb) {
Return<Result> Device::setMasterMute(bool mute) {
    Result retval(Result::NOT_SUPPORTED);
    if (mDevice->set_master_mute != NULL) {
        retval = analyzeStatus("set_master_mute", mDevice->set_master_mute(mDevice, mute));
        retval = analyzeStatus("set_master_mute",
                               mDevice->set_master_mute(mDevice, mute));
    }
    return retval;
}
@@ -174,14 +185,15 @@ Return<void> Device::getMasterMute(getMasterMute_cb _hidl_cb) {
    Result retval(Result::NOT_SUPPORTED);
    bool mute = false;
    if (mDevice->get_master_mute != NULL) {
        retval = analyzeStatus("get_master_mute", mDevice->get_master_mute(mDevice, &mute));
        retval = analyzeStatus("get_master_mute",
                               mDevice->get_master_mute(mDevice, &mute));
    }
    _hidl_cb(retval, mute);
    return Void();
}

Return<void> Device::getInputBufferSize(
        const AudioConfig& config, getInputBufferSize_cb _hidl_cb)  {
Return<void> Device::getInputBufferSize(const AudioConfig& config,
                                        getInputBufferSize_cb _hidl_cb) {
    audio_config_t halConfig;
    HidlUtils::audioConfigToHal(config, &halConfig);
    size_t halBufferSize = mDevice->get_input_buffer_size(mDevice, &halConfig);
@@ -195,8 +207,7 @@ Return<void> Device::getInputBufferSize(
    return Void();
}

Return<void> Device::openOutputStream(
        int32_t ioHandle,
Return<void> Device::openOutputStream(int32_t ioHandle,
                                      const DeviceAddress& device,
                                      const AudioConfig& config,
                                      AudioOutputFlag flags,
@@ -204,19 +215,16 @@ Return<void> Device::openOutputStream(
    audio_config_t halConfig;
    HidlUtils::audioConfigToHal(config, &halConfig);
    audio_stream_out_t* halStream;
    ALOGV("open_output_stream handle: %d devices: %x flags: %#x "
    ALOGV(
        "open_output_stream handle: %d devices: %x flags: %#x "
        "srate: %d format %#x channels %x address %s",
            ioHandle,
            static_cast<audio_devices_t>(device.device), static_cast<audio_output_flags_t>(flags),
            halConfig.sample_rate, halConfig.format, halConfig.channel_mask,
        ioHandle, static_cast<audio_devices_t>(device.device),
        static_cast<audio_output_flags_t>(flags), halConfig.sample_rate,
        halConfig.format, halConfig.channel_mask,
        deviceAddressToHal(device).c_str());
    int status = mDevice->open_output_stream(
            mDevice,
            ioHandle,
            static_cast<audio_devices_t>(device.device),
            static_cast<audio_output_flags_t>(flags),
            &halConfig,
            &halStream,
        mDevice, ioHandle, static_cast<audio_devices_t>(device.device),
        static_cast<audio_output_flags_t>(flags), &halConfig, &halStream,
        deviceAddressToHal(device).c_str());
    ALOGV("open_output_stream status %d stream %p", status, halStream);
    sp<IStreamOut> streamOut;
@@ -225,33 +233,30 @@ Return<void> Device::openOutputStream(
    }
    AudioConfig suggestedConfig;
    HidlUtils::audioConfigFromHal(halConfig, &suggestedConfig);
    _hidl_cb(analyzeStatus("open_output_stream", status), streamOut, suggestedConfig);
    _hidl_cb(analyzeStatus("open_output_stream", status), streamOut,
             suggestedConfig);
    return Void();
}

Return<void> Device::openInputStream(
        int32_t ioHandle,
Return<void> Device::openInputStream(int32_t ioHandle,
                                     const DeviceAddress& device,
                                     const AudioConfig& config,
        AudioInputFlag flags,
        AudioSource source,
                                     AudioInputFlag flags, AudioSource source,
                                     openInputStream_cb _hidl_cb) {
    audio_config_t halConfig;
    HidlUtils::audioConfigToHal(config, &halConfig);
    audio_stream_in_t* halStream;
    ALOGV("open_input_stream handle: %d devices: %x flags: %#x "
    ALOGV(
        "open_input_stream handle: %d devices: %x flags: %#x "
        "srate: %d format %#x channels %x address %s source %d",
            ioHandle,
            static_cast<audio_devices_t>(device.device), static_cast<audio_input_flags_t>(flags),
            halConfig.sample_rate, halConfig.format, halConfig.channel_mask,
            deviceAddressToHal(device).c_str(), static_cast<audio_source_t>(source));
        ioHandle, static_cast<audio_devices_t>(device.device),
        static_cast<audio_input_flags_t>(flags), halConfig.sample_rate,
        halConfig.format, halConfig.channel_mask,
        deviceAddressToHal(device).c_str(),
        static_cast<audio_source_t>(source));
    int status = mDevice->open_input_stream(
            mDevice,
            ioHandle,
            static_cast<audio_devices_t>(device.device),
            &halConfig,
            &halStream,
            static_cast<audio_input_flags_t>(flags),
        mDevice, ioHandle, static_cast<audio_devices_t>(device.device),
        &halConfig, &halStream, static_cast<audio_input_flags_t>(flags),
        deviceAddressToHal(device).c_str(),
        static_cast<audio_source_t>(source));
    ALOGV("open_input_stream status %d stream %p", status, halStream);
@@ -261,7 +266,8 @@ Return<void> Device::openInputStream(
    }
    AudioConfig suggestedConfig;
    HidlUtils::audioConfigFromHal(halConfig, &suggestedConfig);
    _hidl_cb(analyzeStatus("open_input_stream", status), streamIn, suggestedConfig);
    _hidl_cb(analyzeStatus("open_input_stream", status), streamIn,
             suggestedConfig);
    return Void();
}

@@ -269,23 +275,21 @@ Return<bool> Device::supportsAudioPatches() {
    return version() >= AUDIO_DEVICE_API_VERSION_3_0;
}

Return<void> Device::createAudioPatch(
        const hidl_vec<AudioPortConfig>& sources,
Return<void> Device::createAudioPatch(const hidl_vec<AudioPortConfig>& sources,
                                      const hidl_vec<AudioPortConfig>& sinks,
                                      createAudioPatch_cb _hidl_cb) {
    Result retval(Result::NOT_SUPPORTED);
    AudioPatchHandle patch = 0;
    if (version() >= AUDIO_DEVICE_API_VERSION_3_0) {
        std::unique_ptr<audio_port_config[]> halSources(HidlUtils::audioPortConfigsToHal(sources));
        std::unique_ptr<audio_port_config[]> halSinks(HidlUtils::audioPortConfigsToHal(sinks));
        std::unique_ptr<audio_port_config[]> halSources(
            HidlUtils::audioPortConfigsToHal(sources));
        std::unique_ptr<audio_port_config[]> halSinks(
            HidlUtils::audioPortConfigsToHal(sinks));
        audio_patch_handle_t halPatch = AUDIO_PATCH_HANDLE_NONE;
        retval = analyzeStatus(
            "create_audio_patch",
                mDevice->create_audio_patch(
                        mDevice,
                        sources.size(), &halSources[0],
                        sinks.size(), &halSinks[0],
                        &halPatch));
            mDevice->create_audio_patch(mDevice, sources.size(), &halSources[0],
                                        sinks.size(), &halSinks[0], &halPatch));
        if (retval == Result::OK) {
            patch = static_cast<AudioPatchHandle>(halPatch);
        }
@@ -298,15 +302,18 @@ Return<Result> Device::releaseAudioPatch(int32_t patch) {
    if (version() >= AUDIO_DEVICE_API_VERSION_3_0) {
        return analyzeStatus(
            "release_audio_patch",
                mDevice->release_audio_patch(mDevice, static_cast<audio_patch_handle_t>(patch)));
            mDevice->release_audio_patch(
                mDevice, static_cast<audio_patch_handle_t>(patch)));
    }
    return Result::NOT_SUPPORTED;
}

Return<void> Device::getAudioPort(const AudioPort& port, getAudioPort_cb _hidl_cb)  {
Return<void> Device::getAudioPort(const AudioPort& port,
                                  getAudioPort_cb _hidl_cb) {
    audio_port halPort;
    HidlUtils::audioPortToHal(port, &halPort);
    Result retval = analyzeStatus("get_audio_port", mDevice->get_audio_port(mDevice, &halPort));
    Result retval = analyzeStatus("get_audio_port",
                                  mDevice->get_audio_port(mDevice, &halPort));
    AudioPort resultPort = port;
    if (retval == Result::OK) {
        HidlUtils::audioPortFromHal(halPort, &resultPort);
@@ -320,7 +327,8 @@ Return<Result> Device::setAudioPortConfig(const AudioPortConfig& config) {
        struct audio_port_config halPortConfig;
        HidlUtils::audioPortConfigToHal(config, &halPortConfig);
        return analyzeStatus(
                "set_audio_port_config", mDevice->set_audio_port_config(mDevice, &halPortConfig));
            "set_audio_port_config",
            mDevice->set_audio_port_config(mDevice, &halPortConfig));
    }
    return Result::NOT_SUPPORTED;
}
@@ -335,12 +343,14 @@ Return<Result> Device::setScreenState(bool turnedOn) {
    return setParam(AudioParameter::keyScreenState, turnedOn);
}

Return<void> Device::getParameters(const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb)  {
Return<void> Device::getParameters(const hidl_vec<hidl_string>& keys,
                                   getParameters_cb _hidl_cb) {
    getParametersImpl(keys, _hidl_cb);
    return Void();
}

Return<Result> Device::setParameters(const hidl_vec<ParameterValue>& parameters)  {
Return<Result> Device::setParameters(
    const hidl_vec<ParameterValue>& parameters) {
    return setParametersImpl(parameters);
}

+13 −7
Original line number Diff line number Diff line
@@ -52,7 +52,9 @@ Result ParametersUtil::getParam(const char* name, String8* value) {

void ParametersUtil::getParametersImpl(
    const hidl_vec<hidl_string>& keys,
        std::function<void(Result retval, const hidl_vec<ParameterValue>& parameters)> cb)  {
    std::function<void(Result retval,
                       const hidl_vec<ParameterValue>& parameters)>
        cb) {
    AudioParameter halKeys;
    for (size_t i = 0; i < keys.size(); ++i) {
        halKeys.addKey(String8(keys[i].c_str()));
@@ -79,7 +81,8 @@ void ParametersUtil::getParametersImpl(
    cb(retval, result);
}

std::unique_ptr<AudioParameter> ParametersUtil::getParams(const AudioParameter& keys) {
std::unique_ptr<AudioParameter> ParametersUtil::getParams(
    const AudioParameter& keys) {
    String8 paramsAndValues;
    char* halValues = halGetParameters(keys.keysToString().string());
    if (halValues != NULL) {
@@ -93,7 +96,8 @@ std::unique_ptr<AudioParameter> ParametersUtil::getParams(const AudioParameter&

Result ParametersUtil::setParam(const char* name, bool value) {
    AudioParameter param;
    param.add(String8(name), String8(value ? AudioParameter::valueOn : AudioParameter::valueOff));
    param.add(String8(name), String8(value ? AudioParameter::valueOn
                                           : AudioParameter::valueOff));
    return setParams(param);
}

@@ -109,10 +113,12 @@ Result ParametersUtil::setParam(const char* name, const char* value) {
    return setParams(param);
}

Result ParametersUtil::setParametersImpl(const hidl_vec<ParameterValue>& parameters)  {
Result ParametersUtil::setParametersImpl(
    const hidl_vec<ParameterValue>& parameters) {
    AudioParameter params;
    for (size_t i = 0; i < parameters.size(); ++i) {
        params.add(String8(parameters[i].key.c_str()), String8(parameters[i].value.c_str()));
        params.add(String8(parameters[i].key.c_str()),
                   String8(parameters[i].value.c_str()));
    }
    return setParams(params);
}
+50 −50
Original line number Diff line number Diff line
@@ -58,13 +58,12 @@ Return<void> PrimaryDevice::getMasterMute(getMasterMute_cb _hidl_cb) {
    return mDevice->getMasterMute(_hidl_cb);
}

Return<void> PrimaryDevice::getInputBufferSize(
        const AudioConfig& config, getInputBufferSize_cb _hidl_cb)  {
Return<void> PrimaryDevice::getInputBufferSize(const AudioConfig& config,
                                               getInputBufferSize_cb _hidl_cb) {
    return mDevice->getInputBufferSize(config, _hidl_cb);
}

Return<void> PrimaryDevice::openOutputStream(
        int32_t ioHandle,
Return<void> PrimaryDevice::openOutputStream(int32_t ioHandle,
                                             const DeviceAddress& device,
                                             const AudioConfig& config,
                                             AudioOutputFlag flags,
@@ -73,13 +72,10 @@ Return<void> PrimaryDevice::openOutputStream(
}

Return<void> PrimaryDevice::openInputStream(
        int32_t ioHandle,
        const DeviceAddress& device,
        const AudioConfig& config,
        AudioInputFlag flags,
        AudioSource source,
        openInputStream_cb _hidl_cb)  {
    return mDevice->openInputStream(ioHandle, device, config, flags, source, _hidl_cb);
    int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config,
    AudioInputFlag flags, AudioSource source, openInputStream_cb _hidl_cb) {
    return mDevice->openInputStream(ioHandle, device, config, flags, source,
                                    _hidl_cb);
}

Return<bool> PrimaryDevice::supportsAudioPatches() {
@@ -88,8 +84,7 @@ Return<bool> PrimaryDevice::supportsAudioPatches() {

Return<void> PrimaryDevice::createAudioPatch(
    const hidl_vec<AudioPortConfig>& sources,
        const hidl_vec<AudioPortConfig>& sinks,
        createAudioPatch_cb _hidl_cb)  {
    const hidl_vec<AudioPortConfig>& sinks, createAudioPatch_cb _hidl_cb) {
    return mDevice->createAudioPatch(sources, sinks, _hidl_cb);
}

@@ -97,11 +92,13 @@ Return<Result> PrimaryDevice::releaseAudioPatch(int32_t patch) {
    return mDevice->releaseAudioPatch(patch);
}

Return<void> PrimaryDevice::getAudioPort(const AudioPort& port, getAudioPort_cb _hidl_cb)  {
Return<void> PrimaryDevice::getAudioPort(const AudioPort& port,
                                         getAudioPort_cb _hidl_cb) {
    return mDevice->getAudioPort(port, _hidl_cb);
}

Return<Result> PrimaryDevice::setAudioPortConfig(const AudioPortConfig& config)  {
Return<Result> PrimaryDevice::setAudioPortConfig(
    const AudioPortConfig& config) {
    return mDevice->setAudioPortConfig(config);
}

@@ -113,12 +110,13 @@ Return<Result> PrimaryDevice::setScreenState(bool turnedOn) {
    return mDevice->setScreenState(turnedOn);
}

Return<void> PrimaryDevice::getParameters(
        const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb)  {
Return<void> PrimaryDevice::getParameters(const hidl_vec<hidl_string>& keys,
                                          getParameters_cb _hidl_cb) {
    return mDevice->getParameters(keys, _hidl_cb);
}

Return<Result> PrimaryDevice::setParameters(const hidl_vec<ParameterValue>& parameters)  {
Return<Result> PrimaryDevice::setParameters(
    const hidl_vec<ParameterValue>& parameters) {
    return mDevice->setParameters(parameters);
}

@@ -126,7 +124,6 @@ Return<void> PrimaryDevice::debugDump(const hidl_handle& fd) {
    return mDevice->debugDump(fd);
}


// Methods from ::android::hardware::audio::V2_0::IPrimaryDevice follow.
Return<Result> PrimaryDevice::setVoiceVolume(float volume) {
    return mDevice->analyzeStatus(
@@ -136,11 +133,12 @@ Return<Result> PrimaryDevice::setVoiceVolume(float volume) {

Return<Result> PrimaryDevice::setMode(AudioMode mode) {
    return mDevice->analyzeStatus(
            "set_mode",
            mDevice->device()->set_mode(mDevice->device(), static_cast<audio_mode_t>(mode)));
        "set_mode", mDevice->device()->set_mode(
                        mDevice->device(), static_cast<audio_mode_t>(mode)));
}

Return<void> PrimaryDevice::getBtScoNrecEnabled(getBtScoNrecEnabled_cb _hidl_cb)  {
Return<void> PrimaryDevice::getBtScoNrecEnabled(
    getBtScoNrecEnabled_cb _hidl_cb) {
    bool enabled;
    Result retval = mDevice->getParam(AudioParameter::keyBtNrec, &enabled);
    _hidl_cb(retval, enabled);
@@ -151,7 +149,8 @@ Return<Result> PrimaryDevice::setBtScoNrecEnabled(bool enabled) {
    return mDevice->setParam(AudioParameter::keyBtNrec, enabled);
}

Return<void> PrimaryDevice::getBtScoWidebandEnabled(getBtScoWidebandEnabled_cb _hidl_cb)  {
Return<void> PrimaryDevice::getBtScoWidebandEnabled(
    getBtScoWidebandEnabled_cb _hidl_cb) {
    bool enabled;
    Result retval = mDevice->getParam(AUDIO_PARAMETER_KEY_BT_SCO_WB, &enabled);
    _hidl_cb(retval, enabled);
@@ -171,7 +170,8 @@ Return<void> PrimaryDevice::getTtyMode(getTtyMode_cb _hidl_cb) {
}

Return<Result> PrimaryDevice::setTtyMode(IPrimaryDevice::TtyMode mode) {
    return mDevice->setParam(AUDIO_PARAMETER_KEY_TTY_MODE, static_cast<int>(mode));
    return mDevice->setParam(AUDIO_PARAMETER_KEY_TTY_MODE,
                             static_cast<int>(mode));
}

Return<void> PrimaryDevice::getHacEnabled(getHacEnabled_cb _hidl_cb) {
+115 −102

File changed.

Preview size limit exceeded, changes collapsed.

+142 −128

File changed.

Preview size limit exceeded, changes collapsed.

Loading