Skip to content

Check audio plugin against audioplayers v4 #344

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

Closed
DoumanAsh opened this issue Jul 5, 2023 · 14 comments · Fixed by #345
Closed

Check audio plugin against audioplayers v4 #344

DoumanAsh opened this issue Jul 5, 2023 · 14 comments · Fixed by #345

Comments

@DoumanAsh
Copy link
Contributor

This is sort of remainder to do.
There are a lot of changes in audioplayers, including FFI part.

I will need to get myself a raspberry pi again and then I'll start checking it

@DoumanAsh
Copy link
Contributor Author

DoumanAsh commented Jul 6, 2023

From Radek on discord
audioplayers 4.0.0 is not compatible with plugin:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method create on channel xyz.luan/audioplayers)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:308)
<asynchronous suspension>
#1      AudioPlayer._create (package:audioplayers/src/audioplayer.dart:148)
<asynchronous suspension>

There is also incompatibilities with older version:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(illegalargument, Expected `arg['is_local']` to be a bool., null, null)
#0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652)
#1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310)
<asynchronous suspension>
#2      AudioPlayer.play (package:audioplayers/src/audioplayer.dart:131)
<asynchronous suspension>
#3      TicketsProvider.callTicket (package:panel_fe/providers/tickets_provider.dart:85)
<asynchronous suspension>

@bojidartonchev
Copy link
Contributor

bojidartonchev commented Oct 17, 2023

Hello @DoumanAsh,

Do you have info which is the latest supported version atm?

@DoumanAsh
Copy link
Contributor Author

DoumanAsh commented Oct 17, 2023

@bojidartonchev my branch audioplayers_v4 #345 should work with any 4.*.* but I never had time to work on testing it after great refactoring in flutter-pi
Branch is rebased, but not well tested yet

@bojidartonchev
Copy link
Contributor

bojidartonchev commented Oct 18, 2023

Hi @DoumanAsh, tried with your branch but no sound is played from flutter-pi.

Launching gstreamer from command line works.
gst-launch-1.0 playbin uri=file:///tmp/audio/sounds/normal_tap.wav

I saw something strange though. On the first play, resume is not called. On the second play, resume is called twice.

//------->First .play() call
plugins/audioplayers/plugin.c: call(method=setPlayerMode)
plugins/audioplayers/plugin.c: call(method=setSourceUrl)
plugins/audioplayers/player.c: 5bf69305-5ea7-406a-8cac-49fb33d2a308: set source=file:///tmp/audio/sounds/normal_tap.wav
//------->First .play() call end
//------->Second .play() call
plugins/audioplayers/plugin.c: call(method=setPlayerMode)
plugins/audioplayers/plugin.c: call(method=setSourceUrl)
plugins/audioplayers/plugin.c: call(method=resume)
plugins/audioplayers/plugin.c: call(method=resume)
//------->Second .play() call end

This is the complete log from flutter-pi, no errors.

aplay -l output:

root@intel-corei7-64:/tmp# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC888-VD Analog [ALC888-VD Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 10: HDMI 4 [HDMI 4]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 11: HDMI 5 [HDMI 5]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 12: HDMI 6 [HDMI 6]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

@DoumanAsh
Copy link
Contributor Author

@bojidartonchev Got it, probably some issue after rebase, although it is weird that resume is not called at all
Sorry I never had time to finalize it after rebasing, I will find some time this weekend to flash fresh OS image on my raspberry pi and test it again

Btw did it have sound when you played via gst-launch-1.0?
I only used audio jack and never bothered to configure audio devices properly, not sure what is your setup

@bojidartonchev
Copy link
Contributor

@DoumanAsh Yes, I have sound with gst-launch-1.0.

@DoumanAsh
Copy link
Contributor Author

DoumanAsh commented Oct 22, 2023

@bojidartonchev I think dudes responsible for audioplayers changed something again
I just tested and it fails with timeout error (as if no response is received) even though response is sent back
I will try to figure out what changed and maybe just re-write code to align with latest version (5.*.*)

@bojidartonchev
Copy link
Contributor

@DoumanAsh That would be great, thanks.

I have tried with latest version and the issue is the same as with 4.x.x.

@DoumanAsh
Copy link
Contributor Author

@bojidartonchev Latest version is aligned with 5.* but because I tested it against that version you cannot expect it to work for now.
I'm pretty sure API wise I covered all changes with my lastcommit

Unfortunately it doesnt work which sucks and I suspect there is something wrong with how I use flutter channels when replying back...
Not clear what yet, I will try to figure it out

@bojidartonchev
Copy link
Contributor

@DoumanAsh Found the issue.

In audio_player_on_media_state_change there is a check by the source object by name

if (streq(GST_OBJECT_NAME(src), "playbin")) {

but the playbin source's name is actually playbin0. So we can either set a name of the playbin element and check by name, or we can check this way:

if (src == GST_OBJECT(self->playbin)) {

@DoumanAsh
Copy link
Contributor Author

Ok this is interesting, because I'm pretty sure it worked like that in past.
I will change it as per your recommendation then and will test it later after work.

If you have time feel free to test me and let me know if there are any other issues.

I will need to run under ASAN and fix all possible issues in flutter-pi code. I found one minor problem outside of plugin

@bojidartonchev
Copy link
Contributor

bojidartonchev commented Oct 24, 2023

This change is the reason.

As described,
gst_element_factory_make ()

Create a new element of the type defined by the given element factory. If name is NULL, then the element will receive a guaranteed unique name, consisting of the element factory name and a number. If name is given, it will be given the name supplied.

@DoumanAsh
Copy link
Contributor Author

oooh I see
that's unexpected, I probably didn't follow though refactoring for new version.
Good catch, thank you

@DoumanAsh
Copy link
Contributor Author

@bojidartonchev In case you're working on more extensive audio usage, please try my branch in its current state to see if there is any problems with it.
I've been doing some simple testing my side, but it would be good to have someone else to cross check it just in case

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

Successfully merging a pull request may close this issue.

2 participants