Skip to content

Commit

Permalink
some review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alnitak committed Jul 9, 2024
1 parent a34835b commit c284151
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ images/
lib/flutter_soloud_FFIGEN.dart

web/build
web/worker.dart.js.deps
web/worker.dart.js.map

**/android/caches
**/android/.tmp
Expand Down
2 changes: 1 addition & 1 deletion lib/src/bindings/audio_data.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter_soloud/src/bindings/audio_data_extensions.dart';
import 'package:flutter_soloud/src/bindings/audio_data_ffi.dart'
if (dart.library.html) 'audio_data_web.dart';
if (dart.library.js_interop) 'audio_data_web.dart';
import 'package:flutter_soloud/src/bindings/soloud_controller.dart';
import 'package:flutter_soloud/src/exceptions/exceptions.dart';
import 'package:meta/meta.dart';
Expand Down
3 changes: 3 additions & 0 deletions lib/src/bindings/audio_data_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ class AudioDataCtrl {
SoLoudController().captureFFI.getCaptureAudioTexture;

void allocSamples() {
/// This is the max amount of memory [_samplePtr] may need. This number
/// is needed when acquiring data with [getTexture] which is a matrix of
/// 256 rows and 512 columns of floats (4 bytes each).
_samplesPtr = wasmMalloc(512 * 256 * 4);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/bindings/bindings_capture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:flutter_soloud/src/enums.dart';
import 'package:meta/meta.dart';

export 'package:flutter_soloud/src/bindings/bindings_capture_ffi.dart'
if (dart.library.html) 'package:flutter_soloud/src/bindings/bindings_capture_web.dart';
if (dart.library.js_interop) 'package:flutter_soloud/src/bindings/bindings_capture_web.dart';

/// The experimenta functionality to use the microphone used by "SoLoudCapture".
@experimental
Expand Down
2 changes: 1 addition & 1 deletion lib/src/bindings/bindings_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:flutter_soloud/src/sound_hash.dart';
import 'package:meta/meta.dart';

export 'package:flutter_soloud/src/bindings/bindings_player_ffi.dart'
if (dart.library.html) 'package:flutter_soloud/src/bindings/bindings_player_web.dart';
if (dart.library.js_interop) 'package:flutter_soloud/src/bindings/bindings_player_web.dart';

/// Abstract class defining the interface for the platform-specific
/// implementations.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/bindings/soloud_controller.dart
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export 'package:flutter_soloud/src/bindings/soloud_controller_ffi.dart'
if (dart.library.html) 'package:flutter_soloud/src/bindings/soloud_controller_web.dart';
if (dart.library.js_interop) 'package:flutter_soloud/src/bindings/soloud_controller_web.dart';
7 changes: 4 additions & 3 deletions lib/src/soloud.dart
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,9 @@ interface class SoLoud {
/// Provide a [path] of the file to be used as a reference to distinguis
/// this [buffer].
///
/// The [buffer] represents the bytes of an audio file. It could be also a
/// simple WAV format sequence of manually generated bytes.
/// The [buffer] represents the bytes of a supported audio file (not
/// RAW data).
/// It could be also a simple WAV format sequence of manually generated bytes.
///
/// When [mode] is [LoadMode.memory], the whole uncompressed RAW PCM
/// audio is loaded into memory. Used to prevent gaps or lags
Expand All @@ -434,7 +435,7 @@ interface class SoLoud {
/// See the [seek] note problem when using [LoadMode.disk].
/// The default is [LoadMode.memory].
/// IMPORTANT: [LoadMode.memory] used the on web platform could cause UI
/// freezy problems.
/// freeze problems.
///
/// This is the only choice to load a file when using this plugin on the web
/// because browsers cannot read directly files from the loal storage.
Expand Down
3 changes: 3 additions & 0 deletions lib/src/utils/loader_base.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// ignore_for_file: public_member_api_docs

import 'package:flutter/services.dart';
import 'package:flutter_soloud/src/audio_source.dart';
import 'package:flutter_soloud/src/enums.dart';
import 'package:http/http.dart' as http;

/// Stub interface for unsupported plarforms.
interface class SoLoudLoader {
Future<void> initialize() async =>
throw UnsupportedError('platform not supported');
Expand Down
4 changes: 4 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ flutter:
ffiPlugin: true

assets:
# These assets are only needed for the web platform.
# Waiting for https://github.com/flutter/flutter/issues/65065 and
# https://github.com/flutter/flutter/issues/8230 to be addressed
# to make a conditional build.
- web/worker.dart.js
- web/libflutter_soloud_plugin.js
- web/libflutter_soloud_plugin.wasm
1 change: 1 addition & 0 deletions wasm.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -euo pipefail

cd web
sh ./compile_wasm.sh
1 change: 1 addition & 0 deletions web.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -euo pipefail

cd web
sh ./compile_worker.sh
1 change: 1 addition & 0 deletions web/compile_wasm.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -euo pipefail

rm -f libflutter_soloud_plugin.*
rm -r build
Expand Down
3 changes: 2 additions & 1 deletion web/compile_worker.bat
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# -O4
dart compile js -o worker.dart.js ./worker.dart
dart compile js -o worker.dart.js ./worker.dart

4 changes: 2 additions & 2 deletions web/compile_worker.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -O4
dart compile js -O3 -o worker.dart.js ./worker.dart
dart compile js -O3 -o worker.dart.js ./worker.dart

0 comments on commit c284151

Please sign in to comment.