[MPlayer-dev-eng] ALSA 1.x patch needs a small patch if BUFFERTIME is used

Richard Chan rspchan at starhub.net.sg
Sun Nov 23 03:07:49 CET 2003


Hi, if BUFFERTIME is used a small fix is needed due to the slight change 
in ALSA APIs.
Return values are now just error codes; parameter return values are in 
pointer arguments.
For your kind consideration.


BTW (I am new to this ) why is SET_CHUNKSIZE preferred to BUFFERTIME?
I'm getting alsa_init: unable to set periodsize always when trying to 
play back
44.1kHz on a via82xx (fixed 48kHz).




/usr/src/mplayer/main> diff -u libao2/ao_alsa1x.c 
../main2/libao2/ao_alsa1x.c
--- libao2/ao_alsa1x.c  2003-11-23 10:05:06.521940544 +0800
+++ ../main2/libao2/ao_alsa1x.c 2003-11-22 22:16:42.000000000 +0800
@@ -76,8 +76,9 @@
 
 #define ALSA_DEVICE_SIZE 48
 
-#undef BUFFERTIME
-#define SET_CHUNKSIZE
+//#undef BUFFERTIME
+#define BUFFERTIME
+//#define SET_CHUNKSIZE
 #undef USE_POLL
 
 
@@ -526,7 +527,7 @@
        printf("alsa-init: error set block-mode %s\n", snd_strerror(err));
       }
       else if (verbose>0) {
-       printf("alsa-init: pcm opend in %s\n", str_block_mode);
+       printf("alsa-init: pcm opened in %s\n", str_block_mode);
       }
        
       snd_pcm_hw_params_alloca(&alsa_hwparams);
@@ -597,16 +598,20 @@
 #ifdef BUFFERTIME
       {
        int alsa_buffer_time = 500000; /* original 60 */
+       int alsa_period_time;
+       int dir = 0;
 
-       if ((err = snd_pcm_hw_params_set_buffer_time_near(alsa_handler, 
alsa_hwparams, alsa_buffer_time, 0)) < 0)
+       alsa_period_time = alsa_buffer_time/4;
+       if ((err = snd_pcm_hw_params_set_buffer_time_near(alsa_handler, 
alsa_hwparams, &alsa_buffer_time, &dir)) < 0)
          {
            printf("alsa-init: unable to set buffer time near: %s\n",
                   snd_strerror(err));
            return(0);
-         } else
-           alsa_buffer_time = err;
+         } else  {
+           // alsa_buffer_time = err;
+         }
 
-       if ((err = snd_pcm_hw_params_set_period_time_near(alsa_handler, 
alsa_hwparams, alsa_buffer_time/4, 0)) < 0)
+       if ((err = snd_pcm_hw_params_set_period_time_near(alsa_handler, 
alsa_hwparams, &alsa_period_time, &dir)) < 0)
          /* original: alsa_buffer_time/ao_data.bps */
          {
            printf("alsa-init: unable to set period time: %s\n",
@@ -614,7 +619,7 @@
            return(0);
          }
        if (verbose>0)
-         printf("alsa-init: buffer_time: %d, period_time 
:%d\n",alsa_buffer_time, err);
+         printf("alsa-init: buffer_time: %d, period_time 
:%d\n",alsa_buffer_time, alsa_period_time);
       }
 #endif
 





More information about the MPlayer-dev-eng mailing list