/******************************************************************************
NAME
   vc_gencmd_until

SYNOPSIS
   int vc_gencmd_until(const char *cmd, const char *error_string, int timeout);

FUNCTION
   Sends the command repeatedly, until one of the following situations occurs:
   The specified response string is found within the gencmd response.
   The specified error string is found within the gencmd response.
   The timeout is reached.

   The timeout is a rough value, do not use it for precise timing.

RETURNS
   0 if the requested response was detected.
   1 if the error string is detected or the timeout is reached.
******************************************************************************/
int vc_gencmd_until( char        *cmd,
                     const char  *property,
                     char        *value,
                     const char  *error_string,
                     int         timeout) {
   char response[128];
   int length;
   char *ret_value;

   for (;timeout > 0; timeout -= 10) {
      vc_gencmd(response, (int)sizeof(response), cmd);
      if (strstr(response,error_string)) {
         return 1;
      }
      else if (vc_gencmd_string_property(response, property, &ret_value, &length) &&
               strncmp(value,ret_value,(size_t)length)==0) {
         return 0;
      }
      vc_sleep(10);
   }
   // Timed out
   return 1;
}
Exemple #2
0
void status_updater_thread(void* unused)
{
	float bandwidth_in = 0.0f;
	float bandwidth_out = 0.0f;
	int channels = 0;
	int servers = 0;

	while( running )
	{
		network_get_bandwidth_statistics( &bandwidth_in, &bandwidth_out );
		channels = voice_get_channel_count();
		servers = get_server_count();

		// remember these are in bytes, so convert to kb
		bandwidth_in /= 1000.0f;
		bandwidth_out /= 1000.0f;

		// dump to console
		printf("\r| %02u servers | %05u channels | in: %04.2f KB/s | out: %04.2f KB/s |",
			servers, channels, bandwidth_in, bandwidth_out );

		vc_sleep(1000);
	}
}