XMMS2
xmms_sample.h
Go to the documentation of this file.
1 /* XMMS2 - X Music Multiplexer System
2  * Copyright (C) 2003-2011 XMMS2 Team
3  *
4  * PLUGINS ARE NOT CONSIDERED TO BE DERIVED WORK !!!
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  */
16 
17 #ifndef __SAMPLE_H__
18 #define __SAMPLE_H__
19 
20 #include <glib.h>
21 #include "xmms/xmms_streamtype.h"
22 
23 G_BEGIN_DECLS
24 
25 typedef enum {
35  /* DO NOT CHANGE ORDER! Just add to the end! */
37 
38 typedef struct xmms_sample_converter_St xmms_sample_converter_t;
39 
40 
41 typedef gint8 xmms_samples8_t;
42 #define XMMS_SAMPLES8_MIN -128
43 #define XMMS_SAMPLES8_MAX 127
44 typedef guint8 xmms_sampleu8_t;
45 #define XMMS_SAMPLEU8_MAX 255
46 typedef gint16 xmms_samples16_t;
47 #define XMMS_SAMPLES16_MIN -32768
48 #define XMMS_SAMPLES16_MAX 32767
49 typedef guint16 xmms_sampleu16_t;
50 #define XMMS_SAMPLEU16_MAX 65535
51 typedef gint32 xmms_samples32_t;
52 #define XMMS_SAMPLES32_MIN (-2147483647L-1)
53 #define XMMS_SAMPLES32_MAX 2147483647L
54 typedef guint32 xmms_sampleu32_t;
55 #define XMMS_SAMPLEU32_MAX 4294967295UL
56 typedef gfloat xmms_samplefloat_t;
57 typedef gdouble xmms_sampledouble_t;
58 typedef void xmms_sample_t;
59 
60 guint xmms_sample_bytes_to_ms (const xmms_stream_type_t *st, guint samples);
61 
62 static inline gint
63 xmms_sample_size_get (xmms_sample_format_t fmt)
64 {
65  switch (fmt) {
67  return -1;
69  return sizeof (xmms_samples8_t);
71  return sizeof (xmms_sampleu8_t);
73  return sizeof (xmms_samples16_t);
75  return sizeof (xmms_sampleu16_t);
77  return sizeof (xmms_samples32_t);
79  return sizeof (xmms_sampleu32_t);
81  return sizeof (xmms_samplefloat_t);
83  return sizeof (xmms_sampledouble_t);
84  }
85  return -1;
86 }
87 
88 static inline gboolean
89 xmms_sample_signed_get (xmms_sample_format_t fmt)
90 {
91  switch (fmt) {
95  return TRUE;
102  return FALSE;
103  }
104  return FALSE;
105 
106 }
107 
108 static inline const gchar *
109 xmms_sample_name_get (xmms_sample_format_t fmt)
110 {
111  switch (fmt) {
113  return "Unknown";
115  return "S8";
117  return "U8";
119  return "S16";
121  return "U16";
123  return "S32";
125  return "U32";
127  return "FLOAT";
129  return "DOUBLE";
130  }
131  return "UNKNOWN";
132 }
133 
134 G_END_DECLS
135 
136 #endif
gfloat xmms_samplefloat_t
Definition: xmms_sample.h:56
guint8 xmms_sampleu8_t
Definition: xmms_sample.h:44
xmms_sample_format_t
Definition: xmms_sample.h:25
struct xmms_stream_type_St xmms_stream_type_t
guint xmms_sample_bytes_to_ms(const xmms_stream_type_t *st, guint samples)
Convert from bytes to milliseconds for this format.
Definition: sample.head.c:199
struct xmms_sample_converter_St xmms_sample_converter_t
Definition: xmms_sample.h:38
gint32 xmms_samples32_t
Definition: xmms_sample.h:51
guint32 xmms_sampleu32_t
Definition: xmms_sample.h:54
void xmms_sample_t
Definition: xmms_sample.h:58
gint16 xmms_samples16_t
Definition: xmms_sample.h:46
guint16 xmms_sampleu16_t
Definition: xmms_sample.h:49
gdouble xmms_sampledouble_t
Definition: xmms_sample.h:57
gint8 xmms_samples8_t
Definition: xmms_sample.h:41