rem: char fmtstr[20]; const char *fmt; switch (format.u.raw_audio.format) { case media_raw_audio_format::B_AUDIO_FLOAT: fmt = "float"; break; case media_raw_audio_format::B_AUDIO_INT: if (format.u.raw_audio.valid_bits != 0) { sprintf(fmtstr, "%d bit", format.u.raw_audio.valid_bits); fmt = fmtstr; } else { fmt = "32 bit"; } break; case media_raw_audio_format::B_AUDIO_SHORT: fmt = "16 bit"; break; case media_raw_audio_format::B_AUDIO_CHAR: fmt = "8 bit"; break; case media_raw_audio_format::B_AUDIO_UCHAR: fmt = "8 bit unsigned"; break; default: fmt = "unknown"; break; } int a,b; a = int(format.u.raw_audio.frame_rate + 0.05) / 1000; b = int(format.u.raw_audio.frame_rate + 0.05) % 1000; if (b) sprintf(str, "%d.%d kHz %s", a, b / 100, fmt); else sprintf(str, "%d kHz %s", a, fmt); return str;
add: return StringForFormat(buf, input->MediaInput().format);
context: const char *StringForFormat(char *str, const media_format & format){	char fmtstr[20];	const char *fmt;	switch (format.u.raw_audio.format) {		case media_raw_audio_format::B_AUDIO_FLOAT:			fmt = "float";			break;		case media_raw_audio_format::B_AUDIO_INT:			if (format.u.raw_audio.valid_bits != 0) {				sprintf(fmtstr, "%d bit", format.u.raw_audio.valid_bits);				fmt = fmtstr;			} else {				fmt = "32 bit";			}			break;		case media_raw_audio_format::B_AUDIO_SHORT:			fmt = "16 bit";			break;		case media_raw_audio_format::B_AUDIO_CHAR:			fmt = "8 bit";			break;		case media_raw_audio_format::B_AUDIO_UCHAR:			fmt = "8 bit unsigned";			break;		default:			fmt = "unknown";			break;	}	int a,b;	a = int(format.u.raw_audio.frame_rate + 0.05) / 1000;	b = int(format.u.raw_audio.frame_rate + 0.05) % 1000;	if (b)		sprintf(str, "%d.%d kHz %s", a, b / 100, fmt);	else		sprintf(str, "%d kHz %s", a, fmt);	return str;}