stagefright: fix prvalue handling in Mutexed

returning prvalue does not make sense as object will be immediately
destructed. Instead create a move constructor for Locked.

Bug: 27901970
Change-Id: I4013804b1a4af4b5ecb6ab5347d44cfd3b2898ba
diff --git a/include/media/stagefright/foundation/Mutexed.h b/include/media/stagefright/foundation/Mutexed.h
index e905d86..143b140 100644
--- a/include/media/stagefright/foundation/Mutexed.h
+++ b/include/media/stagefright/foundation/Mutexed.h
@@ -103,6 +103,10 @@
     class Locked {
     public:
         inline Locked(Mutexed<T> &mParent);
+        inline Locked(Locked &&from) :
+            mLock(from.mLock),
+            mTreasure(from.mTreasure),
+            mLocked(from.mLocked) {}
         inline ~Locked();
 
         // dereference the protected structure. This returns nullptr if the
@@ -148,9 +152,9 @@
     // Lock the mutex, and create an accessor-guard (a Locked object) to access the underlying
     // structure. This returns an object that dereferences to the wrapped structure when the mutex
     // is locked by it, or otherwise to "null".
-    inline Locked&& lock() {
-        // use rvalue as Locked has no copy constructor
-        return std::move(Locked(*this));
+    // This is just a shorthand for Locked() constructor to avoid specifying the template type.
+    inline Locked lock() {
+        return Locked(*this);
     }
 
 private:
@@ -169,7 +173,6 @@
       mTreasure(mParent.mTreasure),
       mLocked(true) {
     mLock.lock();
-
 }
 
 template<typename T>