wenxin-wang / PulseDroidRtp

Receive and play PulseAudio RTP stream on Android
48 stars 2 forks source link

[Feature request] Support older version of Android #8

Closed garywill closed 3 years ago

garywill commented 3 years ago

Hello @wenxin-wang ,

It's me again : )

Simple Protocol Player NG supports Android 2.2. I'm wondering if your app can also support older version of Android. Since this is, people might think, a simple app.

I'm using an Android 4.4 TV box. And I have a quite old phone running Android 2.2. They're running Simple Protocol Player NG well.

wenxin-wang commented 3 years ago

Simple Protocol Player NG supports Android 2.2. I'm wondering if your app can also support older version of Android.

I will look into it on Spring Festival. What's better than a cozy coding night?

Since this is, people might think, a simple app.

Indeed! But be well aware, I am not a single bit familiar with Android and UI, so if things get out of my hand I will happily give up.

garywill commented 3 years ago

@wenxin-wang Great! Happy to hear that.

so if things get out of my hand I will happily give up.

That's okay. Don't worry. Don't push yourself too hard.

wenxin-wang commented 3 years ago

@garywill Sorry for the long wait. I looked into this issue several times, and finally decided that I don't feel like implementing support for Android 2.2, because my goal for this project is to learn how to use oboe to achieve low latency, which only supports Android 4.4. Though I don't think the app's current latency is good enough, I still think oboe is the way to go, because the API is so easy to use, and the idea of using periodic callbacks to request data from audio thread makes sense to me.

I read the source code for Simple Protocol Player NG, and checked the available API for Android 2.2, and found out that in order to implement the support I have to use now deprecated APIs and there would possible be quirks that I wouldn't want to deal with. The author did a great job tending to all the details, i.e. holding wake locks, using notification to keep the app running in backgrounds, ducking when other app gains audio focus, and I'm learning from him. It's a great app, just use it:).

I do want to point out that it may be possible to set up pulseaudio so that both app can receive data from the same server. For example (I use null-sink because I want to have separated sound from my laptop and my stereo)

pactl unload-module module-null-sink
pactl unload-module module-rtp-send
# For PulseDroidRtp, which uses big endian 16-bit samples
pactl load-module module-null-sink sink_name=rtp channels=2 rate=48000
pactl load-module module-rtp-send source=rtp.monitor format=s16be destination=224.0.0.56 port=4010 mtu=320
# For SimpleProtocolPlayerNg. From the source code I can see that it uses 16-bit samples, but it doesn't seems to care about endianess. My guess is that it uses little endian, see https://kaytat.com/blog/?page_id=301
pactl load-module module-simple-protocol-tcp source=rtp.monitor port=12345 format=s16le

I haven't tried this kind of setup myself, but hopefully this should work. Don't expect these two devices to be in sync though. In my experience even two phones using PulseDroidRtp cannot sync perfectly.

I will leave this issue open for a few while in case anything worth discussing comes up.

garywill commented 3 years ago

finally decided that I don't feel like implementing support for Android 2.2

It's okay. I'll just let my old old palm phone sleep. :)

Will Android 4.4 get supported, right? It's great to support more old devices.


BTW, if we make the receiving and playing job run as a service, we will be able to start/stop it by remote adb (with root), without touching device screen.

That's my personal thought and requirements. Just an advice for discussing. If you feel interested you can dig into it, not required. It's up to you after all.

You've done a good job.

wenxin-wang commented 3 years ago

Will Android 4.4 get supported, right? It's great to support more old devices.

It is supported right now, my stereo runs 4.4.

BTW, if we make the receiving and playing job run as a service, we will be able to start/stop it by remote adb (with root), without touching device screen.

That's a good point. And someone in #9 also mentioned that I should use notification to keep the app running (and start the app on phone startup), which requires the usage of service, so I will look into this while working on that issue. Feel free to join the discussion there (Chinese and English are both fine, just realized you seem to speak Chinese too).

That's my personal thought and requirements. Just an advice for discussing. If you feel interested you can dig into it, not required. It's up to you after all.

Thank you for your support:)