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

Commit 1ff75699 authored by Ytai Ben-Tsvi's avatar Ytai Ben-Tsvi
Browse files

Extract VALUE_OR_RETURN_STATUS to AidlConversion

This seems useful in various places.

Test: Compiles
Change-Id: Iab9b03f806b4c33da68df89437db5639680ce331
parent 07892869
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -26,13 +26,6 @@
namespace android {
namespace media {

#define VALUE_OR_RETURN_STATUS(exp)          \
    ({                                       \
        auto _tmp = (exp);                   \
        if (!_tmp.ok()) return _tmp.error(); \
        std::move(_tmp.value());             \
    })

class MicrophoneInfo : public Parcelable {
public:
    MicrophoneInfo() = default;
@@ -215,8 +208,6 @@ private:
    int32_t mDirectionality;
};

#undef VALUE_OR_RETURN_STATUS

} // namespace media
} // namespace android

+0 −7
Original line number Diff line number Diff line
@@ -29,13 +29,6 @@
#include <private/media/AudioEffectShared.h>
#include <utils/Log.h>

#define VALUE_OR_RETURN_STATUS(exp)          \
    ({                                       \
        auto _tmp = (exp);                   \
        if (!_tmp.ok()) return _tmp.error(); \
        std::move(_tmp.value());             \
    })

namespace android {

using binder::Status;
+3 −3
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@

#include <system/audio.h>

#define VALUE_OR_RETURN_STATUS(x) \
#define VALUE_OR_RETURN_BINDER_STATUS(x) \
    ({ auto _tmp = (x); \
       if (!_tmp.ok()) return Status::fromStatusT(_tmp.error()); \
       std::move(_tmp.value()); })
@@ -532,10 +532,10 @@ void AudioSystem::AudioFlingerClient::binderDied(const wp<IBinder>& who __unused
Status AudioSystem::AudioFlingerClient::ioConfigChanged(
        media::AudioIoConfigEvent _event,
        const media::AudioIoDescriptor& _ioDesc) {
    audio_io_config_event event = VALUE_OR_RETURN_STATUS(
    audio_io_config_event event = VALUE_OR_RETURN_BINDER_STATUS(
            aidl2legacy_AudioIoConfigEvent_audio_io_config_event(_event));
    sp<AudioIoDescriptor> ioDesc(
            VALUE_OR_RETURN_STATUS(aidl2legacy_AudioIoDescriptor_AudioIoDescriptor(_ioDesc)));
            VALUE_OR_RETURN_BINDER_STATUS(aidl2legacy_AudioIoDescriptor_AudioIoDescriptor(_ioDesc)));

    ALOGV("ioConfigChanged() event %d", event);

+7 −0
Original line number Diff line number Diff line
@@ -62,6 +62,13 @@ using ConversionResult = base::expected<T, status_t>;
#define RETURN_IF_ERROR(result) \
    if (status_t _tmp = (result); _tmp != OK) return base::unexpected(_tmp);

#define VALUE_OR_RETURN_STATUS(x)           \
    ({                                      \
       auto _tmp = (x);                     \
       if (!_tmp.ok()) return _tmp.error(); \
       std::move(_tmp.value());             \
     })

/**
 * A generic template to safely cast between integral types, respecting limits of the destination
 * type.
+0 −5
Original line number Diff line number Diff line
@@ -91,11 +91,6 @@
       std::move(_tmp.value());                  \
     })

#define VALUE_OR_RETURN_STATUS(x)           \
    ({ auto _tmp = (x);                     \
       if (!_tmp.ok()) return _tmp.error(); \
       std::move(_tmp.value()); })

// ----------------------------------------------------------------------------

// Note: the following macro is used for extremely verbose logging message.  In
Loading