annotate src/musepack/libmpc.h @ 1171:cbe5598f5de4 trunk

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