alsa-lib: tests: Error in pause/resume

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,
 I was validating pause/resume of my alsa driver for spdif. After few loop of pause/resume snd_pcm_writei routine returns error.
(error code -77, No such device or address).
 
 
For testing I'm using pcm.c in test/pcm.c. I modified pcm.c under name pcm_pause.c to support pause and resume.
I'm attaching my patch for changes below.
 
--- pcm.c 2011-08-13 14:35:15.384157182 +0530
+++ pcm_pause.c 2011-11-30 14:20:26.990180303 +0530
@@ -779,7 +779,7 @@
   {NULL, 0, NULL, 0},
  };
  snd_pcm_t *handle;
- int err, morehelp;
+ int err, morehelp,pid;
  snd_pcm_hw_params_t *hwparams;
  snd_pcm_sw_params_t *swparams;
  int method = 0;
@@ -912,14 +912,40 @@
   areas[chn].first = chn * snd_pcm_format_physical_width(format);
   areas[chn].step = channels * snd_pcm_format_physical_width(format);
  }
-
- err = transfer_methods[method].transfer_loop(handle, samples, areas);
- if (err < 0)
-  printf("Transfer failed: %s\n", snd_strerror(err));
-
- free(areas);
- free(samples);
- snd_pcm_close(handle);
- return 0;
+
+ pid = fork();
+ if(pid > 0){
+  err = transfer_methods[method].transfer_loop(handle, samples, areas);
+  if (err < 0)
+   printf("Transfer failed: %s\n", snd_strerror(err));

+  free(areas);
+  free(samples);
+  snd_pcm_close(handle);
+  return 0;
+ }
+
+ if(pid == 0)
+ {
+  int pause_count = 0;
+  int resume_count = 0;
+  while(1)
+  {
+   sleep(1);
+   if((err = snd_pcm_pause(handle,1)) < 0)
+   {
+    printf("\nPause Failed: %s", snd_strerror(err));
+    exit(EXIT_FAILURE);
+   }
+   printf("\nPAUSED Audio: Count %d\n", ++pause_count);
+   sleep(1);
+   if((err = snd_pcm_pause(handle,0)) < 0)\
+   {
+    printf("\nResume Failed: %s", snd_strerror(err));
+    exit(EXIT_FAILURE);
+   }
+   printf("\nRESUME Audio: Count %d\n", ++resume_count);
+  }
+ }
 }
------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of 
discussion for anyone considering optimizing the pricing and packaging model 
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
_______________________________________________
Alsa-user mailing list
Alsa-user@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-user

[Index of Archives]     [ALSA Devel]     [Linux Audio Users]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]

  Powered by Linux