mirror of
http://mpg123.de/trunk/.git
synced 2025-08-06 10:02:38 +03:00
merge in https://github.com/madebr/mpg123/pull/10 for reducing CPU load when just waiting for terminal input
git-svn-id: svn://scm.orgis.org/mpg123/trunk@5166 35dc7657-300d-0410-a2e5-dc2837fedb53
This commit is contained in:
2
NEWS
2
NEWS
@@ -26,6 +26,8 @@
|
|||||||
- libout123: Add same interruption handling to out123_write() as to
|
- libout123: Add same interruption handling to out123_write() as to
|
||||||
unintr_write(), adding EAGAIN to fix bug 342 (thanks to Steffen Nurpmeso)
|
unintr_write(), adding EAGAIN to fix bug 342 (thanks to Steffen Nurpmeso)
|
||||||
for certain ALSA setups.
|
for certain ALSA setups.
|
||||||
|
- mpg123: Reduce CPU load while just waiting for terminal input
|
||||||
|
(thanks to bolshoytoster on github).
|
||||||
|
|
||||||
1.30.2
|
1.30.2
|
||||||
------
|
------
|
||||||
|
@@ -153,7 +153,7 @@ off_t term_control(mpg123_handle *fr, out123_handle *ao)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
off_t old_offset = offset;
|
off_t old_offset = offset;
|
||||||
term_handle_input(fr, ao, stopped|seeking);
|
term_handle_input(fr, ao, seeking);
|
||||||
if((offset < 0) && (-offset > framenum)) offset = - framenum;
|
if((offset < 0) && (-offset > framenum)) offset = - framenum;
|
||||||
if(param.verbose && offset != old_offset)
|
if(param.verbose && offset != old_offset)
|
||||||
print_stat(fr,offset,ao,1,¶m);
|
print_stat(fr,offset,ao,1,¶m);
|
||||||
@@ -509,7 +509,7 @@ static void term_handle_input(mpg123_handle *fr, out123_handle *ao, int do_delay
|
|||||||
{
|
{
|
||||||
char val;
|
char val;
|
||||||
/* Do we really want that while loop? This means possibly handling multiple inputs that come very rapidly in one go. */
|
/* Do we really want that while loop? This means possibly handling multiple inputs that come very rapidly in one go. */
|
||||||
while(term_get_key(do_delay, &val))
|
while(term_get_key(stopped, do_delay, &val))
|
||||||
{
|
{
|
||||||
term_handle_key(fr, ao, val);
|
term_handle_key(fr, ao, val);
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@ void term_restore(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int term_get_key(int do_delay, char *val)
|
int term_get_key(int stopped, int do_delay, char *val)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -180,7 +180,7 @@ int term_setup(void)
|
|||||||
|
|
||||||
/* Get the next pressed key, if any.
|
/* Get the next pressed key, if any.
|
||||||
Returns 1 when there is a key, 0 if not. */
|
Returns 1 when there is a key, 0 if not. */
|
||||||
int term_get_key(int do_delay, char *val)
|
int term_get_key(int stopped, int do_delay, char *val)
|
||||||
{
|
{
|
||||||
#ifdef __OS2__
|
#ifdef __OS2__
|
||||||
KBDKEYINFO key;
|
KBDKEYINFO key;
|
||||||
@@ -188,7 +188,7 @@ int term_get_key(int do_delay, char *val)
|
|||||||
key.chScan = 0;
|
key.chScan = 0;
|
||||||
if(do_delay)
|
if(do_delay)
|
||||||
DosSleep(10);
|
DosSleep(10);
|
||||||
if(!KbdCharIn(&key,IO_NOWAIT,0) && key.chChar)
|
if(!KbdCharIn(&key,(stopped) ? IO_WAIT : IO_NOWAIT,0) && key.chChar)
|
||||||
{
|
{
|
||||||
*val = key.chChar;
|
*val = key.chChar;
|
||||||
return 1;
|
return 1;
|
||||||
@@ -211,7 +211,8 @@ int term_get_key(int do_delay, char *val)
|
|||||||
|
|
||||||
FD_ZERO(&r);
|
FD_ZERO(&r);
|
||||||
FD_SET(term_fd,&r);
|
FD_SET(term_fd,&r);
|
||||||
if(select(term_fd+1,&r,NULL,NULL,&t) > 0 && FD_ISSET(term_fd,&r))
|
/* No timeout if stopped */
|
||||||
|
if(select(term_fd+1,&r,NULL,NULL,(stopped) ? NULL : &t) > 0 && FD_ISSET(term_fd,&r))
|
||||||
{
|
{
|
||||||
if(read(term_fd,val,1) <= 0)
|
if(read(term_fd,val,1) <= 0)
|
||||||
return 0; /* Well, we couldn't read the key, so there is none. */
|
return 0; /* Well, we couldn't read the key, so there is none. */
|
||||||
|
@@ -90,7 +90,7 @@ int term_present(void){
|
|||||||
|
|
||||||
/* Get the next pressed key, if any.
|
/* Get the next pressed key, if any.
|
||||||
Returns 1 when there is a key, 0 if not. */
|
Returns 1 when there is a key, 0 if not. */
|
||||||
int term_get_key(int do_delay, char *val){
|
int term_get_key(int stopped, int do_delay, char *val){
|
||||||
INPUT_RECORD record;
|
INPUT_RECORD record;
|
||||||
HANDLE input;
|
HANDLE input;
|
||||||
DWORD res;
|
DWORD res;
|
||||||
@@ -99,7 +99,7 @@ int term_get_key(int do_delay, char *val){
|
|||||||
if(input == NULL || input == INVALID_HANDLE_VALUE)
|
if(input == NULL || input == INVALID_HANDLE_VALUE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
while(WaitForSingleObject(input, do_delay ? 10 : 0) == WAIT_OBJECT_0){
|
while(WaitForSingleObject(input, stopped ? INFINITE : (do_delay ? 10 : 0)) == WAIT_OBJECT_0){
|
||||||
do_delay = 0;
|
do_delay = 0;
|
||||||
if(!ReadConsoleInput(input, &record, 1, &res))
|
if(!ReadConsoleInput(input, &record, 1, &res))
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -47,6 +47,6 @@ void term_restore(void);
|
|||||||
* \param val address to store character to
|
* \param val address to store character to
|
||||||
* \return 1 if there is a key, 0 if not
|
* \return 1 if there is a key, 0 if not
|
||||||
*/
|
*/
|
||||||
int term_get_key(int do_delay, char *val);
|
int term_get_key(int stopped, int do_delay, char *val);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user