* hw_params from shared library problem
@ 2006-06-26 21:11 Gerald Grabner
2006-06-26 21:38 ` Lee Revell
2006-06-27 7:14 ` Benoit Fouet
0 siblings, 2 replies; 5+ messages in thread
From: Gerald Grabner @ 2006-06-26 21:11 UTC (permalink / raw)
To: alsa-devel
Hi everybody,
I'm wondering how to correctly build a shared library using alsa
pcm. Setting the hardware parameters in a function which is part of a
shared library produces an error, snd_pcm_hw_params gives "invalid
argument". The example below with three primitive files (main file,
header and function code) illustrates the problem. With a static
library, everything works fine.
My system: gcc 3.4.6 on Gentoo with alsa 1.0.11.
Does anybody have an idea about the cause of this problem or how to
solve it?
Many thanks,
Gerald
***
main.c:
#include "object.h"
int main()
{
object () ;
return 0;
}
object.h:
void object();
object.c:
#include <alsa/asoundlib.h>
#include "object.h"
void object ()
{
snd_pcm_t* pcm;
snd_pcm_hw_params_t* hwparams;
int rc;
unsigned int rate = 44100;
unsigned int channels = 2;
int dir = 0;
if ( snd_pcm_open(&pcm, "default", SND_PCM_STREAM_PLAYBACK, 0) < 0 )
printf("Cannot open pcm.\n");
snd_pcm_hw_params_alloca(&hwparams);
snd_pcm_hw_params_any(pcm, hwparams);
snd_pcm_hw_params_set_access(pcm, hwparams,
SND_PCM_ACCESS_RW_INTERLEAVED);
snd_pcm_hw_params_set_format(pcm, hwparams, SND_PCM_FORMAT_S16_LE);
snd_pcm_hw_params_set_channels (pcm, hwparams, channels);
snd_pcm_hw_params_set_rate_near(pcm, hwparams, &rate, &dir);
rc = snd_pcm_hw_params(pcm, hwparams) ;
if ( rc < 0 )
printf("Error setting hw params: %s.\n", snd_strerror(rc));
}
Compilation:
gcc -c -fPIC object.c
gcc -shared -fPIC -o libTest.so object.o
gcc -o main main.c -L. -lTest -lasound
Output:
Error setting hw params: Invalid argument.
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: hw_params from shared library problem
2006-06-26 21:11 hw_params from shared library problem Gerald Grabner
@ 2006-06-26 21:38 ` Lee Revell
2006-06-27 7:14 ` Benoit Fouet
1 sibling, 0 replies; 5+ messages in thread
From: Lee Revell @ 2006-06-26 21:38 UTC (permalink / raw)
To: Gerald Grabner; +Cc: alsa-devel
On Mon, 2006-06-26 at 23:11 +0200, Gerald Grabner wrote:
> Hi everybody,
>
> I'm wondering how to correctly build a shared library using alsa
> pcm. Setting the hardware parameters in a function which is part of a
> shared library produces an error, snd_pcm_hw_params gives "invalid
> argument". The example below with three primitive files (main file,
> header and function code) illustrates the problem. With a static
> library, everything works fine.
>
> My system: gcc 3.4.6 on Gentoo with alsa 1.0.11.
>
> Does anybody have an idea about the cause of this problem or how to
> solve it?
>
Cannot reproduce it here. It works perfectly. Toolchain bug?
Lee
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: hw_params from shared library problem
2006-06-26 21:11 hw_params from shared library problem Gerald Grabner
2006-06-26 21:38 ` Lee Revell
@ 2006-06-27 7:14 ` Benoit Fouet
2006-06-27 17:08 ` Gerald Grabner
1 sibling, 1 reply; 5+ messages in thread
From: Benoit Fouet @ 2006-06-27 7:14 UTC (permalink / raw)
To: Gerald Grabner; +Cc: alsa-devel
Hi,
Gerald Grabner wrote:
>Hi everybody,
>
>I'm wondering how to correctly build a shared library using alsa
>pcm. Setting the hardware parameters in a function which is part of a
>shared library produces an error, snd_pcm_hw_params gives "invalid
>argument". The example below with three primitive files (main file,
>header and function code) illustrates the problem. With a static
>library, everything works fine.
>
>My system: gcc 3.4.6 on Gentoo with alsa 1.0.11.
>
>Does anybody have an idea about the cause of this problem or how to
>solve it?
>
>Many thanks,
>Gerald
>
>***
>
>main.c:
> #include "object.h"
> int main()
> {
> object () ;
> return 0;
> }
>
>object.h:
> void object();
>
>object.c:
> #include <alsa/asoundlib.h>
> #include "object.h"
> void object ()
> {
> snd_pcm_t* pcm;
> snd_pcm_hw_params_t* hwparams;
> int rc;
> unsigned int rate = 44100;
> unsigned int channels = 2;
> int dir = 0;
> if ( snd_pcm_open(&pcm, "default", SND_PCM_STREAM_PLAYBACK, 0) < 0 )
> printf("Cannot open pcm.\n");
> snd_pcm_hw_params_alloca(&hwparams);
> snd_pcm_hw_params_any(pcm, hwparams);
> snd_pcm_hw_params_set_access(pcm, hwparams,
>SND_PCM_ACCESS_RW_INTERLEAVED);
> snd_pcm_hw_params_set_format(pcm, hwparams, SND_PCM_FORMAT_S16_LE);
> snd_pcm_hw_params_set_channels (pcm, hwparams, channels);
> snd_pcm_hw_params_set_rate_near(pcm, hwparams, &rate, &dir);
> rc = snd_pcm_hw_params(pcm, hwparams) ;
> if ( rc < 0 )
> printf("Error setting hw params: %s.\n", snd_strerror(rc));
> }
>
>Compilation:
> gcc -c -fPIC object.c
> gcc -shared -fPIC -o libTest.so object.o
> gcc -o main main.c -L. -lTest -lasound
>
>
and what if you try to link your dynamic library with asound (actually,
this is the really needer of the link, not your test program) ? I think
this could help...
gcc -shared -fPIC -o libTest.so object.o -lasound
-- Ben
>Output:
> Error setting hw params: Invalid argument.
>
>Using Tomcat but need to do more? Need to support web services, security?
>Get stuff done quickly with pre-integrated technology to make your job easier
>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
>http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
>_______________________________________________
>Alsa-devel mailing list
>Alsa-devel@lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/alsa-devel
>
>
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: hw_params from shared library problem
2006-06-27 7:14 ` Benoit Fouet
@ 2006-06-27 17:08 ` Gerald Grabner
2006-06-27 17:16 ` Takashi Iwai
0 siblings, 1 reply; 5+ messages in thread
From: Gerald Grabner @ 2006-06-27 17:08 UTC (permalink / raw)
To: alsa-devel
Benoit Fouet wrote:
>> Compilation:
>> gcc -c -fPIC object.c
>> gcc -shared -fPIC -o libTest.so object.o
>> gcc -o main main.c -L. -lTest -lasound
>>
>>
> and what if you try to link your dynamic library with asound (actually,
> this is the really needer of the link, not your test program) ? I think
> this could help...
>
> gcc -shared -fPIC -o libTest.so object.o -lasound
Hey, thanks a lot, that did the trick!
Interestingly, other libraries I am using do not require to be specified
when building the shared library.
Gerald
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: hw_params from shared library problem
2006-06-27 17:08 ` Gerald Grabner
@ 2006-06-27 17:16 ` Takashi Iwai
0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2006-06-27 17:16 UTC (permalink / raw)
To: Gerald Grabner; +Cc: alsa-devel
At Tue, 27 Jun 2006 19:08:57 +0200,
Gerald Grabner wrote:
>
> Benoit Fouet wrote:
>
> >> Compilation:
> >> gcc -c -fPIC object.c
> >> gcc -shared -fPIC -o libTest.so object.o
> >> gcc -o main main.c -L. -lTest -lasound
> >>
> >>
> > and what if you try to link your dynamic library with asound (actually,
> > this is the really needer of the link, not your test program) ? I think
> > this could help...
> >
> > gcc -shared -fPIC -o libTest.so object.o -lasound
>
> Hey, thanks a lot, that did the trick!
>
> Interestingly, other libraries I am using do not require to be specified
> when building the shared library.
It's most likely due to versioned symbols used in alsa-lib.
Takashi
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-06-27 17:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-26 21:11 hw_params from shared library problem Gerald Grabner
2006-06-26 21:38 ` Lee Revell
2006-06-27 7:14 ` Benoit Fouet
2006-06-27 17:08 ` Gerald Grabner
2006-06-27 17:16 ` Takashi Iwai
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.