Re: [mpg123-devel] how to create Draining buffer
Brought to you by:
sobukus
From: Thomas O. <tho...@or...> - 2021-06-15 16:55:51
|
Am Tue, 15 Jun 2021 12:30:22 +0000 (UTC) schrieb Didier Castellacci via mpg123-devel <mpg...@li...>: > Do you have any ideas for me to be able to develop the same thing? Sure. Just look at what src/mpg123.c does;-) /* Drain output device/buffer, but still give the option to interrupt things. */ static void controlled_drain(void) { int framesize; size_t drain_block; play_prebuffer(); if(intflag || !out123_buffered(ao)) return; if(out123_getformat(ao, NULL, NULL, NULL, &framesize)) return; drain_block = 1152*framesize; if(param.verbose) fprintf(stderr, "\n"); do { out123_ndrain(ao, drain_block); if(param.verbose) print_buf("Draining buffer: ", ao); #ifdef HAVE_TERMIOS if(param.term_ctrl) term_control(mh, ao); #endif } while(!intflag && out123_buffered(ao)); if(param.verbose) fprintf(stderr, "\n"); } If you don't want to be able to interrupt things, you can just call out123_drain(). The fluff around it is just to figure out a block for out123_ndrain() and to react to key presses … and to give that progress info. Alrighty then, Thomas |