From e74a9ea3030720952bbf6e342e9595b1f2dd19b2 Mon Sep 17 00:00:00 2001 From: "xians@google.com" Date: Tue, 30 Aug 2011 08:27:02 +0000 Subject: [PATCH] AudioDeviceUtility::WaitForKey() pulls two characters if the first one is a newline, but discards the final value. The current code assigns that second value to a local variable, which generates a set-but-unused warning on gcc 4.6.0. Instead, cast the result away. I also refactor the code a bit by adding the right indentation and removing empty lines. Bug=http://code.google.com/p/webrtc/issues/detail?id=53 Test=none Review URL: http://webrtc-codereview.appspot.com/135005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@486 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../main/source/audio_device_utility.cc | 42 +++++++------------ 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/src/modules/audio_device/main/source/audio_device_utility.cc b/src/modules/audio_device/main/source/audio_device_utility.cc index a01ba2e5b..c256f9e3e 100644 --- a/src/modules/audio_device/main/source/audio_device_utility.cc +++ b/src/modules/audio_device/main/source/audio_device_utility.cc @@ -69,42 +69,28 @@ namespace webrtc void AudioDeviceUtility::WaitForKey() { -struct termios oldt, newt; + struct termios oldt, newt; -int ch; + tcgetattr( STDIN_FILENO, &oldt ); + // we don't want getchar to echo! + newt = oldt; + newt.c_lflag &= ~( ICANON | ECHO ); + tcsetattr( STDIN_FILENO, TCSANOW, &newt ); -tcgetattr( STDIN_FILENO, &oldt ); + // catch any newline that's hanging around... + // you'll have to hit enter twice if you + // choose enter out of all available keys -// we don't want getchar to echo! + if (getchar() == '\n') + { + getchar(); + } -newt = oldt; - -newt.c_lflag &= ~( ICANON | ECHO ); - -tcsetattr( STDIN_FILENO, TCSANOW, &newt ); - - - -// catch any newline that's hanging around... - -// you'll have to hit enter twice if you - -// choose enter out of all available keys - -if (getchar() == '\n') - -{ - - ch = getchar(); - -} - - -tcsetattr( STDIN_FILENO, TCSANOW, &oldt ); + tcsetattr( STDIN_FILENO, TCSANOW, &oldt ); } WebRtc_UWord32 AudioDeviceUtility::GetTimeInMS()