[+PLUS] Problem in accessing /dev/dsp
Riyaz Usman
riyazusman at gmail.com
Sun Jan 7 00:23:18 IST 2007
Great Santhosh. Hope this will provide a great momentum for the project,
All the best.
On 1/6/07, Santhosh Thottingal <santhosh00 at gmail.com> wrote:
>
> Got the solution..
> see the below code
>
> /* USE: gcc sndtest2.c -lasound to compile :-)*/
> /* also insure alsa-lib and alsa-lib-devel are installed */
> #include<stdio.h>
> #include<alsa/asoundlib.h>
> snd_output_t *output=NULL;
> static char *device="default"; /* playback device */
> unsigned char buffer[16000*16*300*2/8];
> int main(int argc, char *argv[]){
> int err;
> int rfd;
> unsigned int i;
> snd_pcm_t *handle;
> snd_pcm_sframes_t frames;
> rfd=open(argv[1], O_RDONLY);
> if((err=snd_pcm_open(&handle,device, SND_PCM_STREAM_PLAYBACK,0))<0){
> perror("Playback open error");
> exit(1);
> }
>
> if((err= snd_pcm_set_params(handle,
> SND_PCM_FORMAT_S16_LE,
> SND_PCM_ACCESS_RW_INTERLEAVED,
> 1,
> 16000,
> 1,
> 500000))<0){
>
> printf("Playback open error: %s\n", snd_strerror(err));
> exit(1);
> }
> while(1){
> read(rfd, buffer, sizeof(buffer));
> frames=snd_pcm_writei(handle,buffer,sizeof(buffer));
> if(frames<0){
> printf("snd_pcm_writei failed: %s\n", snd_strerror(err));
> break;
>
> }
> if(frames>0 && frames < (long)sizeof(buffer))
> printf("Short write (expected %li, wrote %li)\n",
> (long)sizeof(buffer), frames);
>
> }
> snd_pcm_close(handle);
>
> return 0;
>
> }
>
> This will multiplex the /dev/dsp device and we can any number of programs
> that access /dev/dsp at the same time.
>
>
> On 1/5/07, Santhosh Thottingal <santhosh00 at gmail.com> wrote:
> >
> > Thanks for your input...
> > Killing the process does not seem to be a good choice.
> > I got some sample code to play sound files using ALSA
> > library(alsa/asoundlib.h from alsa-lib and alsa-lib-devel) from one friend.
> > I will update you after trying it.
> > Thanks,
> > -santhosh
> >
> > On 1/5/07, Pramode C.E. < pramode_ce at yahoo.co.in> wrote:
> >
> > > >
> > > > The problem I am experiencing here is,
> > > > if artsd (or any sound
> > > > system) is holding this device I cannot use
> > > > /dev/dsp. And I cannot guess the
> > > > sound system running on the machine this program is
> > > > going to run. If I kill
> > >
> > > I think there is something called `artsdsp' which
> > > translates calls to /dev/dsp to arts api functions -
> > > but that doesn't solve your problem. Maybe, the only
> > > way out is to use something like `fuser', identify the
> > > process using the sound device and kill it.
> > >
> > >
> > >
> > >
> > > ====================
> > > Pramode C.E
> > > http://pramode.net
> > > ====================
> > >
> > > Send free SMS to your Friends on Mobile from your Yahoo! Messenger.
> > > Download Now! http://messenger.yahoo.com/download.php
> > >
> > >
> > >
> > > _______________________________________________
> > > Palakkad Libre software Users Society Main Mailing List
> > > "Adding freedom to common minds"
> > >
> > > PLUS-discuss at lists.sarovar.org
> > > http://lists.sarovar.org/cgi-bin/mailman/listinfo/plus-discuss
> > >
> > >
> >
>
> _______________________________________________
> Palakkad Libre software Users Society Main Mailing List
> "Adding freedom to common minds"
>
> PLUS-discuss at lists.sarovar.org
> http://lists.sarovar.org/cgi-bin/mailman/listinfo/plus-discuss
>
>
--
Riyaz Usman
http://riyaz.bitinc.co.in
1d:c5:fb:59:df:ec:79:88:ec:81:d9:3a:87:28:10:25
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.sarovar.org/pipermail/plus-discuss/attachments/20070107/759944f6/attachment.xhtml
More information about the PLUS-discuss
mailing list