audio_format: added function audio_format_to_string()

Unified function for converting an audio_format object to a string,
for log messages and for the "status" command.
This commit is contained in:
Max Kellermann
2009-11-10 17:57:14 +01:00
parent e5b119a324
commit cef5dcc0a1
9 changed files with 95 additions and 29 deletions

View File

@@ -55,6 +55,13 @@ struct audio_format {
uint8_t reverse_endian;
};
/**
* Buffer for audio_format_string().
*/
struct audio_format_string {
char buffer[24];
};
/**
* Clears the #audio_format object, i.e. sets all attributes to an
* undefined (invalid) value.
@@ -219,4 +226,16 @@ static inline double audio_format_time_to_size(const struct audio_format *af)
return af->sample_rate * audio_format_frame_size(af);
}
/**
* Renders the #audio_format object into a string, e.g. for printing
* it in a log file.
*
* @param af the #audio_format object
* @param s a buffer to print into
* @return the string, or NULL if the #audio_format object is invalid
*/
const char *
audio_format_to_string(const struct audio_format *af,
struct audio_format_string *s);
#endif