Skip to content

Commit

Permalink
internal/oboe: update to v1.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Feb 14, 2024
1 parent a9a798c commit e7caffb
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 12 deletions.
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.8.0"
const oboeVersion = "1.8.1"

func main() {
if err := run(); err != nil {
Expand Down
8 changes: 7 additions & 1 deletion internal/oboe/oboe_common_AudioStreamBuilder_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ bool AudioStreamBuilder::isCompatible(AudioStreamBase &other) {
}

Result AudioStreamBuilder::openStream(AudioStream **streamPP) {
LOGW("Passing AudioStream pointer deprecated, Use openStream(std::shared_ptr<oboe::AudioStream> &stream) instead.");
return openStreamInternal(streamPP);
}

Result AudioStreamBuilder::openStreamInternal(AudioStream **streamPP) {
auto result = isValidConfig();
if (result != Result::OK) {
LOGW("%s() invalid config %d", __func__, result);
Expand Down Expand Up @@ -202,6 +207,7 @@ Result AudioStreamBuilder::openStream(AudioStream **streamPP) {
}

Result AudioStreamBuilder::openManagedStream(oboe::ManagedStream &stream) {
LOGW("`openManagedStream` is deprecated. Use openStream(std::shared_ptr<oboe::AudioStream> &stream) instead.");
stream.reset();
AudioStream *streamptr;
auto result = openStream(&streamptr);
Expand All @@ -212,7 +218,7 @@ Result AudioStreamBuilder::openManagedStream(oboe::ManagedStream &stream) {
Result AudioStreamBuilder::openStream(std::shared_ptr<AudioStream> &sharedStream) {
sharedStream.reset();
AudioStream *streamptr;
auto result = openStream(&streamptr);
auto result = openStreamInternal(&streamptr);
if (result == Result::OK) {
sharedStream.reset(streamptr);
// Save a weak_ptr in the stream for use with callbacks.
Expand Down
15 changes: 15 additions & 0 deletions internal/oboe/oboe_flowgraph_FlowgraphUtilities_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifndef FLOWGRAPH_UTILITIES_H
#define FLOWGRAPH_UTILITIES_H

#include <math.h>
#include <unistd.h>

using namespace FLOWGRAPH_OUTER_NAMESPACE::flowgraph;
Expand Down Expand Up @@ -50,6 +51,20 @@ static int32_t clamp32FromFloat(float f)
return f > 0 ? f + 0.5 : f - 0.5;
}

/**
* Convert a single-precision floating point value to a Q0.23 integer value, stored in a
* 32 bit signed integer (technically stored as Q8.23, but clamped to Q0.23).
*
* Values outside the range [-1.0, 1.0) are properly clamped to -8388608 and 8388607,
* including -Inf and +Inf. NaN values are considered undefined, and behavior may change
* depending on hardware and future implementation of this function.
*/
static int32_t clamp24FromFloat(float f)
{
static const float scale = 1 << 23;
return (int32_t) lroundf(fmaxf(fminf(f * scale, scale - 1.f), -scale));
}

};

#endif // FLOWGRAPH_UTILITIES_H
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void MultiChannelResampler::writeFrame(const float *frame) {
}

float MultiChannelResampler::sinc(float radians) {
if (abs(radians) < 1.0e-9) return 1.0f; // avoid divide by zero
if (fabsf(radians) < 1.0e-9f) return 1.0f; // avoid divide by zero
return sinf(radians) / radians; // Sinc function
}

Expand Down
8 changes: 8 additions & 0 deletions internal/oboe/oboe_oboe_AudioStreamBuilder_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,14 @@ class AudioStreamBuilder : public AudioStreamBase {

private:

/**
* Use this internally to implement opening with a shared_ptr.
*
* @param stream pointer to a variable to receive the stream address
* @return OBOE_OK if successful or a negative error code.
*/
Result openStreamInternal(AudioStream **streamPP);

/**
* @param other
* @return true if channels, format and sample rate match
Expand Down
3 changes: 2 additions & 1 deletion internal/oboe/oboe_oboe_AudioStreamCallback_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class AudioStreamDataCallback {
* write() on the stream that is making the callback.
*
* Note that numFrames can vary unless AudioStreamBuilder::setFramesPerCallback()
* is called.
* is called. If AudioStreamBuilder::setFramesPerCallback() is NOT called then
* numFrames should always be <= AudioStream::getFramesPerBurst().
*
* Also note that this callback function should be considered a "real-time" function.
* It must not do anything that could cause an unbounded delay because that can cause the
Expand Down
7 changes: 7 additions & 0 deletions internal/oboe/oboe_oboe_AudioStream_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ class AudioStream : public AudioStreamBase {
*
* This cannot be set higher than getBufferCapacity().
*
* This should only be used with Output streams. It will
* be ignored for Input streams because they are generally kept as empty as possible.
*
* For OpenSL ES, this method only has an effect on output stream that do NOT
* use a callback. The blocking writes goes into a buffer in Oboe and the size of that
* buffer is controlled by this method.
*
* @param requestedFrames requested number of frames that can be filled without blocking
* @return the resulting buffer size in frames (obtained using value()) or an error (obtained
* using error())
Expand Down
2 changes: 1 addition & 1 deletion internal/oboe/oboe_oboe_Version_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#define OBOE_VERSION_MINOR 8

// Type: 16-bit unsigned int. Min value: 0 Max value: 65535. See below for description.
#define OBOE_VERSION_PATCH 0
#define OBOE_VERSION_PATCH 1

#define OBOE_STRINGIFY(x) #x
#define OBOE_TOSTRING(x) OBOE_STRINGIFY(x)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
using namespace oboe;

static SLuint32 OpenSLES_convertOutputUsage(Usage oboeUsage) {
SLuint32 openslStream = SL_ANDROID_STREAM_MEDIA;
SLuint32 openslStream;
switch(oboeUsage) {
case Usage::Media:
case Usage::Game:
openslStream = SL_ANDROID_STREAM_MEDIA;
break;
case Usage::VoiceCommunication:
Expand All @@ -43,18 +44,15 @@ static SLuint32 OpenSLES_convertOutputUsage(Usage oboeUsage) {
openslStream = SL_ANDROID_STREAM_ALARM;
break;
case Usage::Notification:
case Usage::NotificationRingtone:
case Usage::NotificationEvent:
openslStream = SL_ANDROID_STREAM_NOTIFICATION;
break;
case Usage::NotificationRingtone:
openslStream = SL_ANDROID_STREAM_RING;
break;
case Usage::AssistanceAccessibility:
case Usage::AssistanceNavigationGuidance:
case Usage::AssistanceSonification:
openslStream = SL_ANDROID_STREAM_SYSTEM;
break;
case Usage::Game:
openslStream = SL_ANDROID_STREAM_MEDIA;
break;
case Usage::Assistant:
default:
openslStream = SL_ANDROID_STREAM_SYSTEM;
Expand Down

0 comments on commit e7caffb

Please sign in to comment.