Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Help
@ 2008-07-24  7:18 Sudeept Prusti
  2008-07-24 16:53 ` Help stan
  0 siblings, 1 reply; 8+ messages in thread
From: Sudeept Prusti @ 2008-07-24  7:18 UTC (permalink / raw)
  To: alsa-devel

Hi all,
 
As i am working on ALSA for last few weeks.Can anyone guide where can i get
moe informative things on ALSA internals (Internally how alsa works).
 
Could anyone suggest what are validation scenario on alsa driver flow.
 
Thanks a lot.
 
Awaiting for response soon.
 
Regards,
Sudeept

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments contained in it.

Contact your Administrator for further information.

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Help
@ 2009-04-24 11:31 Sudeept Prusti
  2009-04-24 11:39 ` Help Jaroslav Kysela
  0 siblings, 1 reply; 8+ messages in thread
From: Sudeept Prusti @ 2009-04-24 11:31 UTC (permalink / raw)
  To: alsa-devel

Hi all,
 
As i am working on alsa for minimal PCM playback (8khz,mono,16 bit pcm file).
 
When i tried to allocate 1k buffer and send through snd_pcm_writei() call it doesn't play perfect and skips are there in between. If we keep on increasing in allocating the buffer for 31 kb then it could play the buffers randomly.
 
Code is attached for ur reference below.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include <alsa/asoundlib.h>
#include <stdio.h>
#include <stdlib.h>

#define  k	(31*1024)

static void playback(FILE *fd);

int main(int argc, char *argv[]) 
{
  FILE *fd;
  fd = fopen(argv[1],"r");
  playback(fd);
  return 0;
}

static void playback(FILE *fd)
{
  int rc,err;
  snd_pcm_t *handle;
  snd_pcm_hw_params_t *params;
  unsigned int val;
  snd_pcm_uframes_t frames;
  unsigned char *buffer;
  int seek_size=0;
  int nonblock = 0;

  printf("Entered Playback Module \n");
	
  /* Open PCM device for playback. */
  rc = snd_pcm_open(&handle, "default",SND_PCM_STREAM_PLAYBACK, 0);
  if(rc >= 0)
  {
  	printf("Open PCM Success:  %d \n",rc);
  }
  if (rc < 0) {
    	fprintf(stderr,"unable to open pcm device: %s\n",snd_strerror(rc));
	exit(1);
  }
  
  /* PCM Hardware Parameters Allocation.  */
  err = snd_pcm_hw_params_malloc (&params);

  if(err>=0)
  {
	printf("Hardware Params Allocation Success:  %d \n",err);
  }

  if (err < 0)
  {
  	fprintf (stderr, "cannot allocate hardware parameter structure (%s)\n", snd_strerror (err));
      	exit (1);
  }
  /* Intialize PCM Hardware Parameters */	
  err = snd_pcm_hw_params_any(handle, params);
  if(err >=0)
  {
  	printf("PCM HW params Initialization Success : %d \n",err);
  }
  if (err < 0)
  {
	printf("Cannot initialize hardware parameter structure \n");
	exit(EXIT_FAILURE);
  }

  /* Set the PCM Hardware parameters. */

  /* Interleaved mode */
  err = snd_pcm_hw_params_set_access(handle, params,SND_PCM_ACCESS_RW_INTERLEAVED);
  if (err >= 0)
  {
	printf("Access Type Available: %d \n",err);
  }
  if (err < 0)
  {
	printf("Access Type Not-available: %d \n",err);
	exit(EXIT_FAILURE);
   }

  /* Signed 16-bit little-endian format */
  err = snd_pcm_hw_params_set_format(handle, params,SND_PCM_FORMAT_S16_LE);
  if (err >= 0)
  {
	printf("Sample format Available: %d \n",err);
  }
  if (err < 0)
  {
	printf("Sample format Non-Available \n");
	exit(EXIT_FAILURE);
  }

  /* One Channel (Mono) */
  err = snd_pcm_hw_params_set_channels(handle, params, 1);
  if (err >= 0)
  {
	printf("Channels Available: %d \n",err);
  }
  if (err < 0)
  {
	printf("Channels Non-Available \n");
	exit(EXIT_FAILURE);
  }

  /* 8khz sampling rate */
  err = snd_pcm_hw_params_set_rate (handle, params, 8000, 0);
  if (err >= 0)
  {
      	printf ("Sample Rate Set Success: %d \n",err);
  }
  if (err < 0)
  {
      	fprintf (stderr, "cannot set sample rate (%s)\n", snd_strerror (err));
      	exit (EXIT_FAILURE);
  }
  
  /* Write the parameters to the alsa-driver */
  rc = snd_pcm_hw_params(handle, params);
  if(rc >=0)
  {
  	printf("Set HW Parameters Success: %d \n",rc);
  }
  if (rc < 0)
  {
   	fprintf(stderr,"Unable to Set HW Parameters: %s\n",snd_strerror(rc));
	exit(1);
  }
  /* Allocate buffer*/
  buffer = (unsigned char *) malloc(k);

  if (buffer == NULL)
  {
	printf("Not Enough Memory: %c \n",buffer);
	exit(1);
  }

  while (!feof(fd))
  {
    if(fd != NULL)
    {
 	printf("File pointer is not NULL \n");
    }
    printf("Current Position of File Pointer is: %d\n",ftell(fd));

    rc = fread(buffer,k,1,fd);
    printf("Data Read from File is: %d \n",rc);
    
    if(rc > 0)
    {
    	printf("File Read Success \n");
    }
    
    seek_size = seek_size + k;    
    fseek(fd,seek_size,SEEK_SET);

    if (rc == 0)
    {
      	printf("End of File Reached: %d \n",rc);
      	break;
    } 
    rc = snd_pcm_writei(handle, buffer, k);
    printf("Write: %d  bytes \n",rc);
    
    if (rc == -EPIPE)
    {
      printf("underrun occurred \n");
      snd_pcm_prepare(handle);
    }
    else if (rc < 0)
    {
    	fprintf(stderr,"Error From Writei Call: %s\n",snd_strerror(rc));
       exit(1);
    }  
   }//End of While
   
   fclose(fd);
   snd_pcm_drain(handle);
   snd_pcm_close(handle);
   free(buffer);
}//End of Playback
--------------------------------------------------------------------------------------------------------------
Can anyone help me out where i am doing wrong.Ur's valuable suggestions are welcomed.
 
