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 |
11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_OPENSLES_COMMON_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_OPENSLES_COMMON_H_ |
12 #define WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_OPENSLES_COMMON_H_ | 12 #define WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_OPENSLES_COMMON_H_ |
13 | 13 |
| 14 #include <stddef.h> |
14 #include <SLES/OpenSLES.h> | 15 #include <SLES/OpenSLES.h> |
15 | 16 |
16 #include "webrtc/base/checks.h" | |
17 | |
18 namespace webrtc { | 17 namespace webrtc { |
19 | 18 |
20 // Returns a string representation given an integer SL_RESULT_XXX code. | 19 // Returns a string representation given an integer SL_RESULT_XXX code. |
21 // The mapping can be found in <SLES/OpenSLES.h>. | 20 // The mapping can be found in <SLES/OpenSLES.h>. |
22 const char* GetSLErrorString(size_t code); | 21 const char* GetSLErrorString(size_t code); |
23 | 22 |
24 SLDataFormat_PCM CreatePcmConfiguration(int sample_rate); | 23 // Configures an SL_DATAFORMAT_PCM structure based on native audio parameters. |
| 24 SLDataFormat_PCM CreatePCMConfiguration(size_t channels, |
| 25 int sample_rate, |
| 26 size_t bits_per_sample); |
25 | 27 |
26 // Helper class for using SLObjectItf interfaces. | 28 // Helper class for using SLObjectItf interfaces. |
27 template <typename SLType, typename SLDerefType> | 29 template <typename SLType, typename SLDerefType> |
28 class ScopedSLObject { | 30 class ScopedSLObject { |
29 public: | 31 public: |
30 ScopedSLObject() : obj_(nullptr) {} | 32 ScopedSLObject() : obj_(nullptr) {} |
31 | 33 |
32 ~ScopedSLObject() { Reset(); } | 34 ~ScopedSLObject() { Reset(); } |
33 | 35 |
34 SLType* Receive() { | 36 SLType* Receive() { |
(...skipping 11 matching lines...) Expand all Loading... |
46 obj_ = nullptr; | 48 obj_ = nullptr; |
47 } | 49 } |
48 } | 50 } |
49 | 51 |
50 private: | 52 private: |
51 SLType obj_; | 53 SLType obj_; |
52 }; | 54 }; |
53 | 55 |
54 typedef ScopedSLObject<SLObjectItf, const SLObjectItf_*> ScopedSLObjectItf; | 56 typedef ScopedSLObject<SLObjectItf, const SLObjectItf_*> ScopedSLObjectItf; |
55 | 57 |
56 } // namespace webrtc_opensl | 58 } // namespace webrtc |
57 | 59 |
58 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_OPENSLES_COMMON_H_ | 60 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_OPENSLES_COMMON_H_ |
OLD | NEW |