Update of /cvsroot/alsa/alsa-oss/alsa
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29837

Modified Files:
        pcm.c 
Log Message:
Added mangling for period/buffer size in mmap mode

Index: pcm.c
===================================================================
RCS file: /cvsroot/alsa/alsa-oss/alsa/pcm.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- pcm.c       1 Mar 2004 08:51:07 -0000       1.14
+++ pcm.c       26 Mar 2004 16:13:55 -0000      1.15
@@ -237,6 +237,7 @@
 #endif
 
                if (str->mmap_buffer) {
+                       snd_pcm_uframes_t size;
                        snd_pcm_access_mask_t *mask;
                        snd_pcm_access_mask_alloca(&mask);
                        snd_pcm_access_mask_any(mask);
@@ -246,10 +247,12 @@
                        err = snd_pcm_hw_params_set_access_mask(pcm, hw, mask);
                        if (err < 0)
                                return err;
-                       err = snd_pcm_hw_params_set_period_size(pcm, hw, 
str->alsa.mmap_period_bytes / str->frame_bytes, 0);
+                       size = str->alsa.mmap_period_bytes / str->frame_bytes;
+                       err = snd_pcm_hw_params_set_period_size_near(pcm, hw, &size, 
NULL);
                        if (err < 0)
                                return err;
-                       err = snd_pcm_hw_params_set_buffer_size(pcm, hw, 
str->alsa.mmap_buffer_bytes / str->frame_bytes);
+                       size = str->alsa.mmap_buffer_bytes / str->frame_bytes;
+                       err = snd_pcm_hw_params_set_buffer_size_near(pcm, hw, &size);
                        if (err < 0)
                                return err;
                        err = snd_pcm_hw_params_set_access(pcm, hw, 
SND_PCM_ACCESS_MMAP_INTERLEAVED);
@@ -316,12 +319,17 @@
                err = snd_pcm_hw_params_get_buffer_size(hw, &str->alsa.buffer_size);
                if (err < 0)
                        return err;
-               str->oss.buffer_size = 1 << ld2(str->alsa.buffer_size);
-               if (str->oss.buffer_size < str->alsa.buffer_size)
-                       str->oss.buffer_size *= 2;
-               str->oss.period_size = 1 << ld2(str->alsa.period_size);
-               if (str->oss.period_size < str->alsa.period_size)
-                       str->oss.period_size *= 2;
+               if (str->mmap_buffer == NULL) {
+                       str->oss.buffer_size = 1 << ld2(str->alsa.buffer_size);
+                       if (str->oss.buffer_size < str->alsa.buffer_size)
+                               str->oss.buffer_size *= 2;
+                       str->oss.period_size = 1 << ld2(str->alsa.period_size);
+                       if (str->oss.period_size < str->alsa.period_size)
+                               str->oss.period_size *= 2;
+               } else {
+                       str->oss.buffer_size = str->alsa.mmap_period_bytes / 
str->frame_bytes;
+                       str->oss.period_size = str->alsa.mmap_buffer_bytes / 
str->frame_bytes;
+               }
                str->oss.periods = str->oss.buffer_size / str->oss.period_size;
                if (str->mmap_areas)
                        free(str->mmap_areas);
@@ -754,7 +762,7 @@
                                           dsp->channels, frames,
                                           dsp->format);
                        err = snd_pcm_mmap_commit(pcm, ofs, frames);
-                       if (err < 0)
+                       if (err <= 0)
                                break;
                        size -= err;
                        str->alsa.appl_ptr += err;
@@ -1345,6 +1353,8 @@
        err = oss_dsp_params(dsp);
        if (err < 0) {
                free(result);
+               str->mmap_buffer = NULL;
+               str->mmap_bytes = 0;
                errno = -err;
                result = MAP_FAILED;
                goto _end;
@@ -1391,7 +1401,7 @@
        diff = hw_ptr - str->alsa.appl_ptr;
        if (diff < 0)
                diff += str->alsa.buffer_size;
-       if (diff < 0)
+       if (diff < 1)
                diff = 1;
        //fprintf(stderr, "avail_min (%i): hw_ptr = %lu, appl_ptr = %lu, diff = 
%lu\n", stream, hw_ptr, str->alsa.appl_ptr, diff);
        snd_pcm_sw_params_set_avail_min(pcm, str->sw_params, diff);



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Alsa-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/alsa-cvslog

Reply via email to