Mercurial > audlegacy-plugins
annotate src/musepack/libmpc.h @ 472:69b8baad0b24 trunk
[svn] - stuff from vfs_get_metadata is already strdup'd
author | nenolod |
---|---|
date | Sun, 21 Jan 2007 02:16:17 -0800 |
parents | 4f7b72c88319 |
children | 1e987b380776 |
rev | line source |
---|---|
232 | 1 #ifndef XMMS_MUSEPACK |
2 #define XMMS_MUSEPACK | |
3 | |
4 //xmms headers | |
5 extern "C" | |
6 { | |
7 #include "audacious/plugin.h" | |
8 #include "audacious/output.h" | |
9 #include "audacious/util.h" | |
10 #include "audacious/configdb.h" | |
11 #include "audacious/titlestring.h" | |
12 #include "audacious/vfs.h" | |
13 } | |
14 | |
15 //stdlib headers | |
16 #include <string.h> | |
17 #include <stdio.h> | |
18 #include <stdlib.h> | |
19 #include <unistd.h> | |
20 #include <math.h> | |
21 | |
22 //libmpcdec headers | |
23 #undef TRUE | |
24 #undef FALSE | |
25 #include <mpcdec/mpcdec.h> | |
26 | |
27 //GTK+ headers | |
28 #include <glib.h> | |
29 #include <gtk/gtk.h> | |
30 | |
31 //taglib headers | |
32 #include <taglib/tag.h> | |
33 #include <taglib/apetag.h> | |
34 #include <taglib/mpcfile.h> | |
35 | |
36 #ifndef M_LN10 | |
37 #define M_LN10 2.3025850929940456840179914546843642 | |
38 #endif | |
39 | |
40 typedef struct PluginConfig | |
41 { | |
42 gboolean clipPrevention; | |
43 gboolean dynamicBitrate; | |
44 gboolean replaygain; | |
45 gboolean albumGain; | |
46 gboolean isEq; | |
47 }; | |
48 | |
49 typedef struct Widgets | |
50 { | |
51 GtkWidget* aboutBox; | |
52 GtkWidget* configBox; | |
53 GtkWidget* bitrateCheck; | |
54 GtkWidget* clippingCheck; | |
55 GtkWidget* replaygainCheck; | |
56 GtkWidget* albumCheck; | |
57 GtkWidget* infoBox; | |
58 GtkWidget* albumEntry; | |
59 GtkWidget* artistEntry; | |
60 GtkWidget* titleEntry; | |
61 GtkWidget* genreEntry; | |
62 GtkWidget* yearEntry; | |
63 GtkWidget* trackEntry; | |
64 GtkWidget* commentEntry; | |
65 GtkWidget* fileEntry; | |
66 }; | |
67 | |
68 typedef struct MpcDecoder | |
69 { | |
70 char* isError; | |
71 double offset; | |
72 bool isOutput; | |
73 bool isAlive; | |
74 bool isPause; | |
75 }; | |
76 | |
77 typedef struct TrackInfo | |
78 { | |
79 int bitrate; | |
80 char* display; | |
81 int length; | |
82 int sampleFreq; | |
83 int channels; | |
84 }; | |
85 | |
86 typedef struct MpcInfo | |
87 { | |
88 char* title; | |
89 char* artist; | |
90 char* album; | |
91 char* comment; | |
92 char* genre; | |
93 char* date; | |
94 unsigned track; | |
95 unsigned year; | |
96 }; | |
97 | |
98 extern "C" InputPlugin * get_iplugin_info(void); | |
99 | |
100 static void mpcOpenPlugin(); | |
101 static void mpcAboutBox(); | |
102 static void mpcConfigBox(); | |
103 static void toggleSwitch(GtkWidget*, gpointer); | |
104 static void saveConfigBox(GtkWidget*, gpointer); | |
260
4f7b72c88319
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
254
diff
changeset
|
105 static int mpcIsOurFile(char*); |
4f7b72c88319
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
254
diff
changeset
|
106 static int mpcIsOurFD(char*,VFSFile*); |
232 | 107 static void mpcPlay(char*); |
108 static void mpcStop(); | |
109 static void mpcPause(short); | |
110 static void mpcSeek(int); | |
111 static void mpcSetEq(int, float, float*); | |
112 static int mpcGetTime(); | |
113 static void mpcGetSongInfo(char*, char**, int*); | |
114 static void freeTags(MpcInfo&); | |
115 static MpcInfo getTags(const char*); | |
116 static void mpcFileInfoBox(char*); | |
117 static void mpcGtkPrintLabel(GtkWidget*, char*, ...); | |
118 static GtkWidget* mpcGtkTagLabel(char*, int, int, int, int, GtkWidget*); | |
119 static GtkWidget* mpcGtkTagEntry(int, int, int, int, int, GtkWidget*); | |
120 static GtkWidget* mpcGtkLabel(GtkWidget*); | |
121 static GtkWidget* mpcGtkButton(char*, GtkWidget*); | |
122 static void removeTags(GtkWidget*, gpointer); | |
123 static void saveTags(GtkWidget*, gpointer); | |
124 static void closeInfoBox(GtkWidget*, gpointer); | |
125 static char* mpcGenerateTitle(const MpcInfo&, char*); | |
126 static void lockAcquire(); | |
127 static void lockRelease(); | |
128 static void* decodeStream(void*); | |
129 static int processBuffer(MPC_SAMPLE_FORMAT*, char*, mpc_decoder&); | |
130 static void* endThread(char*, FILE*, bool); | |
131 static bool isAlive(); | |
132 static void setAlive(bool); | |
133 static double getOffset(); | |
134 static void setOffset(double); | |
135 static bool isPause(); | |
136 static void setReplaygain(mpc_streaminfo&, mpc_decoder&); | |
137 static TitleInput* mpcGetSongTuple(char *); | |
138 | |
139 #ifdef MPC_FIXED_POINT | |
140 inline static int shiftSigned(MPC_SAMPLE_FORMAT val, int shift) | |
141 { | |
142 if (shift > 0) | |
143 val <<= shift; | |
144 else if (shift < 0) | |
145 val >>= -shift; | |
146 return (int) val; | |
147 } | |
148 #endif | |
149 | |
150 inline static void copyBuffer(MPC_SAMPLE_FORMAT* pInBuf, char* pOutBuf, unsigned pLength) | |
151 { | |
152 unsigned pSize = 16; | |
153 int clipMin = -1 << (pSize - 1); | |
154 int clipMax = (1 << (pSize - 1)) - 1; | |
155 int floatScale = 1 << (pSize - 1); | |
156 for (unsigned n = 0; n < 2 * pLength; n++) | |
157 { | |
158 int val; | |
159 #ifdef MPC_FIXED_POINT | |
160 val = shiftSigned(pInBuf[n], pSize - MPC_FIXED_POINT_SCALE_SHIFT); | |
161 #else | |
162 val = (int) (pInBuf[n] * floatScale); | |
163 #endif | |
164 if (val < clipMin) | |
165 val = clipMin; | |
166 else if (val > clipMax) | |
167 val = clipMax; | |
168 unsigned shift = 0; | |
169 do | |
170 { | |
171 pOutBuf[n * 2 + (shift / 8)] = (unsigned char) ((val >> shift) & 0xFF); | |
172 shift += 8; | |
173 } | |
174 while (shift < pSize); | |
175 } | |
176 } | |
177 | |
178 #endif |