All of lore.kernel.org
 help / color / mirror / Atom feed
* libasound dies on snd_pcm_open
@ 2003-02-11 20:47 M. Ritscher
  2003-02-12 17:48 ` M. Ritscher
  0 siblings, 1 reply; 8+ messages in thread
From: M. Ritscher @ 2003-02-11 20:47 UTC (permalink / raw)
  To: alsa-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!

Hope, this isn't a too stupid question...

I've got a problem whilst trying to port my application to the ALSA API.

Following piece of code gives me an error when executed:

- ----------
if ((rc = snd_pcm_open (&capture_handle, sDevice.ascii(),
                          SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK)) < 0) {
      std::cerr << "cannot open audio device" << sDevice << snd_strerror (rc);
      return rc;
}

Definitions:

QString sDevice;
snd_pcm_t *capture_handle;

- ----------

Stopped due to library event.

The stack trace gives me the following:

=========================================================
0x4000a760 in _dl_debug_state () from /lib/ld-linux.so.2 
0x4099deb2 in _dl_open_worker () from /lib/libc.so.6 
0x40009f96 in _dl_catch_error () from /lib/ld-linux.so.2
0x40e9elf5 in _dl_open () from /llb/lilic.so.6
0x404a4et9 in dlopen_doit () from /lib/libdl.so.2 
0x4000ffl6 in _dl_catch_error () from /iib/Id-linux,so.2
0x404a52f4 in _dlerror_run () from /lib/libdl.so.2 
0x404a4f44 in dlopen@@GLIBC_2.1 () from /lib/libdl.so.2 
0x400496cd in snd_dlopen () from /usr/lib/libasound.so.2 
0x40043764 in snd_config_hooks_call () from /usr/lib/libasound.so.2
0x400439d6 in snd_contig_hooks () from lusr/lib/libasound.so.2 
0x40044387 in snd_config_update_r () from /usr/lib/libasound.so.2 
0x40044918 in snd_config_update () from /usr/lib/libasound.so.2 
0x4005d16d in snd_pcm_open() from /usr/lib/libasound.so.2 
0x08056505 in KCorrView::openALSADevice() (this=Ox80e5f1 0) at 
kconview.cpp:579
0x0805585c in KCorrView::openDevice () (this=Ox6095f1 0) at kcorrview.cpp:334 
0x080564c9 in KCoaView::resume () (thls=Ox80e5f1 0) at kcorrview.cpp:571 
0x0805a301 in KCorrMeter (this=Ox80d1328, parent=Ox0, name--0x0) at 
kcorrmeter.cpp:39
0x0805abec in main (argc=l, argv=Oxbfff1414) at main.cpp:49 
0x40dbf4a2 in __libc_start_main () from /lib/libc.so.6
=========================================================

(SuSE 8.1, kernel 2.4.19, alsa 0.9 rc7)

I don't really know where to start looking. 

Even more strange, it was working but failed later with a broken pipe
- ---------------------------------------------------------
long rc = snd_pcm_readi (capture_handle, sBuf, 128);
- ---------------------------------------------------------
And I havn't touched the  openALSADevice(), honestly! 

Any pointers welcome.

Cheers,

Meinhard
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE+SWFpv2LRaMHePXMRAgRiAKCAbxpz4QjHBIpxboreEgddJhR/qACg6cPX
GjMDuYFio5VXtgkQKB/jMF8=
=ALyd
-----END PGP SIGNATURE-----



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: libasound dies on snd_pcm_open
  2003-02-11 20:47 libasound dies on snd_pcm_open M. Ritscher
@ 2003-02-12 17:48 ` M. Ritscher
  2003-02-12 18:18   ` Takashi Iwai
  2003-02-13 20:37   ` M. Ritscher
  0 siblings, 2 replies; 8+ messages in thread
From: M. Ritscher @ 2003-02-12 17:48 UTC (permalink / raw)
  To: alsa-devel

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi again,

On Tuesday 11 February 2003 21:47, M. Ritscher wrote:
> Stopped due to shared library event.
>
I've now compiled a version of libasound with debug enabled and found out that 
it dies on me on line 61 of dlmisc.c
Stopped due to shared library event.

