Index: media/audio/android/opensles_util.h |
diff --git a/media/audio/android/opensles_util.h b/media/audio/android/opensles_util.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..53b544f99ded1d547390fa20c2260b787cea7854 |
--- /dev/null |
+++ b/media/audio/android/opensles_util.h |
@@ -0,0 +1,44 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef MEDIA_AUDIO_OPENSLES_UTIL_H_ |
qinmin
2012/04/02 13:28:54
missing ANDROID
no longer working on chromium
2012/04/02 15:17:38
Sorry, I missed this in the previous set.
Done no
|
+#define MEDIA_AUDIO_OPENSLES_UTIL_H_ |
qinmin
2012/04/02 13:28:54
this too
no longer working on chromium
2012/04/02 15:17:38
Done.
|
+ |
+#include "base/logging.h" |
+#include <SLES/OpenSLES.h> |
+ |
+namespace media { |
+ |
+template <typename SLType, typename SLDerefType> |
+class ScopedSLObject { |
+ public: |
+ ScopedSLObject() : obj_(NULL) {} |
+ |
+ ~ScopedSLObject() { Reset(); } |
+ |
+ SLType* Receive() { |
+ DCHECK(!obj_); |
+ return &obj_; |
+ } |
+ |
+ SLDerefType operator->() { return *obj_; } |
+ |
+ SLType Get() const { return obj_; } |
+ |
+ void Reset() { |
+ if (obj_) { |
+ (*obj_)->Destroy(obj_); |
+ obj_ = NULL; |
+ } |
+ } |
+ |
+ private: |
+ SLType obj_; |
+}; |
+ |
+typedef ScopedSLObject<SLObjectItf, const SLObjectItf_*> ScopedSLObjectItf; |
+ |
+} // namespace media |
+ |
+#endif // MEDIA_AUDIO_OPENSLES_UTIL_H_ |
qinmin
2012/04/02 13:28:54
same here
no longer working on chromium
2012/04/02 15:17:38
Done.
|