[gst-cvs] CVS: gstreamer/plugins/alsa alsa.c,1.5,1.6

Andy Wingo wingo at users.sourceforge.net
Sat Oct 20 16:07:13 PDT 2001


Update of /cvsroot/gstreamer/gstreamer/plugins/alsa
In directory usw-pr-cvs1:/tmp/cvs-serv10284

Modified Files:
	alsa.c 
Log Message:
alsasrc workscvs -z3 commit -m 'alsasrc works\!\!\! I'm going to test it on a hammerfall now.

Index: alsa.c
===================================================================
RCS file: /cvsroot/gstreamer/gstreamer/plugins/alsa/alsa.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- alsa.c	2001/10/20 15:34:09	1.5
+++ alsa.c	2001/10/20 23:06:28	1.6
@@ -703,7 +703,7 @@
         xrun_detected = FALSE;
         
         this->avail = snd_pcm_avail_update (this->handle);
-//        g_print ("snd_pcm_avail_update() = %d\n", this->avail);
+        g_print ("snd_pcm_avail_update() = %d\n", this->avail);
         
         if (this->avail < 0) {
             if (this->avail == -EPIPE) {
@@ -750,40 +750,57 @@
 gst_alsa_src_process (GstAlsa *this, snd_pcm_uframes_t frames)
 {
     GstBuffer *buf;
-    guint32 len;
+    guint32 len, i=0;
     GList *l;
     GstAlsaPad *pad;
     
     len = frames * this->sample_bytes * this->channels;
     
-    l = this->pads;
-    while (l) {
-        pad = GST_ALSA_PAD(l);
-        
-        if (!pad->buf)
-            pad->buf = g_malloc(this->period_frames * this->sample_bytes *
-                                this->channels);
-        
-        memcpy(pad->buf + pad->offset * this->sample_bytes * this->channels, 
-               pad->access_addr, frames);
-        
-        pad->offset += frames;
-        
-        if (pad->offset >= this->period_frames) {
-            if (pad->offset + frames > this->period_frames)
-                G_BREAKPOINT();
+    while (frames) {
+        g_print ("(%d) frames to process: %d\n", i++, frames);
+        l = this->pads;
+        while (l) {
+            pad = GST_ALSA_PAD(l);
             
-            buf = gst_buffer_new();
-            GST_BUFFER_DATA(buf)    = pad->buf;
-            GST_BUFFER_SIZE(buf)    = len;
-            GST_BUFFER_MAXSIZE(buf) = len;
-            gst_pad_push(pad->pad, buf);
-            pad->buf = NULL;
-            pad->offset = 0;
-            return TRUE;
+            if (!pad->buf) {
+                pad->buf = g_malloc(this->period_frames * this->sample_bytes *
+                                    (this->data_interleaved ? this->channels :
+                                    1));
+                //  g_print ("created buffer %p of size %d\n", pad->buf, 
+                //       this->period_frames * this->sample_bytes *
+                //       (this->data_interleaved ? this->channels : 1));
+            }
+            /*
+            g_print ("pad->buf = %p, offset = %d\n", pad->buf, pad->offset);
+            g_print ("about to memcpy(%p, %p, %d)\n", 
+                     pad->buf + pad->offset * this->sample_bytes *
+                     (this->data_interleaved ? this->channels : 1),
+                     pad->access_addr,  MIN(frames, this->period_frames -
+                                            pad->offset) * this->sample_bytes *
+                     (this->data_interleaved ? this->channels : 1));
+            */
+            memcpy(pad->buf + pad->offset * this->sample_bytes * (this->data_interleaved ? this->channels : 1), 
+                   pad->access_addr, 
+                   MIN(frames, this->period_frames - pad->offset) * this->sample_bytes * (this->data_interleaved ? this->channels : 1));
+            
+            pad->offset += MIN(frames, this->period_frames - pad->offset);
+            
+            if (pad->offset >= this->period_frames) {
+                if (pad->offset > this->period_frames)
+                    G_BREAKPOINT();
+                
+                buf = gst_buffer_new();
+                GST_BUFFER_DATA(buf)    = pad->buf;
+                GST_BUFFER_SIZE(buf)    = len;
+                GST_BUFFER_MAXSIZE(buf) = len;
+                gst_pad_push(pad->pad, buf);
+                pad->buf = NULL;
+                pad->offset = 0;
+            }
+            l = l->next;
         }
-        
-        l = l->next;
+        frames -= MIN(frames, this->period_frames - pad->offset); // shouldn't
+        // matter which pad, in theory (tm)
     }
     
     return TRUE;
@@ -1154,7 +1171,7 @@
     
     GST_DEBUG(0, "got %d mmap'd frames\n", (int)this->avail);
     
-//    g_print ("snd_pcm_mmap_begin() sets avail = %d\n", this->avail);
+    g_print ("snd_pcm_mmap_begin() sets avail = %d\n", this->avail);
     
     l = this->pads;
     while (l) {





More information about the Gstreamer-commits mailing list