Skip to content

Fix build on iOS, build with 16K align on Android, seek for released BufferStream #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#### 3.2.3 (3 Aug 2025)
- fix 16 KB native library alignment on Android #248
- fix build issue on iOS and macOS #265 #266
- fix: the `seek` method was causing inconsistent behavior when using `BufferStream` in `BufferingType.released` mode. It is now supported in `BufferingType.preserved` mode.

#### 3.2.2 (16 Jul 2025)
- OGG is now also supported using `readSamplesFrom*` methods.
- fix getPosition and bufferirg for released buffer.
- fix getPosition and buffering for released buffer.

#### 3.2.1 (28 Jun 2025)
- fix #104, #245, #249. It is now possible to use a 3rd party plugin like `audio_session` to manage audio context.
Expand Down
6 changes: 2 additions & 4 deletions android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,10 @@ else()
add_definitions(-DNO_OPUS_OGG_LIBS)
endif()

# target_compile_definitions(flutter_soloud PUBLIC DART_SHARED_LIB)

# Support Android 15 16k page size
# target_link_options(flutter_soloud PRIVATE "-Wl,-z,max-page-size=16384")
target_link_options("${PLUGIN_NAME}" PRIVATE "-Wl,-z,max-page-size=16384")

target_compile_options("${PLUGIN_NAME}" PRIVATE -z max-page-size=16384 -Wall -Wno-error -fPIC -O3) # -ldl -lpthread -lm
target_compile_options("${PLUGIN_NAME}" PRIVATE -Wall -Wno-error -fPIC -O3) # -ldl -lpthread -lm

# List of absolute paths to libraries that should be bundled with the plugin.
set(flutter_soloud_bundled_libraries
Expand Down
2 changes: 2 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,7 @@
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>NSAppleMusicUsageDescription</key>
<string>Explain why your app uses music</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions example/macos/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
audio_session: eaca2512cf2b39212d724f35d11f46180ad3a33e
file_picker: 7584aae6fa07a041af2b36a2655122d42f578c1a
flutter_soloud: 83e9cb3d6ac8e636f6280b0ce4deda5d66e0fb02
flutter_soloud: 3edb2bae1e4f6312002cde60080f80c608ea57a3
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564

PODFILE CHECKSUM: 5e895c4e74302f01a7051c77c78271c4826bc78a
PODFILE CHECKSUM: cb21593040aa62e3ddedef3470f5f0e3c088e0c9

COCOAPODS: 1.16.2
2 changes: 2 additions & 0 deletions example/macos/Runner/DebugProfile.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
</dict>
</plist>
6 changes: 3 additions & 3 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ packages:
dependency: "direct main"
description:
name: file_picker
sha256: ab13ae8ef5580a411c458d6207b6774a6c237d77ac37011b13994879f68a8810
sha256: ef9908739bdd9c476353d6adff72e88fd00c625f5b959ae23f7567bd5137db0a
url: "https://pub.dev"
source: hosted
version: "8.3.7"
version: "10.2.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -116,7 +116,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.2.1"
version: "3.2.2"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:

cupertino_icons: ^1.0.8

file_picker: ^8.1.2
file_picker: ^10.2.0

flutter:
sdk: flutter
Expand Down
7 changes: 6 additions & 1 deletion lib/src/enums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ enum PlayerErrors {
maxActiveVoiceCountReached(26),

/// Trying to get time consumed from wrong buffer type.
wrongBufferTypeToAskForTimeConsumed(27);
wrongBufferTypeToAskForTimeConsumed(27),

/// BufferStream with released buffer type cannot be seeked!
bufferStreamWithReleasedBufferTypeCannotBeSeeked(28);

const PlayerErrors(this.value);

Expand Down Expand Up @@ -178,6 +181,8 @@ enum PlayerErrors {
case PlayerErrors.wrongBufferTypeToAskForTimeConsumed:
return 'Trying to get time consumed from wrong buffer type. '
'This is only available for `BufferingType.preserved` buffers.';
case PlayerErrors.bufferStreamWithReleasedBufferTypeCannotBeSeeked:
return 'BufferStream with released buffer type cannot be seeked.';
}
}

Expand Down
3 changes: 3 additions & 0 deletions lib/src/exceptions/exceptions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ abstract class SoLoudCppException extends SoLoudException {
);
case PlayerErrors.wrongBufferTypeToAskForTimeConsumed:
return const SoLoudWrongBufferTypeToAskForTimeConsumedCppException();
case PlayerErrors.bufferStreamWithReleasedBufferTypeCannotBeSeeked:
// ignore: lines_longer_than_80_chars
return const SoLoudBufferStreamWithReleasedBufferTypeCannotBeSeekedCppException();
}
}