===========================
void *snd_dlopen(const char *name, int mode)
{
<cut>
###>>>	return dlopen(name, mode);
}
============================

name: "/usr/lib/libasound.so.2 (which correctly links to libasound.so.2.0.0)
mode: 2

I've played around with my code a bit and have tried to reduce it to a 
minimum, still, no luck.
============================================
int KCorrView::openNewALSADev(){
 snd_pcm_t *capture_hd;
 int err = 0;
 
 if ((err = snd_pcm_open(&capture_hd, 
         "hwplug:0,0", SND_PCM_STREAM_CAPTURE, 0)) < 0) {
   return err;
 }
return err;
}
============================================

Am I missing the obvious? 

Any help really appreciated.

Thanks,

Meinhard
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE+Sojjv2LRaMHePXMRAmGiAJ99ACyZBFcUXIJogUObV2ZxJkH2/gCeMqIu
MuESBrYRINM20GAoMx2CMH0=
=XHOX
-----END PGP SIGNATURE-----



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: libasound dies on snd_pcm_open
  2003-02-12 17:48 ` M. Ritscher
@ 2003-02-12 18:18   ` Takashi Iwai
  2003-02-12 22:38     ` M. Ritscher
  2003-02-13 20:37   ` M. Ritscher
  1 sibling, 1 reply; 8+ messages in thread
From: Takashi Iwai @ 2003-02-12 18:18 UTC (permalink / raw)
  To: M. Ritscher; +Cc: alsa-devel

