changeset 103:506d7560279c

timer fixes
author arpi_esp
date Tue, 13 Mar 2001 02:22:47 +0000
parents 5978ada9505e
children e69fe7a1a3a9
files mplayer.c
diffstat 1 files changed, 22 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mplayer.c	Tue Mar 13 00:46:38 2001 +0000
+++ b/mplayer.c	Tue Mar 13 02:22:47 2001 +0000
@@ -1183,6 +1183,13 @@
   r=MP3_samplerate; if(ioctl (audio_fd, SNDCTL_DSP_SPEED, &r)==-1)
       printf("audio_setup: your card doesn't support %d Hz samplerate\n",r);
 
+#if 0
+//  r = (64 << 16) + 1024;
+  r = (65536 << 16) + 512;
+    if(ioctl (audio_fd, SNDCTL_DSP_SETFRAGMENT, &r)==-1)
+      printf("audio_setup: your card doesn't support setting fragments\n",r);
+#endif
+
   if(audio_buffer_size==-1){
     // Measuring buffer size:
     audio_buffer_size=0;
@@ -1219,7 +1226,7 @@
   ds_free_packs(d_audio); // free buffered chunks
   d_audio->id=-2;         // do not read audio chunks
   if(a_buffer) free(a_buffer);
-  alsa=1; MP3_samplerate=44100;MP3_bps=MP3_channels=2; // fake, required for timer
+  alsa=1; MP3_samplerate=76800;MP3_bps=MP3_channels=2; // fake, required for timer
 }
 
   current_module=NULL;
@@ -1378,8 +1385,20 @@
       time_frame=0;
     } else {
 //      if(time_frame>0.01) usleep(1000000*(time_frame-0.01)); // sleeping
-      if(time_frame>0.001) usleep(1000000*(time_frame)); // sleeping
-    }
+//      if(time_frame>0.019) usleep(1000000*(time_frame-0.019)); // sleeping
+//      if(time_frame>0.001) usleep(1000000*(time_frame)); // sleeping
+//      if(time_frame>0.02) usleep(1000000*(time_frame)); // sleeping if >20ms
+        while(time_frame>0.007){
+//            printf("TIMER  %8.3f -> ",time_frame*1000);
+//            if(time_frame>0.021)
+//                usleep(time_frame-0.12);
+//            else
+                usleep(1000);
+            time_frame-=GetRelativeTime();
+//            printf("%8.3f    \n",time_frame*1000);
+        }
+      }
+
   }