1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
media / audio / android / opensles_util.h [blame]
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_AUDIO_ANDROID_OPENSLES_UTIL_H_
#define MEDIA_AUDIO_ANDROID_OPENSLES_UTIL_H_
#include <SLES/OpenSLES.h>
#include "base/check.h"
#include "media/base/media_export.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;
// Guesses the channel mask for a given channel count. Android does not offer a
// way to configure the layout, so this will be incorrect for less common
// channel layouts.
MEDIA_EXPORT SLuint32 ChannelCountToSLESChannelMask(int channel_count);
} // namespace media
#endif // MEDIA_AUDIO_ANDROID_OPENSLES_UTIL_H_