Mercurial > audlegacy-plugins
annotate src/musepack/libmpc.h @ 3085:ac0af6b39272
Introduce new GIO plugin to buildsystem. stdio is now deprecated.
Thoughts:
- getc()/ungetc() should be moved to VFS core now
author | William Pitcock <nenolod@atheme.org> |
---|---|
date | Wed, 29 Apr 2009 20:58:36 -0500 |
parents | 3134a0987162 |
children |
rev | line source |
---|---|
232 | 1 #ifndef XMMS_MUSEPACK |
2 #define XMMS_MUSEPACK | |
3 | |
1954
6acf1bda788b
Removed some extraneous includes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1950
diff
changeset
|
4 #include "config.h" |
6acf1bda788b
Removed some extraneous includes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1950
diff
changeset
|
5 |
232 | 6 //xmms headers |
7 extern "C" | |
8 { | |
2971
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2576
diff
changeset
|
9 #include <audlegacy/plugin.h> |
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2576
diff
changeset
|
10 #include <audlegacy/output.h> |
3134a0987162
- changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
2576
diff
changeset
|
11 #include <audlegacy/i18n.h> |
232 | 12 } |
13 | |
14 //stdlib headers | |
15 #include <string.h> | |
16 #include <stdio.h> | |
17 #include <stdlib.h> | |
18 #include <unistd.h> | |
19 #include <math.h> | |
20 | |
21 //libmpcdec headers | |
22 #undef TRUE | |
23 #undef FALSE | |
24 #include <mpcdec/mpcdec.h> | |
25 | |
26 //GTK+ headers | |
27 #include <glib.h> | |
28 #include <gtk/gtk.h> | |
29 | |
30 //taglib headers | |
31 #include <taglib/tag.h> | |
32 #include <taglib/apetag.h> | |
33 #include <taglib/mpcfile.h> | |
34 | |
35 #ifndef M_LN10 | |
36 #define M_LN10 2.3025850929940456840179914546843642 | |
37 #endif | |
38 | |
39 typedef struct PluginConfig | |
40 { | |
41 gboolean clipPrevention; | |
42 gboolean dynamicBitrate; | |
43 gboolean replaygain; | |
44 gboolean albumGain; | |
45 gboolean isEq; | |
46 }; | |
47 | |
48 typedef struct Widgets | |
49 { | |
50 GtkWidget* aboutBox; | |
51 GtkWidget* configBox; | |
52 GtkWidget* bitrateCheck; | |
53 GtkWidget* clippingCheck; | |
54 GtkWidget* replaygainCheck; | |
55 GtkWidget* albumCheck; | |
56 GtkWidget* infoBox; | |
57 GtkWidget* albumEntry; | |
58 GtkWidget* artistEntry; | |
59 GtkWidget* titleEntry; | |
60 GtkWidget* genreEntry; | |
61 GtkWidget* yearEntry; | |
62 GtkWidget* trackEntry; | |
63 GtkWidget* commentEntry; | |
64 GtkWidget* fileEntry; | |
65 }; | |
66 | |
67 typedef struct MpcDecoder | |
68 { | |
2112 | 69 gchar* isError; |
232 | 70 double offset; |
71 bool isOutput; | |
72 bool isAlive; | |
73 bool isPause; | |
74 }; | |
75 | |
76 typedef struct TrackInfo | |
77 { | |
2112 | 78 gint bitrate; |
79 gchar* display; | |
80 gint length; | |
81 gint sampleFreq; | |
82 gint channels; | |
232 | 83 }; |
84 | |
85 typedef struct MpcInfo | |
86 { | |
2112 | 87 gchar* title; |
88 gchar* artist; | |
89 gchar* album; | |
90 gchar* comment; | |
91 gchar* genre; | |
92 gchar* date; | |
93 unsigned track; | |
94 unsigned year; | |
232 | 95 }; |
96 | |
97 static void mpcOpenPlugin(); | |
98 static void mpcAboutBox(); | |
99 static void mpcConfigBox(); | |
100 static void toggleSwitch(GtkWidget*, gpointer); | |
101 static void saveConfigBox(GtkWidget*, gpointer); | |
260
4f7b72c88319
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
254
diff
changeset
|
102 static int mpcIsOurFile(char*); |
4f7b72c88319
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
254
diff
changeset
|
103 static int mpcIsOurFD(char*,VFSFile*); |
567 | 104 static void mpcPlay(InputPlayback *data); |
105 static void mpcStop(InputPlayback *data); | |
106 static void mpcPause(InputPlayback *data, short); | |
107 static void mpcSeek(InputPlayback *data, int); | |
2000
89a445c53318
make musepack compile again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1986
diff
changeset
|
108 //static void mpcSetEq(int, float, float*); |
567 | 109 static int mpcGetTime(InputPlayback *data); |
232 | 110 static void mpcGetSongInfo(char*, char**, int*); |
111 static void freeTags(MpcInfo&); | |
112 static MpcInfo getTags(const char*); | |
113 static void mpcFileInfoBox(char*); | |
1044
b1128efde471
[svn] - get rid of all warnings gcc 4.2.0 emits with my build configuration.
yaz
parents:
567
diff
changeset
|
114 static void mpcGtkPrintLabel(GtkWidget*, const char*, ...); |
b1128efde471
[svn] - get rid of all warnings gcc 4.2.0 emits with my build configuration.
yaz
parents:
567
diff
changeset
|
115 static GtkWidget* mpcGtkTagLabel(const char*, int, int, int, int, GtkWidget*); |
232 | 116 static GtkWidget* mpcGtkTagEntry(int, int, int, int, int, GtkWidget*); |
117 static GtkWidget* mpcGtkLabel(GtkWidget*); | |
1044
b1128efde471
[svn] - get rid of all warnings gcc 4.2.0 emits with my build configuration.
yaz
parents:
567
diff
changeset
|
118 static GtkWidget* mpcGtkButton(const char*, GtkWidget*); |
232 | 119 static void removeTags(GtkWidget*, gpointer); |
120 static void saveTags(GtkWidget*, gpointer); | |
121 static void closeInfoBox(GtkWidget*, gpointer); | |
122 static char* mpcGenerateTitle(const MpcInfo&, char*); | |
123 static void lockAcquire(); | |
124 static void lockRelease(); | |
1986 | 125 static void* decodeStream(InputPlayback*); |
2000
89a445c53318
make musepack compile again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1986
diff
changeset
|
126 static int processBuffer(InputPlayback*, MPC_SAMPLE_FORMAT*, char*, mpc_decoder&); |
89a445c53318
make musepack compile again.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1986
diff
changeset
|
127 //static void* endThread(char*, FILE*, bool); |
232 | 128 static bool isAlive(); |
129 static void setAlive(bool); | |
130 static double getOffset(); | |
131 static void setOffset(double); | |
132 static bool isPause(); | |
133 static void setReplaygain(mpc_streaminfo&, mpc_decoder&); | |
1438
dc3e28d3b92a
mpc: convert, wma: fixes
William Pitcock <nenolod@atheme-project.org>
parents:
1304
diff
changeset
|
134 static Tuple * mpcGetSongTuple(char *); |
232 | 135 |
136 #ifdef MPC_FIXED_POINT | |
137 inline static int shiftSigned(MPC_SAMPLE_FORMAT val, int shift) | |
138 { | |
139 if (shift > 0) | |
140 val <<= shift; | |
141 else if (shift < 0) | |
142 val >>= -shift; | |
143 return (int) val; | |
144 } | |
145 #endif | |
146 | |
147 inline static void copyBuffer(MPC_SAMPLE_FORMAT* pInBuf, char* pOutBuf, unsigned pLength) | |
148 { | |
149 unsigned pSize = 16; | |
150 int clipMin = -1 << (pSize - 1); | |
151 int clipMax = (1 << (pSize - 1)) - 1; | |
152 int floatScale = 1 << (pSize - 1); | |
153 for (unsigned n = 0; n < 2 * pLength; n++) | |
154 { | |
155 int val; | |
156 #ifdef MPC_FIXED_POINT | |
157 val = shiftSigned(pInBuf[n], pSize - MPC_FIXED_POINT_SCALE_SHIFT); | |
158 #else | |
159 val = (int) (pInBuf[n] * floatScale); | |
160 #endif | |
161 if (val < clipMin) | |
162 val = clipMin; | |
163 else if (val > clipMax) | |
164 val = clipMax; | |
165 unsigned shift = 0; | |
166 do | |
167 { | |
168 pOutBuf[n * 2 + (shift / 8)] = (unsigned char) ((val >> shift) & 0xFF); | |
169 shift += 8; | |
170 } | |
171 while (shift < pSize); | |
172 } | |
173 } | |
174 | |
175 #endif |