aboutsummaryrefslogtreecommitdiffstats
path: root/src/audio_format.h
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2011-10-10 09:05:58 +0200
committerMax Kellermann <max@duempel.org>2011-10-10 10:13:43 +0200
commit2c38d19af27ad001876b606950efc0598dd067fb (patch)
tree730aa53c874598d8d1c0441481edbfd00b09baa1 /src/audio_format.h
parent311e627463a17a499a88b50af2404e955115675b (diff)
downloadmpd-2c38d19af27ad001876b606950efc0598dd067fb.tar.gz
mpd-2c38d19af27ad001876b606950efc0598dd067fb.tar.xz
mpd-2c38d19af27ad001876b606950efc0598dd067fb.zip
audio_format: add function attributes
For better optimization.
Diffstat (limited to 'src/audio_format.h')
-rw-r--r--src/audio_format.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/audio_format.h b/src/audio_format.h
index 1e26974bc..8c2906d5f 100644
--- a/src/audio_format.h
+++ b/src/audio_format.h
@@ -20,6 +20,7 @@
#ifndef MPD_AUDIO_FORMAT_H
#define MPD_AUDIO_FORMAT_H
+#include <glib.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
@@ -189,6 +190,7 @@ audio_valid_channel_count(unsigned channels)
* Returns false if the format is not valid for playback with MPD.
* This function performs some basic validity checks.
*/
+G_GNUC_PURE
static inline bool audio_format_valid(const struct audio_format *af)
{
return audio_valid_sample_rate(af->sample_rate) &&
@@ -200,6 +202,7 @@ static inline bool audio_format_valid(const struct audio_format *af)
* Returns false if the format mask is not valid for playback with
* MPD. This function performs some basic validity checks.
*/
+G_GNUC_PURE
static inline bool audio_format_mask_valid(const struct audio_format *af)
{
return (af->sample_rate == 0 ||
@@ -237,6 +240,7 @@ audio_format_mask_apply(struct audio_format *af,
assert(audio_format_valid(af));
}
+G_GNUC_CONST
static inline unsigned
sample_format_size(enum sample_format format)
{
@@ -265,6 +269,7 @@ sample_format_size(enum sample_format format)
/**
* Returns the size of each (mono) sample in bytes.
*/
+G_GNUC_PURE
static inline unsigned audio_format_sample_size(const struct audio_format *af)
{
return sample_format_size((enum sample_format)af->format);
@@ -273,6 +278,7 @@ static inline unsigned audio_format_sample_size(const struct audio_format *af)
/**
* Returns the size of each full frame in bytes.
*/
+G_GNUC_PURE
static inline unsigned
audio_format_frame_size(const struct audio_format *af)
{
@@ -283,6 +289,7 @@ audio_format_frame_size(const struct audio_format *af)
* Returns the floating point factor which converts a time span to a
* storage size in bytes.
*/
+G_GNUC_PURE
static inline double audio_format_time_to_size(const struct audio_format *af)
{
return af->sample_rate * audio_format_frame_size(af);
@@ -295,6 +302,7 @@ static inline double audio_format_time_to_size(const struct audio_format *af)
* @param format a #sample_format enum value
* @return the string
*/
+G_GNUC_PURE G_GNUC_MALLOC
const char *
sample_format_to_string(enum sample_format format);
@@ -306,6 +314,7 @@ sample_format_to_string(enum sample_format format);
* @param s a buffer to print into
* @return the string, or NULL if the #audio_format object is invalid
*/
+G_GNUC_PURE G_GNUC_MALLOC
const char *
audio_format_to_string(const struct audio_format *af,
struct audio_format_string *s);