Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Unhandled Exception: Null check operator used on a null value #5

Open
UNIcodeX opened this issue Jul 8, 2021 · 7 comments
Open

Unhandled Exception: Null check operator used on a null value #5

UNIcodeX opened this issue Jul 8, 2021 · 7 comments

Comments

@UNIcodeX
Copy link

UNIcodeX commented Jul 8, 2021

When calling Libao.open();, I'm getting the message in the title, on Windows 10.

following the stack trace takes me to this

 /// Loads the libao library.
  factory Libao.open([String? /*?*/ path]) {
    if (path != null && path.isNotEmpty) {
      // nada.
    } else if (Platform.isLinux) {
      path = '/usr/lib/x86_64-linux-gnu/libao.so.4';
    }

    final lib = DynamicLibrary.open(path!);  # <<<<
    return Libao._(lib);
  }
@maks
Copy link
Contributor

maks commented Aug 16, 2021

Hmm, yes I probably should have changed that code to be a bit better when I did the port to null-safety.
But how are you passing in the path to the libao dll ? The exception is occurring because the path is null.

@sleepreading
Copy link

Same Problem!
Environment:

Flutter 2.5.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 18116933e7 (9 weeks ago) • 2021-10-15 10:46:35 -0700
Engine • revision d3ea636dc5
Tools • Dart 2.14.4

change code Libao.open() to Libao.open(""), will cause this exception:

Invalid argument(s): Failed to load dynamic library '': dlopen failed: can't read file "/data/app/......-w8jcxgmbluIa0EgCRsGHow==/lib/arm64": Is a directory stack:#0      _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:11:55)
I/flutter (10825): #1      new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:20:12)

@maks
Copy link
Contributor

maks commented Dec 15, 2021

@sleepreading ok but where is the libao shared library that you are trying to use located? The whole point is that you do need to supply the path the library.
It would help if you could also mention what OS/platform you are trying to run this on?

@sleepreading
Copy link

@maks
Sorry for my poor English, this is my Android Phone:

Honor 10 - COL AL10
System: EMUI
Android Version: 10
Kernel-Version: 4.14.116
CPU: HiSilicon Kirin 970
RAM: 6GB

I used your demo code: final ao = Libao.open(); and this will cause the problem as mentioned by @UNIcodeX above:
Null check operator used on a null value, so I change open() to open(''), and this will cause a new exception as I mentioned above.

@maks
Copy link
Contributor

maks commented Dec 15, 2021

No worries and no need to apologise.
Ah I see what you are trying to do now.
As far as I know Libao only supports some desktop operating systems and does not really support Android. You can see the list of all the platforms Libao supports on thier homepage.
However it does seem that some people have experimented with getting it compiled for Android but from what I can see it is not fully functional.

Depending on what audio playback functionality you need, you may be better off looking to use something like just_audio.

@sleepreading
Copy link

Thanks!
I must admit that this library is awesome because just_audio and audioplayers are both non-supported for playBytes()(They only support playing raw audio bytes on android), But your library supports almost every platform(except web).
Turns out, it's really hard to play raw audio bytes(which I received from a server using HTTP or grpc) on all platforms.

@maks
Copy link
Contributor

maks commented Dec 16, 2021

@sleepreading I agree, I really like this package too, but it doesn't change that the underlying libao library does not support Android. I maybe working on a similar Dart FFI package for Android's Oboe library, so I'll make sure to mention it here if I do get it published in the future.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants