[Mplayer-cvslog] CVS: main Makefile,1.36,1.37 mplayer.c,1.135,1.136

GEREOFFY arpi_esp at users.sourceforge.net
Sun Jun 3 01:28:44 CEST 2001


Update of /cvsroot/mplayer/main
In directory usw-pr-cvs1:/tmp/cvs-serv16391

Modified Files:
	Makefile mplayer.c 
Log Message:
libao support

Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/Makefile,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -r1.36 -r1.37
*** Makefile	2001/06/02 22:55:10	1.36
--- Makefile	2001/06/02 23:28:42	1.37
***************
*** 32,36 ****
  	$(CC) -c $(CFLAGS) -o $@ $<
  
! COMMONLIBS = libvo/libvo.a libac3/libac3.a mp3lib/libMP3.a
  
  loader/libloader.a:
--- 32,36 ----
  	$(CC) -c $(CFLAGS) -o $@ $<
  
! COMMONLIBS = libvo/libvo.a libao2/libao.a libac3/libac3.a mp3lib/libMP3.a
  
  loader/libloader.a:
***************
*** 46,49 ****
--- 46,52 ----
  	$(MAKE) -C libvo
  
+ libao2/libao.a:
+ 	$(MAKE) -C libao2
+ 
  libac3/libac3.a:
  	$(MAKE) -C libac3
***************
*** 62,66 ****
  
  $(PRG):	.depend mplayer.o $(OBJS) loader/libloader.a $(DS_DEP) libmpeg2/libmpeg2.a opendivx/libdecore.a $(COMMONLIBS) encore/libencore.a
! 	$(CC) $(CFLAGS) -o $(PRG) mplayer.o $(OBJS) $(XMM_LIBS) $(LIRC_LIBS) $(A_LIBS) -lm $(TERMCAP_LIB) -Lloader -lloader $(DS_LIB) -ldl -Llibmpeg2 -lmpeg2 -Lopendivx -ldecore $(VO_LIBS) $(CSS_LIB) -Lencore -lencore -lpthread
  
  # $(PRG_HQ):	.depend mplayerHQ.o $(OBJS) loader/libloader.a libmpeg2/libmpeg2.a opendivx/libdecore.a $(COMMONLIBS) encore/libencore.a
--- 65,69 ----
  
  $(PRG):	.depend mplayer.o $(OBJS) loader/libloader.a $(DS_DEP) libmpeg2/libmpeg2.a opendivx/libdecore.a $(COMMONLIBS) encore/libencore.a
! 	$(CC) $(CFLAGS) -o $(PRG) mplayer.o $(OBJS) $(XMM_LIBS) $(LIRC_LIBS) $(A_LIBS) -lm $(TERMCAP_LIB) -Lloader -lloader $(DS_LIB) -ldl -Llibmpeg2 -lmpeg2 -Lopendivx -ldecore $(VO_LIBS) -Llibao2 -lao $(CSS_LIB) -Lencore -lencore -lpthread
  
  # $(PRG_HQ):	.depend mplayerHQ.o $(OBJS) loader/libloader.a libmpeg2/libmpeg2.a opendivx/libdecore.a $(COMMONLIBS) encore/libencore.a

Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.135
retrieving revision 1.136
diff -C2 -r1.135 -r1.136
*** mplayer.c	2001/06/02 01:00:22	1.135
--- mplayer.c	2001/06/02 23:28:42	1.136
***************
*** 1,11 ****
  // AVI & MPEG Player    v0.11   (C) 2000-2001. by A'rpi/ESP-team
  
- // Enable ALSA emulation (using 32kB audio buffer) - timer testing only
- //#define SIMULATE_ALSA
- 
- #define RESET_AUDIO(audio_fd) ioctl(audio_fd, SNDCTL_DSP_RESET, NULL)
- //#define PAUSE_AUDIO(audio_fd) ioctl(audio_fd, SNDCTL_DSP_POST, NULL)
- //#define RESET_AUDIO(audio_fd)
- 
  #include <stdio.h>
  #include <stdlib.h>
