Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a4857ed62 | |||
| 962d814318 | |||
| 9276a92c83 | |||
| d16896c4b4 |
@@ -79,8 +79,8 @@ android {
|
||||
applicationId "com.ariacockpit"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 808
|
||||
versionName "0.0.8.8"
|
||||
versionCode 900
|
||||
versionName "0.0.9.0"
|
||||
// Fallback fuer Libraries mit Product Flavors
|
||||
missingDimensionStrategy 'react-native-camera', 'general'
|
||||
}
|
||||
|
||||
@@ -79,11 +79,11 @@ class PcmStreamPlayerModule(reactContext: ReactApplicationContext) : ReactContex
|
||||
val minBuf = AudioTrack.getMinBufferSize(sampleRate, channelConfig, encoding)
|
||||
val bytesPerSecond = sampleRate * channels * 2 // 16-bit = 2 bytes
|
||||
val prerollTarget = (bytesPerSecond * prerollSec).toInt()
|
||||
// Buffer entkoppelt von Preroll — fester ~2s-Buffer reicht. Wenn er
|
||||
// an Preroll gekoppelt ist (z.B. 7s bei preroll=3.5s) und nur kurz
|
||||
// gefuettert wird, stallt AudioTrack auf manchen Geraeten (OnePlus
|
||||
// Android 12: pos bleibt 0 obwohl play() lief).
|
||||
val bufferSize = (bytesPerSecond * 2).coerceAtLeast(minBuf * 8)
|
||||
// Buffer entkoppelt von Preroll — fester ~4s-Buffer. OnePlus A12
|
||||
// mit USAGE_ASSISTANT laeuft AudioTrack erst ab ~3s gepufferter
|
||||
// Daten an. Wir padden Kurztexte vor play() auf 3s (siehe Block
|
||||
// nach mainLoop), Buffer braucht ~1s Headroom weil write() blockt.
|
||||
val bufferSize = (bytesPerSecond * 4).coerceAtLeast(minBuf * 8)
|
||||
prerollBytes = prerollTarget
|
||||
bytesBuffered = 0
|
||||
playbackStarted = false
|
||||
@@ -159,16 +159,11 @@ class PcmStreamPlayerModule(reactContext: ReactApplicationContext) : ReactContex
|
||||
val data = queue.poll(50, java.util.concurrent.TimeUnit.MILLISECONDS)
|
||||
if (data == null) {
|
||||
if (endRequested) {
|
||||
// Falls wir vor Pre-Roll enden (kurzer Text): trotzdem abspielen
|
||||
if (!playbackStarted) {
|
||||
try {
|
||||
t.play()
|
||||
playbackStarted = true
|
||||
Log.i(TAG, "Playback gestartet VOR Pre-Roll (kurzer Text, ${bytesBuffered}B gepuffert)")
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "play() fallback failed: ${e.message}")
|
||||
}
|
||||
}
|
||||
// Bei kurzem Text NICHT hier play() callen — erst nach
|
||||
// Trailing-Silence + Padding (siehe Block nach mainLoop),
|
||||
// damit AudioTrack mit komplett gefuelltem Buffer startet.
|
||||
// OnePlus A12: AudioTrack startet nicht zuverlaessig wenn
|
||||
// play() bei dünnem Buffer gerufen wird.
|
||||
break@mainLoop
|
||||
}
|
||||
// Underrun-Schutz: Stille reinfuettern wenn der AudioTrack-
|
||||
@@ -231,6 +226,31 @@ class PcmStreamPlayerModule(reactContext: ReactApplicationContext) : ReactContex
|
||||
}
|
||||
bytesBuffered += silence.size
|
||||
}
|
||||
// Bei kurzem Text (play() noch nicht gestartet): Buffer auf min.
|
||||
// 3s padden + DANN play(). Auf OnePlus A12 startet AudioTrack
|
||||
// bei < 3s Buffer-Inhalt nicht — pos bleibt auf 0 stehen.
|
||||
// (2s war zu wenig, 8 Worte ~2.5s gingen, 3 Worte ~1s nicht.)
|
||||
if (!playbackStarted && !writerShouldStop) {
|
||||
val minStartBytes = bytesPerSecond * 3
|
||||
if (bytesBuffered < minStartBytes) {
|
||||
val padBytes = (minStartBytes - bytesBuffered.toInt()) and 0x7FFFFFFE
|
||||
val pad = ByteArray(padBytes)
|
||||
var padOff = 0
|
||||
while (padOff < pad.size && !writerShouldStop) {
|
||||
val w = t.write(pad, padOff, pad.size - padOff)
|
||||
if (w <= 0) break
|
||||
padOff += w
|
||||
}
|
||||
bytesBuffered += pad.size
|
||||
}
|
||||
try {
|
||||
t.play()
|
||||
playbackStarted = true
|
||||
Log.i(TAG, "Playback gestartet (kurzer Text, ${bytesBuffered}B komplett gepuffert)")
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "play() short-text failed: ${e.message}")
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Writer-Thread Fehler: ${e.message}")
|
||||
} finally {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "aria-cockpit",
|
||||
"version": "0.0.8.8",
|
||||
"version": "0.0.9.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"android": "react-native run-android",
|
||||
|
||||
Reference in New Issue
Block a user