All of lore.kernel.org
 help / color / mirror / Atom feed
From: stan <stanl@cox.net>
To: alsa-devel@alsa-project.org
Subject: Re: SOLVED Re: snd_pcm_hw_params_set_format fails with invalid argument
Date: Tue, 7 Aug 2007 08:32:25 -0700	[thread overview]
Message-ID: <20070807083225.51e3ebb1@localhost.localdomain> (raw)
In-Reply-To: <20070807082621.5a557ca4@localhost.localdomain>

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

And here it is with attachments.  

On Tue, 7 Aug 2007 08:26:21 -0700
stan <stanl@cox.net> wrote:

> I sent this directly to Takashi by mistake.  I could have sworn I saw
> the list in the to field but I must be mistaken.  Here it is for the
> list.
> 
> On Tue, 7 Aug 2007 08:02:42 -0700
> stan <stanl@cox.net> wrote:
> 
> > On Tue, 07 Aug 2007 15:38:40 +0200
> > Takashi Iwai <tiwai@suse.de> wrote:
> > 
> > > At Mon, 6 Aug 2007 09:22:01 -0700,
> > > stan wrote:
> > > > 
> > > > On Mon, 6 Aug 2007 09:04:57 -0700
> > > > stan <stanl@cox.net> wrote:
> > > > 
> > > > > I downloaded the hg alsa-lib snapshot of July 14, 2007,
> > > > > compiled it, (on Fedora 7 you will have to make a link to
> > > > > compile, cd /usr/include
> > > > > ln -s python2.5 python)
> > > > > and linked my program against it.  It works again so the issue
> > > > > has been fixed in the latest version of alsa lib.  Any
> > > > > estimate of when this version will be released for public
> > > > > consumption? My app is dead in the water with the current
> > > > > version of alsa, so anyone trying to use it will have a
> > > > > terrible user experience.  :-(  I want to give some
> > > > > indication of when people can expect it to start working
> > > > > again. In the meantime I'll create instructions on how to
> > > > > install the hg version to usr/local and change the library
> > > > > linking.
> > > > > 
> > > > > Thanks.
> > > > > 
> > > > For anyone interested, these are the formats that fail in 1.0.14
> > > > final
> > > > 
> > > > Value of last format 43
> > > > test of sample format 14 failed (Invalid argument)
> > > > test of sample format 15 failed (Invalid argument)
> > > > test of sample format 16 failed (Invalid argument)
> > > > test of sample format 17 failed (Invalid argument)
> > > > test of sample format 18 failed (Invalid argument)
> > > > test of sample format 19 failed (Invalid argument)
> > > > test of sample format 23 failed (Invalid argument)
> > > > test of sample format 24 failed (Invalid argument)
> > > > test of sample format 25 failed (Invalid argument)
> > > > test of sample format 26 failed (Invalid argument)
> > > > test of sample format 27 failed (Invalid argument)
> > > > test of sample format 28 failed (Invalid argument)
> > > > test of sample format 29 failed (Invalid argument)
> > > > test of sample format 30 failed (Invalid argument)
> > > > test of sample format 31 failed (Invalid argument)
> > > > Format returned (0)
> > > > 
> > > > 
> > > > and these are the formats that fail in the hg version.
> > > > 
> > > > Value of last format 43
> > > > test of sample format 18 failed (Invalid argument)
> > > > test of sample format 19 failed (Invalid argument)
> > > > test of sample format 23 failed (Invalid argument)
> > > > test of sample format 24 failed (Invalid argument)
> > > > test of sample format 25 failed (Invalid argument)
> > > > test of sample format 26 failed (Invalid argument)
> > > > test of sample format 27 failed (Invalid argument)
> > > > test of sample format 28 failed (Invalid argument)
> > > > test of sample format 29 failed (Invalid argument)
> > > > test of sample format 30 failed (Invalid argument)
> > > > test of sample format 31 failed (Invalid argument)
> > > > Format returned (16)
> > > 
> > > Could you give me the simple test case for checking the same thing
> > > on my system?
> > > 
> > > 
> > > thanks,
> > > 
> > > Takashi
> > 
> > They are attached as file test_case.c and shell script mktest.
> > 
> > Running ./mktest should generate an executable named test_case.
> > Running that should generate the above output.
> > 
> > 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[-- Attachment #2: mktest --]
[-- Type: application/octet-stream, Size: 105 bytes --]

#!/bin/bash

OPT='-Wall -W -O2 -s '
LIBS=' -lasound '

gcc $OPT test_case.c $LIBS -o test_case || exit 1

[-- Attachment #3: test_case.c --]
[-- Type: text/x-csrc, Size: 2876 bytes --]

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <ctype.h>
#include <alsa/asoundlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/soundcard.h>
#include <samplerate.h>
#include <sndfile.h>
#include <math.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <getopt.h>
#include <poll.h>
#include <pthread.h>
#include <dlfcn.h>
int main ();
void alsa_open ();

// START OF PROGRAMS
//
// M A I N
//

int
main ()
{
  alsa_open ();
  return 0;
}
/*------------------------------------------------------------------------------
**	Linux alsa functions for playing a sound.
*/

void
alsa_open ()
{	
  //char *default_device = "default" ;
  char *device = "plughw:0,0" ;
	int err ;
	snd_pcm_t *alsa_dev = NULL ;
	snd_pcm_hw_params_t *hw_params ;

  err = snd_pcm_open (&alsa_dev, device, SND_PCM_STREAM_PLAYBACK, 0);
	if (err < 0)
	{	fprintf (stderr, "cannot open audio device \"%s\" (%s)\n", device, snd_strerror (err)) ;
		goto catch_error ;
		} ;

  err = snd_pcm_hw_params_malloc (&hw_params);
	if (err < 0)
	{	fprintf (stderr, "cannot allocate hardware parameter structure (%s)\n", snd_strerror (err)) ;
		goto catch_error ;
		} ;

  err = snd_pcm_hw_params_any (alsa_dev, hw_params);
	if (err < 0)
	{	fprintf (stderr, "cannot initialize hardware parameter structure (%s)\n", snd_strerror (err)) ;
		goto catch_error ;
		} ;

  err = snd_pcm_hw_params_set_access (alsa_dev, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
	if (err < 0)
	{	fprintf (stderr, "cannot set access type (%s)\n", snd_strerror (err)) ;
		goto catch_error ;
		} ;

  int iformat;
  fprintf (stderr, "Value of last format %lu\n", 
                          (unsigned long) SND_PCM_FORMAT_LAST) ;
  for (iformat = 0; iformat <= SND_PCM_FORMAT_LAST; iformat++)
  {
    err = snd_pcm_hw_params_test_format (alsa_dev, hw_params, iformat);
    if (err < 0)
      fprintf (stderr, "test of sample format %lu failed (%s)\n", 
                          (unsigned long) iformat, snd_strerror (err)) ;
  }

  err = snd_pcm_hw_params_set_format (alsa_dev, hw_params, SND_PCM_FORMAT_FLOAT64);
	if (err < 0)
	{	fprintf (stderr, "cannot set sample format %lu (%s)\n", 
                        (unsigned long) SND_PCM_FORMAT_FLOAT64, snd_strerror (err)) ;
		goto catch_error ;
		} ;

  snd_pcm_format_t fval;
  snd_pcm_hw_params_get_format (hw_params, &fval);
  fprintf (stderr, "Format (%lu)\n", (unsigned long) fval);
  if ((unsigned long) fval != (unsigned long) SND_PCM_FORMAT_FLOAT64)
    fprintf (stderr, "Format (%lu) differs from requested (%lu)\n", 
              (unsigned long) fval, (unsigned long) SND_PCM_FORMAT_FLOAT64);

  snd_pcm_close (alsa_dev) ;

catch_error :

	if (err < 0 && alsa_dev != NULL)
	{	snd_pcm_close (alsa_dev) ;
		} ;
}              

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

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

      reply	other threads:[~2007-08-07 15:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-03 18:20 snd_pcm_hw_params_set_format fails with invalid argument stan
2007-08-05 20:10 ` stan
2007-08-06 16:04   ` SOLVED " stan
2007-08-06 16:22     ` stan
2007-08-07 13:38       ` Takashi Iwai
     [not found]         ` <20070807080242.0da2a0ff@localhost.localdomain>
2007-08-07 15:26           ` stan
2007-08-07 15:32             ` stan [this message]

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=20070807083225.51e3ebb1@localhost.localdomain \
    --to=stanl@cox.net \
    --cc=alsa-devel@alsa-project.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.