sommd / auto-mute

Automatically mute or unmute your media volume based on the type of audio playing for Android 8.0 and up.
GNU General Public License v3.0
15 stars 1 forks source link

Breaks Duolingo #10

Open Gooberpatrol66 opened 1 year ago

Gooberpatrol66 commented 1 year ago

This app breaks Duolingo, which re-mutes itself repeatedly. Can I bypass this app for it?

azizLIGHT commented 7 months ago

Per the dev in a previously closed issue

Auto Mute can't detect which app audio is coming from since Android doesn't provide this, so implementing any kind of per-app detection (as the title of this issue suggests) isn't possible either, so I'm going to close this issue

Their suggestion is to use the settings quick tile to enable disable Auto Mute for this scenario. Sometimes I forget to enable Auto Mute after using Duolingo and get surprised by sounds from other apps later on. Maybe that is a easier to tackle problem: re-enabling auto mute after some time automatically.

azizLIGHT commented 7 months ago

Maybe it is possible to use some automation app like Tasker to disable auto-mute when Duolingo is in the foreground, and then re-enable Auto Mute when Duolingo is no longer in the foreground

sommd commented 7 months ago

Like @azizLIGHT said, there's no way to detect which app audio is coming from, so it's not possible to allow/ignore-list per app.

What exactly is broken about Duolingo? Is it that Auto Mute is muting the audio after Duolingo stops playing audio, and then when it starts again it's muted? You might be able to workaround that by increasing Delay setting. If it's something else, could you try to describe what the problem is in more detail :slightly_smiling_face:.

azizLIGHT commented 7 months ago

I will try to explain Duolingo problems with Auto Mute.

With Auto Mute enabled, when I turn up the volume and start playing audio in Duolingo, the audio will finish playing without a mute. But then I ask Duolingo to immediately repeat the same audio and this repeated audio will get muted while it is playing mid-sentence. I tried with 5 second and 15 second delay.

It feels like Auto Mute is counting the delay from the beginning of when the audio was played rather than counting the delay from when the audio was finished playing. Or it could be that the delay counter does not restart when another audio stream is playing again after finishing audio previously. I am not sure though.

I have Show volume control when muting and when unmuting enabled. So I can see muting happen twice: volume control appears on screen with a muted symbol. Once during the Duolingo speech, and then again after some delay (which is probably the delay seconds I picked). So it could be that there is two mutings are happening, one from the beginning of Duolingo audio, and then one when the audio finished.

Increasing the delay to 30 seconds helps but there is still some unintended muting.

I can see Auto Mute's notification correctly detect 1 audio stream playing when Duolingo is speaking and then correctly detect 0 audio streams playing when Duolingo finishes speaking. But during normal operation of Duolingo, I will be playing audio, the audio will finish, and I will replay the audio again (so 1 audio stream -> 0 audio stream -> 1 audio stream in Auto Mute's notificaiton). In reality audio stream is going constantly 1 -> 0 -> 1 -> 0 -> 1 -> 0 and eventually some audio streams get muted.

Hope this helps somewhat

azizLIGHT commented 7 months ago

I put the delay to 5 minutes and did my Duolingo lesson without a problem. But after a fee minutes I saw the volume control appear on screen for no reason showing the volume as muted, many times. It showed the muted volume, then 5 seconds later, show muted volume again, then wait some seconds, and show muted volume again, repeatedly many times. The first mute makes sense, but the others? I played no audio after using Duolingo. In this scenario with a 5 minute delay in Auto Mute, it seems Auto Mute queued a bunch of mute events to occur and they are all triggering one after the other, some seconds apart, mimicing how a Duolesson audio output would have gone.

I think Auto Mute does not use the delay timer setting between individual mute events. But then again why are there multiple mute events. It should just mute once after all audio stops, and after the delay timer reaches 0, no matter how many times I was able to play audio before the delay timer reached 0. The last time audio was played is when the only timer should be started, and when this 1 and only timer reaches 0, then Auto Mute should mute

sommd commented 7 months ago

Ah, I think I know what's happening, and it is indeed a bug in Auto Mute.

Auto Mute should only even have on mute schedule at a time, since we only schedule the mute after all the audio playback stops, and we cancel it whenever audio playback starts. The problem is that there are certain audio playback types that we ignore (these are just labeled "other" in the notification), but we're not quite ignoring them correctly. E.g. if there's no non-other audio types playing, then when an "other" audio type will always schedule a mute even though it shouldn't. To fix it we just need to ignore any audio-stopped events from "other" audio types.

From what it sounds like, Duolingo does fit this "other" audio type (which usually corresponds to audio that doesn't use the media volume stream, but maybe Duolingo is weird). Just to confirm, could you check in the notification what type of audio stream is playing? The notification title with say "X audio stream(s) playing" but if you expand it it should say "X music/media/game/other audio stream(s) playing", I'm guessing that Duolingo will be "other".

I'll try to work on a fix this weekend and put up a Beta build for you to test (if I have time). With the fix Duolingo (and any other app that's detected as the "other" audio type) should be completely ignored, so it won't auto mute or unmute at all.

azizLIGHT commented 7 months ago

Screenshot_20240426-084004 You're right it is the Other type!

sommd commented 7 months ago

I think I've fixed the issue and I've uploaded a Beta for you to test out. You can download it from here, just download the .apk file and you should be able to install it (it should just upgrade the already installed app even if it was installed from Google Play, no need to uninstall).

Let me know if it fixes the issue :)

azizLIGHT commented 7 months ago

This update no longer tries to mute Duolingo repeatedly!

Basically I will be auto muted and hit volume up and start a Duolingo lesson and even with a low 5 second delay I didnt encounter any mute. So IMO this issue is solved. Great work!

What remains is a unmuted media volume that doesn't get mute now or later. It means if you expect auto mute to be engaged, that after Duolingo (1 other audio stream), if you browse somewhere later and they have audio output, you will hear it (1 media audio stream) and if you stop it and wait the 5 sec delay, then Auto Mute will engage. So there could be some surprises depending on when the next audio occurs and if you were expecting a mute or not.

sommd commented 7 months ago

Glad to hear it fixed the issue. And yeah, the app now behaves exactly the same as if there's no audio playing and you unmute manually, so it won't re-mute automatically. #5 would fix this, so you could automatically have it mute after you manually unmute, but I haven't had time to work on features sorry.

I'll keep testing the beta and then release 1.5.1 to everyone either this week or next week, then this issue should be able to be closed 🙂