--- 1,4 ----
***************
*** 44,47 ****
--- 37,42 ----
  #include "libvo/sub.h"
  
+ #include "libao2/audio_out.h"
+ 
  // CODECS:
  #include "mp3lib/mp3.h"
***************
*** 294,347 ****
  
  //**************************************************************************//
- 
- #ifdef SIMULATE_ALSA
- // Simulate ALSA buffering on OSS device :)  (for testing...)
- 
- #define fake_ALSA_size 32768
- char fake_ALSA_buffer[fake_ALSA_size];
- int fake_ALSA_len=0;
- 
- void fake_ALSA_write(int audio_fd,char* a_buffer,int len){
- while(len>0){
-   int x=fake_ALSA_size-fake_ALSA_len;
-   if(x>0){
-     if(x>len) x=len;
-     memcpy(&fake_ALSA_buffer[fake_ALSA_len],a_buffer,x);
-     fake_ALSA_len+=x;len-=x;
-   }
-   if(fake_ALSA_len>=fake_ALSA_size){
-     write(audio_fd,fake_ALSA_buffer,fake_ALSA_len);
-     fake_ALSA_len=0;
-   }
- }
- }
- #endif
- 
  //**************************************************************************//
  
- int audio_delay_method=2;
- int audio_buffer_size=-1;
- 
- int get_audio_delay(int audio_fd){
-   if(audio_delay_method==2){
-       // 
-       int r=0;
-       if(ioctl(audio_fd, SNDCTL_DSP_GETODELAY, &r)!=-1)
-          return r;
-       audio_delay_method=1; // fallback if not supported
-   }
-   if(audio_delay_method==1){
-       // SNDCTL_DSP_GETOSPACE
-       audio_buf_info zz;
-       if(ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &zz)!=-1)
-          return audio_buffer_size-zz.bytes;
-       audio_delay_method=0; // fallback if not supported
-   }
-   return audio_buffer_size;
- }
- 
- 
- //**************************************************************************//
- 
  // AVI file header reader/parser/writer:
  //#include "aviheader.c"
--- 289,294 ----
***************
*** 361,364 ****
--- 308,312 ----
  
  static vo_functions_t *video_out=NULL;
+ static ao_functions_t *audio_out=NULL;
  
  static int play_in_bg=0;
***************
*** 601,604 ****
--- 549,555 ----
    }
  
