Skip to content

USB disconnect or reset mutes sound on the computer #1609

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
deshipu opened this issue Mar 1, 2019 · 15 comments
Closed

USB disconnect or reset mutes sound on the computer #1609

deshipu opened this issue Mar 1, 2019 · 15 comments
Labels
Milestone

Comments

@deshipu
Copy link

deshipu commented Mar 1, 2019

For some reason with the 4.0 code, even with CIRCUITPYTHON_USB_HID=0 and CIRCUITPYTHON_USB_MIDI=0, disconnecting or hard-resetting the board results in my sound getting muted. I tested that initially with PewPew (which is pretty much a Trinket M0), but confirmed it now with a Hallowing M0 Express.

Interestingly enough, nothing is appearing in xev when that happens.

@dhalbert
Copy link
Collaborator

dhalbert commented Mar 1, 2019

This is on Ubuntu, right? We should test on other OS's.

@siddacious
Copy link

I've been plugging/unplugging, resetting etc. ad nauseam the last few days with master+ and haven't noticed anything getting muted on my Mac (Mojave)

@deshipu
Copy link
Author

deshipu commented Mar 1, 2019

Yes, more precisely Linux Mint with XFCE4. It doesn't happen on Fedora 28, also with XFCE4.

@deshipu
Copy link
Author

deshipu commented Mar 1, 2019

I think that it is not keyboard — I disabled keyboard shortcuts for volume control, and it still happens.

@dhalbert
Copy link
Collaborator

dhalbert commented Mar 1, 2019

are they regular keyboard shortcuts or Consumer Control shortcuts?

@deshipu
Copy link
Author

deshipu commented Mar 1, 2019

How do I tell?

I just checked that it doesn't happen with 4.0.0-alpha.5 but does with beta.0

@deshipu
Copy link
Author

deshipu commented Mar 1, 2019

Looks like commit b5e40f5 is the problem.

@dhalbert
Copy link
Collaborator

dhalbert commented Mar 1, 2019

Thanks for the bisect or equivalent. That's a big commit: USB MIDI and a lot of tinyusb changes. I'll put a sniffer on the USB traffic and see what's up.

@deshipu
Copy link
Author

deshipu commented Mar 1, 2019

Another thing that may be relevant: the board shows up in alsamixer in the list of sound cards. My current working theory is that Ubuntu does something weird when a sound card is disconnected — perhaps the same mechanism that switches volume when headphones are connected/disconnected.

@deshipu
Copy link
Author

deshipu commented Mar 1, 2019

I wonder how hard it would be for the board not to appear as a MIDI device when CIRCUITPYTHON_USB_MIDI is disabled, and also not appear as a keyboard when CIRCUITPYTHON_USB_HID is disabled.

@dhalbert
Copy link
Collaborator

dhalbert commented Mar 1, 2019

Then it's the MIDI. USB MIDI is a subclass of audio device (from https://github.com/adafruit/circuitpython/blob/master/tools/gen_usb_descriptor.py)

audio_midi_interface = standard.InterfaceDescriptor(
    description="Midi goodness",
    bInterfaceClass=audio.AUDIO_CLASS_DEVICE,
    bInterfaceSubClass=audio.AUDIO_SUBCLASS_MIDI_STREAMING,
    bInterfaceProtocol=audio.AUDIO_PROTOCOL_V1,
    iInterface=StringIndex.index("CircuitPython MIDI"),

I wonder how hard it would be for the board not to appear as a MIDI device when CIRCUITPYTHON_USB_MIDI is disabled, and also not appear as a keyboard when CIRCUITPYTHON_USB_HID is disabled.

We have an open issue (#1015) for dynamic USB descriptors. We could possibly conditionalize the static descriptor in the file above for now.

@kevinjwalters
Copy link

kevinjwalters commented Mar 1, 2019

I found the CPX didn't work as a keyboard when I plugged it into a school's computer. It made me wonder if there was something about the other usb devices that it was showing up as which made it block the port. It's alluded to in https://forums.adafruit.com/viewtopic.php?f=48&t=146648#p725650

I'd tweaked the CPX dice project (https://github.com/kevinjwalters/circuitpython-examples/blob/master/cpx/cpx-dice-typer.py) and it was supposed to type the numbers. Worked at home but not at the school I was volunteering at. I didn't have time to delve deeper. I might be able to revisit this but I suspect they'll be a lack of expertise on site.

If there was a way to stop the CPX from ever pretending to be the other USB devices I didn't need that would have been a useful quick debugging step and potentially a solution for that environment. Maybe.

@tannewt tannewt added this to the Long term milestone Mar 20, 2019
@dhalbert dhalbert added the usb label Oct 31, 2019
@deshipu
Copy link
Author

deshipu commented Sep 2, 2020

I think this is now fixed on the system side, and we can close it.

@deshipu deshipu closed this as completed Sep 2, 2020
@kevinjwalters
Copy link

@deshipu What do you mean, was this a bug on the linux side of things?

@deshipu
Copy link
Author

deshipu commented Sep 5, 2020

Yes, Ubuntu and derivatives would reset the sound level to zero when a new MIDI device was connected. CircuitPython devices happen to be MIDI devices.

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

No branches or pull requests

5 participants