I’ll try to add “hw:” in front of the device handles.
Generally that’d be required if you’re using the hw:<card>[,device] device addressing, yes. You probably want to treat all device names, addresses, and handles as “opaque”, though, meaning you don’t care what the actual string looks like, and select your intended device through some other criteria.
That’s where default comes from, in a way. It leaves the device choice to the user. I understood that you intend to access some other audio device, typically non-default. In that case it’s ideal if you have any uniquely identifiable device information associated with the class of device you want to use, enumerate all “sound cards” to find those matching your criteria, and “hand down” the associated PCM handle to where you need it, without needing to know what it actually looks like.
Another way is to get a list of all “sound cards” of the system, and offer a legible selection of names/descriptions to the user in your application’s options to explicitly select the correct device, and have an internal mapping of that selection to it’s ASCII identifiers of PCM handles. Again, no need to know what the identifier looks like, you only need to match the user’s selection to it’s internal ID. This offloads the potentially difficult decision what device to use to your user, though, who may be even more lost being asked that question.
With “pcm” as the iface parameter in snd_device_name_hint() this should not happen. Did you check out and pilfer the code from aplay.c as I suggested before?
Post minimal, compilable sources to show your issue and the output you get, please.
The way is to use the appropriate ALSA library functions as mentioned in the associated docs, and see referenced examples for an outline how the flow is authoritatively supposed to look like, right from the tap.
Please elaborate “weird results for some reason” with minimal examples, as in “this is what I get running this code, and that is what I expected”. More often than not, the process of writing up your problems for external review leads to understanding, or at least to a couple good ideas what you might be doing wrong, or expecting to work differently.
The ALSA API is dense, and very C. It’s super-easy to make wrong assumptions about how things should work there. Great training for slogging through API docs, though. :)
/ˈwaɪzɝd/ for added effect! Don’t go overboard, though, or you may be called a custard.
I’d have a look at the aplay.c implementation for listing PCM device names (-L), pcm_list().
It’s basically using snd_device_name_hint(-1, “pcm”, &hints) and snd_device_name_get_hint() calls to discover the PCM device names.
Sehr geehrter Oberster Nudelgerichtshof,
mit Bedauern nehme ich die Ablehnung des Antrags zur Kenntnis, und werde mich fürderhin form- wie fristgerecht beim nächstem Stammtisch über den endgültigen Verfall deutschen Brauchtums, korrupte und inkompetente Behörden und Politiker, sowie die anhaltende Respektlosigkeit der Jugend gegenüber dem Alter beschweren. Vorbehaltlich stelle ich ebenfalls eine fundierte Kritik der Spielweise der deutschen Fußballnationalmannschaft in Aussicht.
Mit der Ihnen zustehenden Hochachtung,
Ein Wutbürger
Sehr geehrte @[email protected],
ich bringe hiermit einen möglichen Verstoß gegen IIeL #1, #5, und #9 zur Anzeige und stelle Strafantrag. Öffentliches Interesse ist bekundet. Ich fordere unverzügliche und kompromisslose Anwendung der Regularien zur Aufrechterhaltung der öffentlichen Ordnung, bevor Schlimmeres geschieht!
Hochachtungsvoll,
ein besorgter Bürger
PS: Ironie ist irgendwann nicht mehr als solche eindeutig erkennbar. Darum hier: ;-)
Und wenn das Treppenhaus nicht um 07:30 Uhr geputzt und trocken(!) ist, wird einstweilig erschossen. Wo kämen wir sonst hin!
Wie deutsch willst du sein? Ja.