Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rene Herman <rene.herman@keyaccess.nl>
To: Mark Constable <markc@renta.net>
Cc: alsa-user@lists.sourceforge.net,
	ALSA devel <alsa-devel@alsa-project.org>
Subject: Re: How to get set/fixed sample rate of ALSA device?
Date: Mon, 08 Oct 2007 01:52:26 +0200	[thread overview]
Message-ID: <4709713A.8000404@keyaccess.nl> (raw)
In-Reply-To: <200710080841.37709.markc@renta.net>

[-- Attachment #1: Type: text/plain, Size: 988 bytes --]

On 10/08/2007 12:41 AM, Mark Constable wrote:

> Any chance that your program could take an arg to investigate
> other cards (or perhaps plugins) and also return an errno so
> it could be used in scripts ?

Only if you promise to never drop CCs again (although I don't know about 
plugins).

>  # gcc -W -Wall -o snd_rate snd_rate.c -l asound
>  snd_rate.c: In function 'main':
>  snd_rate.c:14: warning: the address of ‘params’ will always evaluate as 'true'

That's the ALSA snd_pcm_hw_params_alloca(). No such warning here, but I've 
made it a regular malloc.

>  # snd_rate
>  snd_pcm_open: Device or resource busy
> 
> In fact, why isn't there a single simple "alsainfo" type
> program that tells a user some (or a lot) of info about
> their hardware and alsa-lib install ?

I guess because noone wrote one :-)

It seems by the way that dir != 0 _can_ be returned for hw devices, and this 
just ignores it. Just some rounding issue I guess.

Rene.


[-- Attachment #2: alsa-rate.c --]
[-- Type: text/plain, Size: 1309 bytes --]

/* gcc -W -Wall -o alsa-rate alsa-rate.c -lasound */

#include <stdio.h>
#include <alsa/asoundlib.h>

int main(int argc, char *argv[])
{
	char *device;
	snd_pcm_t *handle;
	snd_pcm_hw_params_t *params;
	unsigned int min;
	unsigned int max;
	int dir;
	int err;

	device = argc > 1 ? argv[1] : "hw:0,0";

	err = snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, 0);
	if (err < 0) {
		fprintf(stderr, "snd_pcm_open: %s\n", snd_strerror(err));
		return err;
	}
	err = snd_pcm_hw_params_malloc(&params);
	if (err < 0) {
		fprintf(stderr, "snd_pcm_hw_params_alloc: %s\n",
			snd_strerror(err));
		return err;
	}
	err = snd_pcm_hw_params_any(handle, params);
	if (err < 0) {
		fprintf(stderr, "snd_pcm_hw_params_any: %s\n",
			snd_strerror(err));
		return err;
	}
	err = snd_pcm_close(handle);
	if (err < 0) {
		fprintf(stderr, "snd_pcm_close: %s\n", snd_strerror(err));
		return err;
	}
	err = snd_pcm_hw_params_get_rate_min(params, &min, &dir);
	if (err < 0) {
		fprintf(stderr, "snd_pcm_hw_params_get_rate_min: %s\n",
			snd_strerror(err));
		return err;
	}
	err = snd_pcm_hw_params_get_rate_max(params, &max, &dir);
	if (err < 0) {
		fprintf(stderr, "snd_pcm_hw_params_get_rate_max: %s\n",
			snd_strerror(err));
		return err;
	}
	snd_pcm_hw_params_free(params);

	printf("%u-%u\n", min, max);
	return 0;
}

[-- Attachment #3: Type: text/plain, Size: 314 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

[-- Attachment #4: Type: text/plain, Size: 158 bytes --]

_______________________________________________
Alsa-user mailing list
Alsa-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/alsa-user

  parent reply	other threads:[~2007-10-07 23:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <b97f4ee40710061456l5aa0764alce22c505401c7e6f@mail.gmail.com>
     [not found] ` <4708F918.3060207@keyaccess.nl>
     [not found]   ` <b97f4ee40710071004o23ea40a1w8c8f754b47083b95@mail.gmail.com>
2007-10-07 22:07     ` How to get set/fixed sample rate of ALSA device? Rene Herman
2007-10-07 22:27       ` Rene Herman
     [not found]       ` <200710080841.37709.markc@renta.net>
2007-10-07 23:52         ` Rene Herman [this message]
2007-10-08 19:09       ` Peteris Krisjanis
2007-10-08 19:14         ` Bill Unruh
2007-10-08 19:30           ` Rene Herman
2007-10-09  0:23             ` Rene Herman
2007-10-15 20:20               ` [Alsa-user] " Rene Herman
2007-10-16 13:26                 ` [alsa-devel] " Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4709713A.8000404@keyaccess.nl \
    --to=rene.herman@keyaccess.nl \
    --cc=alsa-devel@alsa-project.org \
    --cc=alsa-user@lists.sourceforge.net \
    --cc=markc@renta.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox