All of lore.kernel.org
 help / color / mirror / Atom feed
* Alsa not working when linked to a library
@ 2009-09-25 17:05 Fortini Matteo
  2009-09-25 17:10 ` Fortini Matteo
  2009-09-29  9:27 ` Takashi Iwai
  0 siblings, 2 replies; 3+ messages in thread
From: Fortini Matteo @ 2009-09-25 17:05 UTC (permalink / raw)
  To: alsa-devel

Hi,
I'm experiencing a very strange behavior.

I'm using alsa 1.0.18 on a powerpc platform.

If I run the following simple code from the main of a .c file, it works 
perfectly, but if I put into a shared .so library (libaudio.so), then I 
link the main with -laudio -lasound, then the hwparams structure is not 
filled with anything, while the alsa functions don't return any error.

Do you have any clue why this could happen?

TIA

############################################################
int play_sample(char *pcm_name, char *samplename)
{
    int res;
    snd_pcm_t *pcm_handle;         
    snd_pcm_hw_params_t *hwparams;           
    const char *name= (pcm_name != NULL) ? pcm_name : "speaker";

    if ( (res = snd_pcm_open(&pcm_handle, name, SND_PCM_STREAM_PLAYBACK, 
0)) < 0) {
        fprintf(stderr, "Error opening PCM device %s\n", pcm_name);
        return 1;
    } else {
        printf ("snd_pcm_open returned %d\n", res);
    }

  
    snd_pcm_hw_params_malloc(&hwparams);
    if (snd_pcm_hw_params_any(pcm_handle, hwparams) < 0) {
        fprintf(stderr, "Can not configure this PCM device.\n");
        return 1;

   snd_pcm_close(pcm_handle);
}


int main (void)
{
    play_sample (NULL, "test_sound.wav);

    return 0;
}
############################################################

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

* Re: Alsa not working when linked to a library
  2009-09-25 17:05 Alsa not working when linked to a library Fortini Matteo
@ 2009-09-25 17:10 ` Fortini Matteo
  2009-09-29  9:27 ` Takashi Iwai
  1 sibling, 0 replies; 3+ messages in thread
From: Fortini Matteo @ 2009-09-25 17:10 UTC (permalink / raw)
  To: alsa-devel@alsa-project.org

Just to add:
(yes I know I didn't free the hwparams structure, but it is done in the 
rest of the code I cut)

the "speaker" device is virtual, generated with dmix on asound.conf:
pcm.pcm1774 {
    type hw
    card 0
}
ctl.pcm1774 {
    type hw
    card 0
}

pcm.buzzer {
        type dshare
        ipc_key 6678293
        ipc_key_add_uid yes
        slave {
                pcm "hw:0,0"
                buffer_size 16384
                period_time 2
                period_size 1024
        }
        bindings {
                0 0
        }
}

pcm.speaker {
        type dshare
        ipc_key 6678293
        ipc_key_add_uid yes
        slave {
                pcm "hw:0,0"
                buffer_size 16384
                period_time 2
                period_size 1024
        }
        bindings {
                0 1
        }
}



Fortini Matteo ha scritto:
> Hi,
> I'm experiencing a very strange behavior.
>
> I'm using alsa 1.0.18 on a powerpc platform.
>
> If I run the following simple code from the main of a .c file, it works 
> perfectly, but if I put into a shared .so library (libaudio.so), then I 
> link the main with -laudio -lasound, then the hwparams structure is not 
> filled with anything, while the alsa functions don't return any error.
>
> Do you have any clue why this could happen?
>
> TIA
>
> ############################################################
> int play_sample(char *pcm_name, char *samplename)
> {
>     int res;
>     snd_pcm_t *pcm_handle;         
>     snd_pcm_hw_params_t *hwparams;           
>     const char *name= (pcm_name != NULL) ? pcm_name : "speaker";
>
>     if ( (res = snd_pcm_open(&pcm_handle, name, SND_PCM_STREAM_PLAYBACK, 
> 0)) < 0) {
>         fprintf(stderr, "Error opening PCM device %s\n", pcm_name);
>         return 1;
>     } else {
>         printf ("snd_pcm_open returned %d\n", res);
>     }
>
>   
>     snd_pcm_hw_params_malloc(&hwparams);
>     if (snd_pcm_hw_params_any(pcm_handle, hwparams) < 0) {
>         fprintf(stderr, "Can not configure this PCM device.\n");
>         return 1;
>
>    snd_pcm_close(pcm_handle);
> }
>
>
> int main (void)
> {
>     play_sample (NULL, "test_sound.wav);
>
>     return 0;
> }
> ############################################################
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
>   

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

* Re: Alsa not working when linked to a library
  2009-09-25 17:05 Alsa not working when linked to a library Fortini Matteo
  2009-09-25 17:10 ` Fortini Matteo
@ 2009-09-29  9:27 ` Takashi Iwai
  1 sibling, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2009-09-29  9:27 UTC (permalink / raw)
  To: Fortini Matteo; +Cc: alsa-devel

At Fri, 25 Sep 2009 19:05:50 +0200,
Fortini Matteo wrote:
> 
> Hi,
> I'm experiencing a very strange behavior.
> 
> I'm using alsa 1.0.18 on a powerpc platform.
> 
> If I run the following simple code from the main of a .c file, it works 
> perfectly, but if I put into a shared .so library (libaudio.so), then I 
> link the main with -laudio -lasound, then the hwparams structure is not 
> filled with anything, while the alsa functions don't return any error.
> 
> Do you have any clue why this could happen?

I guess it's an issue regarding the versioned symbols.
Your library (libaudio.so) should be also linked with libasound.so
so that the linker can pick up the proper versioned symbols.


Takashi

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

end of thread, other threads:[~2009-09-29  9:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-25 17:05 Alsa not working when linked to a library Fortini Matteo
2009-09-25 17:10 ` Fortini Matteo
2009-09-29  9:27 ` 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.