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"
14 template <typename SLType
, typename SLDerefType
>
15 class ScopedSLObject
{
17 ScopedSLObject() : obj_(NULL
) {}
19 ~ScopedSLObject() { Reset(); }
26 SLDerefType
operator->() { return *obj_
; }
28 SLType
Get() const { return obj_
; }
32 (*obj_
)->Destroy(obj_
);
41 typedef ScopedSLObject
<SLObjectItf
, const SLObjectItf_
*> ScopedSLObjectItf
;
45 #endif // MEDIA_AUDIO_ANDROID_OPENSLES_UTIL_H_