Extract VALUE_OR_RETURN_STATUS to AidlConversion

This seems useful in various places.

Test: Compiles
Change-Id: Iab9b03f806b4c33da68df89437db5639680ce331
diff --git a/include/media/MicrophoneInfo.h b/include/media/MicrophoneInfo.h
index dd90a11..93f53d5 100644
--- a/include/media/MicrophoneInfo.h
+++ b/include/media/MicrophoneInfo.h
@@ -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 @@
     int32_t mDirectionality;
 };
 
-#undef VALUE_OR_RETURN_STATUS
-
 } // namespace media
 } // namespace android
 
diff --git a/media/libaudioclient/AudioEffect.cpp b/media/libaudioclient/AudioEffect.cpp
index e5a7029..ae899c0 100644
--- a/media/libaudioclient/AudioEffect.cpp
+++ b/media/libaudioclient/AudioEffect.cpp
@@ -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;
diff --git a/media/libaudioclient/AudioSystem.cpp b/media/libaudioclient/AudioSystem.cpp
index cfe5f3a..d163feb 100644
--- a/media/libaudioclient/AudioSystem.cpp
+++ b/media/libaudioclient/AudioSystem.cpp
@@ -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 @@
 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);
 
diff --git a/media/libaudioclient/include/media/AidlConversion.h b/media/libaudioclient/include/media/AidlConversion.h
index 78f9b83..0751736 100644
--- a/media/libaudioclient/include/media/AidlConversion.h
+++ b/media/libaudioclient/include/media/AidlConversion.h
@@ -62,6 +62,13 @@
 #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.
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index bba46c7..8b94f43 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -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
diff --git a/services/audiopolicy/service/AudioPolicyClientImpl.cpp b/services/audiopolicy/service/AudioPolicyClientImpl.cpp
index f7d570e..4876fe7 100644
--- a/services/audiopolicy/service/AudioPolicyClientImpl.cpp
+++ b/services/audiopolicy/service/AudioPolicyClientImpl.cpp
@@ -23,13 +23,6 @@
 
 #include "BinderProxy.h"
 
-#define VALUE_OR_RETURN_STATUS(exp)          \
-    ({                                       \
-        auto _tmp = (exp);                   \
-        if (!_tmp.ok()) return _tmp.error(); \
-        std::move(_tmp.value());             \
-    })
-
 namespace android {
 
 /* implementation of the client interface from the policy manager */