Skip to content

Commit

Permalink
Merge pull request #82 from alnitak/dev
Browse files Browse the repository at this point in the history
fix: Init error on hot restart #81
  • Loading branch information
alnitak authored May 6, 2024
2 parents d84f466 + 4b6d0c6 commit bd77bb1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 2.0.1 (6 May 2024)
- Fix init error on hot restart.

### 2.0.0 (5 Apr 2024)
- A giant leap forward from the previous version (many thanks to Filip Hráček).
- Major changes to API. There are quick fixes (`dart fix`) to automatically rename many changed APIs.
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.0.0-pre.4"
version: "2.0.1"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down
13 changes: 13 additions & 0 deletions lib/src/soloud.dart
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,19 @@ interface class SoLoud {
return;
}

// if `!_isInitialized` but the engine is initialized in native, therefore
// the developer may have carried out a hot reload which does not imply
// the release of the native player.
// Just deinit the engine to be re-inited later.
if (SoLoudController().soLoudFFI.isInited()) {
_log.warning('init() called when the native player is already '
'initialized. This is expected after a hot restart but not '
"otherwise. If you see this in production logs, there's probably "
'a bug in your code. You may have neglected to deinit() SoLoud '
'during the current lifetime of the app.');
deinit();
}

if (_initializeCompleter != null) {
_log.severe('initialize() called while already initializing. '
'Avoid this by checking the `initialized` Future before '
Expand Down
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: 2.0.0
version: 2.0.1
issue_tracker: https://github.com/alnitak/flutter_soloud/issues
homepage: https://github.com/alnitak/flutter_soloud
maintainer: Marco Bavagnoli (@lildeimos)
Expand Down

0 comments on commit bd77bb1

Please sign in to comment.