]> code.delx.au - pulseaudio/blobdiff - polyp/module-alsa-source.c
commit liboil porting changes
[pulseaudio] / polyp / module-alsa-source.c
index 34f08f95a0372d05edd3d746ff6b6f89e41c518e..67e38a1d9edc7b5a250d4858265d47e82984c8ca 100644 (file)
@@ -4,7 +4,7 @@
   This file is part of polypaudio.
  
   polypaudio is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published
+  it under the terms of the GNU Lesser General Public License as published
   by the Free Software Foundation; either version 2 of the License,
   or (at your option) any later version.
  
@@ -13,7 +13,7 @@
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   General Public License for more details.
  
-  You should have received a copy of the GNU General Public License
+  You should have received a copy of the GNU Lesser General Public License
   along with polypaudio; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
@@ -46,6 +46,8 @@ PA_MODULE_DESCRIPTION("ALSA Source")
 PA_MODULE_VERSION(PACKAGE_VERSION)
 PA_MODULE_USAGE("source_name=<name for the source> device=<ALSA device> format=<sample format> channels=<number of channels> rate=<sample rate> fragments=<number of fragments> fragment_size=<fragment size>")
 
+#define PA_TYPEID_ALSA PA_TYPEID_MAKE('A', 'L', 'S', 'A')
+
 struct userdata {
     snd_pcm_t *pcm_handle;
     struct pa_source *source;
@@ -166,7 +168,7 @@ int pa__init(struct pa_core *c, struct pa_module*m) {
     const char *dev;
     struct pa_sample_spec ss;
     unsigned periods, fragsize;
-    snd_pcm_uframes_t buffer_size;
+    snd_pcm_uframes_t period_size;
     size_t frame_size;
     
     if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
@@ -187,7 +189,7 @@ int pa__init(struct pa_core *c, struct pa_module*m) {
         pa_log(__FILE__": failed to parse buffer metrics\n");
         goto fail;
     }
-    buffer_size = fragsize/frame_size*periods;
+    period_size = fragsize;
     
     u = pa_xmalloc0(sizeof(struct userdata));
     m->userdata = u;
@@ -198,12 +200,12 @@ int pa__init(struct pa_core *c, struct pa_module*m) {
         goto fail;
     }
 
-    if (pa_alsa_set_hw_params(u->pcm_handle, &ss, &periods, &buffer_size) < 0) {
+    if (pa_alsa_set_hw_params(u->pcm_handle, &ss, &periods, &period_size) < 0) {
         pa_log(__FILE__": Failed to set hardware parameters\n");
         goto fail;
     }
 
-    u->source = pa_source_new(c, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME), 0, &ss);
+    u->source = pa_source_new(c, PA_TYPEID_ALSA, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME), 0, &ss);
     assert(u->source);
 
     u->source->userdata = u;
@@ -217,7 +219,7 @@ int pa__init(struct pa_core *c, struct pa_module*m) {
     }
 
     u->frame_size = frame_size;
-    u->fragment_size = buffer_size*u->frame_size/periods;
+    u->fragment_size = period_size;
 
     pa_log(__FILE__": using %u fragments of size %u bytes.\n", periods, u->fragment_size);