audio/format: reformat

This commit is contained in:
wm4 2013-11-07 22:12:26 +01:00
parent 6c4b504eca
commit aa48eeac97
2 changed files with 55 additions and 57 deletions

View File

@ -31,8 +31,7 @@ int af_fmt2bits(int format)
if (AF_FORMAT_IS_AC3(format)) return 16;
if (format == AF_FORMAT_UNKNOWN)
return 0;
switch(format & AF_FORMAT_BITS_MASK)
{
switch (format & AF_FORMAT_BITS_MASK) {
case AF_FORMAT_8BIT: return 8;
case AF_FORMAT_16BIT: return 16;
case AF_FORMAT_24BIT: return 24;
@ -65,7 +64,7 @@ int af_fmt_change_bits(int format, int bits)
/* Convert format to str input str is a buffer for the
converted string, size is the size of the buffer */
char* af_fmt2str(int format, char* str, int size)
char *af_fmt2str(int format, char* str, int size)
{
const char *name = af_fmt2str_short(format);
snprintf(str, size, "%s", name);
@ -122,11 +121,10 @@ bool af_fmt_is_valid(int format)
const char *af_fmt2str_short(int format)
{
int i;
for (i = 0; af_fmtstr_table[i].name; i++)
for (int i = 0; af_fmtstr_table[i].name; i++) {
if (af_fmtstr_table[i].format == format)
return af_fmtstr_table[i].name;
}
return "??";
}
@ -143,9 +141,9 @@ int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int sampler
int af_str2fmt_short(bstr str)
{
for (int i = 0; af_fmtstr_table[i].name; i++)
for (int i = 0; af_fmtstr_table[i].name; i++) {
if (!bstrcasecmp0(str, af_fmtstr_table[i].name))
return af_fmtstr_table[i].format;
}
return 0;
}

View File

@ -136,8 +136,8 @@ int af_fmt_change_bits(int format, int bits);
// Amount of bytes that contain audio of the given duration, aligned to frames.
int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int samplerate);
char* af_fmt2str(int format, char* str, int size);
const char* af_fmt2str_short(int format);
char *af_fmt2str(int format, char* str, int size);
const char *af_fmt2str_short(int format);
bool af_fmt_is_valid(int format);