1
0
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:
thor
2022-10-05 21:33:10 +00:00
parent 8b44db8d88
commit bf896f1255
6 changed files with 12 additions and 9 deletions

View File

@@ -180,7 +180,7 @@ int term_setup(void)
/* Get the next pressed key, if any.
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__
KBDKEYINFO key;
@@ -188,7 +188,7 @@ int term_get_key(int do_delay, char *val)
key.chScan = 0;
if(do_delay)
DosSleep(10);
if(!KbdCharIn(&key,IO_NOWAIT,0) && key.chChar)
if(!KbdCharIn(&key,(stopped) ? IO_WAIT : IO_NOWAIT,0) && key.chChar)
{
*val = key.chChar;
return 1;
@@ -211,7 +211,8 @@ int term_get_key(int do_delay, char *val)
FD_ZERO(&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)
return 0; /* Well, we couldn't read the key, so there is none. */