Mercurial > audlegacy
annotate Plugins/Input/musepack/libmpc.cpp @ 369:5d0a74c31ee6 trunk
[svn] Use file magic instead of extensions.
author | chainsaw |
---|---|
date | Sat, 31 Dec 2005 15:04:34 -0800 |
parents | 2dd23cdf6c4b |
children | e9cf6c7c6623 |
rev | line source |
---|---|
293
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
1 #include "libmpc.h" |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
2 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
3 #define FORCED_THREAD_STACKSIZE 1024 * 1000 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
4 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
5 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
6 using TagLib::MPC::File; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
7 using TagLib::Tag; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
8 using TagLib::String; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
9 using TagLib::APE::ItemListMap; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
10 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
11 InputPlugin MpcPlugin = { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
12 NULL, //File Handle FILE* handle |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
13 NULL, //Filename char* filename |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
14 NULL, //Name of Plugin char* filename |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
15 mpcOpenPlugin, //Open Plugin [CALLBACK] |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
16 mpcAboutBox, //Show About box [CALLBACK] |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
17 mpcConfigBox, //Show Configure box [CALLBACK] |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
18 mpcIsOurFile, //Check if it's our file [CALLBACK] |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
19 NULL, //Scan the directory [UNUSED] |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
20 mpcPlay, //Play [CALLBACK] |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
21 mpcStop, //Stop [CALLBACK] |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
22 mpcPause, //Pause [CALLBACK] |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
23 mpcSeek, //Seek [CALLBACK] |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
24 mpcSetEq, //Set EQ [CALLBACK] |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
25 mpcGetTime, //Get Time [CALLBACK] |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
26 NULL, //Get Volume [UNUSED] |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
27 NULL, //Set Volume [UNUSED] |
294 | 28 NULL, //Close Plugin [UNUSED] |
293
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
29 NULL, //Obsolete [UNUSED] |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
30 NULL, //Visual plugins add_vis_pcm(int time, AFormat fmt, int nch, int length, void *ptr) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
31 NULL, //Set Info Settings set_info(char *title, int length, int rate, int freq, int nch) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
32 NULL, //set Info Text set_info_text(char* text) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
33 mpcGetSongInfo, //Get Title String callback [CALLBACK] |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
34 mpcFileInfoBox, //Show File Info Box [CALLBACK] |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
35 NULL, //Output Plugin Handle OutputPlugin output |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
36 }; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
37 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
38 extern "C" |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
39 InputPlugin* get_iplugin_info() |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
40 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
41 MpcPlugin.description = g_strdup_printf("Musepack Audio Plugin 1.2"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
42 return &MpcPlugin; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
43 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
44 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
45 static PluginConfig pluginConfig = {0}; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
46 static Widgets widgets = {0}; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
47 static MpcDecoder mpcDecoder = {0}; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
48 static TrackInfo track = {0}; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
49 |
294 | 50 static GThread *threadHandle; |
51 GStaticMutex threadMutex = G_STATIC_MUTEX_INIT; | |
293
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
52 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
53 static void mpcOpenPlugin() |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
54 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
55 ConfigDb *cfg; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
56 cfg = bmp_cfg_db_open(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
57 bmp_cfg_db_get_bool(cfg, "musepack", "clipPrevention", &pluginConfig.clipPrevention); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
58 bmp_cfg_db_get_bool(cfg, "musepack", "albumGain", &pluginConfig.albumGain); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
59 bmp_cfg_db_get_bool(cfg, "musepack", "dynamicBitrate", &pluginConfig.dynamicBitrate); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
60 bmp_cfg_db_get_bool(cfg, "musepack", "replaygain", &pluginConfig.replaygain); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
61 bmp_cfg_db_close(cfg); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
62 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
63 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
64 static void mpcAboutBox() |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
65 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
66 GtkWidget* aboutBox = widgets.aboutBox; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
67 if (aboutBox) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
68 gdk_window_raise(aboutBox->window); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
69 else |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
70 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
71 char* titleText = g_strdup_printf("Musepack Decoder Plugin 1.2"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
72 char* contentText = "Plugin code by\nBenoit Amiaux\nMartin Spuler\nKuniklo\n\nGet latest version at http://musepack.net\n"; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
73 char* buttonText = "Nevermind"; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
74 aboutBox = xmms_show_message(titleText, contentText, buttonText, FALSE, NULL, NULL); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
75 widgets.aboutBox = aboutBox; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
76 gtk_signal_connect(GTK_OBJECT(aboutBox), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &widgets.aboutBox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
77 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
78 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
79 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
80 static void mpcConfigBox() |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
81 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
82 GtkWidget* configBox = widgets.configBox; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
83 if(configBox) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
84 gdk_window_raise(configBox->window); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
85 else |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
86 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
87 configBox = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
88 gtk_window_set_type_hint(GTK_WINDOW(configBox), GDK_WINDOW_TYPE_HINT_DIALOG); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
89 widgets.configBox = configBox; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
90 gtk_signal_connect(GTK_OBJECT(configBox), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &widgets.configBox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
91 gtk_window_set_title(GTK_WINDOW(configBox), "Musepack Decoder Configuration"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
92 gtk_window_set_policy(GTK_WINDOW(configBox), FALSE, FALSE, FALSE); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
93 gtk_container_border_width(GTK_CONTAINER(configBox), 10); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
94 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
95 GtkWidget* notebook = gtk_notebook_new(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
96 GtkWidget* vbox = gtk_vbox_new(FALSE, 10); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
97 gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
98 gtk_container_add(GTK_CONTAINER(configBox), vbox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
99 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
100 //General Settings Tab |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
101 GtkWidget* generalSet = gtk_frame_new("General Settings"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
102 gtk_container_border_width(GTK_CONTAINER(generalSet), 5); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
103 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
104 GtkWidget* gSvbox = gtk_vbox_new(FALSE, 10); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
105 gtk_container_border_width(GTK_CONTAINER(gSvbox), 5); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
106 gtk_container_add(GTK_CONTAINER(generalSet), gSvbox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
107 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
108 GtkWidget* bitrateCheck = gtk_check_button_new_with_label("Enable Dynamic Bitrate Display"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
109 widgets.bitrateCheck = bitrateCheck; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
110 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bitrateCheck), pluginConfig.dynamicBitrate); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
111 gtk_box_pack_start(GTK_BOX(gSvbox), bitrateCheck, FALSE, FALSE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
112 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), generalSet, gtk_label_new("Plugin")); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
113 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
114 //ReplayGain Settings Tab |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
115 GtkWidget* replaygainSet = gtk_frame_new("ReplayGain Settings"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
116 gtk_container_border_width(GTK_CONTAINER(replaygainSet), 5); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
117 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
118 GtkWidget* rSVbox = gtk_vbox_new(FALSE, 10); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
119 gtk_container_border_width(GTK_CONTAINER(rSVbox), 5); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
120 gtk_container_add(GTK_CONTAINER(replaygainSet), rSVbox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
121 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
122 GtkWidget* clippingCheck = gtk_check_button_new_with_label("Enable Clipping Prevention"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
123 widgets.clippingCheck = clippingCheck; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
124 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(clippingCheck), pluginConfig.clipPrevention); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
125 gtk_box_pack_start(GTK_BOX(rSVbox), clippingCheck, FALSE, FALSE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
126 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
127 GtkWidget* replaygainCheck = gtk_check_button_new_with_label("Enable ReplayGain"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
128 widgets.replaygainCheck = replaygainCheck; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
129 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(replaygainCheck), pluginConfig.replaygain); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
130 gtk_box_pack_start(GTK_BOX(rSVbox), replaygainCheck, FALSE, FALSE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
131 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
132 GtkWidget* replaygainType = gtk_frame_new("ReplayGain Type"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
133 gtk_box_pack_start(GTK_BOX(rSVbox), replaygainType, FALSE, FALSE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
134 gtk_signal_connect(GTK_OBJECT(replaygainCheck), "toggled", GTK_SIGNAL_FUNC(toggleSwitch), replaygainType); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
135 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
136 GtkWidget* rgVbox = gtk_vbox_new(FALSE, 5); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
137 gtk_container_set_border_width(GTK_CONTAINER(rgVbox), 5); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
138 gtk_container_add(GTK_CONTAINER(replaygainType), rgVbox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
139 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
140 GtkWidget* trackCheck = gtk_radio_button_new_with_label(NULL, "Use Track Gain"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
141 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(trackCheck), !pluginConfig.albumGain); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
142 gtk_box_pack_start(GTK_BOX(rgVbox), trackCheck, FALSE, FALSE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
143 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
144 GtkWidget* albumCheck = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(trackCheck)), "Use Album Gain"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
145 widgets.albumCheck = albumCheck; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
146 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(albumCheck), pluginConfig.albumGain); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
147 gtk_box_pack_start(GTK_BOX(rgVbox), albumCheck, FALSE, FALSE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
148 gtk_widget_set_sensitive(replaygainType, pluginConfig.replaygain); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
149 gtk_notebook_append_page(GTK_NOTEBOOK(notebook), replaygainSet, gtk_label_new("ReplayGain")); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
150 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
151 //Buttons |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
152 GtkWidget* buttonBox = gtk_hbutton_box_new(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
153 gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonBox), GTK_BUTTONBOX_END); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
154 gtk_button_box_set_spacing(GTK_BUTTON_BOX(buttonBox), 5); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
155 gtk_box_pack_start(GTK_BOX(vbox), buttonBox, FALSE, FALSE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
156 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
157 GtkWidget* okButton = gtk_button_new_with_label("Ok"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
158 gtk_signal_connect(GTK_OBJECT(okButton), "clicked", GTK_SIGNAL_FUNC(saveConfigBox), NULL); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
159 GTK_WIDGET_SET_FLAGS(okButton, GTK_CAN_DEFAULT); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
160 gtk_box_pack_start(GTK_BOX(buttonBox), okButton, TRUE, TRUE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
161 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
162 GtkWidget* cancelButton = gtk_button_new_with_label("Cancel"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
163 gtk_signal_connect_object(GTK_OBJECT(cancelButton), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(widgets.configBox)); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
164 GTK_WIDGET_SET_FLAGS(cancelButton, GTK_CAN_DEFAULT); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
165 gtk_widget_grab_default(cancelButton); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
166 gtk_box_pack_start(GTK_BOX(buttonBox), cancelButton, TRUE, TRUE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
167 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
168 gtk_widget_show_all(configBox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
169 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
170 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
171 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
172 static void toggleSwitch(GtkWidget* p_Widget, gpointer p_Data) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
173 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
174 gtk_widget_set_sensitive(GTK_WIDGET(p_Data), gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_Widget))); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
175 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
176 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
177 static void saveConfigBox(GtkWidget* p_Widget, gpointer p_Data) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
178 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
179 ConfigDb* cfg; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
180 GtkToggleButton* tb; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
181 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
182 tb = GTK_TOGGLE_BUTTON(widgets.replaygainCheck); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
183 pluginConfig.replaygain = gtk_toggle_button_get_active(tb); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
184 tb = GTK_TOGGLE_BUTTON(widgets.clippingCheck); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
185 pluginConfig.clipPrevention = gtk_toggle_button_get_active(tb); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
186 tb = GTK_TOGGLE_BUTTON(widgets.bitrateCheck); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
187 pluginConfig.dynamicBitrate = gtk_toggle_button_get_active(tb); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
188 tb = GTK_TOGGLE_BUTTON(widgets.albumCheck); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
189 pluginConfig.albumGain = gtk_toggle_button_get_active(tb); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
190 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
191 cfg = bmp_cfg_db_open(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
192 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
193 bmp_cfg_db_set_bool(cfg, "musepack", "clipPrevention", pluginConfig.clipPrevention); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
194 bmp_cfg_db_set_bool(cfg, "musepack", "albumGain", pluginConfig.albumGain); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
195 bmp_cfg_db_set_bool(cfg, "musepack", "dynamicBitrate", pluginConfig.dynamicBitrate); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
196 bmp_cfg_db_set_bool(cfg, "musepack", "replaygain", pluginConfig.replaygain); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
197 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
198 bmp_cfg_db_close(cfg); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
199 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
200 gtk_widget_destroy (widgets.configBox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
201 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
202 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
203 static int mpcIsOurFile(char* p_Filename) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
204 { |
369 | 205 VFSFile *file; |
206 gchar magic[3]; | |
207 if (file = vfs_fopen(p_Filename, "rb")) { | |
208 vfs_fread(magic, 1, 3, file); | |
209 if (!strncmp(magic, "MP+", 3)) { | |
210 vfs_fclose(file); | |
211 return 1; | |
212 } | |
213 vfs_fclose(file); | |
214 } | |
215 return 0; | |
293
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
216 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
217 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
218 static void mpcPlay(char* p_Filename) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
219 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
220 mpcDecoder.offset = -1; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
221 mpcDecoder.isAlive = true; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
222 mpcDecoder.isOutput = false; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
223 mpcDecoder.isPause = false; |
294 | 224 threadHandle = g_thread_create(GThreadFunc(decodeStream), (void *) g_strdup(p_Filename), TRUE, NULL); |
293
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
225 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
226 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
227 static void mpcStop() |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
228 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
229 setAlive(false); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
230 if (threadHandle) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
231 { |
294 | 232 g_thread_join(threadHandle); |
293
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
233 if (mpcDecoder.isOutput) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
234 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
235 MpcPlugin.output->buffer_free(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
236 MpcPlugin.output->close_audio(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
237 mpcDecoder.isOutput = false; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
238 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
239 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
240 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
241 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
242 static void mpcPause(short p_Pause) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
243 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
244 lockAcquire(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
245 mpcDecoder.isPause = p_Pause; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
246 MpcPlugin.output->pause(p_Pause); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
247 lockRelease(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
248 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
249 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
250 static void mpcSeek(int p_Offset) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
251 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
252 lockAcquire(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
253 mpcDecoder.offset = static_cast<double> (p_Offset); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
254 MpcPlugin.output->flush(1000 * p_Offset); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
255 lockRelease(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
256 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
257 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
258 static void mpcSetEq(int on, float preamp, float* eq) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
259 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
260 pluginConfig.isEq = static_cast<bool> (on); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
261 init_iir(on, preamp, eq); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
262 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
263 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
264 static int mpcGetTime() |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
265 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
266 if(!isAlive()) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
267 return -1; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
268 return MpcPlugin.output->output_time(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
269 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
270 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
271 static void mpcGetSongInfo(char* p_Filename, char** p_Title, int* p_Length) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
272 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
273 FILE* input = fopen(p_Filename, "rb"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
274 if(input) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
275 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
276 MpcInfo tags = getTags(p_Filename); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
277 *p_Title = mpcGenerateTitle(tags, p_Filename); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
278 freeTags(tags); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
279 mpc_streaminfo info; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
280 mpc_reader_file reader; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
281 mpc_reader_setup_file_reader(&reader, input); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
282 mpc_streaminfo_read(&info, &reader.reader); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
283 *p_Length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info)); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
284 fclose(input); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
285 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
286 else |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
287 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
288 char* temp = g_strdup_printf("[xmms-musepack] mpcGetSongInfo is unable to open %s\n", p_Filename); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
289 perror(temp); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
290 free(temp); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
291 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
292 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
293 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
294 static void freeTags(MpcInfo& tags) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
295 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
296 free(tags.title); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
297 free(tags.artist); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
298 free(tags.album); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
299 free(tags.comment); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
300 free(tags.genre); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
301 free(tags.date); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
302 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
303 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
304 static MpcInfo getTags(const char* p_Filename) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
305 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
306 File oFile(p_Filename, false); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
307 Tag* poTag = oFile.tag(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
308 MpcInfo tags = {0}; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
309 tags.title = g_strdup(poTag->title().toCString(true)); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
310 tags.artist = g_strdup(poTag->artist().toCString(true)); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
311 tags.album = g_strdup(poTag->album().toCString(true)); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
312 tags.genre = g_strdup(poTag->genre().toCString(true)); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
313 tags.comment = g_strdup(poTag->comment().toCString(true)); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
314 tags.year = poTag->year(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
315 tags.track = poTag->track(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
316 TagLib::APE::Tag* ape = oFile.APETag(false); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
317 if(ape) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
318 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
319 ItemListMap map = ape->itemListMap(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
320 if(map.contains("YEAR")) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
321 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
322 tags.date = g_strdup(map["YEAR"].toString().toCString(true)); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
323 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
324 else |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
325 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
326 tags.date = g_strdup_printf("%d", tags.year); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
327 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
328 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
329 return tags; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
330 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
331 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
332 static void mpcFileInfoBox(char* p_Filename) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
333 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
334 GtkWidget* infoBox = widgets.infoBox; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
335 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
336 if(infoBox) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
337 gdk_window_raise(infoBox->window); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
338 else |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
339 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
340 infoBox = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
341 gtk_window_set_type_hint(GTK_WINDOW(infoBox), GDK_WINDOW_TYPE_HINT_DIALOG); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
342 widgets.infoBox = infoBox; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
343 gtk_window_set_policy(GTK_WINDOW(infoBox), FALSE, FALSE, FALSE); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
344 gtk_signal_connect(GTK_OBJECT(infoBox), "destroy", GTK_SIGNAL_FUNC(closeInfoBox), NULL); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
345 gtk_container_set_border_width(GTK_CONTAINER(infoBox), 10); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
346 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
347 GtkWidget* iVbox = gtk_vbox_new(FALSE, 10); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
348 gtk_container_add(GTK_CONTAINER(infoBox), iVbox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
349 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
350 GtkWidget* filenameHbox = gtk_hbox_new(FALSE, 5); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
351 gtk_box_pack_start(GTK_BOX(iVbox), filenameHbox, FALSE, TRUE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
352 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
353 GtkWidget* fileLabel = gtk_label_new("Filename:"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
354 gtk_box_pack_start(GTK_BOX(filenameHbox), fileLabel, FALSE, TRUE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
355 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
356 GtkWidget* fileEntry = gtk_entry_new(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
357 widgets.fileEntry = fileEntry; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
358 gtk_editable_set_editable(GTK_EDITABLE(fileEntry), FALSE); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
359 gtk_box_pack_start(GTK_BOX(filenameHbox), fileEntry, TRUE, TRUE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
360 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
361 GtkWidget* iHbox = gtk_hbox_new(FALSE, 10); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
362 gtk_box_pack_start(GTK_BOX(iVbox), iHbox, FALSE, TRUE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
363 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
364 GtkWidget* leftBox = gtk_vbox_new(FALSE, 10); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
365 gtk_box_pack_start(GTK_BOX(iHbox), leftBox, FALSE, FALSE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
366 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
367 //Tag labels |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
368 GtkWidget* tagFrame = gtk_frame_new("Musepack Tag"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
369 gtk_box_pack_start(GTK_BOX(leftBox), tagFrame, FALSE, FALSE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
370 gtk_widget_set_sensitive(tagFrame, TRUE); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
371 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
372 GtkWidget* iTable = gtk_table_new(5, 5, FALSE); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
373 gtk_container_set_border_width(GTK_CONTAINER(iTable), 5); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
374 gtk_container_add(GTK_CONTAINER(tagFrame), iTable); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
375 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
376 mpcGtkTagLabel("Title:", 0, 1, 0, 1, iTable); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
377 GtkWidget* titleEntry = mpcGtkTagEntry(1, 4, 0, 1, 0, iTable); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
378 widgets.titleEntry = titleEntry; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
379 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
380 mpcGtkTagLabel("Artist:", 0, 1, 1, 2, iTable); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
381 GtkWidget* artistEntry = mpcGtkTagEntry(1, 4, 1, 2, 0, iTable); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
382 widgets.artistEntry = artistEntry; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
383 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
384 mpcGtkTagLabel("Album:", 0, 1, 2, 3, iTable); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
385 GtkWidget* albumEntry = mpcGtkTagEntry(1, 4, 2, 3, 0, iTable); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
386 widgets.albumEntry = albumEntry; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
387 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
388 mpcGtkTagLabel("Comment:", 0, 1, 3, 4, iTable); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
389 GtkWidget* commentEntry = mpcGtkTagEntry(1, 4, 3, 4, 0, iTable); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
390 widgets.commentEntry = commentEntry; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
391 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
392 mpcGtkTagLabel("Year:", 0, 1, 4, 5, iTable); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
393 GtkWidget* yearEntry = mpcGtkTagEntry(1, 2, 4, 5, 4, iTable); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
394 widgets.yearEntry = yearEntry; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
395 gtk_widget_set_usize(yearEntry, 4, -1); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
396 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
397 mpcGtkTagLabel("Track:", 2, 3, 4, 5, iTable); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
398 GtkWidget* trackEntry = mpcGtkTagEntry(3, 4, 4, 5, 4, iTable); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
399 widgets.trackEntry = trackEntry; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
400 gtk_widget_set_usize(trackEntry, 3, -1); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
401 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
402 mpcGtkTagLabel("Genre:", 0, 1, 5, 6, iTable); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
403 GtkWidget* genreEntry = mpcGtkTagEntry(1, 4, 5, 6, 0, iTable); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
404 widgets.genreEntry = genreEntry; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
405 gtk_widget_set_usize(genreEntry, 20, -1); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
406 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
407 //Buttons |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
408 GtkWidget* buttonBox = gtk_hbutton_box_new(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
409 gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonBox), GTK_BUTTONBOX_END); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
410 gtk_button_box_set_spacing(GTK_BUTTON_BOX(buttonBox), 5); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
411 gtk_box_pack_start(GTK_BOX(leftBox), buttonBox, FALSE, FALSE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
412 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
413 GtkWidget* saveButton = mpcGtkButton("Save", buttonBox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
414 gtk_signal_connect(GTK_OBJECT(saveButton), "clicked", GTK_SIGNAL_FUNC(saveTags), NULL); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
415 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
416 GtkWidget* removeButton = mpcGtkButton("Remove Tag", buttonBox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
417 gtk_signal_connect_object(GTK_OBJECT(removeButton), "clicked", GTK_SIGNAL_FUNC(removeTags), NULL); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
418 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
419 GtkWidget* cancelButton = mpcGtkButton("Cancel", buttonBox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
420 gtk_signal_connect_object(GTK_OBJECT(cancelButton), "clicked", GTK_SIGNAL_FUNC(closeInfoBox), NULL); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
421 gtk_widget_grab_default(cancelButton); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
422 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
423 //File information |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
424 GtkWidget* infoFrame = gtk_frame_new("Musepack Info"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
425 gtk_box_pack_start(GTK_BOX(iHbox), infoFrame, FALSE, FALSE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
426 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
427 GtkWidget* infoVbox = gtk_vbox_new(FALSE, 5); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
428 gtk_container_add(GTK_CONTAINER(infoFrame), infoVbox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
429 gtk_container_set_border_width(GTK_CONTAINER(infoVbox), 10); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
430 gtk_box_set_spacing(GTK_BOX(infoVbox), 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
431 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
432 GtkWidget* streamLabel = mpcGtkLabel(infoVbox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
433 GtkWidget* encoderLabel = mpcGtkLabel(infoVbox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
434 GtkWidget* profileLabel = mpcGtkLabel(infoVbox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
435 GtkWidget* bitrateLabel = mpcGtkLabel(infoVbox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
436 GtkWidget* rateLabel = mpcGtkLabel(infoVbox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
437 GtkWidget* channelsLabel = mpcGtkLabel(infoVbox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
438 GtkWidget* lengthLabel = mpcGtkLabel(infoVbox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
439 GtkWidget* fileSizeLabel = mpcGtkLabel(infoVbox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
440 GtkWidget* trackPeakLabel = mpcGtkLabel(infoVbox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
441 GtkWidget* trackGainLabel = mpcGtkLabel(infoVbox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
442 GtkWidget* albumPeakLabel = mpcGtkLabel(infoVbox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
443 GtkWidget* albumGainLabel = mpcGtkLabel(infoVbox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
444 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
445 FILE* input = fopen(p_Filename, "rb"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
446 if(input) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
447 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
448 mpc_streaminfo info; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
449 mpc_reader_file reader; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
450 mpc_reader_setup_file_reader(&reader, input); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
451 mpc_streaminfo_read(&info, &reader.reader); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
452 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
453 int time = static_cast<int> (mpc_streaminfo_get_length(&info)); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
454 int minutes = time / 60; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
455 int seconds = time % 60; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
456 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
457 mpcGtkPrintLabel(streamLabel, "Streamversion %d", info.stream_version); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
458 mpcGtkPrintLabel(encoderLabel, "Encoder: \%s", info.encoder); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
459 mpcGtkPrintLabel(profileLabel, "Profile: \%s", info.profile_name); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
460 mpcGtkPrintLabel(bitrateLabel, "Average bitrate: \%6.1f kbps", info.average_bitrate * 1.e-3); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
461 mpcGtkPrintLabel(rateLabel, "Samplerate: \%d Hz", info.sample_freq); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
462 mpcGtkPrintLabel(channelsLabel, "Channels: \%d", info.channels); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
463 mpcGtkPrintLabel(lengthLabel, "Length: \%d:\%.2d", minutes, seconds); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
464 mpcGtkPrintLabel(fileSizeLabel, "File size: \%d Bytes", info.total_file_length); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
465 mpcGtkPrintLabel(trackPeakLabel, "Track Peak: \%5u", info.peak_title); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
466 mpcGtkPrintLabel(trackGainLabel, "Track Gain: \%-+2.2f dB", 0.01 * info.gain_title); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
467 mpcGtkPrintLabel(albumPeakLabel, "Album Peak: \%5u", info.peak_album); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
468 mpcGtkPrintLabel(albumGainLabel, "Album Gain: \%-+5.2f dB", 0.01 * info.gain_album); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
469 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
470 MpcInfo tags = getTags(p_Filename); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
471 gtk_entry_set_text(GTK_ENTRY(titleEntry), tags.title); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
472 gtk_entry_set_text(GTK_ENTRY(artistEntry), tags.artist); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
473 gtk_entry_set_text(GTK_ENTRY(albumEntry), tags.album); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
474 gtk_entry_set_text(GTK_ENTRY(commentEntry), tags.comment); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
475 gtk_entry_set_text(GTK_ENTRY(genreEntry), tags.genre); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
476 char* entry = g_strdup_printf ("%d", tags.track); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
477 gtk_entry_set_text(GTK_ENTRY(trackEntry), entry); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
478 free(entry); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
479 entry = g_strdup_printf ("%d", tags.year); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
480 gtk_entry_set_text(GTK_ENTRY(yearEntry), entry); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
481 free(entry); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
482 entry = g_filename_display_name(p_Filename); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
483 gtk_entry_set_text(GTK_ENTRY(fileEntry), entry); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
484 free(entry); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
485 freeTags(tags); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
486 fclose(input); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
487 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
488 else |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
489 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
490 char* temp = g_strdup_printf("[xmms-musepack] mpcFileInfoBox is unable to read tags from %s", p_Filename); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
491 perror(temp); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
492 free(temp); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
493 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
494 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
495 char* name = g_filename_display_basename(p_Filename); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
496 char* text = g_strdup_printf("File Info - %s", name); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
497 free(name); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
498 gtk_window_set_title(GTK_WINDOW(infoBox), text); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
499 free(text); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
500 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
501 gtk_widget_show_all(infoBox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
502 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
503 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
504 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
505 static void mpcGtkPrintLabel(GtkWidget* widget, char* format,...) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
506 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
507 va_list args; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
508 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
509 va_start(args, format); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
510 char* temp = g_strdup_vprintf(format, args); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
511 va_end(args); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
512 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
513 gtk_label_set_text(GTK_LABEL(widget), temp); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
514 free(temp); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
515 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
516 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
517 static GtkWidget* mpcGtkTagLabel(char* p_Text, int a, int b, int c, int d, GtkWidget* p_Box) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
518 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
519 GtkWidget* label = gtk_label_new(p_Text); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
520 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
521 gtk_table_attach(GTK_TABLE(p_Box), label, a, b, c, d, GTK_FILL, GTK_FILL, 5, 5); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
522 return label; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
523 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
524 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
525 static GtkWidget* mpcGtkTagEntry(int a, int b, int c, int d, int p_Size, GtkWidget* p_Box) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
526 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
527 GtkWidget* entry; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
528 if(p_Size == 0) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
529 entry = gtk_entry_new(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
530 else |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
531 entry = gtk_entry_new_with_max_length(p_Size); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
532 gtk_table_attach(GTK_TABLE(p_Box), entry, a, b, c, d, |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
533 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND | GTK_SHRINK), |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
534 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND | GTK_SHRINK), 0, 5); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
535 return entry; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
536 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
537 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
538 static GtkWidget* mpcGtkLabel(GtkWidget* p_Box) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
539 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
540 GtkWidget* label = gtk_label_new(""); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
541 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
542 gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
543 gtk_box_pack_start(GTK_BOX(p_Box), label, FALSE, FALSE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
544 return label; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
545 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
546 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
547 static GtkWidget* mpcGtkButton(char* p_Text, GtkWidget* p_Box) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
548 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
549 GtkWidget* button = gtk_button_new_with_label(p_Text); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
550 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
551 gtk_box_pack_start(GTK_BOX(p_Box), button, TRUE, TRUE, 0); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
552 return button; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
553 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
554 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
555 static void removeTags(GtkWidget * w, gpointer data) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
556 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
557 File oFile(gtk_entry_get_text(GTK_ENTRY(widgets.fileEntry))); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
558 oFile.remove(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
559 oFile.save(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
560 closeInfoBox(NULL, NULL); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
561 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
562 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
563 static void saveTags(GtkWidget* w, gpointer data) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
564 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
565 File oFile(gtk_entry_get_text(GTK_ENTRY(widgets.fileEntry))); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
566 Tag* poTag = oFile.tag(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
567 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
568 char* cAlbum = g_strdup(gtk_entry_get_text(GTK_ENTRY(widgets.albumEntry))); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
569 char* cArtist = g_strdup(gtk_entry_get_text(GTK_ENTRY(widgets.artistEntry))); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
570 char* cTitle = g_strdup(gtk_entry_get_text(GTK_ENTRY(widgets.titleEntry))); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
571 char* cGenre = g_strdup(gtk_entry_get_text(GTK_ENTRY(widgets.genreEntry))); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
572 char* cComment = g_strdup(gtk_entry_get_text(GTK_ENTRY(widgets.commentEntry))); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
573 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
574 const String album = String(cAlbum, TagLib::String::UTF8); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
575 const String artist = String(cArtist, TagLib::String::UTF8); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
576 const String title = String(cTitle, TagLib::String::UTF8); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
577 const String genre = String(cGenre, TagLib::String::UTF8); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
578 const String comment = String(cComment, TagLib::String::UTF8); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
579 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
580 poTag->setAlbum(album); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
581 poTag->setArtist(artist); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
582 poTag->setTitle(title); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
583 poTag->setGenre(genre); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
584 poTag->setComment(comment); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
585 poTag->setYear(atoi(gtk_entry_get_text(GTK_ENTRY(widgets.yearEntry)))); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
586 poTag->setTrack(atoi(gtk_entry_get_text(GTK_ENTRY(widgets.trackEntry)))); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
587 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
588 free(cAlbum); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
589 free(cArtist); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
590 free(cTitle); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
591 free(cGenre); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
592 free(cComment); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
593 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
594 oFile.save(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
595 closeInfoBox(NULL, NULL); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
596 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
597 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
598 static void closeInfoBox(GtkWidget* w, gpointer data) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
599 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
600 gtk_widget_destroy(widgets.infoBox); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
601 widgets.infoBox = NULL; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
602 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
603 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
604 static char* mpcGenerateTitle(const MpcInfo& p_Tags, const char* p_Filename) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
605 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
606 TitleInput* input; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
607 //From titlestring.h |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
608 input = g_new0(TitleInput, 1); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
609 input->__size = XMMS_TITLEINPUT_SIZE; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
610 input->__version = XMMS_TITLEINPUT_VERSION; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
611 //end |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
612 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
613 input->file_name = g_filename_display_basename(p_Filename); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
614 input->file_path = g_path_get_dirname(p_Filename); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
615 input->file_ext = "mpc"; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
616 input->date = g_strdup(p_Tags.date); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
617 input->track_name = g_strdup(p_Tags.title); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
618 input->performer = g_strdup(p_Tags.artist); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
619 input->album_name = g_strdup(p_Tags.album); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
620 input->track_number = p_Tags.track; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
621 input->year = p_Tags.year; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
622 input->genre = g_strdup(p_Tags.genre); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
623 input->comment = g_strdup(p_Tags.comment); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
624 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
625 char* title = xmms_get_titlestring (xmms_get_gentitle_format(), input); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
626 if(!title) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
627 title = g_strdup(input->file_name); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
628 else if (!*title) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
629 title = g_strdup(input->file_name); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
630 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
631 free(input->file_name); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
632 free(input->file_path); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
633 free(input->track_name); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
634 free(input->performer); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
635 free(input->album_name); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
636 free(input->genre); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
637 free(input->comment); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
638 free(input->date); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
639 g_free(input); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
640 return title; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
641 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
642 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
643 static void* endThread(char* p_FileName, FILE* p_FileHandle, bool release) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
644 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
645 free(p_FileName); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
646 if(release) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
647 lockRelease(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
648 if(mpcDecoder.isError) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
649 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
650 perror(mpcDecoder.isError); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
651 free(mpcDecoder.isError); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
652 mpcDecoder.isError = NULL; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
653 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
654 setAlive(false); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
655 if(p_FileHandle) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
656 fclose(p_FileHandle); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
657 if(track.display) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
658 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
659 free(track.display); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
660 track.display = NULL; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
661 } |
294 | 662 g_thread_exit(NULL); |
293
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
663 return 0; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
664 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
665 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
666 static void* decodeStream(void* data) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
667 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
668 lockAcquire(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
669 char* filename = static_cast<char*> (data); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
670 FILE* input = fopen(filename, "rb"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
671 if (!input) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
672 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
673 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open %s", filename); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
674 return endThread(filename, input, true); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
675 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
676 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
677 mpc_reader_file reader; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
678 mpc_reader_setup_file_reader(&reader, input); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
679 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
680 mpc_streaminfo info; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
681 if (mpc_streaminfo_read(&info, &reader.reader) != ERROR_CODE_OK) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
682 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
683 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to read %s", filename); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
684 return endThread(filename, input, true); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
685 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
686 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
687 MpcInfo tags = getTags(filename); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
688 track.display = mpcGenerateTitle(tags, filename); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
689 track.length = static_cast<int> (1000 * mpc_streaminfo_get_length(&info)); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
690 track.bitrate = static_cast<int> (info.average_bitrate); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
691 track.sampleFreq = info.sample_freq; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
692 track.channels = info.channels; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
693 freeTags(tags); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
694 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
695 MpcPlugin.set_info(track.display, track.length, track.bitrate, track.sampleFreq, track.channels); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
696 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
697 mpc_decoder decoder; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
698 mpc_decoder_setup(&decoder, &reader.reader); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
699 if (!mpc_decoder_initialize(&decoder, &info)) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
700 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
701 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to initialize decoder on %s", filename); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
702 return endThread(filename, input, true); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
703 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
704 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
705 setReplaygain(info, decoder); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
706 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
707 MPC_SAMPLE_FORMAT sampleBuffer[MPC_DECODER_BUFFER_LENGTH]; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
708 char xmmsBuffer[MPC_DECODER_BUFFER_LENGTH * 4]; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
709 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
710 if (!MpcPlugin.output->open_audio(FMT_S16_LE, track.sampleFreq, track.channels)) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
711 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
712 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] decodeStream is unable to open an audio output"); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
713 return endThread(filename, input, true); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
714 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
715 else |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
716 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
717 mpcDecoder.isOutput = true; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
718 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
719 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
720 lockRelease(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
721 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
722 int counter = 2 * track.sampleFreq / 3; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
723 while (isAlive()) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
724 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
725 if (getOffset() != -1) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
726 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
727 mpc_decoder_seek_seconds(&decoder, mpcDecoder.offset); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
728 setOffset(-1); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
729 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
730 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
731 lockAcquire(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
732 short iPlaying = MpcPlugin.output->buffer_playing()? 1 : 0; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
733 int iFree = MpcPlugin.output->buffer_free(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
734 if (!mpcDecoder.isPause && iFree >= ((1152 * 4) << iPlaying)) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
735 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
736 unsigned status = processBuffer(sampleBuffer, xmmsBuffer, decoder); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
737 if (status == (unsigned) (-1)) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
738 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
739 mpcDecoder.isError = g_strdup_printf("[xmms-musepack] error from internal decoder on %s", filename); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
740 return endThread(filename, input, true); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
741 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
742 else if (status == 0) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
743 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
744 //mpcDecoder.isError = g_strdup_printf("[xmms-musepack] null output from internal decoder on %s", filename); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
745 return endThread(filename, input, true); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
746 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
747 lockRelease(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
748 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
749 if(pluginConfig.dynamicBitrate) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
750 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
751 counter -= status; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
752 if(counter < 0) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
753 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
754 MpcPlugin.set_info(track.display, track.length, track.bitrate, track.sampleFreq, track.channels); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
755 counter = 2 * track.sampleFreq / 3; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
756 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
757 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
758 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
759 else |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
760 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
761 lockRelease(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
762 xmms_usleep(10000); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
763 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
764 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
765 return endThread(filename, input, false); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
766 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
767 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
768 static int processBuffer(MPC_SAMPLE_FORMAT* sampleBuffer, char* xmmsBuffer, mpc_decoder& decoder) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
769 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
770 mpc_uint32_t vbrAcc = 0; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
771 mpc_uint32_t vbrUpd = 0; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
772 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
773 unsigned status = mpc_decoder_decode(&decoder, sampleBuffer, &vbrAcc, &vbrUpd); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
774 copyBuffer(sampleBuffer, xmmsBuffer, status); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
775 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
776 if (pluginConfig.dynamicBitrate) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
777 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
778 track.bitrate = static_cast<int> (vbrUpd * track.sampleFreq / 1152); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
779 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
780 |
347
2dd23cdf6c4b
[svn] Use the audacious filterchain for musepack. (I'm not removing the equalizer, because it looks like a better equalizer than the one we have right now.)
nenolod
parents:
294
diff
changeset
|
781 produce_audio(MpcPlugin.output->written_time(), FMT_S16_LE, track.channels, status * 4, xmmsBuffer, NULL); |
293
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
782 return status; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
783 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
784 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
785 static void setReplaygain(mpc_streaminfo& info, mpc_decoder& decoder) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
786 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
787 if(!pluginConfig.replaygain && !pluginConfig.clipPrevention) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
788 return; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
789 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
790 int peak = pluginConfig.albumGain ? info.peak_album : info.peak_title; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
791 double gain = pluginConfig.albumGain ? info.gain_album : info.gain_title; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
792 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
793 if(!peak) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
794 peak = 32767; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
795 if(!gain) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
796 gain = 1.; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
797 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
798 double clip = 32767. / peak; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
799 gain = exp((M_LN10 / 2000.) * gain); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
800 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
801 if(pluginConfig.clipPrevention && !pluginConfig.replaygain) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
802 gain = clip; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
803 else if(pluginConfig.replaygain && pluginConfig.clipPrevention) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
804 if(clip < gain) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
805 gain = clip; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
806 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
807 mpc_decoder_scale_output(&decoder, gain); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
808 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
809 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
810 inline static void lockAcquire() |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
811 { |
294 | 812 g_static_mutex_lock(&threadMutex); |
293
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
813 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
814 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
815 inline static void lockRelease() |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
816 { |
294 | 817 g_static_mutex_unlock(&threadMutex); |
293
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
818 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
819 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
820 inline static bool isAlive() |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
821 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
822 lockAcquire(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
823 bool isAlive = mpcDecoder.isAlive; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
824 lockRelease(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
825 return isAlive; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
826 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
827 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
828 inline static bool isPause() |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
829 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
830 lockAcquire(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
831 bool isPause = mpcDecoder.isPause; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
832 lockRelease(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
833 return isPause; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
834 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
835 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
836 inline static void setAlive(bool isAlive) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
837 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
838 lockAcquire(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
839 mpcDecoder.isAlive = isAlive; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
840 lockRelease(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
841 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
842 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
843 inline static double getOffset() |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
844 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
845 lockAcquire(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
846 double offset = mpcDecoder.offset; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
847 lockRelease(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
848 return offset; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
849 } |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
850 |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
851 inline static void setOffset(double offset) |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
852 { |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
853 lockAcquire(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
854 mpcDecoder.offset = offset; |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
855 lockRelease(); |
9b191695629c
[svn] Add musepack input plugin & hook into build system.
chainsaw
parents:
diff
changeset
|
856 } |