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>
22
23G_BEGIN_DECLS
24
25typedef enum {
35 /* DO NOT CHANGE ORDER! Just add to the end! */
37
38typedef struct xmms_sample_converter_St xmms_sample_converter_t;
39
40
41typedef gint8 xmms_samples8_t;
42#define XMMS_SAMPLES8_MIN -128
43#define XMMS_SAMPLES8_MAX 127
44typedef guint8 xmms_sampleu8_t;
45#define XMMS_SAMPLEU8_MAX 255
46typedef gint16 xmms_samples16_t;
47#define XMMS_SAMPLES16_MIN -32768
48#define XMMS_SAMPLES16_MAX 32767
49typedef guint16 xmms_sampleu16_t;
50#define XMMS_SAMPLEU16_MAX 65535
51typedef gint32 xmms_samples32_t;
52#define XMMS_SAMPLES32_MIN (-2147483647L-1)
53#define XMMS_SAMPLES32_MAX 2147483647L
54typedef guint32 xmms_sampleu32_t;
55#define XMMS_SAMPLEU32_MAX 4294967295UL
56typedef gfloat xmms_samplefloat_t;
57typedef gdouble xmms_sampledouble_t;
58typedef void xmms_sample_t;
59
60guint xmms_sample_bytes_to_ms (const xmms_stream_type_t *st, guint samples);
61
62static inline gint
63xmms_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
88static inline gboolean
89xmms_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
108static inline const gchar *
109xmms_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
134G_END_DECLS
135
136#endif
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
gint8 xmms_samples8_t
Definition: xmms_sample.h:41
gfloat xmms_samplefloat_t
Definition: xmms_sample.h:56
gint16 xmms_samples16_t
Definition: xmms_sample.h:46
void xmms_sample_t
Definition: xmms_sample.h:58
gdouble xmms_sampledouble_t
Definition: xmms_sample.h:57
guint32 xmms_sampleu32_t
Definition: xmms_sample.h:54
guint8 xmms_sampleu8_t
Definition: xmms_sample.h:44
gint32 xmms_samples32_t
Definition: xmms_sample.h:51
struct xmms_sample_converter_St xmms_sample_converter_t
Definition: xmms_sample.h:38
xmms_sample_format_t
Definition: xmms_sample.h:25
@ XMMS_SAMPLE_FORMAT_S16
Definition: xmms_sample.h:29
@ XMMS_SAMPLE_FORMAT_U16
Definition: xmms_sample.h:30
@ XMMS_SAMPLE_FORMAT_DOUBLE
Definition: xmms_sample.h:34
@ XMMS_SAMPLE_FORMAT_FLOAT
Definition: xmms_sample.h:33
@ XMMS_SAMPLE_FORMAT_U8
Definition: xmms_sample.h:28
@ XMMS_SAMPLE_FORMAT_UNKNOWN
Definition: xmms_sample.h:26
@ XMMS_SAMPLE_FORMAT_S32
Definition: xmms_sample.h:31
@ XMMS_SAMPLE_FORMAT_S8
Definition: xmms_sample.h:27
@ XMMS_SAMPLE_FORMAT_U32
Definition: xmms_sample.h:32
guint16 xmms_sampleu16_t
Definition: xmms_sample.h:49
struct xmms_stream_type_St xmms_stream_type_t