Exemplo n.º 1
0
char			*my_put_fnbr_s(float nbr)
{
  int			i;
  char			*str;

  if ((str = malloc_and_init()) == NULL)
    return (NULL);
  i = 0;
  str = my_strcatprint(str, my_put_nbr_s((int)nbr));
  nbr -= (int)nbr;
  str = my_strcatchar(str, '.');
  while (i < 5)
    {
      nbr *= 10.0;
      str = my_strcatchar(str, 48 + (int)nbr);
      nbr -= (int)nbr;
      i++;
    }
  return (str);
}
Exemplo n.º 2
0
char			*disp_unprintablele_s(char *str)
{
  int			i;
  char			*result;

  if ((result = malloc_and_init()) == NULL)
    return (NULL);
  i = 0;
  while (str[i] != '\0')
    {
      if (str[i] < 32 || str[i] > 126)
	{
	  result = my_strcatchar(result, '\\');
	  result = my_strcatprint(result,
				  my_putnbr_base_s(str[i], "01234567", 2));
	}
      else
	result = my_strcatchar(result, str[i]);
      i++;
    }
  return (result);
}
Exemplo n.º 3
0
mbx_error_code _mbx_out_new(_mbx_out *out_p, const char *name, const char *dev_name, _mbx_out_cb cb, void *output_cb_userdata) {
    int dev_exists = 0;
    if ( mbx_output_device_exists(dev_name, &dev_exists) != MBX_SUCCESS ) {
        return MBX_PULSEAUDIO_ERROR;
    }
    if ( ! dev_exists ) {
        return MBX_DEVICE_DOES_NOT_EXIST;
    }
    malloc_and_init(out_p, name, dev_name, cb, output_cb_userdata);
    if ( init_pulseaudio(*out_p) != MBX_SUCCESS ) {
        unset_all_callbacks(*out_p);
        do_free_audio_output(*out_p);
        return MBX_PULSEAUDIO_ERROR;
    }
    while ( (*out_p)->state == _MBX_OUT_INITIALIZING ) {
        usleep(10*1000); /* 10ms */
    }
    if ( (*out_p)->state == _MBX_OUT_PULSEAUDIO_ERROR ) {
        unset_all_callbacks(*out_p);
        do_free_audio_output(*out_p);
        return MBX_PULSEAUDIO_ERROR;
    }
    return MBX_SUCCESS;
}