Skip to content

Commit d9934c7

Browse files
committed
fix Android: crashes after opus stream playback #365
1 parent 3e77c87 commit d9934c7

File tree

4 files changed

+53
-5
lines changed

4 files changed

+53
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11

2+
#### 3.4.3 (XX Xxx 2025)
3+
- fix Android: crashes after opus stream playback #365
4+
25
#### 3.4.2 (8 Nov 2025)
36
- fix Android: NO_OPUS_OGG_LIBS for Android build used in `gradle.properties` not always worked #358. And Thanks to @mingjunsiek #361 #354
47
- fix: memory leak in FlutterSoLoudFfi.addAudioDataStream #359. Thanks to @DarthRainbows

example/macos/Podfile.lock

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
PODS:
2+
- audio_session (0.0.1):
3+
- FlutterMacOS
4+
- file_picker (0.0.1):
5+
- FlutterMacOS
6+
- flutter_soloud (0.0.1):
7+
- FlutterMacOS
8+
- FlutterMacOS (1.0.0)
9+
- path_provider_foundation (0.0.1):
10+
- Flutter
11+
- FlutterMacOS
12+
13+
DEPENDENCIES:
14+
- audio_session (from `Flutter/ephemeral/.symlinks/plugins/audio_session/macos`)
15+
- file_picker (from `Flutter/ephemeral/.symlinks/plugins/file_picker/macos`)
16+
- flutter_soloud (from `Flutter/ephemeral/.symlinks/plugins/flutter_soloud/macos`)
17+
- FlutterMacOS (from `Flutter/ephemeral`)
18+
- path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`)
19+
20+
EXTERNAL SOURCES:
21+
audio_session:
22+
:path: Flutter/ephemeral/.symlinks/plugins/audio_session/macos
23+
file_picker:
24+
:path: Flutter/ephemeral/.symlinks/plugins/file_picker/macos
25+
flutter_soloud:
26+
:path: Flutter/ephemeral/.symlinks/plugins/flutter_soloud/macos
27+
FlutterMacOS:
28+
:path: Flutter/ephemeral
29+
path_provider_foundation:
30+
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin
31+
32+
SPEC CHECKSUMS:
33+
audio_session: eaca2512cf2b39212d724f35d11f46180ad3a33e
34+
file_picker: 7584aae6fa07a041af2b36a2655122d42f578c1a
35+
flutter_soloud: 93c20641a100d25bfbc84a8b86e867f350ef29ac
36+
FlutterMacOS: d0db08ddef1a9af05a5ec4b724367152bb0500b1
37+
path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564
38+
39+
PODFILE CHECKSUM: 5e895c4e74302f01a7051c77c78271c4826bc78a
40+
41+
COCOAPODS: 1.16.2

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: >-
33
A low-level audio plugin for Flutter,
44
mainly meant for games and immersive apps.
55
Based on the SoLoud (C++) audio engine.
6-
version: 3.4.2
6+
version: 3.4.3
77
homepage: https://github.com/alnitak/flutter_soloud
88
maintainer: Marco Bavagnoli (@lildeimos)
99
platforms:

src/audiobuffer/audiobuffer.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,14 @@ namespace SoLoud
7171

7272
unsigned int bufferSize = mParent->mBuffer.getFloatsBufferSize();
7373
float *buffer = reinterpret_cast<float *>(mParent->mBuffer.buffer.data());
74-
int samplesToRead = mOffset + aSamplesToRead > bufferSize ? bufferSize - mOffset : aSamplesToRead;
74+
int samplesToRead = aSamplesToRead;
75+
if (mOffset + (unsigned int)samplesToRead * mChannels > bufferSize)
76+
{
77+
samplesToRead = (bufferSize - mOffset) / mChannels;
78+
}
7579
if (samplesToRead <= 0)
7680
{
77-
memset(aBuffer, 0, sizeof(float) * aSamplesToRead);
81+
memset(aBuffer, 0, sizeof(float) * aSamplesToRead * mChannels);
7882
// Calculate mStreamPosition based on mOffset
7983
mStreamPosition = mOffset / (float)(mBaseSamplerate * mChannels);
8084

@@ -92,7 +96,7 @@ namespace SoLoud
9296

9397
if (samplesToRead != aSamplesToRead)
9498
{
95-
memset(aBuffer, 0, sizeof(float) * aSamplesToRead);
99+
memset(aBuffer, 0, sizeof(float) * aSamplesToRead * mChannels);
96100
}
97101

98102
if (mChannels == 1)
@@ -110,7 +114,7 @@ namespace SoLoud
110114
{
111115
for (i = 0; i < samplesToRead; i++)
112116
{
113-
aBuffer[j * samplesToRead + i] = buffer[mOffset + i * mChannels + j];
117+
aBuffer[j * aSamplesToRead + i] = buffer[mOffset + i * mChannels + j];
114118
}
115119
}
116120
}

0 commit comments

Comments
 (0)