annotate src/musepack/libmpc.cxx @ 2147:e49d9b0ee308

Change my mail.
author Jonathan Schleifer <js@h3c.de>
date Thu, 01 Nov 2007 15:37:43 +0100
parents 2f2ffbc2d04d
children ac599b9b0490
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 #include "libmpc.h"
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
2
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
3 #define FORCED_THREAD_STACKSIZE 1024 * 1000
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
4 #define REMOVE_NONEXISTANT_TAG(x) if (!*x) { x = NULL; }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
5
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
6 using TagLib::MPC::File;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
7 using TagLib::Tag;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
8 using TagLib::String;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
9 using TagLib::APE::ItemListMap;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
10
1044
b1128efde471 [svn] - get rid of all warnings gcc 4.2.0 emits with my build configuration.
yaz
parents: 659
diff changeset
11 const gchar *mpc_fmts[] = { "mpc", NULL };
372
a157306caf03 [svn] - finalize the plugin-side of the extension-assist ABI
nenolod
parents: 368
diff changeset
12
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
13 InputPlugin MpcPlugin = {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
14 NULL, //File Handle FILE* handle
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
15 NULL, //Filename char* filename
1185
6d749f573b3b suppress warnings.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1079
diff changeset
16 (gchar *)"Musepack Audio Plugin",
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
17 mpcOpenPlugin, //Open Plugin [CALLBACK]
1621
031e91938009 musepack: C++ at it's worst.
William Pitcock <nenolod@atheme.org>
parents: 1510
diff changeset
18 NULL, //Cleanup [UNUSED]
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
19 mpcAboutBox, //Show About box [CALLBACK]
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
20 mpcConfigBox, //Show Configure box [CALLBACK]
1621
031e91938009 musepack: C++ at it's worst.
William Pitcock <nenolod@atheme.org>
parents: 1510
diff changeset
21 FALSE, //Enabled/Disabled [BOOLEAN]
260
4f7b72c88319 [svn] So input.c wants to have the old-style function available...
chainsaw
parents: 254
diff changeset
22 mpcIsOurFile, //Check if it's our file [CALLBACK]
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
23 NULL, //Scan the directory [UNUSED]
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
24 mpcPlay, //Play [CALLBACK]
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
25 mpcStop, //Stop [CALLBACK]
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
26 mpcPause, //Pause [CALLBACK]
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
27 mpcSeek, //Seek [CALLBACK]
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
28 NULL, //Set EQ [CALLBACK]
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
29 mpcGetTime, //Get Time [CALLBACK]
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
30 NULL, //Get Volume [UNUSED]
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
31 NULL, //Set Volume [UNUSED]
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
32 NULL, //Obsolete [UNUSED]
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
33 NULL, //Visual plugins add_vis_pcm(int time, AFormat fmt, int nch, int length, void *ptr)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
34 NULL, //Set Info Settings set_info(char *title, int length, int rate, int freq, int nch)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
35 NULL, //set Info Text set_info_text(char* text)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
36 mpcGetSongInfo, //Get Title String callback [CALLBACK]
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
37 mpcFileInfoBox, //Show File Info Box [CALLBACK]
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
38 NULL, //Output Plugin Handle OutputPlugin output
254
cdf9756d1528 [svn] Port to NewVFS file probe.
chainsaw
parents: 232
diff changeset
39 mpcGetSongTuple,//Acquire tuple for song [CALLBACK]
cdf9756d1528 [svn] Port to NewVFS file probe.
chainsaw
parents: 232
diff changeset
40 NULL,
cdf9756d1528 [svn] Port to NewVFS file probe.
chainsaw
parents: 232
diff changeset
41 NULL,
cdf9756d1528 [svn] Port to NewVFS file probe.
chainsaw
parents: 232
diff changeset
42 mpcIsOurFD,
1044
b1128efde471 [svn] - get rid of all warnings gcc 4.2.0 emits with my build configuration.
yaz
parents: 659
diff changeset
43 (gchar **)mpc_fmts
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
44 };
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
45
1079
d0d7b6dd45f0 [svn] - musepack: transition to plugin API v2
nenolod
parents: 1044
diff changeset
46 InputPlugin *mpc_iplist[] = { &MpcPlugin, NULL };
d0d7b6dd45f0 [svn] - musepack: transition to plugin API v2
nenolod
parents: 1044
diff changeset
47
1395
761e17b23e0c added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents: 1357
diff changeset
48 DECLARE_PLUGIN(musepack, NULL, NULL, mpc_iplist, NULL, NULL, NULL, NULL,NULL);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
49
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
50 static PluginConfig pluginConfig = {0};
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
51 static Widgets widgets = {0};
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
52 static MpcDecoder mpcDecoder = {0};
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
53 static TrackInfo track = {0};
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
54
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
55 static GThread *threadHandle;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
56 GStaticMutex threadMutex = G_STATIC_MUTEX_INIT;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
57
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
58 /*
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
59 * VFS callback implementation, adapted from mpc_reader.c.
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
60 * This _IS_ very sick, but it works. -nenolod
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
61 */
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
62 static mpc_int32_t
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
63 aud_vfs_fread_impl(void *data, void *ptr, mpc_int32_t size)
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
64 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
65 mpc_reader_file *d = (mpc_reader_file *) data;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
66 VFSFile *file = (VFSFile *) d->file;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
67
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
68 return (mpc_int32_t) aud_vfs_fread(ptr, 1, size, file);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
69 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
70
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
71 static mpc_bool_t
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
72 aud_vfs_fseek_impl(void *data, mpc_int32_t offset)
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
73 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
74 mpc_reader_file *d = (mpc_reader_file *) data;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
75 VFSFile *file = (VFSFile *) d->file;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
76
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
77 return d->is_seekable ? aud_vfs_fseek(file, offset, SEEK_SET) == 0 : FALSE;
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
78 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
79
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
80 static mpc_int32_t
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
81 aud_vfs_ftell_impl(void *data)
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
82 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
83 mpc_reader_file *d = (mpc_reader_file *) data;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
84 VFSFile *file = (VFSFile *) d->file;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
85
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
86 return aud_vfs_ftell(file);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
87 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
88
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
89 static mpc_int32_t
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
90 aud_vfs_getsize_impl(void *data)
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
91 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
92 mpc_reader_file *d = (mpc_reader_file *) data;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
93
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
94 return d->file_size;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
95 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
96
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
97 static mpc_bool_t
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
98 aud_vfs_canseek_impl(void *data)
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
99 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
100 mpc_reader_file *d = (mpc_reader_file *) data;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
101
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
102 return d->is_seekable;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
103 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
104
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
105 /*
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
106 * This sets up an mpc_reader_file object to read from VFS instead of libc.
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
107 * Essentially, we use this instead of the normal constructor.
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
108 * - nenolod
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
109 */
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
110 void
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
111 mpc_reader_setup_file_vfs(mpc_reader_file *p_reader, VFSFile *input)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
112 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
113 p_reader->reader.seek = aud_vfs_fseek_impl;
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
114 p_reader->reader.read = aud_vfs_fread_impl;
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
115 p_reader->reader.tell = aud_vfs_ftell_impl;
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
116 p_reader->reader.get_size = aud_vfs_getsize_impl;
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
117 p_reader->reader.canseek = aud_vfs_canseek_impl;
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
118 p_reader->reader.data = p_reader;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
119
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
120 p_reader->file = (FILE *) input; // no worries, it gets cast back -nenolod
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
121 p_reader->is_seekable = TRUE; // XXX streams
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
122
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
123 aud_vfs_fseek(input, 0, SEEK_END);
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
124 p_reader->file_size = aud_vfs_ftell(input);
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
125 aud_vfs_fseek(input, 0, SEEK_SET);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
126 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
127
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
128 static void mpcOpenPlugin()
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
129 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
130 ConfigDb *cfg;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
131 cfg = bmp_cfg_db_open();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
132 bmp_cfg_db_get_bool(cfg, "musepack", "clipPrevention", &pluginConfig.clipPrevention);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
133 bmp_cfg_db_get_bool(cfg, "musepack", "albumGain", &pluginConfig.albumGain);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
134 bmp_cfg_db_get_bool(cfg, "musepack", "dynamicBitrate", &pluginConfig.dynamicBitrate);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
135 bmp_cfg_db_get_bool(cfg, "musepack", "replaygain", &pluginConfig.replaygain);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
136 bmp_cfg_db_close(cfg);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
137 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
138
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
139 static void mpcAboutBox()
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
140 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
141 GtkWidget* aboutBox = widgets.aboutBox;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
142 if (aboutBox)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
143 gdk_window_raise(aboutBox->window);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
144 else
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
145 {
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
146 char* titleText = g_strdup_printf(_("Musepack Decoder Plugin 1.2"));
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
147 const char* contentText = _("Plugin code by\nBenoit Amiaux\nMartin Spuler\nKuniklo\n\nGet latest version at http://musepack.net\n");
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
148 const char* buttonText = _("Nevermind");
1677
f6f5603a0954 xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents: 1676
diff changeset
149 aboutBox = audacious_info_dialog(titleText, contentText, buttonText, FALSE, NULL, NULL);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
150 widgets.aboutBox = aboutBox;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
151 g_signal_connect(G_OBJECT(aboutBox), "destroy", G_CALLBACK(gtk_widget_destroyed), &widgets.aboutBox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
152 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
153 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
154
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
155 static void mpcConfigBox()
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
156 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
157 GtkWidget* configBox = widgets.configBox;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
158 if(configBox)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
159 gdk_window_raise(configBox->window);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
160 else
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
161 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
162 configBox = gtk_window_new(GTK_WINDOW_TOPLEVEL);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
163 gtk_window_set_type_hint(GTK_WINDOW(configBox), GDK_WINDOW_TYPE_HINT_DIALOG);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
164 widgets.configBox = configBox;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
165 g_signal_connect(G_OBJECT(configBox), "destroy", G_CALLBACK(gtk_widget_destroyed), &widgets.configBox);
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
166 gtk_window_set_title(GTK_WINDOW(configBox), _("Musepack Decoder Configuration"));
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
167 gtk_window_set_policy(GTK_WINDOW(configBox), FALSE, FALSE, FALSE);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
168 gtk_container_border_width(GTK_CONTAINER(configBox), 10);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
169
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
170 GtkWidget* notebook = gtk_notebook_new();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
171 GtkWidget* vbox = gtk_vbox_new(FALSE, 10);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
172 gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
173 gtk_container_add(GTK_CONTAINER(configBox), vbox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
174
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
175 //General Settings Tab
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
176 GtkWidget* generalSet = gtk_frame_new(_("General Settings"));
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
177 gtk_container_border_width(GTK_CONTAINER(generalSet), 5);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
178
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
179 GtkWidget* gSvbox = gtk_vbox_new(FALSE, 10);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
180 gtk_container_border_width(GTK_CONTAINER(gSvbox), 5);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
181 gtk_container_add(GTK_CONTAINER(generalSet), gSvbox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
182
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
183 GtkWidget* bitrateCheck = gtk_check_button_new_with_label(_("Enable Dynamic Bitrate Display"));
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
184 widgets.bitrateCheck = bitrateCheck;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
185 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bitrateCheck), pluginConfig.dynamicBitrate);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
186 gtk_box_pack_start(GTK_BOX(gSvbox), bitrateCheck, FALSE, FALSE, 0);
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
187 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), generalSet, gtk_label_new(_("Plugin")));
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
188
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
189 //ReplayGain Settings Tab
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
190 GtkWidget* replaygainSet = gtk_frame_new(_("ReplayGain Settings"));
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
191 gtk_container_border_width(GTK_CONTAINER(replaygainSet), 5);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
192
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
193 GtkWidget* rSVbox = gtk_vbox_new(FALSE, 10);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
194 gtk_container_border_width(GTK_CONTAINER(rSVbox), 5);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
195 gtk_container_add(GTK_CONTAINER(replaygainSet), rSVbox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
196
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
197 GtkWidget* clippingCheck = gtk_check_button_new_with_label(_("Enable Clipping Prevention"));
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
198 widgets.clippingCheck = clippingCheck;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
199 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(clippingCheck), pluginConfig.clipPrevention);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
200 gtk_box_pack_start(GTK_BOX(rSVbox), clippingCheck, FALSE, FALSE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
201
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
202 GtkWidget* replaygainCheck = gtk_check_button_new_with_label(_("Enable ReplayGain"));
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
203 widgets.replaygainCheck = replaygainCheck;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
204 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(replaygainCheck), pluginConfig.replaygain);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
205 gtk_box_pack_start(GTK_BOX(rSVbox), replaygainCheck, FALSE, FALSE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
206
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
207 GtkWidget* replaygainType = gtk_frame_new(_("ReplayGain Type"));
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
208 gtk_box_pack_start(GTK_BOX(rSVbox), replaygainType, FALSE, FALSE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
209 g_signal_connect(G_OBJECT(replaygainCheck), "toggled", G_CALLBACK(toggleSwitch), replaygainType);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
210
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
211 GtkWidget* rgVbox = gtk_vbox_new(FALSE, 5);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
212 gtk_container_set_border_width(GTK_CONTAINER(rgVbox), 5);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
213 gtk_container_add(GTK_CONTAINER(replaygainType), rgVbox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
214
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
215 GtkWidget* trackCheck = gtk_radio_button_new_with_label(NULL, _("Use Track Gain"));
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
216 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(trackCheck), !pluginConfig.albumGain);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
217 gtk_box_pack_start(GTK_BOX(rgVbox), trackCheck, FALSE, FALSE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
218
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
219 GtkWidget* albumCheck = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(trackCheck)), _("Use Album Gain"));
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
220 widgets.albumCheck = albumCheck;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
221 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(albumCheck), pluginConfig.albumGain);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
222 gtk_box_pack_start(GTK_BOX(rgVbox), albumCheck, FALSE, FALSE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
223 gtk_widget_set_sensitive(replaygainType, pluginConfig.replaygain);
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
224 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), replaygainSet, gtk_label_new(_("ReplayGain")));
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
225
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
226 //Buttons
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
227 GtkWidget* buttonBox = gtk_hbutton_box_new();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
228 gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonBox), GTK_BUTTONBOX_END);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
229 gtk_button_box_set_spacing(GTK_BUTTON_BOX(buttonBox), 5);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
230 gtk_box_pack_start(GTK_BOX(vbox), buttonBox, FALSE, FALSE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
231
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
232 GtkWidget* okButton = gtk_button_new_with_label(_("Ok"));
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
233 g_signal_connect(G_OBJECT(okButton), "clicked", G_CALLBACK(saveConfigBox), NULL);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
234 GTK_WIDGET_SET_FLAGS(okButton, GTK_CAN_DEFAULT);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
235 gtk_box_pack_start(GTK_BOX(buttonBox), okButton, TRUE, TRUE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
236
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
237 GtkWidget* cancelButton = gtk_button_new_with_label(_("Cancel"));
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
238 g_signal_connect_swapped(G_OBJECT(cancelButton), "clicked", G_CALLBACK(gtk_widget_destroy), GTK_OBJECT(widgets.configBox));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
239 GTK_WIDGET_SET_FLAGS(cancelButton, GTK_CAN_DEFAULT);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
240 gtk_widget_grab_default(cancelButton);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
241 gtk_box_pack_start(GTK_BOX(buttonBox), cancelButton, TRUE, TRUE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
242
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
243 gtk_widget_show_all(configBox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
244 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
245 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
246
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
247 static void toggleSwitch(GtkWidget* p_Widget, gpointer p_Data)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
248 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
249 gtk_widget_set_sensitive(GTK_WIDGET(p_Data), gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_Widget)));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
250 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
251
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
252 static void saveConfigBox(GtkWidget* p_Widget, gpointer p_Data)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
253 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
254 ConfigDb* cfg;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
255 GtkToggleButton* tb;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
256
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
257 tb = GTK_TOGGLE_BUTTON(widgets.replaygainCheck);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
258 pluginConfig.replaygain = gtk_toggle_button_get_active(tb);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
259 tb = GTK_TOGGLE_BUTTON(widgets.clippingCheck);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
260 pluginConfig.clipPrevention = gtk_toggle_button_get_active(tb);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
261 tb = GTK_TOGGLE_BUTTON(widgets.bitrateCheck);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
262 pluginConfig.dynamicBitrate = gtk_toggle_button_get_active(tb);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
263 tb = GTK_TOGGLE_BUTTON(widgets.albumCheck);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
264 pluginConfig.albumGain = gtk_toggle_button_get_active(tb);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
265
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
266 cfg = bmp_cfg_db_open();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
267
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
268 bmp_cfg_db_set_bool(cfg, "musepack", "clipPrevention", pluginConfig.clipPrevention);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
269 bmp_cfg_db_set_bool(cfg, "musepack", "albumGain", pluginConfig.albumGain);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
270 bmp_cfg_db_set_bool(cfg, "musepack", "dynamicBitrate", pluginConfig.dynamicBitrate);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
271 bmp_cfg_db_set_bool(cfg, "musepack", "replaygain", pluginConfig.replaygain);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
272
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
273 bmp_cfg_db_close(cfg);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
274
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
275 gtk_widget_destroy (widgets.configBox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
276 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
277
260
4f7b72c88319 [svn] So input.c wants to have the old-style function available...
chainsaw
parents: 254
diff changeset
278 static int mpcIsOurFile(char* p_Filename)
4f7b72c88319 [svn] So input.c wants to have the old-style function available...
chainsaw
parents: 254
diff changeset
279 {
4f7b72c88319 [svn] So input.c wants to have the old-style function available...
chainsaw
parents: 254
diff changeset
280 VFSFile *file;
4f7b72c88319 [svn] So input.c wants to have the old-style function available...
chainsaw
parents: 254
diff changeset
281 gchar magic[3];
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
282 if ((file = aud_vfs_fopen(p_Filename, "rb"))) {
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
283 aud_vfs_fread(magic, 1, 3, file);
260
4f7b72c88319 [svn] So input.c wants to have the old-style function available...
chainsaw
parents: 254
diff changeset
284 if (!memcmp(magic, "MP+", 3)) {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
285 aud_vfs_fclose(file);
260
4f7b72c88319 [svn] So input.c wants to have the old-style function available...
chainsaw
parents: 254
diff changeset
286 return 1;
4f7b72c88319 [svn] So input.c wants to have the old-style function available...
chainsaw
parents: 254
diff changeset
287 }
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
288 aud_vfs_fclose(file);
260
4f7b72c88319 [svn] So input.c wants to have the old-style function available...
chainsaw
parents: 254
diff changeset
289 }
4f7b72c88319 [svn] So input.c wants to have the old-style function available...
chainsaw
parents: 254
diff changeset
290 return 0;
4f7b72c88319 [svn] So input.c wants to have the old-style function available...
chainsaw
parents: 254
diff changeset
291 }
4f7b72c88319 [svn] So input.c wants to have the old-style function available...
chainsaw
parents: 254
diff changeset
292
254
cdf9756d1528 [svn] Port to NewVFS file probe.
chainsaw
parents: 232
diff changeset
293 static int mpcIsOurFD(char* p_Filename, VFSFile* file)
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
294 {
254
cdf9756d1528 [svn] Port to NewVFS file probe.
chainsaw
parents: 232
diff changeset
295 gchar magic[3];
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
296 aud_vfs_fread(magic, 1, 3, file);
260
4f7b72c88319 [svn] So input.c wants to have the old-style function available...
chainsaw
parents: 254
diff changeset
297 if (!memcmp(magic, "MP+", 3))
254
cdf9756d1528 [svn] Port to NewVFS file probe.
chainsaw
parents: 232
diff changeset
298 return 1;
cdf9756d1528 [svn] Port to NewVFS file probe.
chainsaw
parents: 232
diff changeset
299 return 0;
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
300 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
301
567
1e987b380776 [svn] - update to new plugin API
nenolod
parents: 372
diff changeset
302 static void mpcPlay(InputPlayback *data)
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
303 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
304 mpcDecoder.offset = -1;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
305 mpcDecoder.isAlive = true;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
306 mpcDecoder.isOutput = false;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
307 mpcDecoder.isPause = false;
1357
cf46ed0ee590 musepack: new threading model
William Pitcock <nenolod@atheme-project.org>
parents: 1304
diff changeset
308 threadHandle = g_thread_self();
1447
195b5657303e updated input plugins to use set_pb_ready to signal to the core that they're ready for playback
Giacomo Lozito <james@develia.org>
parents: 1438
diff changeset
309 data->set_pb_ready(data);
1986
4b78df9dcf93 more set_params()
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
310 decodeStream(data);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
311 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
312
567
1e987b380776 [svn] - update to new plugin API
nenolod
parents: 372
diff changeset
313 static void mpcStop(InputPlayback *data)
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
314 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
315 setAlive(false);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
316 if (threadHandle)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
317 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
318 g_thread_join(threadHandle);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
319 if (mpcDecoder.isOutput)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
320 {
567
1e987b380776 [svn] - update to new plugin API
nenolod
parents: 372
diff changeset
321 data->output->buffer_free();
1e987b380776 [svn] - update to new plugin API
nenolod
parents: 372
diff changeset
322 data->output->close_audio();
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
323 mpcDecoder.isOutput = false;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
324 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
325 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
326 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
327
567
1e987b380776 [svn] - update to new plugin API
nenolod
parents: 372
diff changeset
328 static void mpcPause(InputPlayback *data, short p_Pause)
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
329 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
330 lockAcquire();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
331 mpcDecoder.isPause = p_Pause;
567
1e987b380776 [svn] - update to new plugin API
nenolod
parents: 372
diff changeset
332 data->output->pause(p_Pause);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
333 lockRelease();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
334 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
335
567
1e987b380776 [svn] - update to new plugin API
nenolod
parents: 372
diff changeset
336 static void mpcSeek(InputPlayback *data, int p_Offset)
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
337 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
338 lockAcquire();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
339 mpcDecoder.offset = static_cast<double> (p_Offset);
567
1e987b380776 [svn] - update to new plugin API
nenolod
parents: 372
diff changeset
340 data->output->flush(1000 * p_Offset);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
341 lockRelease();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
342 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
343
567
1e987b380776 [svn] - update to new plugin API
nenolod
parents: 372
diff changeset
344 static int mpcGetTime(InputPlayback *data)
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
345 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
346 if(!isAlive())
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
347 return -1;
567
1e987b380776 [svn] - update to new plugin API
nenolod
parents: 372
diff changeset
348 return data->output->output_time();
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
349 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
350
1438
dc3e28d3b92a mpc: convert, wma: fixes
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
351 static Tuple *mpcGetSongTuple(char* p_Filename)
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
352 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
353 VFSFile *input = aud_vfs_fopen(p_Filename, "rb");
1438
dc3e28d3b92a mpc: convert, wma: fixes
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
354 Tuple *tuple = NULL;
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
355
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
356 if(input)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
357 {
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1704
diff changeset
358 tuple = aud_tuple_new_from_filename(p_Filename);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
359
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
360 MpcInfo tags = getTags(p_Filename);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
361
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1704
diff changeset
362 aud_tuple_associate_string(tuple, FIELD_DATE, NULL, tags.date);
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1704
diff changeset
363 aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, tags.title);
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1704
diff changeset
364 aud_tuple_associate_string(tuple, FIELD_ARTIST, NULL, tags.artist);
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1704
diff changeset
365 aud_tuple_associate_string(tuple, FIELD_ALBUM, NULL, tags.album);
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1704
diff changeset
366 aud_tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, tags.track);
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1704
diff changeset
367 aud_tuple_associate_int(tuple, FIELD_YEAR, NULL, tags.year);
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1704
diff changeset
368 aud_tuple_associate_string(tuple, FIELD_GENRE, NULL, tags.genre);
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1704
diff changeset
369 aud_tuple_associate_string(tuple, FIELD_COMMENT, NULL, tags.comment);
1438
dc3e28d3b92a mpc: convert, wma: fixes
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
370
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
371 freeTags(tags);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
372
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
373 mpc_streaminfo info;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
374 mpc_reader_file reader;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
375 mpc_reader_setup_file_vfs(&reader, input);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
376 mpc_streaminfo_read(&info, &reader.reader);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
377
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1704
diff changeset
378 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, static_cast<int> (1000 * mpc_streaminfo_get_length(&info)));
1478
dd05a74648a7 Improve ${codec} and ${quality} tuples.
William Pitcock <nenolod@atheme-project.org>
parents: 1477
diff changeset
379
dd05a74648a7 Improve ${codec} and ${quality} tuples.
William Pitcock <nenolod@atheme-project.org>
parents: 1477
diff changeset
380 gchar *scratch = g_strdup_printf("Musepack v%d (encoder %s)", info.stream_version, info.encoder);
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1704
diff changeset
381 aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, scratch);
1478
dd05a74648a7 Improve ${codec} and ${quality} tuples.
William Pitcock <nenolod@atheme-project.org>
parents: 1477
diff changeset
382 g_free(scratch);
dd05a74648a7 Improve ${codec} and ${quality} tuples.
William Pitcock <nenolod@atheme-project.org>
parents: 1477
diff changeset
383
dd05a74648a7 Improve ${codec} and ${quality} tuples.
William Pitcock <nenolod@atheme-project.org>
parents: 1477
diff changeset
384 scratch = g_strdup_printf("lossy (%s)", info.profile_name);
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1704
diff changeset
385 aud_tuple_associate_string(tuple, FIELD_QUALITY, NULL, scratch);
1478
dd05a74648a7 Improve ${codec} and ${quality} tuples.
William Pitcock <nenolod@atheme-project.org>
parents: 1477
diff changeset
386 g_free(scratch);
dd05a74648a7 Improve ${codec} and ${quality} tuples.
William Pitcock <nenolod@atheme-project.org>
parents: 1477
diff changeset
387
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
388 aud_vfs_fclose(input);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
389 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
390 else
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
391 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
392 char* temp = g_strdup_printf("[xmms-musepack] mpcGetSongInfo is unable to open %s\n", p_Filename);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
393 perror(temp);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
394 free(temp);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
395 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
396
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
397 return tuple;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
398 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
399
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
400 static void mpcGetSongInfo(char* p_Filename, char** p_Title, int* p_Length)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
401 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
402 VFSFile *input = aud_vfs_fopen(p_Filename, "rb");
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
403 if(input)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
404 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
405 MpcInfo tags = getTags(p_Filename);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
406 *p_Title = mpcGenerateTitle(tags, p_Filename);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
407 freeTags(tags);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
408 mpc_streaminfo info;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
409 mpc_reader_file reader;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
410 mpc_reader_setup_file_vfs(&reader, input);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
411 mpc_streaminfo_read(&info, &reader.reader);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
412 *p_Length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info));
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
413 aud_vfs_fclose(input);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
414 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
415 else
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
416 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
417 char* temp = g_strdup_printf("[xmms-musepack] mpcGetSongInfo is unable to open %s\n", p_Filename);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
418 perror(temp);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
419 free(temp);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
420 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
421 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
422
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
423 static void freeTags(MpcInfo& tags)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
424 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
425 free(tags.title);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
426 free(tags.artist);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
427 free(tags.album);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
428 free(tags.comment);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
429 free(tags.genre);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
430 free(tags.date);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
431 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
432
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
433 static MpcInfo getTags(const char* p_Filename)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
434 {
1477
04311d687e94 fix musepack tag retrieval
William Pitcock <nenolod@atheme-project.org>
parents: 1473
diff changeset
435 gchar *pRealFilename = g_filename_from_uri(p_Filename, NULL, NULL);
04311d687e94 fix musepack tag retrieval
William Pitcock <nenolod@atheme-project.org>
parents: 1473
diff changeset
436 File oFile(pRealFilename ? pRealFilename : p_Filename, false);
04311d687e94 fix musepack tag retrieval
William Pitcock <nenolod@atheme-project.org>
parents: 1473
diff changeset
437 g_free(pRealFilename);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
438 Tag* poTag = oFile.tag();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
439 MpcInfo tags = {0};
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
440 tags.title = g_strdup(poTag->title().toCString(true));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
441 REMOVE_NONEXISTANT_TAG(tags.title);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
442 tags.artist = g_strdup(poTag->artist().toCString(true));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
443 REMOVE_NONEXISTANT_TAG(tags.artist);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
444 tags.album = g_strdup(poTag->album().toCString(true));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
445 REMOVE_NONEXISTANT_TAG(tags.album);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
446 tags.genre = g_strdup(poTag->genre().toCString(true));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
447 REMOVE_NONEXISTANT_TAG(tags.genre);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
448 tags.comment = g_strdup(poTag->comment().toCString(true));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
449 REMOVE_NONEXISTANT_TAG(tags.comment);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
450 tags.year = poTag->year();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
451 tags.track = poTag->track();
659
d1a03def0021 [svn] - disable broken APETag support for now, can cause crashes
nenolod
parents: 567
diff changeset
452 #if 0
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
453 TagLib::APE::Tag* ape = oFile.APETag(false);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
454 if(ape)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
455 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
456 ItemListMap map = ape->itemListMap();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
457 if(map.contains("YEAR"))
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
458 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
459 tags.date = g_strdup(map["YEAR"].toString().toCString(true));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
460 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
461 else
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
462 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
463 tags.date = g_strdup_printf("%d", tags.year);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
464 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
465 }
659
d1a03def0021 [svn] - disable broken APETag support for now, can cause crashes
nenolod
parents: 567
diff changeset
466 #endif
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
467 return tags;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
468 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
469
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
470 static void mpcFileInfoBox(char* p_Filename)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
471 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
472 GtkWidget* infoBox = widgets.infoBox;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
473
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
474 if(infoBox)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
475 gdk_window_raise(infoBox->window);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
476 else
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
477 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
478 infoBox = gtk_window_new(GTK_WINDOW_TOPLEVEL);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
479 gtk_window_set_type_hint(GTK_WINDOW(infoBox), GDK_WINDOW_TYPE_HINT_DIALOG);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
480 widgets.infoBox = infoBox;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
481 gtk_window_set_policy(GTK_WINDOW(infoBox), FALSE, FALSE, FALSE);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
482 g_signal_connect(G_OBJECT(infoBox), "destroy", G_CALLBACK(closeInfoBox), NULL);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
483 gtk_container_set_border_width(GTK_CONTAINER(infoBox), 10);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
484
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
485 GtkWidget* iVbox = gtk_vbox_new(FALSE, 10);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
486 gtk_container_add(GTK_CONTAINER(infoBox), iVbox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
487
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
488 GtkWidget* filenameHbox = gtk_hbox_new(FALSE, 5);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
489 gtk_box_pack_start(GTK_BOX(iVbox), filenameHbox, FALSE, TRUE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
490
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
491 GtkWidget* fileLabel = gtk_label_new(_("Filename:"));
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
492 gtk_box_pack_start(GTK_BOX(filenameHbox), fileLabel, FALSE, TRUE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
493
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
494 GtkWidget* fileEntry = gtk_entry_new();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
495 widgets.fileEntry = fileEntry;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
496 gtk_editable_set_editable(GTK_EDITABLE(fileEntry), FALSE);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
497 gtk_box_pack_start(GTK_BOX(filenameHbox), fileEntry, TRUE, TRUE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
498
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
499 GtkWidget* iHbox = gtk_hbox_new(FALSE, 10);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
500 gtk_box_pack_start(GTK_BOX(iVbox), iHbox, FALSE, TRUE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
501
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
502 GtkWidget* leftBox = gtk_vbox_new(FALSE, 10);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
503 gtk_box_pack_start(GTK_BOX(iHbox), leftBox, FALSE, FALSE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
504
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
505 //Tag labels
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
506 GtkWidget* tagFrame = gtk_frame_new(_("Musepack Tag"));
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
507 gtk_box_pack_start(GTK_BOX(leftBox), tagFrame, FALSE, FALSE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
508 gtk_widget_set_sensitive(tagFrame, TRUE);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
509
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
510 GtkWidget* iTable = gtk_table_new(5, 5, FALSE);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
511 gtk_container_set_border_width(GTK_CONTAINER(iTable), 5);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
512 gtk_container_add(GTK_CONTAINER(tagFrame), iTable);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
513
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
514 mpcGtkTagLabel(_("Title:"), 0, 1, 0, 1, iTable);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
515 GtkWidget* titleEntry = mpcGtkTagEntry(1, 4, 0, 1, 0, iTable);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
516 widgets.titleEntry = titleEntry;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
517
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
518 mpcGtkTagLabel(_("Artist:"), 0, 1, 1, 2, iTable);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
519 GtkWidget* artistEntry = mpcGtkTagEntry(1, 4, 1, 2, 0, iTable);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
520 widgets.artistEntry = artistEntry;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
521
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
522 mpcGtkTagLabel(_("Album:"), 0, 1, 2, 3, iTable);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
523 GtkWidget* albumEntry = mpcGtkTagEntry(1, 4, 2, 3, 0, iTable);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
524 widgets.albumEntry = albumEntry;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
525
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
526 mpcGtkTagLabel(_("Comment:"), 0, 1, 3, 4, iTable);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
527 GtkWidget* commentEntry = mpcGtkTagEntry(1, 4, 3, 4, 0, iTable);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
528 widgets.commentEntry = commentEntry;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
529
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
530 mpcGtkTagLabel(_("Year:"), 0, 1, 4, 5, iTable);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
531 GtkWidget* yearEntry = mpcGtkTagEntry(1, 2, 4, 5, 4, iTable);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
532 widgets.yearEntry = yearEntry;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
533 gtk_widget_set_usize(yearEntry, 4, -1);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
534
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
535 mpcGtkTagLabel(_("Track:"), 2, 3, 4, 5, iTable);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
536 GtkWidget* trackEntry = mpcGtkTagEntry(3, 4, 4, 5, 4, iTable);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
537 widgets.trackEntry = trackEntry;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
538 gtk_widget_set_usize(trackEntry, 3, -1);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
539
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
540 mpcGtkTagLabel(_("Genre:"), 0, 1, 5, 6, iTable);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
541 GtkWidget* genreEntry = mpcGtkTagEntry(1, 4, 5, 6, 0, iTable);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
542 widgets.genreEntry = genreEntry;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
543 gtk_widget_set_usize(genreEntry, 20, -1);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
544
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
545 //Buttons
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
546 GtkWidget* buttonBox = gtk_hbutton_box_new();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
547 gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonBox), GTK_BUTTONBOX_END);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
548 gtk_button_box_set_spacing(GTK_BUTTON_BOX(buttonBox), 5);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
549 gtk_box_pack_start(GTK_BOX(leftBox), buttonBox, FALSE, FALSE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
550
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
551 GtkWidget* saveButton = mpcGtkButton(_("Save"), buttonBox);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
552 g_signal_connect(G_OBJECT(saveButton), "clicked", G_CALLBACK(saveTags), NULL);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
553
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
554 GtkWidget* removeButton = mpcGtkButton(_("Remove Tag"), buttonBox);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
555 g_signal_connect_swapped(G_OBJECT(removeButton), "clicked", G_CALLBACK(removeTags), NULL);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
556
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
557 GtkWidget* cancelButton = mpcGtkButton(_("Cancel"), buttonBox);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
558 g_signal_connect_swapped(G_OBJECT(cancelButton), "clicked", G_CALLBACK(closeInfoBox), NULL);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
559 gtk_widget_grab_default(cancelButton);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
560
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
561 //File information
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
562 GtkWidget* infoFrame = gtk_frame_new(_("Musepack Info"));
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
563 gtk_box_pack_start(GTK_BOX(iHbox), infoFrame, FALSE, FALSE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
564
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
565 GtkWidget* infoVbox = gtk_vbox_new(FALSE, 5);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
566 gtk_container_add(GTK_CONTAINER(infoFrame), infoVbox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
567 gtk_container_set_border_width(GTK_CONTAINER(infoVbox), 10);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
568 gtk_box_set_spacing(GTK_BOX(infoVbox), 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
569
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
570 GtkWidget* streamLabel = mpcGtkLabel(infoVbox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
571 GtkWidget* encoderLabel = mpcGtkLabel(infoVbox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
572 GtkWidget* profileLabel = mpcGtkLabel(infoVbox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
573 GtkWidget* bitrateLabel = mpcGtkLabel(infoVbox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
574 GtkWidget* rateLabel = mpcGtkLabel(infoVbox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
575 GtkWidget* channelsLabel = mpcGtkLabel(infoVbox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
576 GtkWidget* lengthLabel = mpcGtkLabel(infoVbox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
577 GtkWidget* fileSizeLabel = mpcGtkLabel(infoVbox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
578 GtkWidget* trackPeakLabel = mpcGtkLabel(infoVbox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
579 GtkWidget* trackGainLabel = mpcGtkLabel(infoVbox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
580 GtkWidget* albumPeakLabel = mpcGtkLabel(infoVbox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
581 GtkWidget* albumGainLabel = mpcGtkLabel(infoVbox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
582
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
583 VFSFile *input = aud_vfs_fopen(p_Filename, "rb");
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
584 if(input)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
585 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
586 mpc_streaminfo info;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
587 mpc_reader_file reader;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
588 mpc_reader_setup_file_vfs(&reader, input);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
589 mpc_streaminfo_read(&info, &reader.reader);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
590
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
591 int time = static_cast<int> (mpc_streaminfo_get_length(&info));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
592 int minutes = time / 60;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
593 int seconds = time % 60;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
594
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
595 mpcGtkPrintLabel(streamLabel, _("Streamversion %d"), info.stream_version);
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
596 mpcGtkPrintLabel(encoderLabel, _("Encoder: %s"), info.encoder);
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
597 mpcGtkPrintLabel(profileLabel, _("Profile: %s"), info.profile_name);
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
598 mpcGtkPrintLabel(bitrateLabel, _("Average bitrate: %6.1f kbps"), info.average_bitrate * 1.e-3);
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
599 mpcGtkPrintLabel(rateLabel, _("Samplerate: %d Hz"), info.sample_freq);
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
600 mpcGtkPrintLabel(channelsLabel, _("Channels: %d"), info.channels);
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
601 mpcGtkPrintLabel(lengthLabel, _("Length: %d:\%.2d"), minutes, seconds);
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
602 mpcGtkPrintLabel(fileSizeLabel, _("File size: %d Bytes"), info.total_file_length);
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
603 mpcGtkPrintLabel(trackPeakLabel, _("Track Peak: %5u"), info.peak_title);
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
604 mpcGtkPrintLabel(trackGainLabel, _("Track Gain: %-+2.2f dB"), 0.01 * info.gain_title);
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
605 mpcGtkPrintLabel(albumPeakLabel, _("Album Peak: %5u"), info.peak_album);
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
606 mpcGtkPrintLabel(albumGainLabel, _("Album Gain: %-+5.2f dB"), 0.01 * info.gain_album);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
607
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
608 MpcInfo tags = getTags(p_Filename);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
609 gtk_entry_set_text(GTK_ENTRY(titleEntry), tags.title);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
610 gtk_entry_set_text(GTK_ENTRY(artistEntry), tags.artist);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
611 gtk_entry_set_text(GTK_ENTRY(albumEntry), tags.album);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
612 gtk_entry_set_text(GTK_ENTRY(commentEntry), tags.comment);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
613 gtk_entry_set_text(GTK_ENTRY(genreEntry), tags.genre);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
614 char* entry = g_strdup_printf ("%d", tags.track);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
615 gtk_entry_set_text(GTK_ENTRY(trackEntry), entry);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
616 free(entry);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
617 entry = g_strdup_printf ("%d", tags.year);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
618 gtk_entry_set_text(GTK_ENTRY(yearEntry), entry);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
619 free(entry);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
620 entry = g_filename_display_name(p_Filename);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
621 gtk_entry_set_text(GTK_ENTRY(fileEntry), entry);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
622 free(entry);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
623 freeTags(tags);
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
624 aud_vfs_fclose(input);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
625 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
626 else
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
627 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
628 char* temp = g_strdup_printf("[xmms-musepack] mpcFileInfoBox is unable to read tags from %s", p_Filename);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
629 perror(temp);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
630 free(temp);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
631 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
632
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
633 char* name = g_filename_display_basename(p_Filename);
1304
f34112ab9101 As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents: 1185
diff changeset
634 char* text = g_strdup_printf(_("File Info - %s"), name);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
635 free(name);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
636 gtk_window_set_title(GTK_WINDOW(infoBox), text);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
637 free(text);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
638
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
639 gtk_widget_show_all(infoBox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
640 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
641 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
642
1044
b1128efde471 [svn] - get rid of all warnings gcc 4.2.0 emits with my build configuration.
yaz
parents: 659
diff changeset
643 static void mpcGtkPrintLabel(GtkWidget* widget, const char* format,...)
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
644 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
645 va_list args;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
646
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
647 va_start(args, format);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
648 char* temp = g_strdup_vprintf(format, args);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
649 va_end(args);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
650
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
651 gtk_label_set_text(GTK_LABEL(widget), temp);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
652 free(temp);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
653 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
654
1044
b1128efde471 [svn] - get rid of all warnings gcc 4.2.0 emits with my build configuration.
yaz
parents: 659
diff changeset
655 static GtkWidget* mpcGtkTagLabel(const char* p_Text, int a, int b, int c, int d, GtkWidget* p_Box)
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
656 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
657 GtkWidget* label = gtk_label_new(p_Text);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
658 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
659 gtk_table_attach(GTK_TABLE(p_Box), label, a, b, c, d, GTK_FILL, GTK_FILL, 5, 5);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
660 return label;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
661 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
662
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
663 static GtkWidget* mpcGtkTagEntry(int a, int b, int c, int d, int p_Size, GtkWidget* p_Box)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
664 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
665 GtkWidget* entry;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
666 if(p_Size == 0)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
667 entry = gtk_entry_new();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
668 else
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
669 entry = gtk_entry_new_with_max_length(p_Size);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
670 gtk_table_attach(GTK_TABLE(p_Box), entry, a, b, c, d,
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
671 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND | GTK_SHRINK),
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
672 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND | GTK_SHRINK), 0, 5);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
673 return entry;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
674 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
675
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
676 static GtkWidget* mpcGtkLabel(GtkWidget* p_Box)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
677 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
678 GtkWidget* label = gtk_label_new("");
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
679 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
680 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
681 gtk_box_pack_start(GTK_BOX(p_Box), label, FALSE, FALSE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
682 return label;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
683 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
684
1044
b1128efde471 [svn] - get rid of all warnings gcc 4.2.0 emits with my build configuration.
yaz
parents: 659
diff changeset
685 static GtkWidget* mpcGtkButton(const char* p_Text, GtkWidget* p_Box)
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
686 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
687 GtkWidget* button = gtk_button_new_with_label(p_Text);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
688 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
689 gtk_box_pack_start(GTK_BOX(p_Box), button, TRUE, TRUE, 0);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
690 return button;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
691 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
692
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
693 static void removeTags(GtkWidget * w, gpointer data)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
694 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
695 File oFile(gtk_entry_get_text(GTK_ENTRY(widgets.fileEntry)));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
696 oFile.remove();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
697 oFile.save();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
698 closeInfoBox(NULL, NULL);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
699 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
700
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
701 static void saveTags(GtkWidget* w, gpointer data)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
702 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
703 File oFile(gtk_entry_get_text(GTK_ENTRY(widgets.fileEntry)));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
704 Tag* poTag = oFile.tag();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
705
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
706 char* cAlbum = g_strdup(gtk_entry_get_text(GTK_ENTRY(widgets.albumEntry)));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
707 char* cArtist = g_strdup(gtk_entry_get_text(GTK_ENTRY(widgets.artistEntry)));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
708 char* cTitle = g_strdup(gtk_entry_get_text(GTK_ENTRY(widgets.titleEntry)));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
709 char* cGenre = g_strdup(gtk_entry_get_text(GTK_ENTRY(widgets.genreEntry)));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
710 char* cComment = g_strdup(gtk_entry_get_text(GTK_ENTRY(widgets.commentEntry)));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
711
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
712 const String album = String(cAlbum, TagLib::String::UTF8);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
713 const String artist = String(cArtist, TagLib::String::UTF8);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
714 const String title = String(cTitle, TagLib::String::UTF8);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
715 const String genre = String(cGenre, TagLib::String::UTF8);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
716 const String comment = String(cComment, TagLib::String::UTF8);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
717
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
718 poTag->setAlbum(album);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
719 poTag->setArtist(artist);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
720 poTag->setTitle(title);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
721 poTag->setGenre(genre);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
722 poTag->setComment(comment);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
723 poTag->setYear(atoi(gtk_entry_get_text(GTK_ENTRY(widgets.yearEntry))));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
724 poTag->setTrack(atoi(gtk_entry_get_text(GTK_ENTRY(widgets.trackEntry))));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
725
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
726 free(cAlbum);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
727 free(cArtist);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
728 free(cTitle);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
729 free(cGenre);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
730 free(cComment);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
731
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
732 oFile.save();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
733 closeInfoBox(NULL, NULL);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
734 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
735
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
736 static void closeInfoBox(GtkWidget* w, gpointer data)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
737 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
738 gtk_widget_destroy(widgets.infoBox);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
739 widgets.infoBox = NULL;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
740 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
741
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
742 static char* mpcGenerateTitle(const MpcInfo& p_Tags, char* p_Filename)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
743 {
1438
dc3e28d3b92a mpc: convert, wma: fixes
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
744 Tuple* tuple = mpcGetSongTuple(p_Filename);
dc3e28d3b92a mpc: convert, wma: fixes
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
745
2055
2f2ffbc2d04d gentitle changes
William Pitcock <nenolod@atheme.org>
parents: 1998
diff changeset
746 char* title = aud_tuple_formatter_make_title_string(tuple, aud_get_gentitle_format());
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
747
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1704
diff changeset
748 aud_tuple_free((void *) tuple);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
749 return title;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
750 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
751
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
752 static void* endThread(char* p_FileName, VFSFile * p_FileHandle, bool release)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
753 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
754 free(p_FileName);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
755 if(release)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
756 lockRelease();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
757 if(mpcDecoder.isError)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
758 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
759 perror(mpcDecoder.isError);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
760 free(mpcDecoder.isError);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
761 mpcDecoder.isError = NULL;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
762 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
763 setAlive(false);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
764 if(p_FileHandle)
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
765 aud_vfs_fclose(p_FileHandle);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
766 if(track.display)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
767 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
768 free(track.display);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
769 track.display = NULL;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
770 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
771 return 0;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
772 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
773
1986
4b78df9dcf93 more set_params()
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
774 static void* decodeStream(InputPlayback *data)
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
775 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
776 lockAcquire();
1986
4b78df9dcf93 more set_params()
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
777 char* filename = data->filename;
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
778 VFSFile *input = aud_vfs_fopen(filename, "rb");
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
779 if (!input)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
780 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
781 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open %s", filename);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
782 return endThread(filename, input, true);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
783 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
784
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
785 mpc_reader_file reader;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
786 mpc_reader_setup_file_vfs(&reader, input);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
787
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
788 mpc_streaminfo info;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
789 if (mpc_streaminfo_read(&info, &reader.reader) != ERROR_CODE_OK)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
790 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
791 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to read %s", filename);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
792 return endThread(filename, input, true);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
793 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
794
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
795 MpcInfo tags = getTags(filename);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
796 track.display = mpcGenerateTitle(tags, filename);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
797 track.length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info));
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
798 track.bitrate = static_cast<int> (info.average_bitrate);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
799 track.sampleFreq = info.sample_freq;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
800 track.channels = info.channels;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
801 freeTags(tags);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
802
1986
4b78df9dcf93 more set_params()
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
803 data->set_params(data, track.display, track.length, track.bitrate, track.sampleFreq, track.channels);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
804
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
805 mpc_decoder decoder;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
806 mpc_decoder_setup(&decoder, &reader.reader);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
807 if (!mpc_decoder_initialize(&decoder, &info))
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
808 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
809 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to initialize decoder on %s", filename);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
810 return endThread(filename, input, true);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
811 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
812
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
813 setReplaygain(info, decoder);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
814
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
815 MPC_SAMPLE_FORMAT sampleBuffer[MPC_DECODER_BUFFER_LENGTH];
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
816 char xmmsBuffer[MPC_DECODER_BUFFER_LENGTH * 4];
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
817
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
818 if (!MpcPlugin.output->open_audio(FMT_S16_LE, track.sampleFreq, track.channels))
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
819 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
820 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open an audio output");
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
821 return endThread(filename, input, true);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
822 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
823 else
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
824 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
825 mpcDecoder.isOutput = true;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
826 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
827
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
828 lockRelease();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
829
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
830 int counter = 2 * track.sampleFreq / 3;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
831 while (isAlive())
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
832 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
833 if (getOffset() != -1)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
834 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
835 mpc_decoder_seek_seconds(&decoder, mpcDecoder.offset);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
836 setOffset(-1);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
837 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
838
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
839 lockAcquire();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
840 short iPlaying = MpcPlugin.output->buffer_playing()? 1 : 0;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
841 int iFree = MpcPlugin.output->buffer_free();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
842 if (!mpcDecoder.isPause && iFree >= ((1152 * 4) << iPlaying))
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
843 {
1998
8f3188746b64 chase last changeset in aud
William Pitcock <nenolod@atheme.org>
parents: 1986
diff changeset
844 unsigned status = processBuffer(data, sampleBuffer, xmmsBuffer, decoder);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
845 if (status == (unsigned) (-1))
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
846 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
847 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] error from internal decoder on %s", filename);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
848 return endThread(filename, input, true);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
849 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
850 if (status == 0 && iPlaying == 0)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
851 return endThread(filename, input, true);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
852
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
853 lockRelease();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
854
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
855 if(pluginConfig.dynamicBitrate)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
856 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
857 counter -= status;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
858 if(counter < 0)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
859 {
1986
4b78df9dcf93 more set_params()
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
860 data->set_params(data, track.display, track.length, track.bitrate, track.sampleFreq, track.channels);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
861 counter = 2 * track.sampleFreq / 3;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
862 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
863 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
864 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
865 else
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
866 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
867 lockRelease();
1676
aee4ebea943a xmms_usleep() was removed, use g_usleep()
Matti Hamalainen <ccr@tnsp.org>
parents: 1621
diff changeset
868 g_usleep(10000);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
869 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
870 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
871 return endThread(filename, input, false);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
872 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
873
1998
8f3188746b64 chase last changeset in aud
William Pitcock <nenolod@atheme.org>
parents: 1986
diff changeset
874 static int processBuffer(InputPlayback *playback,
8f3188746b64 chase last changeset in aud
William Pitcock <nenolod@atheme.org>
parents: 1986
diff changeset
875 MPC_SAMPLE_FORMAT* sampleBuffer, char* xmmsBuffer, mpc_decoder& decoder)
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
876 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
877 mpc_uint32_t vbrAcc = 0;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
878 mpc_uint32_t vbrUpd = 0;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
879
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
880 unsigned status = mpc_decoder_decode(&decoder, sampleBuffer, &vbrAcc, &vbrUpd);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
881 copyBuffer(sampleBuffer, xmmsBuffer, status);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
882
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
883 if (pluginConfig.dynamicBitrate)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
884 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
885 track.bitrate = static_cast<int> (vbrUpd * track.sampleFreq / 1152);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
886 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
887
1998
8f3188746b64 chase last changeset in aud
William Pitcock <nenolod@atheme.org>
parents: 1986
diff changeset
888 playback->pass_audio(playback, FMT_S16_LE, track.channels, status * 4, xmmsBuffer, NULL);
232
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
889 return status;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
890 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
891
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
892 static void setReplaygain(mpc_streaminfo& info, mpc_decoder& decoder)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
893 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
894 if(!pluginConfig.replaygain && !pluginConfig.clipPrevention)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
895 return;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
896
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
897 int peak = pluginConfig.albumGain ? info.peak_album : info.peak_title;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
898 double gain = pluginConfig.albumGain ? info.gain_album : info.gain_title;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
899
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
900 if(!peak)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
901 peak = 32767;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
902 if(!gain)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
903 gain = 1.;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
904
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
905 double clip = 32767. / peak;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
906 gain = exp((M_LN10 / 2000.) * gain);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
907
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
908 if(pluginConfig.clipPrevention && !pluginConfig.replaygain)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
909 gain = clip;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
910 else if(pluginConfig.replaygain && pluginConfig.clipPrevention)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
911 if(clip < gain)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
912 gain = clip;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
913
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
914 mpc_decoder_scale_output(&decoder, gain);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
915 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
916
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
917 inline static void lockAcquire()
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
918 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
919 g_static_mutex_lock(&threadMutex);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
920 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
921
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
922 inline static void lockRelease()
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
923 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
924 g_static_mutex_unlock(&threadMutex);
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
925 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
926
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
927 inline static bool isAlive()
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
928 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
929 lockAcquire();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
930 bool isAlive = mpcDecoder.isAlive;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
931 lockRelease();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
932 return isAlive;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
933 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
934
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
935 inline static bool isPause()
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
936 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
937 lockAcquire();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
938 bool isPause = mpcDecoder.isPause;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
939 lockRelease();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
940 return isPause;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
941 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
942
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
943 inline static void setAlive(bool isAlive)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
944 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
945 lockAcquire();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
946 mpcDecoder.isAlive = isAlive;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
947 lockRelease();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
948 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
949
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
950 inline static double getOffset()
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
951 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
952 lockAcquire();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
953 double offset = mpcDecoder.offset;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
954 lockRelease();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
955 return offset;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
956 }
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
957
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
958 inline static void setOffset(double offset)
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
959 {
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
960 lockAcquire();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
961 mpcDecoder.offset = offset;
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
962 lockRelease();
6c78d6d3cdb7 [svn] - put musepack support back
nenolod
parents:
diff changeset
963 }