+ // check audio_out
+ audio_out=audio_out_drivers[0];
+ 
  // check codec.conf
  if(!parse_codec_cfg(get_path("codecs.conf"))){
***************
*** 949,953 ****
  if(stream_dump_type){
    FILE *f;
-   int len;
    demux_stream_t *ds=NULL;
    // select stream to dump
--- 900,903 ----
***************
*** 1379,1385 ****
  //================== MAIN: ==========================
  {
! int audio_fd=-1;
! int outburst=OUTBURST;
! float audio_buffer_delay=0;
  
  //float buffer_delay=0;
--- 1329,1333 ----
  //================== MAIN: ==========================
  {
! //float audio_buffer_delay=0;
  
  //float buffer_delay=0;
***************
*** 1436,1525 ****
  
  if(has_audio){
- #ifdef USE_XMMP_AUDIO
-   xmm_Init( &xmm );
-   xmm.cSound = (XMM_PluginSound *)xmm_PluginRegister( XMMP_AUDIO_DRIVER );
-   if( xmm.cSound ){
-     pSound = xmm.cSound->Init( &xmm );
-     if( pSound && pSound->Start( pSound, sh_audio->samplerate, sh_audio->channels,
-                 ( sh_audio->samplesize == 2 ) ?  XMM_SOUND_FMT_S16LE : XMM_SOUND_FMT_U8 )){
-         printf("XMM: audio setup ok\n");
-     } else {
-       has_audio=0;
-     }
-   } else has_audio=0;
- #else
-   audio_fd=open(dsp, O_WRONLY);
-   if(audio_fd<0){
-     printf("Can't open audio device %s  -> nosound\n",dsp);
-     has_audio=0;
-   }
- #endif
- }
  
! if(has_audio){
! #ifdef USE_XMMP_AUDIO
!   if(audio_buffer_size==-1){
!     // Measuring buffer size:
!     audio_buffer_delay=pSound->QueryDelay(pSound, 0);
!   } else {
!     // -abs commandline option
!     audio_buffer_delay=audio_buffer_size/(float)(sh_audio->o_bps);
    }
- #else
-   int r;
-   audio_buf_info zz;
- 
-   r=sh_audio->sample_format;
- //  (sh_audio->samplesize==2)?AFMT_S16_LE:AFMT_U8;
-   ioctl (audio_fd, SNDCTL_DSP_SETFMT, &r);
-   printf("audio_setup: sample format: 0x%X  (requested: 0x%X)\n",r,sh_audio->sample_format);
-   
-   r=sh_audio->channels-1; ioctl (audio_fd, SNDCTL_DSP_STEREO, &r);
-   
-   r=sh_audio->samplerate; if(ioctl (audio_fd, SNDCTL_DSP_SPEED, &r)==-1){
-       printf("audio_setup: your card doesn't support %d Hz samplerate => nosound\n",r);
-       has_audio=0;
-   } else
-       printf("audio_setup: using %d Hz samplerate (requested: %d)\n",r,sh_audio->samplerate);
  
!   if(ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &zz)==-1){
!       printf("audio_setup: driver doesn't support SNDCTL_DSP_GETOSPACE :-(\n");
!       r=0;
!       if(ioctl(audio_fd, SNDCTL_DSP_GETBLKSIZE, &r)==-1){
!           printf("audio_setup: %d bytes/frag (config.h)\n",outburst);
!       } else {
!           outburst=r;
!           printf("audio_setup: %d bytes/frag (GETBLKSIZE)\n",outburst);
!       }
!   } else {
!       printf("audio_setup: frags: %3d/%d  (%d bytes/frag)  free: %6d\n",
!           zz.fragments, zz.fragstotal, zz.fragsize, zz.bytes);
!       if(audio_buffer_size==-1) audio_buffer_size=zz.bytes;
!       outburst=zz.fragsize;
!   }
! 
!   if(audio_buffer_size==-1){
!     // Measuring buffer size:
!     audio_buffer_size=0;
! #ifdef HAVE_AUDIO_SELECT
!     while(audio_buffer_size<0x40000){
!       fd_set rfds;
!       struct timeval tv;
!       FD_ZERO(&rfds); FD_SET(audio_fd,&rfds);
!       tv.tv_sec=0; tv.tv_usec = 0;
!       if(!select(audio_fd+1, NULL, &rfds, NULL, &tv)) break;
!       write(audio_fd,&sh_audio->a_buffer[sh_audio->a_buffer_len],outburst);
!       audio_buffer_size+=outburst;
!     }
!     if(audio_buffer_size==0){
!         printf("\n   ***  Your audio driver DOES NOT support select()  ***\n");
!           printf("Recompile mplayer with #undef HAVE_AUDIO_SELECT in config.h !\n\n");
!         exit_player("audio_init");
!     }
! #endif
!   }
!   audio_buffer_delay=audio_buffer_size/(float)(sh_audio->o_bps);
! #endif
!   printf("Audio buffer size: %d bytes, delay: %5.3fs\n",audio_buffer_size,audio_buffer_delay);
  
    // fixup audio buffer size:
--- 1384,1394 ----
  
  if(has_audio){
  
!   if(!audio_out->init(sh_audio->samplerate,sh_audio->channels,sh_audio->sample_format,0)){
!     printf("couldn't open/init audio device -> NOSOUND\n");
!     has_audio=0;
    }
  
! //  printf("Audio buffer size: %d bytes, delay: %5.3fs\n",audio_buffer_size,audio_buffer_delay);
  
    // fixup audio buffer size:
***************
*** 1530,1537 ****
  
  //  a_frame=-(audio_buffer_delay);
-   a_frame=0;
- //  RESET_AUDIO(audio_fd);
  }
  
  
  if(!has_audio){
--- 1399,1405 ----
  
  //  a_frame=-(audio_buffer_delay);
  }
  
+   a_frame=0;
  
  if(!has_audio){
***************
*** 1559,1563 ****
  if(file_format==DEMUXER_TYPE_AVI && has_audio){
    //a_pts=d_audio->pts;
!   printf("Initial frame delay  A: %d  V: %d\n",sh_audio->audio.dwInitialFrames,sh_video->video.dwInitialFrames);
    if(!pts_from_bps){
      float x=(float)(sh_audio->audio.dwInitialFrames-sh_video->video.dwInitialFrames)*sh_video->frametime;
--- 1427,1431 ----
  if(file_format==DEMUXER_TYPE_AVI && has_audio){
    //a_pts=d_audio->pts;
!   printf("Initial frame delay  A: %d  V: %d\n",(int)sh_audio->audio.dwInitialFrames,(int)sh_video->video.dwInitialFrames);
    if(!pts_from_bps){
      float x=(float)(sh_audio->audio.dwInitialFrames-sh_video->video.dwInitialFrames)*sh_video->frametime;
***************
*** 1578,1582 ****
    sh_video->fps=force_fps;
    sh_video->frametime=1.0f/sh_video->fps;
!   printf("FPS forced to be %5.3  (ftime: %5.3f)\n",sh_video->fps,sh_video->frametime);
  }
  
--- 1446,1450 ----
    sh_video->fps=force_fps;
    sh_video->frametime=1.0f/sh_video->fps;
!   printf("FPS forced to be %5.3f  (ftime: %5.3f)\n",sh_video->fps,sh_video->frametime);
  }
  
***************
*** 1596,1609 ****
  while(has_audio){
    unsigned int t;
!   int playsize=outburst;
!   audio_buf_info zz;
!   int use_select=1;
    
!   if(ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &zz)!=-1){
!       // calculate exact buffer space:
!       playsize=zz.fragments*zz.fragsize;
!       if(!playsize) break; // buffer is full, do not block here!!!
!       use_select=0;
!   }
    
    if(playsize>MAX_OUTBURST) playsize=MAX_OUTBURST; // we shouldn't exceed it!
--- 1464,1470 ----
  while(has_audio){
    unsigned int t;
!   int playsize=audio_out->get_space();
    
!   if(!playsize) break; // buffer is full, do not block here!!!
    
    if(playsize>MAX_OUTBURST) playsize=MAX_OUTBURST; // we shouldn't exceed it!
***************
*** 1622,1641 ****
    
    if(playsize>sh_audio->a_buffer_len) playsize=sh_audio->a_buffer_len;
-   playsize/=outburst; playsize*=outburst; // rounding to fragment boundary
    
! //  printf("play %d bytes of %d [max: %d]\n",playsize,sh_audio->a_buffer_len,sh_audio->a_buffer_size);
  
!   // Play sound from the buffer:
!   if(playsize>0){ // if not EOF
! #ifdef USE_XMMP_AUDIO
!     pSound->Write( pSound, sh_audio->a_buffer, playsize );
! #else
! #ifdef SIMULATE_ALSA
!     fake_ALSA_write(audio_fd,sh_audio->a_buffer,playsize); // for testing purposes
! #else
!     playsize=write(audio_fd,sh_audio->a_buffer,playsize);
! #endif
! #endif
!     if(playsize>0){
        sh_audio->a_buffer_len-=playsize;
        memcpy(sh_audio->a_buffer,&sh_audio->a_buffer[playsize],sh_audio->a_buffer_len);
--- 1483,1490 ----
    
    if(playsize>sh_audio->a_buffer_len) playsize=sh_audio->a_buffer_len;
    
!   playsize=audio_out->play(sh_audio->a_buffer,playsize,0);
  
!   if(playsize>0){
        sh_audio->a_buffer_len-=playsize;
        memcpy(sh_audio->a_buffer,&sh_audio->a_buffer[playsize],sh_audio->a_buffer_len);
***************
*** 1643,1670 ****
        //a_pts+=playsize/(float)(sh_audio->o_bps);
  //      time_frame+=playsize/(float)(sh_audio->o_bps);
-     }
- #ifndef USE_XMMP_AUDIO
- #ifndef SIMULATE_ALSA
-     // check buffer
- #ifdef HAVE_AUDIO_SELECT
-     if(use_select){  // do not use this code if SNDCTL_DSP_GETOSPACE works
-        fd_set rfds;
-        struct timeval tv;
-        FD_ZERO(&rfds);
-        FD_SET(audio_fd, &rfds);
-        tv.tv_sec = 0;
-        tv.tv_usec = 0;
-        if(select(audio_fd+1, NULL, &rfds, NULL, &tv)){
-          a_frame+=OUTBURST/(float)(sh_audio->o_bps);
- //         a_pts+=OUTBURST/(float)(sh_audio->o_bps);
- //         printf("Filling audio buffer...\n");
-          continue;
- //       } else {
- //         printf("audio buffer full...\n");
-        }
-     }
- #endif
- #endif
- #endif
    }
  
--- 1492,1495 ----
***************
*** 1908,1912 ****
  
        if(has_audio){
!           int delay=get_audio_delay(audio_fd);
            if(verbose>1)printf("delay=%d\n",delay);
            time_frame=v_frame;
--- 1733,1737 ----
  
        if(has_audio){
!           int delay=audio_out->get_delay();
            if(verbose>1)printf("delay=%d\n",delay);
            time_frame=v_frame;
***************
*** 1922,1926 ****
  
        if(has_audio){
!           int delay=get_audio_delay(audio_fd);
            if(verbose>1)printf("delay=%d\n",delay);
            time_frame=v_frame;
--- 1747,1751 ----
  
        if(has_audio){
!           int delay=audio_out->get_delay();
            if(verbose>1)printf("delay=%d\n",delay);
            time_frame=v_frame;
***************
*** 1970,1974 ****
  
      // unplayed bytes in our and soundcard/dma buffer:
!     int delay_bytes=get_audio_delay(audio_fd)+sh_audio->a_buffer_len;
      float delay=(float)delay_bytes/(float)sh_audio->o_bps;
  
--- 1795,1799 ----
  
      // unplayed bytes in our and soundcard/dma buffer:
!     int delay_bytes=audio_out->get_delay()+sh_audio->a_buffer_len;
      float delay=(float)delay_bytes/(float)sh_audio->o_bps;
  
***************
*** 2031,2035 ****
      // No audio:
      //if(d_video->pts)
!     int v_pts=d_video->pts;
      if(frame_corr_num==5){
  //      printf("A: ---   V:%6.1f   \r",v_pts);
--- 1856,1860 ----
      // No audio:
      //if(d_video->pts)
!     float v_pts=d_video->pts;
      if(frame_corr_num==5){
  //      printf("A: ---   V:%6.1f   \r",v_pts);
***************
*** 2056,2060 ****
    if(osd_function==OSD_PAUSE){
        printf("\n------ PAUSED -------\r");fflush(stdout);
!       RESET_AUDIO(audio_fd); // stop audio
  #ifdef HAVE_GUI
        if ( nogui )
--- 1881,1885 ----
    if(osd_function==OSD_PAUSE){
        printf("\n------ PAUSED -------\r");fflush(stdout);
!       audio_out->reset(); // stop audio
  #ifdef HAVE_GUI
        if ( nogui )
***************
*** 2411,2415 ****
          current_module=NULL;
  
!         RESET_AUDIO(audio_fd);
  
          c_total=0; // kell ez?
--- 2236,2240 ----
          current_module=NULL;
  
!         audio_out->reset(); // stop audio
  
          c_total=0; // kell ez?
***************
*** 2434,2439 ****
  
  //================= Update OSD ====================
! { int i;
!   if(osd_level>=2){
        int pts=d_video->pts;
        if(pts==osd_last_pts-1) ++pts; else osd_last_pts=pts;
--- 2259,2263 ----
  
  //================= Update OSD ====================
! { if(osd_level>=2){
        int pts=d_video->pts;
        if(pts==osd_last_pts-1) ++pts; else osd_last_pts=pts;


_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog



More information about the MPlayer-cvslog mailing list