Move dead submodules in-tree

Signed-off-by: swurl <swurl@swurl.xyz>
This commit is contained in:
swurl 2025-05-31 02:33:02 -04:00
parent c0cceff365
commit 6c655321e6
Signed by: crueter
GPG key ID: A5A7629F109C8FD1
4081 changed files with 1185566 additions and 45 deletions

View file

@ -0,0 +1,53 @@
#
# Copyright 2022 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
cmake_minimum_required(VERSION 3.4.1)
# Set the path to the Oboe library directory
set (OBOE_DIR ../../../../../)
#message("OBOE_DIR = " + ${OBOE_DIR})
add_subdirectory(${OBOE_DIR} ./oboe-bin)
# include folders
include_directories(
${OBOE_DIR}/include
${CMAKE_CURRENT_LIST_DIR}
)
# App specific sources
set (APP_SOURCES
SimpleNoiseMaker.cpp
MinimalOboeJNI.cpp
)
# Build the minimaloboe (native) library
add_library(minimaloboe SHARED
${APP_SOURCES}
)
# Enable optimization flags: if having problems with source level debugging,
# disable -Ofast ( and debug ), re-enable after done debugging.
target_compile_options(minimaloboe PRIVATE -Wall -Werror "$<$<CONFIG:RELEASE>:-Ofast>")
target_link_libraries( # Specifies the target library.
minimaloboe
oboe
# Links the target library to the log library
# included in the NDK.
log)
target_link_options(minimaloboe PRIVATE "-Wl,-z,max-page-size=16384")

View file

@ -0,0 +1,66 @@
/*
* Copyright 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <jni.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
static const char *TAG = "MinimalOboeJNI";
#include <android/log.h>
#include <SimpleNoiseMaker.h>
// JNI functions are "C" calling convention
#ifdef __cplusplus
extern "C" {
#endif
using namespace oboe;
// Use a static object so we don't have to worry about it getting deleted at the wrong time.
static SimpleNoiseMaker sPlayer;
/**
* Native (JNI) implementation of AudioPlayer.startAudiostreamNative()
*/
JNIEXPORT jint JNICALL Java_com_example_minimaloboe_AudioPlayer_startAudioStreamNative(
JNIEnv * /* env */, jobject) {
__android_log_print(ANDROID_LOG_INFO, TAG, "%s", __func__);
Result result = sPlayer.open();
if (result == Result::OK) {
result = sPlayer.start();
}
return (jint) result;
}
/**
* Native (JNI) implementation of AudioPlayer.stopAudioStreamNative()
*/
JNIEXPORT jint JNICALL Java_com_example_minimaloboe_AudioPlayer_stopAudioStreamNative(
JNIEnv * /* env */, jobject) {
__android_log_print(ANDROID_LOG_INFO, TAG, "%s", __func__);
// We need to close() even if the stop() fails because we need to delete the resources.
Result result1 = sPlayer.stop();
Result result2 = sPlayer.close();
// Return first failure code.
return (jint) ((result1 != Result::OK) ? result1 : result2);
}
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,92 @@
/*
* Copyright 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdlib.h>
static const char *TAG = "SimpleNoiseMaker";
#include <android/log.h>
#include <SimpleNoiseMaker.h>
using namespace oboe;
oboe::Result SimpleNoiseMaker::open() {
// Use shared_ptr to prevent use of a deleted callback.
mDataCallback = std::make_shared<MyDataCallback>();
mErrorCallback = std::make_shared<MyErrorCallback>(this);
AudioStreamBuilder builder;
oboe::Result result = builder.setSharingMode(oboe::SharingMode::Exclusive)
->setPerformanceMode(oboe::PerformanceMode::LowLatency)
->setFormat(oboe::AudioFormat::Float)
->setChannelCount(kChannelCount)
->setDataCallback(mDataCallback)
->setErrorCallback(mErrorCallback)
// Open using a shared_ptr.
->openStream(mStream);
return result;
}
oboe::Result SimpleNoiseMaker::start() {
return mStream->requestStart();
}
oboe::Result SimpleNoiseMaker::stop() {
return mStream->requestStop();
}
oboe::Result SimpleNoiseMaker::close() {
return mStream->close();
}
/**
* This callback method will be called from a high priority audio thread.
* It should only do math and not do any blocking operations like
* reading or writing files, memory allocation, or networking.
* @param audioStream
* @param audioData pointer to an array of samples to be filled
* @param numFrames number of frames needed
* @return
*/
DataCallbackResult SimpleNoiseMaker::MyDataCallback::onAudioReady(
AudioStream *audioStream,
void *audioData,
int32_t numFrames) {
// We requested float when we built the stream.
float *output = (float *) audioData;
// Fill buffer with random numbers to create "white noise".
int numSamples = numFrames * kChannelCount;
for (int i = 0; i < numSamples; i++) {
// drand48() returns a random number between 0.0 and 1.0.
// Center and scale it to a reasonable value.
*output++ = (float) ((drand48() - 0.5) * 0.6);
}
return oboe::DataCallbackResult::Continue;
}
void SimpleNoiseMaker::MyErrorCallback::onErrorAfterClose(oboe::AudioStream *oboeStream,
oboe::Result error) {
__android_log_print(ANDROID_LOG_INFO, TAG,
"%s() - error = %s",
__func__,
oboe::convertToText(error)
);
// Try to open and start a new stream after a disconnect.
if (mParent->open() == Result::OK) {
mParent->start();
}
}

View file

@ -0,0 +1,71 @@
/*
* Copyright 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SIMPLE_NOISE_MAKER_H
#define SIMPLE_NOISE_MAKER_H
#include "oboe/Oboe.h"
/**
* Play white noise using Oboe.
*/
class SimpleNoiseMaker {
public:
/**
* Open an Oboe stream.
* @return OK or negative error code.
*/
oboe::Result open();
oboe::Result start();
oboe::Result stop();
oboe::Result close();
private:
class MyDataCallback : public oboe::AudioStreamDataCallback {
public:
oboe::DataCallbackResult onAudioReady(
oboe::AudioStream *audioStream,
void *audioData,
int32_t numFrames) override;
};
class MyErrorCallback : public oboe::AudioStreamErrorCallback {
public:
MyErrorCallback(SimpleNoiseMaker *parent) : mParent(parent) {}
virtual ~MyErrorCallback() {
}
void onErrorAfterClose(oboe::AudioStream *oboeStream, oboe::Result error) override;
private:
SimpleNoiseMaker *mParent;
};
std::shared_ptr<oboe::AudioStream> mStream;
std::shared_ptr<MyDataCallback> mDataCallback;
std::shared_ptr<MyErrorCallback> mErrorCallback;
static constexpr int kChannelCount = 2;
};
#endif //SIMPLE_NOISE_MAKER_H