Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Merging latest changes in to CDep branch" #58

Merged
merged 45 commits into from
Feb 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
72247fd
Revert "AAudio now used on API 27 rather than 26"
dturner Feb 12, 2018
e206752
Revert "Do not use AAudio unless running on Android 8.1 or higher"
dturner Feb 12, 2018
f3f8102
Revert "Adding unit tests and testing script"
dturner Feb 12, 2018
097f3e9
Revert "Version bump from 0.9 to 0.10"
dturner Feb 12, 2018
ad337b9
Revert "More concise return strings for convertToText methods"
dturner Feb 12, 2018
70bfc12
Revert "Adding convertToText for AudioApi"
dturner Feb 12, 2018
9c2e8bf
Revert "Rename ApiIndex to AudioApi, move into Definitions.h"
dturner Feb 12, 2018
9b73d07
Revert "Initialize mStreamCallback to nullptr. Fixes #44."
dturner Feb 12, 2018
acc4271
Revert "Add convertToText(StreamState). Fixes #38"
dturner Feb 12, 2018
c7188a8
Revert "Move float scaling value into constant. Fixes #21"
dturner Feb 12, 2018
adee426
Revert "Add disconnected state"
dturner Feb 12, 2018
5d2e272
Revert "Input streams are live"
dturner Feb 12, 2018
14fdd2f
Revert "Oboe works with NDK r15"
dturner Feb 12, 2018
bf35a7e
Revert "Change Version from class to struct"
dturner Feb 12, 2018
d48e5f2
Revert "Use #defines for version numbers"
dturner Feb 12, 2018
517f612
Revert "Adding version information"
dturner Feb 12, 2018
f0bf6aa
Revert "Update the CMakeLists.txt complete example"
dturner Feb 12, 2018
7d578c4
Revert "oboe: make chanCountToChanMask non-virtual"
dturner Feb 12, 2018
7f05126
Revert "oboe: address review comments, better singleton"
dturner Feb 12, 2018
2dd7bfc
Revert "oboe: OPenSL ES opens moved into stream open"
dturner Feb 12, 2018
0282806
Revert "oboe: cleanup OpenSL ES input"
dturner Feb 12, 2018
fca82b5
Revert "oboe: implement input stream"
dturner Feb 12, 2018
1fcc25e
Revert "oboe: move OpenSL ES output code to its own class"
dturner Feb 12, 2018
48fac90
Revert "oboe: OpenSL ES refactor engine"
dturner Feb 12, 2018
5d69fc0
Revert "New diagrams for sharing modes"
dturner Feb 12, 2018
880012b
Revert "Minor text reordering to make it easier to diff"
dturner Feb 12, 2018
179c2ea
Revert "Updated text and added diagram on sharing modes"
dturner Feb 12, 2018
62013d8
Revert "Clearer instructions for adding Oboe to a project"
dturner Feb 12, 2018
aba9533
Revert "Oboe can be added to an existing project using CMake add_subd…
dturner Feb 12, 2018
f3e8b28
Revert "Changing std::make_unique to std::unique_ptr to avoid depende…
dturner Feb 12, 2018
05a54f5
Revert "Add TODO for convertToText method to return int value in string"
dturner Feb 12, 2018
82df4d7
Revert "Adding template method convertToText"
dturner Feb 12, 2018
caf9fb3
Revert "Revert to using raw pointer for setCallback"
dturner Feb 12, 2018
85a2cd1
Revert "member vairable alignment"
dturner Feb 12, 2018
91ea9a8
Revert "Minor edits to address comments"
dturner Feb 12, 2018
021d18e
Revert "Rename Stream to AudioStream"
dturner Feb 12, 2018
2ef3ed8
Revert "Use std::shared_ptr for callback object"
dturner Feb 12, 2018
7fcc0b8
Revert "Add default case to convert methods"
dturner Feb 12, 2018
b0417cd
Revert "More documentation fixes"
dturner Feb 12, 2018
4658dde
Revert "Documentation tidy up"
dturner Feb 12, 2018
dd615c4
Revert "Use oboe namespace"
dturner Feb 12, 2018
ea28de2
Revert "oboe: automatically stop and close a stream when disconnected"
dturner Feb 12, 2018
c6522d8
Revert "Update FifoBuffer.cpp"
dturner Feb 12, 2018
56374c5
Revert "oboe callback: remove onExit()"
dturner Feb 12, 2018
f7a8c8a
Revert "oboe: fix dlsym for getFramesWritten/Read"
dturner Feb 12, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 6 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
cmake_minimum_required(VERSION 3.4.1)

