Skip to content

Commit 57e596c

Browse files
committed
Fix to record/stream audio when the screen is off or the app is in the background
1 parent 31ccc9e commit 57e596c

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

app/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ android {
2626
applicationId = "io.opentakserver.opentakicu"
2727
minSdk = 26
2828
targetSdk = 34
29-
//versionCode = 1
30-
//versionName = "1.4.5.1"
3129

3230
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
3331
}

app/src/main/java/io/opentakserver/opentakicu/Camera2Service.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public void onCreate() {
257257

258258
int type = 0;
259259
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
260-
type = ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA;
260+
type = ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE|ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA;
261261
}
262262

263263
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) {
@@ -588,13 +588,13 @@ public void onSensorChanged(SensorEvent sensorEvent) {
588588
}
589589

590590
if (hasGravityData && hasGeomagneticData) {
591-
float identityMatrix[] = new float[9];
592-
float rotationMatrix[] = new float[9];
591+
float[] identityMatrix = new float[9];
592+
float[] rotationMatrix = new float[9];
593593
boolean success = SensorManager.getRotationMatrix(rotationMatrix, identityMatrix,
594594
gravityData, geomagneticData);
595595

596596
if (success) {
597-
float orientationMatrix[] = new float[3];
597+
float[] orientationMatrix = new float[3];
598598
SensorManager.getOrientation(rotationMatrix, orientationMatrix);
599599
float rotationInRadians = orientationMatrix[0];
600600
rotationInDegrees = Math.toDegrees(rotationInRadians);

app/src/main/java/io/opentakserver/opentakicu/contants/Preferences.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class Preferences {
6969
public static final String AUDIO_SAMPLE_RATE = "samplerate";
7070
public static final String AUDIO_SAMPLE_RATE_DEFAULT = "44100";
7171
public static final String AUDIO_CODEC = "audio_codec";
72-
public static final String AUDIO_CODEC_DEFAULT = AudioCodec.OPUS.name();
72+
public static final String AUDIO_CODEC_DEFAULT = AudioCodec.AAC.name();
7373
public static final String STEREO_AUDIO = "stereo";
7474
public static final boolean STEREO_AUDIO_DEFAULT = true;
7575
public static final String AUDIO_ECHO_CANCEL = "echo_cancel";

app/src/main/java/io/opentakserver/opentakicu/preferences/AudioPreferencesFragment.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ private void setAudioCodecs() {
7979
} else if (protocol.equals("srt") || protocol.equals("udp")){
8080
codecs.add(AudioCodec.OPUS.name());
8181
codecs.add(AudioCodec.AAC.name());
82+
} else {
83+
codecs.add(AudioCodec.OPUS.name());
84+
codecs.add(AudioCodec.AAC.name());
85+
codecs.add(AudioCodec.G711.name());
8286
}
8387

8488
codec.setEntries(codecs.toArray(new CharSequence[codecs.size()]));

0 commit comments

Comments
 (0)