8000 Add device enumeration for Android by MrGuim · Pull Request #1049 · mackron/miniaudio · GitHub
[go: up one dir, main page]

Skip to content

Add device enumeration for Android - #1049

Closed
MrGuim wants to merge 6 commits into
mackron:dev-0.12from
MrGuim:feat/android-device-enumeration
Closed

MrGuim wants to merge 6 commits into
mackron:dev-0.12from
MrGuim:feat/android-device-enumeration

Conversation

@MrGuim
@MrGuim MrGuim commented Sep 25, 2025
Copy link
Copy Markdown

This is a draft proposal for retrieving and enumerating audio devices on Android using the JNI interface. It's not ready for merging yet, but I'd like to start a discussion about this approach.

What are your thoughts on using the JNI interface to get the device list?

Known issues that need addressing:

  1. Default Device Selection Problem: Currently, the default device is determined by its index position in the list, since there's no direct way to get the preferred audio route. The only alternative would be to:

    However, I don't think this approach is ideal. An alternative would be creating a priority system based on device type (e.g., speaker > bluetooth > built-in).

  2. Missing device type information: The current implementation doesn't expose the device type, which is crucial for disambiguation. Many devices show multiple entries with the same name (typically the phone's model name) for different audio outputs like built-in speaker and built-in earphone, making them impossible to distinguish without type information.

@mackron
mackron commented Sep 27, 2025
Copy link
Copy Markdown
Owner

Thanks. Let me sit on this and consider it. I'm not immediately against it or anything.

A question. This comes from my own ignorance - with the JNI_OnLoad() implementation, does the fact that this is implemented in miniaudio mean that the application itself cannot define it themselves or else they get multiple definition errors at compile time? If this is the case, I won't allow that. It's too invasive. Instead, I'd rather have a pJavaVM member in ma_context_config (typed as void*) that is passed in from the application.

@MrGuim
MrGuim commented Sep 30, 2025
Copy link
Copy Markdown
Author

Yes, that's correct. Do you think those updates would work better?

I can't figure out why the Android build keeps failing. Sorry for all the testing - I'm not very experienced with C.

@mackron
mackron commented Feb 27, 2026
Copy link
Copy Markdown
Owner

I've had more of a look at this and have decided not to accept it.

I didn't notice this before, but this PR depends on C++. miniaudio is a C library. This would result in the AAudio backend having different behaviour depending on whether or not it's a C++ build or a C build. This is a maintenance nightmare and I will not be accepting it.

If you need this functionality I'd recommend you maintain your own branch.

@mackron mackron closed this Feb 27, 2026
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 this pull request may close these issues.

3 participants

0