disable sound due to crash

This commit is contained in:
open-trade 2020-11-27 10:52:09 +08:00
parent 00358b456d
commit 8edabe654f
2 changed files with 26 additions and 20 deletions

View File

@ -39,7 +39,7 @@ android {
defaultConfig { defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.carriez.flutter_hbb" applicationId "com.carriez.flutter_hbb"
minSdkVersion 16 minSdkVersion 18
targetSdkVersion 29 targetSdkVersion 29
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()
versionName flutterVersionName versionName flutterVersionName

View File

@ -73,11 +73,11 @@ class FfiModel with ChangeNotifier {
await _audioPlayer.stopPlayer(); await _audioPlayer.stopPlayer();
} }
Future<Null> update( void update(
String id, String id,
BuildContext context, BuildContext context,
void Function(Map<String, dynamic> evt, String id, BuildContext context) void Function(Map<String, dynamic> evt, String id, BuildContext context)
handleMsgbox) async { handleMsgbox) {
var pos; var pos;
for (;;) { for (;;) {
var evt = FFI.popEvent(); var evt = FFI.popEvent();
@ -98,6 +98,7 @@ class FfiModel with ChangeNotifier {
} else if (name == 'permission') { } else if (name == 'permission') {
FFI.ffiModel.updatePermission(evt); FFI.ffiModel.updatePermission(evt);
} else if (name == "audio_format") { } else if (name == "audio_format") {
() async {
try { try {
var s = int.parse(evt['sample_rate']); var s = int.parse(evt['sample_rate']);
// var c = int.parse(evt['channels']); // var c = int.parse(evt['channels']);
@ -109,6 +110,7 @@ class FfiModel with ChangeNotifier {
} catch (e) { } catch (e) {
print('audio_format: $e'); print('audio_format: $e');
} }
}();
} }
} }
if (pos != null) FFI.cursorModel.updateCursorPosition(pos); if (pos != null) FFI.cursorModel.updateCursorPosition(pos);
@ -133,17 +135,19 @@ class FfiModel with ChangeNotifier {
} }
}); });
} }
}
var frame = FFI._getAudio(); var frame = FFI._getAudio();
if (frame != null && frame != nullptr) { if (frame != null && frame != nullptr) {
final ref = frame.ref; final ref = frame.ref;
final bytes = Uint8List.sublistView(ref.data.asTypedList(ref.len)); final bytes = Uint8List.sublistView(ref.data.asTypedList(ref.len));
() async {
try { try {
await _audioPlayer.feedFromStream(bytes); // await _audioPlayer.feedFromStream(bytes);
} catch (e) { } catch (e) {
print('play audio frame: $e'); print('play audio frame: $e');
} }
FFI._freeRgba(frame); FFI._freeRgba(frame);
} }();
} }
} }
@ -248,6 +252,7 @@ class CanvasModel with ChangeNotifier {
} }
void updateScale(double v) { void updateScale(double v) {
if (FFI.imageModel.image == null) return;
final offset = FFI.cursorModel.offset; final offset = FFI.cursorModel.offset;
var r = FFI.cursorModel.getVisibleRect(); var r = FFI.cursorModel.getVisibleRect();
final px0 = (offset.dx - r.left) * _scale; final px0 = (offset.dx - r.left) * _scale;
@ -310,6 +315,7 @@ class CursorModel with ChangeNotifier {
} }
void updatePan(double dx, double dy) { void updatePan(double dx, double dy) {
if (FFI.imageModel.image == null) return;
final scale = FFI.canvasModel.scale; final scale = FFI.canvasModel.scale;
dx /= scale; dx /= scale;
dy /= scale; dy /= scale;