Expand Down
14 changes: 14 additions & 0 deletions lib/src/exceptions/exceptions_from_cpp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,17 @@ class SoLoudWrongBufferTypeToAskForTimeConsumedCppException
'for time consumed. Please use a buffer of type '
'`BufferingType.released`. (on the C++ side).';
}

/// The buffer stream with released buffer type cannot be seeked.
class SoLoudBufferStreamWithReleasedBufferTypeCannotBeSeekedCppException
extends SoLoudCppException {
/// Creates a new
/// [SoLoudBufferStreamWithReleasedBufferTypeCannotBeSeekedCppException].
const SoLoudBufferStreamWithReleasedBufferTypeCannotBeSeekedCppException([
super.message,
]);

@override
String get description => 'The buffer stream with released buffer type '
'cannot be seeked. (on the C++ side).';
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: >-
A low-level audio plugin for Flutter,
mainly meant for games and immersive apps.
Based on the SoLoud (C++) audio engine.
version: 3.2.2
version: 3.2.3
homepage: https://github.com/alnitak/flutter_soloud
maintainer: Marco Bavagnoli (@lildeimos)
platforms:
Expand Down
2 changes: 2 additions & 0 deletions src/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ typedef enum PlayerErrors
maxActiveVoiceCountReached = 26,
/// Trying to get time consumed from wrong buffer type.
wrongBufferTypeToAskForTimeConsumed = 27,
/// Buffer stream with released buffer type, cannot be seeked.
bufferStreamWithReleasedBufferTypeCannotBeSeeked = 28
} PlayerErrors_t;

/// Possible read sample errors
Expand Down
14 changes: 14 additions & 0 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ const std::string Player::getErrorString(PlayerErrors errorCode) const
return "error: failed to decode Opus packet!";
case bufferStreamCanBePlayedOnlyOnce:
return "error: buffer stream can be played only once!";
case maxActiveVoiceCountReached:
return "error: the maximum number of active voices has been reached!";
case wrongBufferTypeToAskForTimeConsumed:
return "error: trying to get time consumed from wrong buffer type!";
case bufferStreamWithReleasedBufferTypeCannotBeSeeked:
return "error: buffer stream with released buffer type cannot be seeked!";
}
return "Other error";
}
Expand Down Expand Up @@ -784,6 +790,14 @@ PlayerErrors Player::seek(SoLoud::handle handle, float time)
return backendNotInited;

ActiveSound *sound = findByHandle(handle);

// A BufferStream using `release` buffer type cannot use seek.
if (sound->soundType == SoundType::TYPE_BUFFER_STREAM &&
static_cast<SoLoud::BufferStream *>(sound->sound.get())->getBufferingType() == BufferingType::RELEASED)
{
return bufferStreamWithReleasedBufferTypeCannotBeSeeked;
}

bool isGroupHandle = soloud.isVoiceGroup(handle);
if ((sound == nullptr || sound->soundType == TYPE_SYNTH) && !isGroupHandle)
return invalidParameter;
Expand Down
6 changes: 5 additions & 1 deletion src/waveform/miniaudio_libvorbis.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if !defined(NO_OPUS_OGG_LIBS)

#ifndef miniaudio_libvorbis_c
#define miniaudio_libvorbis_c

Expand Down Expand Up @@ -737,4 +739,6 @@ ma_decoding_backend_vtable* ma_decoding_backend_libvorbis = &ma_gDecodingBackend
ma_decoding_backend_vtable* ma_decoding_backend_libvorbis = NULL;
#endif

#endif /* miniaudio_libvorbis_c */
#endif /* miniaudio_libvorbis_c */

#endif /* !defined(MA_NO_LIBVORBIS) */