At Wed, 12 Feb 2003 18:48:12 +0100,
M. Ritscher <mr203010spam@gmx.net> wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi again,
> 
> On Tuesday 11 February 2003 21:47, M. Ritscher wrote:
> > Stopped due to shared library event.
> >
> I've now compiled a version of libasound with debug enabled and found out that 
> it dies on me on line 61 of dlmisc.c
> Stopped due to shared library event.
> 
> ===========================
> void *snd_dlopen(const char *name, int mode)
> {
> <cut>
> ###>>>	return dlopen(name, mode);
> }
> ============================
> 
> name: "/usr/lib/libasound.so.2 (which correctly links to libasound.so.2.0.0)
> mode: 2
> 
> I've played around with my code a bit and have tried to reduce it to a 
> minimum, still, no luck.
> ============================================
> int KCorrView::openNewALSADev(){
>  snd_pcm_t *capture_hd;
>  int err = 0;
>  
>  if ((err = snd_pcm_open(&capture_hd, 
>          "hwplug:0,0", SND_PCM_STREAM_CAPTURE, 0)) < 0) {
            ^^^^^^

is this correct?  not "plughw:0,0" ?


Takashi


-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: libasound dies on snd_pcm_open
  2003-02-12 18:18   ` Takashi Iwai
@ 2003-02-12 22:38     ` M. Ritscher
  0 siblings, 0 replies; 8+ messages in thread
From: M. Ritscher @ 2003-02-12 22:38 UTC (permalink / raw)
  To: alsa-devel

On Wednesday 12 February 2003 19:18, Takashi Iwai wrote:
> >  if ((err = snd_pcm_open(&capture_hd,
> >          "hwplug:0,0", SND_PCM_STREAM_CAPTURE, 0)) < 0) {
>             ^^^^^^
>
> is this correct?  not "plughw:0,0" ?
Well, sorry, "plughw:0,0" of course. Doesn't change anything though.

Meinhard


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: libasound dies on snd_pcm_open
  2003-02-12 17:48 ` M. Ritscher
  2003-02-12 18:18   ` Takashi Iwai
@ 2003-02-13 20:37   ` M. Ritscher
  2003-02-13 21:00     ` Jaroslav Kysela
  1 sibling, 1 reply; 8+ messages in thread
From: M. Ritscher @ 2003-02-13 20:37 UTC (permalink / raw)
  To: alsa-devel

[-- Attachment #1: clearsigned data --]
[-- Type: Text/Plain, Size: 851 bytes --]

Hi again,

seems I was following a red herring. My debugger mislead me.
The function 'snd_pcm_open()' isn't the culprit, it really dies here:

==========================
int rc = 0;

int exactRate
     = snd_pcm_hw_params_set_rate_near (capture_handle, hw_params, 
&uSampleRate, &rc);
	if(rc !=  0) {
==========================
With the following definitions, declarations:
unsigned int uSampleRate - value 16100;
snd_pcm_t *capture_handle;
snd_pcm_hw_params_t *hw_params;

//ALSA library
#define ALSA_PCM_NEW_HW_PARAMS_API
#include <alsa/asoundlib.h>

It never returns from the call to "snd_pcm_hw_params_set_rate_near" and the 
cpu is maxing out.

What I'm doing wrong? I'm really clueless now.

You can see from the attached text file what I've been trying...


Any help really appreciated.

Thanks,

Meinhard
>

[-- Attachment #2: openAlsaDevice.cpp --]
[-- Type: text/x-c++src, Size: 2998 bytes --]


int KCorrView::openALSADevice(){

	int rc = 0;
	snd_pcm_hw_params_t *hw_params;
	const char *cTemp = 0;
	//snd_pcm_access_t access = ;


	cTemp = sDevice.ascii();
	std::cerr <<  sDevice << std::endl;
	if ((rc = snd_pcm_open (&capture_handle, sDevice.ascii(),
														SND_PCM_STREAM_CAPTURE, 0)) < 0) {
		std::cerr << "cannot open audio device" << sDevice << snd_strerror (rc);
		return rc;
	}
/*	if ((rc = snd_pcm_hw_params_malloc (&hw_params)) < 0) {
		std::cerr << "cannot allocate hardware parameter structure" <<  snd_strerror (rc);
		return rc;
	} */

	snd_pcm_hw_params_alloca (&hw_params);
	
	if ((rc = snd_pcm_hw_params_any (capture_handle, hw_params)) < 0) {
		std::cerr << "cannot initialize hardware parameter structure" << snd_strerror (rc);
		return rc;
	}
	
	if ((rc = snd_pcm_hw_params_set_access (capture_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
		// cerr << "cannot set access type" << snd_strerror (rc);
		return rc;
	}
	if ((rc = snd_pcm_hw_params_set_format (capture_handle, hw_params, SND_PCM_FORMAT_S16_LE)) < 0) {
		std::cerr << "cannot set sample format " << snd_strerror (rc);
		return rc;
	}
	
	if ((rc = snd_pcm_hw_params_set_channels(capture_handle, hw_params, 2))  < 0) {
		std::cerr << "Could not set to stereo" << snd_strerror(rc) << std::endl;
		return rc;
	}

/*	int exactRate
	      = snd_pcm_hw_params_set_rate_near (capture_handle, hw_params, &uSampleRate, &rc);
	if(rc !=  0) {
		std::cerr << "Sample rate " << uSampleRate << "is'nt supported by your hardware. Using "
		 << exactRate << "Hz instaed. " << std::endl;
	}
	std::cout << "snd_pcm_hw_params_set_rate_near returned with:  " << exactRate << std::endl;
	*/

	unsigned int rrate = uSampleRate;
	if((rc = snd_pcm_hw_params_set_rate_near (capture_handle, hw_params, &rrate, 0)) < 0){
		std::cerr << "Failed to set sample rate: "<< uSampleRate <<  snd_strerror (rc);
	}
	if(rrate !=  uSampleRate) {
		std::cerr << "Sample rate " << uSampleRate << "is'nt supported by your hardware. Using "
		 << rrate << "Hz instaed. " << std::endl;
	}
	std::cout << "snd_pcm_hw_params_set_rate_near returned with:  " << rc << std::endl;


	if ((rc = snd_pcm_hw_params_set_channels (capture_handle, hw_params, 2)) < 0) {
		std::cerr << "cannot set channel count " << snd_strerror (rc);
		return rc;
	}
	if ((rc = snd_pcm_hw_params (capture_handle, hw_params)) < 0) {
		std::cerr << "cannot set parameters " << snd_strerror (rc);
		return rc;
	}
	snd_pcm_hw_params_free (hw_params);
	if ((rc = snd_pcm_prepare (capture_handle)) < 0) {
		std::cerr << "cannot prepare audio interface for use " << snd_strerror (rc);
		return rc;
	}

  std::cout << "successfully set up ALSA 0.9 device" << std::endl;

  char buf[512];
  long a;

	if ((a = snd_pcm_readi (capture_handle, buf, 128)) < 0) {
			std::cerr << "read from audio interface failed: " << snd_strerror (a) << std::endl;
			return -1;
	}
	/*
	for(int i=0; i <128; i++){
			std::cout << buf[i];
	}
	std::cout << "  " << std::endl;
	*/
	return rc;
}

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: libasound dies on snd_pcm_open
  2003-02-13 20:37   ` M. Ritscher
@ 2003-02-13 21:00     ` Jaroslav Kysela
  2003-02-14  7:00       ` mr203010spam
  2003-02-14 14:44       ` M. Ritscher
  0 siblings, 2 replies; 8+ messages in thread
From: Jaroslav Kysela @ 2003-02-13 21:00 UTC (permalink / raw)
  To: M. Ritscher; +Cc: alsa-devel@lists.sourceforge.net

On Thu, 13 Feb 2003, M. Ritscher wrote:

> Hi again,
> 
> seems I was following a red herring. My debugger mislead me.
> The function 'snd_pcm_open()' isn't the culprit, it really dies here:

Before we start any debugging - are you using the alsa-lib from CVS? I've 
fixed some problems which may relate to your report a few days ago.

						Jaroslav

-----
Jaroslav Kysela <perex@suse.cz>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs



-------------------------------------------------------
This SF.NET email is sponsored by: FREE  SSL Guide from Thawte
are you planning your Web Server Security? Click here to get a FREE
Thawte SSL guide and find the answers to all your  SSL security issues.
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: libasound dies on snd_pcm_open
  2003-02-13 21:00     ` Jaroslav Kysela
@ 2003-02-14  7:00       ` mr203010spam
  2003-02-14 14:44       ` M. Ritscher
  1 sibling, 0 replies; 8+ messages in thread
From: mr203010spam @ 2003-02-14  7:00 UTC (permalink / raw)
  To: alsa-devel

Hi Jaroslav,

> Before we start any debugging - are you using the alsa-lib from CVS? I've 
> fixed some problems which may relate to your report a few days ago.
> 
No, I'm using 0.9rc7. Seems I have to make myself familiar with using the
CVS version than.

Cheer,

Meinhard

-- 
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!



-------------------------------------------------------
This SF.NET email is sponsored by: FREE  SSL Guide from Thawte
are you planning your Web Server Security? Click here to get a FREE
Thawte SSL guide and find the answers to all your  SSL security issues.
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: libasound dies on snd_pcm_open
  2003-02-13 21:00     ` Jaroslav Kysela
  2003-02-14  7:00       ` mr203010spam
@ 2003-02-14 14:44       ` M. Ritscher
  1 sibling, 0 replies; 8+ messages in thread
From: M. Ritscher @ 2003-02-14 14:44 UTC (permalink / raw)
  To: alsa-devel

On Thursday 13 February 2003 22:00, Jaroslav Kysela wrote:
> are you using the alsa-lib from CVS?
Thanks Jaroslav, that fixed the problem. At least the one with the library. 
Now I can start debugging my own code...

Cheers,

Meinhard



-------------------------------------------------------
This SF.NET email is sponsored by: FREE  SSL Guide from Thawte
are you planning your Web Server Security? Click here to get a FREE
Thawte SSL guide and find the answers to all your  SSL security issues.
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0026en

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2003-02-14 14:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-11 20:47 libasound dies on snd_pcm_open M. Ritscher
2003-02-12 17:48 ` M. Ritscher
2003-02-12 18:18   ` Takashi Iwai
2003-02-12 22:38     ` M. Ritscher
2003-02-13 20:37   ` M. Ritscher
2003-02-13 21:00     ` Jaroslav Kysela
2003-02-14  7:00       ` mr203010spam
2003-02-14 14:44       ` M. Ritscher

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.