void buffer_drain(void) { #ifndef NOXFERMEM int s; while ((s = xfermem_get_usedspace(buffermem))) { struct timeval wait170 = {0, 170000}; if(intflag) break; buffer_ignore_lowmem(); if(param.verbose) print_stat(mh,0,s); #ifdef HAVE_TERMIOS if(param.term_ctrl) term_control(mh, ao); #endif select(0, NULL, NULL, NULL, &wait170); } #endif }
off_t term_control(mpg123_handle *fr, audio_output_t *ao) { offset = 0; debug1("control for frame: %li", (long)mpg123_tellframe(fr)); if(!term_enable) return 0; if(paused) { /* pause_cycle counts the remaining frames _after_ this one, thus <0, not ==0 . */ if(--pause_cycle < 0) { pause_recycle(fr); if(param.usebuffer) { while(paused && xfermem_get_usedspace(buffermem)) { buffer_ignore_lowmem(); term_handle_input(fr, ao, TRUE); } /* Undo the cycling offset if we are done with cycling. */ if(!paused) pause_uncycle(); } } } do { term_handle_input(fr, ao, stopped|seeking); if((offset < 0) && (-offset > framenum)) offset = - framenum; if(param.verbose && offset != 0) print_stat(fr,offset,0); } while (stopped); /* Make the seeking experience with buffer less annoying. No sound during seek, but at least it is possible to go backwards. */ if(offset) { if((offset = mpg123_seek_frame(fr, offset, SEEK_CUR)) >= 0) debug1("seeked to %li", (long)offset); else error1("seek failed: %s!", mpg123_strerror(fr)); /* Buffer resync already happened on un-stop? */ /* if(param.usebuffer) buffer_resync();*/ } return 0; }