Re: SOLVED Re: snd_pcm_hw_params_set_format fails with invalid argument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



And here it is with attachments.  

On Tue, 7 Aug 2007 08:26:21 -0700
stan <stanl@xxxxxxx> 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@xxxxxxx> wrote:
> 
> > On Tue, 07 Aug 2007 15:38:40 +0200
> > Takashi Iwai <tiwai@xxxxxxx> wrote:
> > 
> > > At Mon, 6 Aug 2007 09:22:01 -0700,
> > > stan wrote:
> > > > 
> > > > On Mon, 6 Aug 2007 09:04:57 -0700
> > > > stan <stanl@xxxxxxx> 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@xxxxxxxxxxxxxxxx
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

Attachment: mktest
Description: Binary data

#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) ;
		} ;
}              
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux