Adds "tts" permission for Input Tools & XKB extension.
[chromium-blink-merge.git] / media / audio / android / opensles_util.h
blobbc6d0410af9a7ba2b25b655f4d6f169e7274bdbd
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_AUDIO_ANDROID_OPENSLES_UTIL_H_
6 #define MEDIA_AUDIO_ANDROID_OPENSLES_UTIL_H_
8 #include <SLES/OpenSLES.h>
10 #include "base/logging.h"
12 namespace media {
14 template <typename SLType, typename SLDerefType>
15 class ScopedSLObject {
16 public:
17 ScopedSLObject() : obj_(NULL) {}
19 ~ScopedSLObject() { Reset(); }
21 SLType* Receive() {
22 DCHECK(!obj_);
23 return &obj_;
26 SLDerefType operator->() { return *obj_; }
28 SLType Get() const { return obj_; }
30 void Reset() {
31 if (obj_) {
32 (*obj_)->Destroy(obj_);
33 obj_ = NULL;
37 private:
38 SLType obj_;
41 typedef ScopedSLObject<SLObjectItf, const SLObjectItf_*> ScopedSLObjectItf;
43 } // namespace media
45 #endif // MEDIA_AUDIO_ANDROID_OPENSLES_UTIL_H_