OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 // Helper class for using SLObjectItf interfaces. | 22 // Helper class for using SLObjectItf interfaces. |
23 template <typename SLType, typename SLDerefType> | 23 template <typename SLType, typename SLDerefType> |
24 class ScopedSLObject { | 24 class ScopedSLObject { |
25 public: | 25 public: |
26 ScopedSLObject() : obj_(nullptr) {} | 26 ScopedSLObject() : obj_(nullptr) {} |
27 | 27 |
28 ~ScopedSLObject() { Reset(); } | 28 ~ScopedSLObject() { Reset(); } |
29 | 29 |
30 SLType* Receive() { | 30 SLType* Receive() { |
31 DCHECK(!obj_); | 31 RTC_DCHECK(!obj_); |
32 return &obj_; | 32 return &obj_; |
33 } | 33 } |
34 | 34 |
35 SLDerefType operator->() { return *obj_; } | 35 SLDerefType operator->() { return *obj_; } |
36 | 36 |
37 SLType Get() const { return obj_; } | 37 SLType Get() const { return obj_; } |
38 | 38 |
39 void Reset() { | 39 void Reset() { |
40 if (obj_) { | 40 if (obj_) { |
41 (*obj_)->Destroy(obj_); | 41 (*obj_)->Destroy(obj_); |
42 obj_ = nullptr; | 42 obj_ = nullptr; |
43 } | 43 } |
44 } | 44 } |
45 | 45 |
46 private: | 46 private: |
47 SLType obj_; | 47 SLType obj_; |
48 }; | 48 }; |
49 | 49 |
50 typedef ScopedSLObject<SLObjectItf, const SLObjectItf_*> ScopedSLObjectItf; | 50 typedef ScopedSLObject<SLObjectItf, const SLObjectItf_*> ScopedSLObjectItf; |
51 | 51 |
52 } // namespace webrtc_opensl | 52 } // namespace webrtc_opensl |
53 | 53 |
54 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_OPENSLES_COMMON_H_ | 54 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_OPENSLES_COMMON_H_ |
OLD | NEW |