set (oboe_sources
src/aaudio/AAudioLoader.cpp
src/aaudio/AudioStreamAAudio.cpp
src/common/LatencyTuner.cpp
src/common/AudioStream.cpp
src/common/AudioStreamBuilder.cpp
src/common/Utilities.cpp
src/fifo/FifoBuffer.cpp
src/fifo/FifoController.cpp
src/fifo/FifoControllerBase.cpp
src/fifo/FifoControllerIndirect.cpp
src/opensles/AudioInputStreamOpenSLES.cpp
src/opensles/AudioOutputStreamOpenSLES.cpp
src/opensles/AudioStreamBuffered.cpp
src/opensles/AudioStreamOpenSLES.cpp
src/opensles/EngineOpenSLES.cpp
src/opensles/OpenSLESUtilities.cpp
src/opensles/OutputMixerOpenSLES.cpp
)

add_library(oboe STATIC ${oboe_sources})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -std=c++11")

# Specify directories which the compiler should look for headers
target_include_directories(oboe PRIVATE src include)
include_directories(
include
src)

target_compile_options(oboe PRIVATE -std=c++11
PRIVATE -Wall
PRIVATE "$<$<CONFIG:DEBUG>:-Werror>") # Only include -Werror when building debug config
file(GLOB_RECURSE oboe_sources src/*)

target_link_libraries(oboe PRIVATE log OpenSLES)
add_library(oboe STATIC ${oboe_sources})
135 changes: 68 additions & 67 deletions FullGuide.md

Large diffs are not rendered by default.

85 changes: 37 additions & 48 deletions GettingStarted.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,42 @@
# Getting Started
The easiest way to start using Oboe is to build it from source by adding a few steps to an existing Android Studio project.

## Adding Oboe to your project

### 1. Clone the github repository
## Building Oboe
Start by cloning the Oboe repository:

git clone https://github.com/google/oboe

**Make a note of the path which you cloned oboe into - you will need it shortly**

### 2. Update CMakeLists.txt
Open your app's `CMakeLists.txt`. This can be found under `External Build Files` in the Android project view.
Open your app's `CMakeLists.txt`, this can be found under `External Build Files` in the Android project view.

![CMakeLists.txt location in Android Studio](cmakelists-location-in-as.png "CMakeLists.txt location in Android Studio")

Now add the following commands to the end of `CMakeLists.txt`. **Remember to update `**PATH TO OBOE**` with your local Oboe path from the previous step**:

# Set the path to the Oboe directory.
set (OBOE_DIR ***PATH TO OBOE***)

# Add the Oboe library as a subdirectory in your project.
add_subdirectory (${OBOE_DIR} ./oboe)

# Specify the path to the Oboe header files.
include_directories (${OBOE_DIR}/include)
Now add the following build steps to `CMakeLists.txt`, making sure you update `/local/path/to/oboe` with your local Oboe repository directory:

# Build the Oboe library
set (OBOE_DIR /local/path/to/oboe)
file (GLOB_RECURSE OBOE_SOURCES ${OBOE_DIR}/src/*)
include_directories(${OBOE_DIR}/include ${OBOE_DIR}/src)
add_library(oboe STATIC ${OBOE_SOURCES})

In the same file find the [`target_link_libraries`](https://cmake.org/cmake/help/latest/command/target_link_libraries.html) command.
Add `oboe` to the list of libraries which your app's library depends on. For example:
In the same file *after* your own library definition (by default it is named `native-lib`) add the dependencies for the Oboe and OpenSLES libraries:

target_link_libraries(native-lib oboe)
target_link_libraries(native-lib log oboe OpenSLES)

Here's a complete example `CMakeLists.txt` file:

cmake_minimum_required(VERSION 3.4.1)

# Build the Oboe library
set (OBOE_DIR /Users/donturner/Code/workspace-android/oboe)
file (GLOB_RECURSE OBOE_SOURCES ${OBOE_DIR}/src/*)
include_directories(${OBOE_DIR}/include ${OBOE_DIR}/src)
add_library(oboe STATIC ${OBOE_SOURCES})

# Build our own native library
add_library (native-lib SHARED src/main/cpp/native-lib.cpp )
add_library( native-lib SHARED src/main/cpp/native-lib.cpp )

# Specify the libraries which our native library is dependent on, including Oboe
target_link_libraries (native-lib log oboe)

# Build the Oboe library
set (OBOE_DIR ../../../oboe)
add_subdirectory (${OBOE_DIR} ./oboe)

# Make the Oboe public headers available to our app
include_directories (${OBOE_DIR}/include)
# Specify the libraries which our native library is dependent on
target_link_libraries( native-lib log oboe OpenSLES )

Verify that your project builds correctly. If you have any issues building please [report them here](issues/new).

Expand All @@ -59,24 +48,24 @@ Include the Oboe header:

#include <oboe/Oboe.h>

Streams are built using an `AudioStreamBuilder`. Create one like this:
Streams are built using an `OboeStreamBuilder`. Create one like this:

oboe::AudioStreamBuilder builder;
OboeStreamBuilder builder;

Use the builder's set methods to set properties on the stream (you can read more about these properties in the [full guide](FullGuide.md)):

builder.setDirection(oboe::Direction::Output);
builder.setPerformanceMode(oboe::PerformanceMode::LowLatency);
builder.setSharingMode(oboe::SharingMode::Exclusive);
builder.setDirection(OBOE_DIRECTION_OUTPUT);
builder.setPerformanceMode(OBOE_PERFORMANCE_MODE_LOW_LATENCY);
builder.setSharingMode(OBOE_SHARING_MODE_EXCLUSIVE);

Define an `AudioStreamCallback` class to receive callbacks whenever the stream requires new data.
Define an `OboeStreamCallback` class to receive callbacks whenever the stream requires new data.

class MyCallback : public oboe::AudioStreamCallback {
class MyCallback : public OboeStreamCallback {
public:
oboe::Result
onAudioReady(oboe::AudioStream *audioStream, void *audioData, int32_t numFrames){
oboe_data_callback_result_t
onAudioReady(OboeStream *audioStream, void *audioData, int32_t numFrames){
generateSineWave(static_cast<float *>(audioData), numFrames);
return oboe::DataCallbackResult::Continue;
return OBOE_CALLBACK_RESULT_CONTINUE;
}
};

Expand All @@ -87,21 +76,21 @@ Supply this callback class to the builder:

Open the stream:

oboe::AudioStream *stream;
oboe::Result result = builder.openStream(&stream);
OboeStream *stream;
oboe_result_t result = builder.openStream(&stream);

Check the result to make sure the stream was opened successfully. Oboe has a convenience method for converting its types into human-readable strings called `oboe::convertToText`:
Check the result to make sure the stream was opened successfully. Oboe has many convenience methods for converting its types into human-readable strings, they all start with `Oboe_convert`:

if (result != Result::OK){
LOGE("Failed to create stream. Error: %s", oboe::convertToText(result));
if (result != OBOE_OK){
LOGE("Failed to create stream. Error: %s", Oboe_convertResultToText(result));
}

Note that this sample code uses the [logging macros from here](https://github.com/googlesamples/android-audio-high-performance/blob/master/debug-utils/logging_macros.h).

Check the properties of the created stream. The **format** is one property which you should check. The default is `float` on API 21+ and `int16_t` on API 20 or lower. This will dictate the `audioData` type in the `AudioStreamCallback::onAudioReady` callback.
Check the properties of the created stream. The **format** is one property which you should check. The default is `float` on API 21+ and `int16_t` on API 20 or lower. This will dictate the `audioData` type in the `OboeStreamCallback::onAudioReady` callback.

oboe::AudioFormat format = stream->getFormat();
LOGI("AudioStream format is %s", oboe::convertToText(format));
oboe_audio_format_t format = stream->getFormat();
LOGI("Stream format is %s", Oboe_convertAudioFormatToText(format));

Now start the stream.

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@

Oboe is a C++ library which makes it easy to build high-performance audio apps on Android. It was created primarily to allow developers to target a simplified API that works across multiple API levels back to API level 16 (Jelly Bean).

**Note:** This version (0.9) of Oboe only supports playback (output) streams. Support for recording (input) streams is in active development.

[Get started with Oboe here](GettingStarted.md).

## Features
- Compatible with API 16 onwards - runs on 99% of Android devices
- Chooses the audio API (OpenSL ES on API 16+ or AAudio on API 27+) which will give the best audio performance on the target Android device
- Chooses the audio API (OpenSL ES on API 16+ or AAudio on API 26+) which will give the best audio performance on the target Android device
- Automatic latency tuning
- Modern C++ allowing you to write clean, elegant code

## Requirements
To build Oboe you will need the [Android NDK](https://developer.android.com/ndk/index.html) r15 or above
To build Oboe you will need the [Android NDK](https://developer.android.com/ndk/index.html) r16 or above

## Documentation
- [Getting Started Guide](GettingStarted.md)
Expand Down
4 changes: 2 additions & 2 deletions build_all_android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ build_oboe x86_64 21
printf "%s\r\n" "example: |" >> ${CDEP_MANIFEST_FILE}
printf "%s\r\n" " #include <oboe/Oboe.h>" >> ${CDEP_MANIFEST_FILE}
printf "%s\r\n" " void openStream() {" >> ${CDEP_MANIFEST_FILE}
printf "%s\r\n" " AudioStreamBuilder builder;" >> ${CDEP_MANIFEST_FILE}
printf "%s\r\n" " AudioStream *stream;" >> ${CDEP_MANIFEST_FILE}
printf "%s\r\n" " OboeStreamBuilder builder;" >> ${CDEP_MANIFEST_FILE}
printf "%s\r\n" " OboeStream *stream;" >> ${CDEP_MANIFEST_FILE}
printf "%s\r\n" " builder.openStream(&stream);" >> ${CDEP_MANIFEST_FILE}
printf "%s\r\n" " }" >> ${CDEP_MANIFEST_FILE}

Expand Down
69 changes: 0 additions & 69 deletions include/oboe/AudioStreamCallback.h

This file was deleted.

Loading