Skip to content

Commit

Permalink
v1.6.1: Fixes Android support
Browse files Browse the repository at this point in the history
  • Loading branch information
birdofpreyru committed Aug 29, 2023
1 parent dc72e49 commit 536a053
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 12 deletions.
55 changes: 55 additions & 0 deletions android/src/main/java/com/drpogodin/reactnativeaudio/Errors.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.drpogodin.reactnativeaudio;

import android.util.Log;
import com.facebook.react.bridge.Promise;

public enum Errors {
NOT_IMPLEMENTED("Not implemented");

private String message;
public static final String LOGTAG = "RN_AUDIO";

Errors(String message) {
this.message = message;
}

public Error getError() {
return new Error(this.getMessage());
}

public Exception getException() {
return new Exception(this.getMessage());
}

public String getMessage() {
return this.message;
}

public Errors log() {
Log.e(Errors.LOGTAG, this.getMessage());
return this;
}

public Errors log(Exception e) {
Log.e(Errors.LOGTAG, e.toString());
return this.log();
}

public void reject(Promise promise) {
if (promise != null) {
promise.reject(this.toString(), this.getMessage(), this.getError());
}
}

public void reject(Promise promise, String details) {
if (promise != null) {
String message = this.getMessage();
if (details != null) message += ": " + details;
promise.reject(this.toString(), message, this.getError());
}
}

public String toString() {
return Errors.LOGTAG + ":" + this.name();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule;

import com.drpogodin.reactnativeaudio.Errors;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -155,6 +157,17 @@ public void muteInputStream(double streamId, boolean muted) {
inputStreams.get(streamId).muted = muted;
}

/**
* This method is currently used only for a sound playback test in
* the Example App, and this test for now is intended mostly for testing
* the audio session configuration on iOS, thus not yet implemented for
* Android.
*/
@ReactMethod
public void playTest() {
Errors.NOT_IMPLEMENTED.log();
}

/**
* Stops, and releases an input audio stream.
* @param streamId
Expand Down
3 changes: 2 additions & 1 deletion android/src/oldarch/ReactNativeAudioSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public Map<String,Object> getConstants() {
public abstract void getInputAvailable(Promise promise);

public abstract void listen(
double streamId,
double audioSource,
double sampleRate,
double channelConfig,
Expand All @@ -32,7 +33,7 @@ public abstract void listen(
);

public abstract void muteInputStream(double streamId, boolean muted);
public abstract void unlisten(double streamId);
public abstract void unlisten(double streamId, Promise promise);
public abstract void addListener(String eventName);
public abstract void removeListeners(double count);
}
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dr.pogodin/react-native-audio",
"version": "1.6.0",
"version": "1.6.1",
"description": "React Native: access to the audio input stream",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down Expand Up @@ -67,7 +67,7 @@
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.6.4",
"pod-install": "^0.1.39",
"prettier": "^3.0.2",
"prettier": "^3.0.3",
"react": "18.2.0",
"react-native": "0.72.4",
"react-native-builder-bob": "^0.21.3",
Expand Down

0 comments on commit 536a053

Please sign in to comment.