Skip to content
This repository was archived by the owner on Oct 9, 2019. It is now read-only.

Commit 1ba1545

Browse files
committed
Initial commit of the hello-oboe sample
Change-Id: I3af2bc33b56608f18b6fbe1a912575ba71828b4d
1 parent e9316f6 commit 1ba1545

38 files changed

+1649
-21
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "oboe/hello-oboe/src/main/cpp/oboe"]
2+
path = oboe/hello-oboe/src/main/cpp/oboe
3+
url = sso://devrel/libraries/android/oboe
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Fri Mar 17 15:07:01 PDT 2017
1+
#Mon Oct 16 16:25:02 BST 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

audio-device/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ apply plugin: 'com.android.library'
22

33
android {
44
compileSdkVersion 26
5-
buildToolsVersion "26.0.0"
5+
buildToolsVersion '26.0.2'
66
defaultConfig {
7-
minSdkVersion 26
7+
minSdkVersion 16
88
targetSdkVersion 26
99
versionCode 1
1010
versionName "1.0"

audio-device/src/main/java/com/google/sample/audio_device/AudioDeviceListEntry.java

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18+
import android.annotation.TargetApi;
1819
import android.media.AudioDeviceInfo;
1920
import android.media.AudioManager;
2021

@@ -75,6 +76,7 @@ public int hashCode() {
7576
* GET_DEVICES_INPUTS.
7677
* @return A list of AudioDeviceListEntry objects
7778
*/
79+
@TargetApi(23)
7880
static List<AudioDeviceListEntry> createListFrom(AudioDeviceInfo[] devices, int directionType){
7981

8082
List<AudioDeviceListEntry> listEntries = new Vector<>();

audio-device/src/main/java/com/google/sample/audio_device/AudioDeviceSpinner.java

+29-17
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18+
import android.annotation.TargetApi;
1819
import android.content.Context;
1920
import android.content.res.Resources.Theme;
2021
import android.media.AudioDeviceCallback;
@@ -29,66 +30,77 @@ public class AudioDeviceSpinner extends Spinner {
2930

3031
private static final int AUTO_SELECT_DEVICE_ID = 0;
3132
private static final String TAG = AudioDeviceSpinner.class.getName();
32-
private int mDirectionType = AudioManager.GET_DEVICES_OUTPUTS;
33+
private int mDirectionType;
34+
private AudioDeviceAdapter mDeviceAdapter;
35+
private AudioManager mAudioManager;
3336

3437
public AudioDeviceSpinner(Context context){
3538
super(context);
39+
setup(context);
3640
}
3741

3842
public AudioDeviceSpinner(Context context, int mode){
3943
super(context, mode);
44+
setup(context);
4045
}
4146

4247
public AudioDeviceSpinner(Context context, AttributeSet attrs){
4348
super(context, attrs);
49+
setup(context);
4450
}
4551

4652
public AudioDeviceSpinner(Context context, AttributeSet attrs, int defStyleAttr){
4753
super(context, attrs, defStyleAttr);
54+
setup(context);
4855
}
4956

5057
public AudioDeviceSpinner(Context context, AttributeSet attrs, int defStyleAttr, int mode){
5158
super(context, attrs, defStyleAttr, mode);
59+
setup(context);
5260
}
5361

5462
public AudioDeviceSpinner(Context context, AttributeSet attrs, int defStyleAttr,
5563
int defStyleRes, int mode){
5664
super(context, attrs, defStyleAttr, defStyleRes, mode);
65+
setup(context);
5766
}
5867
public AudioDeviceSpinner(Context context, AttributeSet attrs, int defStyleAttr,
5968
int defStyleRes, int mode, Theme popupTheme){
6069
super(context, attrs, defStyleAttr, defStyleRes, mode, popupTheme);
70+
setup(context);
6171
}
6272

63-
public void setDirectionType(int directionType){
64-
this.mDirectionType = directionType;
65-
setupAdapter();
66-
}
73+
private void setup(Context context){
74+
mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
6775

68-
private void setupAdapter(){
69-
70-
Context context = getContext();
71-
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
72-
73-
final AudioDeviceAdapter deviceAdapter = new AudioDeviceAdapter(context);
74-
setAdapter(deviceAdapter);
76+
mDeviceAdapter = new AudioDeviceAdapter(context);
77+
setAdapter(mDeviceAdapter);
7578

7679
// Add a default entry to the list and select it
77-
deviceAdapter.add(new AudioDeviceListEntry(AUTO_SELECT_DEVICE_ID,
80+
mDeviceAdapter.add(new AudioDeviceListEntry(AUTO_SELECT_DEVICE_ID,
7881
context.getString(R.string.auto_select)));
7982
setSelection(0);
83+
}
84+
85+
@TargetApi(23)
86+
public void setDirectionType(int directionType){
87+
this.mDirectionType = directionType;
88+
setupAudioDeviceCallback();
89+
}
90+
91+
@TargetApi(23)
92+
private void setupAudioDeviceCallback(){
8093

81-
// Listen for changes
8294
// Note that we will immediately receive a call to onDevicesAdded with the list of
8395
// devices which are currently connected.
84-
audioManager.registerAudioDeviceCallback(new AudioDeviceCallback() {
96+
mAudioManager.registerAudioDeviceCallback(new AudioDeviceCallback() {
8597
@Override
8698
public void onAudioDevicesAdded(AudioDeviceInfo[] addedDevices) {
8799

88100
List<AudioDeviceListEntry> deviceList =
89101
AudioDeviceListEntry.createListFrom(addedDevices, mDirectionType);
90102
if (deviceList.size() > 0){
91-
deviceAdapter.addAll(deviceList);
103+
mDeviceAdapter.addAll(deviceList);
92104
}
93105
}
94106

@@ -97,7 +109,7 @@ public void onAudioDevicesRemoved(AudioDeviceInfo[] removedDevices) {
97109
List<AudioDeviceListEntry> deviceList =
98110
AudioDeviceListEntry.createListFrom(removedDevices, mDirectionType);
99111
for (AudioDeviceListEntry entry : deviceList){
100-
deviceAdapter.remove(entry);
112+
mDeviceAdapter.remove(entry);
101113
}
102114
}
103115
}, null);

oboe/README.md

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
Oboe Samples
2+
==============
3+
These samples demonstrate how to use the Oboe library:
4+
5+
1. hello-oboe: creates an output (playback) stream and plays a
6+
sine wave when you tap the screen
7+
8+
Pre-requisites
9+
-------------
10+
* Android device or emulator running API 16 (Jelly Bean) or above
11+
* [Android SDK 26](https://developer.android.com/about/versions/oreo/android-8.0-migration.html#ptb)
12+
* [NDK r16](https://developer.android.com/ndk/downloads/index.html) or above
13+
* [Android Studio 2.3.0+](https://developer.android.com/studio/index.html)
14+
15+
Getting Started
16+
---------------
17+
1. [Install Android Studio](https://developer.android.com/studio/index.html)
18+
1. Clone this sample repository
19+
1. Import the sample project into Android Studio
20+
- File -> New -> Import Project
21+
- Browse to oboe/build.gradle
22+
- Click "OK"
23+
1. Click Run -> Run, choose the sample you wish to run
24+
25+
Screenshots
26+
-----------
27+
![hello-oboe-screenshot](hello-oboe-screenshot.png)
28+
29+
Support
30+
-------
31+
If you've found an error in these samples, please [file an issue](https://github.com/googlesamples/android-audio-high-performance/issues/new).
32+
33+
Patches are encouraged, and may be submitted by [forking this project](https://github.com/googlesamples/android-audio-high-performance/fork) and
34+
submitting a pull request through GitHub. Please see [CONTRIBUTING.md](../CONTRIBUTING.md) for more details.
35+
36+
- [Stack Overflow](http://stackoverflow.com/questions/tagged/android-ndk)
37+
- [Google+ Community](https://plus.google.com/communities/105153134372062985968)
38+
- [Android Tools Feedback](http://tools.android.com/feedback)
39+
40+
41+
License
42+
-------
43+
Copyright 2017 Google, Inc.
44+
45+
Licensed to the Apache Software Foundation (ASF) under one or more contributor
46+
license agreements. See the NOTICE file distributed with this work for
47+
additional information regarding copyright ownership. The ASF licenses this
48+
file to you under the Apache License, Version 2.0 (the "License"); you may not
49+
use this file except in compliance with the License. You may obtain a copy of
50+
the License at
51+
52+
http://www.apache.org/licenses/LICENSE-2.0
53+
54+
Unless required by applicable law or agreed to in writing, software
55+
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
56+
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
57+
License for the specific language governing permissions and limitations under
58+
the License.
59+
60+
Version History
61+
---------------
62+
- 18th October 2017 - Initial version

oboe/TODO

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Oboe Samples TODO
2+
- Figure out a way of not duplicating the "common" module in both the aaudio and oboe samples.
3+
This can be done:
4+
https://stackoverflow.com/questions/17479076/android-studio-add-external-project-to-build-gradle
5+
- Buffer size selection isn't working - does it work in hello-aaudio?
6+
- Getting crash on Pixel 2 when changing playback device quickly, probably need to have a
7+
"restarting streams" state which blocks calls to change the device id

oboe/build.gradle

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2015 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
19+
20+
21+
22+
buildscript {
23+
repositories {
24+
jcenter()
25+
}
26+
dependencies {
27+
classpath 'com.android.tools.build:gradle:3.0.0-rc1'
28+
// NOTE: Do not place your application dependencies here; they belong
29+
// in the individual module build.gradle files
30+
}
31+
}
32+
33+
allprojects {
34+
repositories {
35+
jcenter()
36+
}
37+
}

oboe/gradle.properties

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# Copyright 2015 The Android Open Source Project
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
#
17+
18+
# Project-wide Gradle settings.
19+
20+
# IDE (e.g. Android Studio) users:
21+
# Gradle settings configured through the IDE *will override*
22+
# any settings specified in this file.
23+
24+
# For more details on how to configure your build environment visit
25+
# http://www.gradle.org/docs/current/userguide/build_environment.html
26+
27+
# Specifies the JVM arguments used for the daemon process.
28+
# The setting is particularly useful for tweaking memory settings.
29+
# Default value: -Xmx10248m -XX:MaxPermSize=256m
30+
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
31+
32+
# When configured, Gradle will run in incubating parallel mode.
33+
# This option should only be used with decoupled projects. More details, visit
34+
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
35+
# org.gradle.parallel=true
52.4 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Thu Oct 12 11:30:59 BST 2017
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

0 commit comments

Comments
 (0)