Logo Search packages:      
Sourcecode: pulseaudio version File versions

char* pa_bytes_snprint ( char *  s,
size_t  l,
unsigned  v 
)

Pretty print a byte size value. (i.e. "2.5 MiB")

Definition at line 151 of file sample.c.

                                                      {
    pa_assert(s);

    if (v >= ((unsigned) 1024)*1024*1024)
        pa_snprintf(s, l, "%0.1f GiB", ((double) v)/1024/1024/1024);
    else if (v >= ((unsigned) 1024)*1024)
        pa_snprintf(s, l, "%0.1f MiB", ((double) v)/1024/1024);
    else if (v >= (unsigned) 1024)
        pa_snprintf(s, l, "%0.1f KiB", ((double) v)/1024);
    else
        pa_snprintf(s, l, "%u B", (unsigned) v);

    return s;
}


Generated by  Doxygen 1.6.0   Back to index