Best Regards,
Sudeept

^ permalink raw reply	[flat|nested] 8+ messages in thread
* help
@ 2007-12-02  4:24 YanBob
  2007-12-02 17:09 ` help Tobin Davis
  0 siblings, 1 reply; 8+ messages in thread
From: YanBob @ 2007-12-02  4:24 UTC (permalink / raw)
  To: alsa-devel

hello, my  linux is ubuntu with Linux bob-laptop 2.6.22-14-generic #1
SMP Sun Oct 14 23:05:12 GMT 2007 i686 GNU/Linux.
        now the problem is that,no sound comes out when i use ubuntu.
        i have google some pages, and followed the steps as they said. But i
turns out that my sound card is still not working. At the end of this
email,
i send you  some inf. about my sound card. And my laptop model is Lenovo
F41.
 Could you please help me?   thanks a million!!

bob@bob-laptop:~$ aplay -l
**** PLAYBACK硬件设备列表 ****
卡 0: Intel [HDA Intel], 设备 0: ALC262 Analog [ALC262 Analog]
  子设备: 1/1
  子设备:#0: subdevice #0
卡 0: Intel [HDA Intel], 设备 1: ALC262 Digital [ALC262 Digital]
  子设备: 1/1
  子设备:#0: subdevice #0
卡 0: Intel [HDA Intel], 设备 6: Si3054 Modem [Si3054 Modem]
  子设备: 1/1
  子设备:#0: subdevice #0

bob@bob-laptop:~$ lspci -vv|grep Audio
00:1b.0 Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio
Controller (rev 03)

bob@bob-laptop:~$ cat /proc/asound/cards 
 0 [Intel          ]: HDA-Intel - HDA Intel
                      HDA Intel at 0xf8300000 irq 22

bob@bob-laptop:~$ lsmod|grep snd
snd_hda_intel         263712  1 
snd_pcm_oss            44672  0 
snd_mixer_oss          17664  1 snd_pcm_oss
snd_pcm                80388  2 snd_hda_intel,snd_pcm_oss
snd_seq_dummy           4740  0 
snd_seq_oss            33152  0 
snd_seq_midi            9600  0 
snd_rawmidi            25728  1 snd_seq_midi
snd_seq_midi_event      8448  2 snd_seq_oss,snd_seq_midi
snd_seq                53232  6
snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_seq_midi_event
snd_timer              24324  2 snd_pcm,snd_seq
snd_seq_device          9228  5
snd_seq_dummy,snd_seq_oss,snd_seq_midi,snd_rawmidi,snd_seq
snd                    54660  11
snd_hda_intel,snd_pcm_oss,snd_mixer_oss,snd_pcm,snd_seq_oss,snd_rawmidi,snd_seq,snd_timer,snd_seq_device
soundcore               8800  1 snd
snd_page_alloc         11400  2 snd_hda_intel,snd_pcm


bob@bob-laptop:~$ cat /proc/asound/version 
Advanced Linux Sound Architecture Driver Version 1.0.14 (Thu May 31
09:03:25 2007 UTC).
























































      ___________________________________________________________ 
进入雅虎游戏嘉年华,赢取液晶显示器! 
http://cn.mail.yahoo.com/promo/carnival07/
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

end of thread, other threads:[~2009-04-24 15:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-24  7:18 Help Sudeept Prusti
2008-07-24 16:53 ` Help stan
  -- strict thread matches above, loose matches on Subject: below --
2009-04-24 11:31 Help Sudeept Prusti
2009-04-24 11:39 ` Help Jaroslav Kysela
2009-04-24 11:53   ` Help Sudeept Prusti
2009-04-24 16:05     ` Help Alan Horstmann
2007-12-02  4:24 help YanBob
2007-12-02 17:09 ` help Tobin Davis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox