Skip to content
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

[BUG]:flutter app to send sound via udp and play it #1139

Open
kamil-bit opened this issue Jan 4, 2025 · 0 comments
Open

[BUG]:flutter app to send sound via udp and play it #1139

kamil-bit opened this issue Jan 4, 2025 · 0 comments

Comments

@kamil-bit
Copy link

kamil-bit commented Jan 4, 2025

(only Android operating system)i use flutter_sound: 9.17.8 to record and play here is important part of code. I use
the same app on two phones first record second play. It works i hear sound
I get something like this
"Audio packet Lost !"
" releaseBuffer() track 0xc2a30400 disabled due to previous underrun, restarting"

but after when i stop send sound via udp on first phone app in second phone stop working i get this exception

releaseBuffer() track 0xc2a30400 disabled due to previous underrun, restarting
F/AudioTrackShared(11140): Assertion failed: !(stepCount <= mUnreleased && mUnreleased <= mFrameCount)
F/libc (1750): Fatal signal 6 (SIGABRT), code -6 in tid 1574 (Thread-267)


Build fingerprint:
Revision: '2'

pid: 17840, tid: 19374, name: Thread-267 >>> com.example.x <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Abort message: 'Assertion failed: !(stepCount <= mUnreleased && mUnreleased <= mFrameCount)'

udp = await RawDatagramSocket.bind(
                InternetAddress(mojip),
                int.parse( mojport.text));
            await Permission.microphone.request();
            StreamController<Uint8List> audioStreamController = StreamController<Uint8List>();
            await recorder.openRecorder();
            await recorder.startRecorder(
              toStream: audioStreamController.sink ,
              codec: Codec.pcm16,
              sampleRate: 16000, // Częstotliwość próbkowania44100 było
              numChannels: 1,   // Liczba kanałów (mono)
            );
            await recorder.pauseRecorder();
            List<int>lista=[];
            audioStreamController.stream.listen((buffer) {
              lista+=buffer;//buffer has size about 500 bytes
              if(lista.length>10000-1000)
              {
                udp.send(lista, InternetAddress(cnt.text),int.parse(cnt2.text));
                lista.clear();
              }
            });
            final player = FlutterSoundPlayer();
            await player.openPlayer();
            
            await player.startPlayerFromStream
              (bufferSize: 10000,
                codec: Codec.pcm16 ,// Actually this is the only codec possible
                numChannels: 1, // Actually this is the only value possible. You cannot have several channels.
                sampleRate: 16000 // This parameter is very important if you want to specify your own sample rate
            );
            udp.listen((data)async{
              var zm=udp.receive();
              if(zm!=null){
                if(zm.data.length>0)
                await player.feedFromStream(zm.data);
              }
              });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant