Skip to content

Commit

Permalink
upadte Oboe to 1.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Oct 15, 2023
1 parent 9ca1b3f commit af511fa
Show file tree
Hide file tree
Showing 40 changed files with 1,464 additions and 63 deletions.
2 changes: 1 addition & 1 deletion internal/oboe/README-oboe.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ Oboe is a C++ library which makes it easy to build high-performance audio apps o
- [Getting Started Guide](docs/GettingStarted.md)
- [Full Guide to Oboe](docs/FullGuide.md)
- [API reference](https://google.github.io/oboe)
- [Tech Notes](docs/notes/)
- [History of Audio features/bugs by Android version](docs/AndroidAudioHistory.md)
- [Migration guide for apps using OpenSL ES](docs/OpenSLESMigration.md)
- [Frequently Asked Questions](docs/FAQ.md) (FAQ)
- [Wiki](https://github.com/google/oboe/wiki)
- [Our roadmap](https://github.com/google/oboe/milestones) - Vote on a feature/issue by adding a thumbs up to the first comment.

### Community
Expand Down
2 changes: 1 addition & 1 deletion internal/oboe/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"strings"
)

const oboeVersion = "1.7.0"
const oboeVersion = "1.8.0"

func main() {
if err := run(); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion internal/oboe/oboe_aaudio_AAudioExtensions_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ typedef struct AAudioStreamStruct AAudioStream;
* Call some AAudio test routines that are not part of the normal API.
*/
class AAudioExtensions {
public:
private: // Because it is a singleton. Call getInstance() instead.
AAudioExtensions() {
int32_t policy = getIntegerProperty("aaudio.mmap_policy", 0);
mMMapSupported = isPolicyEnabled(policy);
Expand All @@ -50,6 +50,7 @@ class AAudioExtensions {
mMMapExclusiveSupported = isPolicyEnabled(policy);
}

public:
static bool isPolicyEnabled(int32_t policy) {
return (policy == AAUDIO_POLICY_AUTO || policy == AAUDIO_POLICY_ALWAYS);
}
Expand Down
62 changes: 59 additions & 3 deletions internal/oboe/oboe_aaudio_AAudioLoader_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,23 @@ int AAudioLoader::open() {
builder_setSessionId = load_V_PBI("AAudioStreamBuilder_setSessionId");
}

if (getSdkVersion() >= __ANDROID_API_Q__){
builder_setAllowedCapturePolicy = load_V_PBI("AAudioStreamBuilder_setAllowedCapturePolicy");
}

if (getSdkVersion() >= __ANDROID_API_R__){
builder_setPrivacySensitive = load_V_PBO("AAudioStreamBuilder_setPrivacySensitive");
}

if (getSdkVersion() >= __ANDROID_API_S__){
builder_setPackageName = load_V_PBCPH("AAudioStreamBuilder_setPackageName");
builder_setAttributionTag = load_V_PBCPH("AAudioStreamBuilder_setAttributionTag");
}

if (getSdkVersion() >= __ANDROID_API_S_V2__) {
builder_setChannelMask = load_V_PBU("AAudioStreamBuilder_setChannelMask");
builder_setIsContentSpatialized = load_V_PBO("AAudioStreamBuilder_setIsContentSpatialized");
builder_setSpatializationBehavior = load_V_PBI("AAudioStreamBuilder_setSpatializationBehavior");
}

builder_delete = load_I_PB("AAudioStreamBuilder_delete");
Expand All @@ -112,6 +122,10 @@ int AAudioLoader::open() {
stream_getChannelCount = load_I_PS("AAudioStream_getSamplesPerFrame");
}

if (getSdkVersion() >= __ANDROID_API_R__) {
stream_release = load_I_PS("AAudioStream_release");
}

stream_close = load_I_PS("AAudioStream_close");

stream_getBufferSize = load_I_PS("AAudioStream_getBufferSizeInFrames");
Expand Down Expand Up @@ -143,9 +157,26 @@ int AAudioLoader::open() {
stream_getSessionId = load_I_PS("AAudioStream_getSessionId");
}

if (getSdkVersion() >= __ANDROID_API_Q__){
stream_getAllowedCapturePolicy = load_I_PS("AAudioStream_getAllowedCapturePolicy");
}

if (getSdkVersion() >= __ANDROID_API_R__){
stream_isPrivacySensitive = load_O_PS("AAudioStream_isPrivacySensitive");
}

if (getSdkVersion() >= __ANDROID_API_S_V2__) {
stream_getChannelMask = load_U_PS("AAudioStream_getChannelMask");
stream_isContentSpatialized = load_O_PS("AAudioStream_isContentSpatialized");
stream_getSpatializationBehavior = load_I_PS("AAudioStream_getSpatializationBehavior");
}

if (getSdkVersion() >= __ANDROID_API_U__) {
stream_getHardwareChannelCount = load_I_PS("AAudioStream_getHardwareChannelCount");
stream_getHardwareSampleRate = load_I_PS("AAudioStream_getHardwareSampleRate");
stream_getHardwareFormat = load_F_PS("AAudioStream_getHardwareFormat");
}

return 0;
}

Expand Down Expand Up @@ -215,10 +246,10 @@ AAudioLoader::signature_F_PS AAudioLoader::load_F_PS(const char *functionName) {
return reinterpret_cast<signature_F_PS>(proc);
}

AAudioLoader::signature_B_PS AAudioLoader::load_B_PS(const char *functionName) {
AAudioLoader::signature_O_PS AAudioLoader::load_O_PS(const char *functionName) {
void *proc = dlsym(mLibHandle, functionName);
AAudioLoader_check(proc, functionName);
return reinterpret_cast<signature_B_PS>(proc);
return reinterpret_cast<signature_O_PS>(proc);
}

AAudioLoader::signature_I_PB AAudioLoader::load_I_PB(const char *functionName) {
Expand Down Expand Up @@ -269,6 +300,12 @@ AAudioLoader::signature_U_PS AAudioLoader::load_U_PS(const char *functionName) {
return reinterpret_cast<signature_U_PS>(proc);
}

AAudioLoader::signature_V_PBO AAudioLoader::load_V_PBO(const char *functionName) {
void *proc = dlsym(mLibHandle, functionName);
AAudioLoader_check(proc, functionName);
return reinterpret_cast<signature_V_PBO>(proc);
}

// Ensure that all AAudio primitive data types are int32_t
#define ASSERT_INT32(type) static_assert(std::is_same<int32_t, type>::value, \
#type" must be int32_t")
Expand Down Expand Up @@ -385,7 +422,20 @@ AAudioLoader::signature_U_PS AAudioLoader::load_U_PS(const char *functionName) {

#endif // __NDK_MAJOR__ >= 17

// The aaudio channel masks were added in NDK 24,
// aaudio_allowed_capture_policy_t was added in NDK 20,
// which is the first version to support Android Q (API 29).
#if __NDK_MAJOR__ >= 20

ASSERT_INT32(aaudio_allowed_capture_policy_t);

static_assert((int32_t)AllowedCapturePolicy::Unspecified == AAUDIO_UNSPECIFIED, ERRMSG);
static_assert((int32_t)AllowedCapturePolicy::All == AAUDIO_ALLOW_CAPTURE_BY_ALL, ERRMSG);
static_assert((int32_t)AllowedCapturePolicy::System == AAUDIO_ALLOW_CAPTURE_BY_SYSTEM, ERRMSG);
static_assert((int32_t)AllowedCapturePolicy::None == AAUDIO_ALLOW_CAPTURE_BY_NONE, ERRMSG);

#endif // __NDK_MAJOR__ >= 20

// The aaudio channel masks and spatialization behavior were added in NDK 24,
// which is the first version to support Android SC_V2 (API 32).
#if __NDK_MAJOR__ >= 24

Expand Down Expand Up @@ -443,6 +493,12 @@ AAudioLoader::signature_U_PS AAudioLoader::load_U_PS(const char *functionName) {
static_assert((uint32_t)ChannelMask::CM9Point1Point6 == AAUDIO_CHANNEL_9POINT1POINT6, ERRMSG);
static_assert((uint32_t)ChannelMask::FrontBack == AAUDIO_CHANNEL_FRONT_BACK, ERRMSG);

ASSERT_INT32(aaudio_spatialization_behavior_t);

static_assert((int32_t)SpatializationBehavior::Unspecified == AAUDIO_UNSPECIFIED, ERRMSG);
static_assert((int32_t)SpatializationBehavior::Auto == AAUDIO_SPATIALIZATION_BEHAVIOR_AUTO, ERRMSG);
static_assert((int32_t)SpatializationBehavior::Never == AAUDIO_SPATIALIZATION_BEHAVIOR_NEVER, ERRMSG);

#endif

#endif // AAUDIO_AAUDIO_H
Expand Down
40 changes: 38 additions & 2 deletions internal/oboe/oboe_aaudio_AAudioLoader_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ typedef int32_t aaudio_session_id_t;
#if __NDK_MAJOR__ < 24
// Defined in SC_V2
typedef uint32_t aaudio_channel_mask_t;
typedef int32_t aaudio_spatialization_behavior_t;
#endif

#ifndef __ANDROID_API_Q__
#define __ANDROID_API_Q__ 29
#endif

#ifndef __ANDROID_API_R__
#define __ANDROID_API_R__ 30
#endif

#ifndef __ANDROID_API_S__
Expand All @@ -79,6 +88,10 @@ typedef uint32_t aaudio_channel_mask_t;
#define __ANDROID_API_S_V2__ 32
#endif

#ifndef __ANDROID_API_U__
#define __ANDROID_API_U__ 34
#endif

namespace oboe {

/**
Expand All @@ -100,6 +113,8 @@ class AAudioLoader {
// C = Const prefix
// H = cHar
// U = uint32_t
// O = bOol

typedef int32_t (*signature_I_PPB)(AAudioStreamBuilder **builder);

typedef const char * (*signature_CPH_I)(int32_t);
Expand All @@ -116,6 +131,9 @@ class AAudioLoader {

typedef void (*signature_V_PBCPH)(AAudioStreamBuilder *, const char *);

// AAudioStreamBuilder_setPrivacySensitive
typedef void (*signature_V_PBO)(AAudioStreamBuilder *, bool);

typedef int32_t (*signature_I_PS)(AAudioStream *); // AAudioStream_getSampleRate()
typedef int64_t (*signature_L_PS)(AAudioStream *); // AAudioStream_getFramesRead()
// AAudioStream_setBufferSizeInFrames()
Expand All @@ -141,7 +159,7 @@ class AAudioLoader {

typedef int32_t (*signature_I_PSKPLPL)(AAudioStream *, clockid_t, int64_t *, int64_t *);

typedef bool (*signature_B_PS)(AAudioStream *);
typedef bool (*signature_O_PS)(AAudioStream *);

typedef uint32_t (*signature_U_PS)(AAudioStream *);

Expand Down Expand Up @@ -181,9 +199,15 @@ class AAudioLoader {
signature_V_PBI builder_setInputPreset = nullptr;
signature_V_PBI builder_setSessionId = nullptr;

signature_V_PBO builder_setPrivacySensitive = nullptr;
signature_V_PBI builder_setAllowedCapturePolicy = nullptr;

signature_V_PBCPH builder_setPackageName = nullptr;
signature_V_PBCPH builder_setAttributionTag = nullptr;

signature_V_PBO builder_setIsContentSpatialized = nullptr;
signature_V_PBI builder_setSpatializationBehavior = nullptr;

signature_V_PBPDPV builder_setDataCallback = nullptr;
signature_V_PBPEPV builder_setErrorCallback = nullptr;

Expand All @@ -198,6 +222,7 @@ class AAudioLoader {

signature_I_PSKPLPL stream_getTimestamp = nullptr;

signature_I_PS stream_release = nullptr;
signature_I_PS stream_close = nullptr;

signature_I_PS stream_getChannelCount = nullptr;
Expand Down Expand Up @@ -228,8 +253,18 @@ class AAudioLoader {
signature_I_PS stream_getInputPreset = nullptr;
signature_I_PS stream_getSessionId = nullptr;

signature_O_PS stream_isPrivacySensitive = nullptr;
signature_I_PS stream_getAllowedCapturePolicy = nullptr;

signature_U_PS stream_getChannelMask = nullptr;

signature_O_PS stream_isContentSpatialized = nullptr;
signature_I_PS stream_getSpatializationBehavior = nullptr;

signature_I_PS stream_getHardwareChannelCount = nullptr;
signature_I_PS stream_getHardwareSampleRate = nullptr;
signature_F_PS stream_getHardwareFormat = nullptr;

private:
AAudioLoader() {}
~AAudioLoader();
Expand All @@ -246,14 +281,15 @@ class AAudioLoader {
signature_I_PS load_I_PS(const char *name);
signature_L_PS load_L_PS(const char *name);
signature_F_PS load_F_PS(const char *name);
signature_B_PS load_B_PS(const char *name);
signature_O_PS load_O_PS(const char *name);
signature_I_PSI load_I_PSI(const char *name);
signature_I_PSPVIL load_I_PSPVIL(const char *name);
signature_I_PSCPVIL load_I_PSCPVIL(const char *name);
signature_I_PSTPTL load_I_PSTPTL(const char *name);
signature_I_PSKPLPL load_I_PSKPLPL(const char *name);
signature_V_PBU load_V_PBU(const char *name);
signature_U_PS load_U_PS(const char *name);
signature_V_PBO load_V_PBO(const char *name);

void *mLibHandle = nullptr;
};
Expand Down
Loading

0 comments on commit af511fa

Please sign in to comment.