137
|
1 /*
|
|
2 * Audacious, a cross-platform multimedia player.
|
|
3 * Copyright (C) 2005 Audacious Team
|
|
4 *
|
|
5 * Based on BMP-WMA:
|
|
6 * Copyright (C) 2004 Roman Bogorodskiy <bogorodskiy@inbox.ru>
|
|
7 *
|
|
8 * This program is free software; you can redistribute it and/or modify
|
|
9 * it under the terms of the GNU General Public License as published by
|
|
10 * the Free Software Foundation; either version 2 of the License, or
|
|
11 * (at your option) any later version.
|
|
12 *
|
|
13 * This program is distributed in the hope that it will be useful,
|
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 * GNU General Public License for more details.
|
|
17 *
|
|
18 * You should have received a copy of the GNU General Public License
|
|
19 * along with this program; if not, write to the Free Software
|
|
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
21 */
|
|
22
|
|
23 #ifdef HAVE_MALLOC_H
|
|
24 #include <malloc.h>
|
|
25 #endif
|
|
26 #include <pthread.h>
|
|
27
|
|
28 #include <glib.h>
|
|
29 #include <glib/gprintf.h>
|
|
30
|
|
31 #include <audacious/plugin.h>
|
|
32 #include <audacious/configfile.h>
|
|
33 #include <audacious/util.h>
|
|
34 #include <audacious/titlestring.h>
|
|
35 #include <audacious/vfs.h>
|
|
36
|
|
37 #ifdef HAVE_CONFIG_H
|
|
38 # include "config.h"
|
|
39 #endif
|
|
40
|
|
41 #include "avcodec.h"
|
|
42 #include "avformat.h"
|
|
43 #include "iir.h"
|
|
44
|
|
45 #define ST_BUFF 1024
|
|
46
|
|
47 static GtkWidget *about_dialog;
|
|
48 static GtkWidget *dialog;
|
|
49
|
|
50 static gboolean wma_decode = 0;
|
|
51 static gboolean wma_pause = 0;
|
|
52 static gboolean wma_eq_on = 0;
|
|
53 static int wma_seekpos = -1;
|
|
54 static int wma_st_buff, wma_idx;
|
|
55 static pthread_t wma_decode_thread;
|
|
56 static pthread_mutex_t wma_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
57 static AVCodecContext *c = NULL;
|
|
58 static AVFormatContext *ic = NULL;
|
|
59 static uint8_t *wma_outbuf, *wma_s_outbuf;
|
|
60
|
|
61 char description[64];
|
|
62 static void wma_about(void);
|
|
63 static void wma_init(void);
|
|
64 static int wma_is_our_file(char *filename);
|
|
65 static void wma_play_file(char *filename);
|
|
66 static void wma_stop(void);
|
|
67 static void wma_seek(int time);
|
|
68 static void wma_do_pause(short p);
|
|
69 static int wma_get_time(void);
|
|
70 static void wma_get_song_info(char *filename, char **title, int *length);
|
|
71 static void wma_file_info_box(char *filename);
|
|
72 static void wma_set_eq(int q_on, float q_preamp, float *q_bands);
|
|
73 static char *wsong_title;
|
|
74 static int wsong_time;
|
|
75
|
|
76 InputPlugin *get_iplugin_info(void);
|
|
77
|
|
78 InputPlugin wma_ip =
|
|
79 {
|
|
80 NULL, /* Filled in by xmms */
|
|
81 NULL, /* Filled in by xmms */
|
|
82 description, /* The description that is shown in the preferences box */
|
|
83 wma_init, /* Called when the plugin is loaded */
|
|
84 wma_about, /* Show the about box */
|
|
85 NULL, /* Show the configure box */
|
|
86 wma_is_our_file, /* Return 1 if the plugin can handle the file */
|
|
87 NULL, /* Scan dir */
|
|
88 wma_play_file, /* Play file */
|
|
89 wma_stop, /* Stop */
|
|
90 wma_do_pause, /* Pause */
|
|
91 wma_seek, /* Seek */
|
|
92 wma_set_eq, /* Set the equalizer, most plugins won't be able to do this */
|
|
93 wma_get_time, /* Get the time, usually returns the output plugins output time */
|
|
94 NULL, /* Get volume */
|
|
95 NULL, /* Set volume */
|
|
96 NULL, /* OBSOLETE! */
|
|
97 NULL, /* OBSOLETE! */
|
|
98 NULL, /* Send data to the visualization plugins */
|
|
99 NULL, /* Fill in the stuff that is shown in the player window */
|
|
100 NULL, /* Show some text in the song title box. */
|
|
101 wma_get_song_info, /* Function to grab the title string */
|
|
102 wma_file_info_box, /* Bring up an info window for the filename passed in */
|
|
103 NULL /* Handle to the current output plugin. */
|
|
104 };
|
|
105
|
|
106 InputPlugin *get_iplugin_info(void)
|
|
107 {
|
|
108 wma_ip.description = g_strdup_printf("WMA Audio Plugin");
|
|
109 return &wma_ip;
|
|
110 }
|
|
111
|
|
112 static void wma_about(void)
|
|
113 {
|
|
114 static GtkWidget *aboutbox;
|
|
115 gchar *text;
|
|
116
|
|
117 if (aboutbox)
|
|
118 return;
|
|
119
|
|
120 text = g_strdup_printf("WMA Plugin %s\n\n"
|
|
121 "Created by Roman Bogorodskiy <bogorodskiy@inbox.ru>\n"
|
|
122 "Based on xmms-wma written by Mokrushin I.V. aka McMCC <mcmcc@mail.ru>\n"
|
|
123 "See AUTHORS for details\n",
|
|
124 VERSION);
|
|
125
|
|
126 aboutbox = xmms_show_message("About the WMA decoder",
|
|
127 text,
|
|
128 "OK", FALSE, NULL, NULL);
|
|
129
|
|
130 g_free(text);
|
|
131 gtk_signal_connect(GTK_OBJECT(aboutbox), "destroy",
|
|
132 GTK_SIGNAL_FUNC(gtk_widget_destroyed), &aboutbox);
|
|
133 }
|
|
134
|
|
135 static void wma_init(void)
|
|
136 {
|
|
137
|
|
138 avcodec_init();
|
|
139 avcodec_register_all();
|
|
140 av_register_all();
|
|
141 init_iir();
|
|
142 }
|
|
143
|
|
144 static int wma_is_our_file(char *filename)
|
|
145 {
|
|
146 gchar *ext;
|
|
147 ext = strrchr(filename, '.');
|
|
148
|
|
149 if (ext)
|
|
150 if (!strncasecmp(ext, ".wma", 4))
|
|
151 return TRUE;
|
|
152
|
|
153 return FALSE;
|
|
154 }
|
|
155
|
|
156 static void wma_do_pause(short p)
|
|
157 {
|
|
158
|
|
159 wma_pause = p;
|
|
160 wma_ip.output->pause(wma_pause);
|
|
161 }
|
|
162
|
|
163 static void wma_seek(int time)
|
|
164 {
|
|
165 wma_seekpos = time;
|
|
166 if (wma_pause)
|
|
167 wma_ip.output->pause(0);
|
|
168
|
|
169 while (wma_decode && wma_seekpos!=-1)
|
|
170 xmms_usleep(10000);
|
|
171
|
|
172 if (wma_pause)
|
|
173 wma_ip.output->pause(1);
|
|
174 }
|
|
175
|
|
176 static int wma_get_time(void)
|
|
177 {
|
|
178 wma_ip.output->buffer_free();
|
|
179 if (wma_decode)
|
|
180 return wma_ip.output->output_time();
|
|
181
|
|
182 return -1;
|
|
183 }
|
|
184
|
|
185 static void wma_set_eq(int q_on, float q_preamp, float *q_bands)
|
|
186 {
|
|
187 int chn;
|
|
188 int index;
|
|
189 float value;
|
|
190
|
|
191 wma_eq_on = q_on;
|
|
192
|
|
193 if (wma_eq_on) {
|
|
194 q_preamp = q_preamp/1.6;
|
|
195 for (chn = 0; chn < c->channels; chn++)
|
|
196 preamp[chn] = 1.0 + 0.0932471 * q_preamp + 0.00279033 * q_preamp * q_preamp;
|
|
197
|
|
198 for (index = 0; index < 10; index++) {
|
|
199 value = q_bands[index]/1.2;
|
|
200
|
|
201 for (chn = 0; chn < c->channels; chn++)
|
|
202 gain[index][chn] = 0.03 * value + 0.000999999 * value * value;
|
|
203 }
|
|
204 }
|
|
205 }
|
|
206
|
|
207 static gchar *extname(const char *filename)
|
|
208 {
|
|
209 gchar *ext = strrchr(filename, '.');
|
|
210
|
|
211 if (ext != NULL)
|
|
212 ++ext;
|
|
213 return ext;
|
|
214 }
|
|
215
|
|
216 static char* w_getstr(char* str)
|
|
217 {
|
|
218 /* TODO
|
|
219 * Seems, this function was stolen from mpg123 xmms plugin,
|
|
220 * we need to get rid of it since I feel it is not useful)
|
|
221 */
|
|
222
|
|
223 if (str && strlen(str) > 0)
|
|
224 return str;
|
|
225
|
|
226 return NULL;
|
|
227 }
|
|
228
|
|
229 static gchar *get_song_title(AVFormatContext *in, gchar * filename)
|
|
230 {
|
|
231 gchar *ret = NULL;
|
|
232 TitleInput *input;
|
|
233
|
|
234 XMMS_NEW_TITLEINPUT(input);
|
|
235
|
|
236 if ((in->title[0] != '\0') || (in->author[0] != '\0') || (in->album[0] != '\0') ||
|
|
237 (in->comment[0] != '\0') || (in->genre[0] != '\0') || (in->year != 0) || (in->track != 0))
|
|
238 {
|
|
239 input->performer = w_getstr(in->author);
|
|
240 input->album_name = w_getstr(in->album);
|
|
241 input->track_name = w_getstr(in->title);
|
|
242 input->year = in->year;
|
|
243 input->track_number = in->track;
|
|
244 input->genre = w_getstr(in->genre);
|
|
245 input->comment = w_getstr(in->comment);
|
|
246 }
|
|
247
|
|
248 input->file_name = (gchar *)g_basename(filename);
|
|
249 input->file_path = filename;
|
|
250 input->file_ext = extname(filename);
|
|
251 ret = xmms_get_titlestring(xmms_get_gentitle_format(), input);
|
|
252
|
|
253 g_free(input);
|
|
254
|
|
255 if (!ret) {
|
|
256 ret = g_strdup(g_basename(filename));
|
|
257
|
|
258 if (extname(ret) != NULL)
|
|
259 *(extname(ret) - 1) = '\0';
|
|
260 }
|
|
261
|
|
262 return ret;
|
|
263 }
|
|
264
|
|
265 static guint get_song_time(AVFormatContext *in)
|
|
266 {
|
|
267
|
|
268 if (in->duration)
|
|
269 return in->duration/1000;
|
|
270 else
|
|
271 return 0;
|
|
272 }
|
|
273
|
|
274 static void wma_get_song_info(char *filename, char **title_real, int *len_real)
|
|
275 {
|
|
276 AVFormatContext *in = NULL;
|
|
277
|
|
278 (*len_real) = -1;
|
|
279 (*title_real) = NULL;
|
|
280
|
|
281 if (av_open_input_file(&in, filename, NULL, 0, NULL) < 0)
|
|
282 return;
|
|
283
|
|
284 av_find_stream_info(in);
|
|
285 (*len_real) = get_song_time(in);
|
|
286 (*title_real) = get_song_title(in, filename);
|
|
287 av_close_input_file(in);
|
|
288 }
|
|
289
|
|
290 static void wma_playbuff(int out_size)
|
|
291 {
|
|
292 FifoBuffer f;
|
|
293 int sst_buff;
|
|
294
|
|
295 fifo_init(&f, out_size*2);
|
|
296 fifo_write(&f, wma_outbuf, out_size, &f.wptr);
|
|
297
|
|
298 while (!fifo_read(&f, wma_s_outbuf, wma_st_buff, &f.rptr) && wma_decode) {
|
|
299 if (wma_eq_on)
|
|
300 sst_buff = iir((gpointer)&wma_s_outbuf, wma_st_buff);
|
|
301 else
|
|
302 sst_buff = wma_st_buff;
|
|
303
|
|
304 if (wma_pause)
|
|
305 memset(wma_s_outbuf, 0, sst_buff);
|
|
306
|
|
307 while (wma_ip.output->buffer_free() < wma_st_buff)
|
|
308 xmms_usleep(20000);
|
|
309
|
|
310 if (wma_seekpos == -1)
|
|
311 wma_ip.add_vis_pcm(wma_ip.output->written_time(), FMT_S16_NE,
|
|
312 c->channels, sst_buff, (short *)wma_s_outbuf);
|
|
313
|
|
314 wma_ip.output->write_audio((short *)wma_s_outbuf, sst_buff);
|
|
315 memset(wma_s_outbuf, 0, sst_buff);
|
|
316 }
|
|
317
|
|
318 fifo_free(&f);
|
|
319
|
|
320 return;
|
|
321 }
|
|
322
|
|
323 static void *wma_play_loop(void *arg)
|
|
324 {
|
|
325 uint8_t *inbuf_ptr;
|
|
326 int out_size, size, len;
|
|
327 AVPacket pkt;
|
|
328
|
|
329 pthread_mutex_lock(&wma_mutex);
|
|
330
|
|
331 while (wma_decode) {
|
|
332 if (wma_seekpos != -1) {
|
|
333 av_seek_frame(ic, wma_idx, wma_seekpos * 1000000LL);
|
|
334 wma_ip.output->flush(wma_seekpos * 1000);
|
|
335 wma_seekpos = -1;
|
|
336 }
|
|
337
|
|
338 if (av_read_frame(ic, &pkt) < 0)
|
|
339 break;
|
|
340
|
|
341 size = pkt.size;
|
|
342 inbuf_ptr = pkt.data;
|
|
343
|
|
344 if (size == 0)
|
|
345 break;
|
|
346
|
|
347 while (size > 0) {
|
|
348 len = avcodec_decode_audio(c, (short *)wma_outbuf,
|
|
349 &out_size, inbuf_ptr, size);
|
|
350
|
|
351 if (len < 0)
|
|
352 break;
|
|
353
|
|
354 if (out_size <= 0)
|
|
355 continue;
|
|
356
|
|
357 wma_playbuff(out_size);
|
|
358
|
|
359 size -= len;
|
|
360 inbuf_ptr += len;
|
|
361
|
|
362 if (pkt.data)
|
|
363 av_free_packet(&pkt);
|
|
364 }
|
|
365 }
|
|
366
|
|
367 while (wma_decode && wma_ip.output->buffer_playing())
|
|
368 xmms_usleep(30000);
|
|
369
|
|
370 wma_decode = 0;
|
|
371
|
|
372 /* XXX
|
|
373 * that's all odd
|
|
374 */
|
|
375
|
|
376 if (wma_s_outbuf)
|
|
377 g_free(wma_s_outbuf);
|
|
378
|
|
379 if (wma_outbuf)
|
|
380 g_free(wma_outbuf);
|
|
381
|
|
382 if (pkt.data)
|
|
383 av_free_packet(&pkt);
|
|
384 if (c)
|
|
385 avcodec_close(c);
|
|
386 if (ic)
|
|
387 av_close_input_file(ic);
|
|
388
|
|
389 pthread_mutex_unlock(&wma_mutex);
|
|
390 pthread_exit(NULL);
|
|
391 }
|
|
392
|
|
393 static void wma_play_file(char *filename)
|
|
394 {
|
|
395 AVCodec *codec;
|
|
396
|
|
397 if (av_open_input_file(&ic, filename, NULL, 0, NULL) < 0)
|
|
398 return;
|
|
399
|
|
400 for (wma_idx = 0; wma_idx < ic->nb_streams; wma_idx++) {
|
|
401 c = &ic->streams[wma_idx]->codec;
|
|
402
|
|
403 if(c->codec_type == CODEC_TYPE_AUDIO)
|
|
404 break;
|
|
405 }
|
|
406
|
|
407 av_find_stream_info(ic);
|
|
408
|
|
409 codec = avcodec_find_decoder(c->codec_id);
|
|
410
|
|
411 if (!codec)
|
|
412 return;
|
|
413
|
|
414 if (avcodec_open(c, codec) < 0)
|
|
415 return;
|
|
416
|
|
417 wsong_title = get_song_title(ic, filename);
|
|
418 wsong_time = get_song_time(ic);
|
|
419
|
|
420 if (wma_ip.output->open_audio(FMT_S16_NE, c->sample_rate, c->channels) <= 0)
|
|
421 return;
|
|
422
|
|
423 wma_st_buff = ST_BUFF;
|
|
424
|
|
425 wma_ip.set_info(wsong_title, wsong_time, c->bit_rate, c->sample_rate, c->channels);
|
|
426
|
|
427 wma_s_outbuf = g_malloc0(wma_st_buff);
|
|
428 wma_outbuf = g_malloc0(AVCODEC_MAX_AUDIO_FRAME_SIZE);
|
|
429 wma_seekpos = -1;
|
|
430 wma_decode = 1;
|
|
431 pthread_create(&wma_decode_thread, NULL, wma_play_loop, NULL);
|
|
432 }
|
|
433
|
|
434 static void wma_stop(void)
|
|
435 {
|
|
436 wma_decode = 0;
|
|
437
|
|
438 if (wma_pause)
|
|
439 wma_do_pause(0);
|
|
440
|
|
441 pthread_join(wma_decode_thread, NULL);
|
|
442 wma_ip.output->close_audio();
|
|
443 }
|
|
444
|
|
445 static void wma_file_info_box (char *filename)
|
|
446 {
|
|
447 GtkWidget *dialog_vbox1;
|
|
448 GtkWidget *vbox1;
|
|
449 GtkWidget *hbox1;
|
|
450 GtkWidget *label_name;
|
|
451 GtkWidget *entry_filename;
|
|
452 GtkWidget *hbox2;
|
|
453 GtkWidget *frame_wma_info;
|
|
454 GtkWidget *alignment1;
|
|
455 GtkWidget *table1;
|
|
456 GtkWidget *label_album;
|
|
457 GtkWidget *label_year;
|
|
458 GtkWidget *label_track;
|
|
459 GtkWidget *label_genre;
|
|
460 GtkWidget *label_comments;
|
|
461 /*GtkWidget *label_copyright;*/
|
|
462 GtkWidget *label_wma_version;
|
|
463 GtkWidget *label_bitrate;
|
|
464 GtkWidget *label_rate;
|
|
465 GtkWidget *label_chans;
|
|
466 GtkWidget *label_play_time;
|
|
467 GtkWidget *label_filesize;
|
|
468 GtkWidget *label_wma_vers_val;
|
|
469 GtkWidget *label_bitrate_val;
|
|
470 GtkWidget *label_rate_val;
|
|
471 GtkWidget *label_chans_val;
|
|
472 GtkWidget *label_playtime_val;
|
|
473 GtkWidget *label_filesize_val;
|
|
474 GtkWidget *label4;
|
|
475 GtkWidget *frame_tags;
|
|
476 GtkWidget *alignment2;
|
|
477 GtkWidget *table2;
|
|
478 GtkWidget *label_artist;
|
|
479 GtkWidget *label_title;
|
|
480 GtkWidget *entry_artist;
|
|
481 GtkWidget *entry_album;
|
|
482 GtkWidget *entry_year;
|
|
483 GtkWidget *entry_title;
|
|
484 GtkWidget *entry_track;
|
|
485 GtkWidget *entry_genre;
|
|
486 GtkWidget *entry_comments;
|
|
487 /* GtkWidget *entry_copyright;*/
|
|
488 GtkWidget *label5;
|
|
489 GtkWidget *dialog_action_area1;
|
|
490 GtkWidget *okbutton;
|
|
491
|
|
492 AVFormatContext *in = NULL;
|
|
493 AVCodecContext *s = NULL;
|
|
494 AVCodec *codec;
|
|
495 gint tns, thh, tmm, tss;
|
|
496 gint i;
|
|
497 gchar *title,
|
|
498 *channels,
|
|
499 *bitrate,
|
|
500 *playtime,
|
|
501 *samplerate,
|
|
502 *filesize;
|
|
503 VFSFile *f;
|
|
504
|
|
505 if (dialog) {
|
|
506 (void)g_printf("Info dialog is already opened!\n");
|
|
507 return;
|
|
508 }
|
|
509
|
|
510 if (av_open_input_file(&in, filename, NULL, 0, NULL) < 0)
|
|
511 return;
|
|
512
|
|
513 for(i = 0; i < in->nb_streams; i++) {
|
|
514 s = &in->streams[i]->codec;
|
|
515 if(s->codec_type == CODEC_TYPE_AUDIO)
|
|
516 break;
|
|
517 }
|
|
518
|
|
519 av_find_stream_info(in);
|
|
520 codec = avcodec_find_decoder(s->codec_id);
|
|
521
|
|
522 /* window title */
|
|
523 title = g_strdup_printf("File Info - %s", g_basename(filename));
|
|
524
|
|
525 /* channels */
|
|
526 if (s->channels == 1)
|
|
527 channels = g_strdup("MONO");
|
|
528 else
|
|
529 channels = g_strdup("STEREO");
|
|
530
|
|
531 /* bitrate */
|
|
532 bitrate = g_strdup_printf("%d Kb/s", (s->bit_rate / 1000));
|
|
533
|
|
534 /* playtime */
|
|
535 if (in->duration != 0) {
|
|
536 tns = in->duration/1000000LL;
|
|
537 thh = tns/3600;
|
|
538 tmm = (tns%3600)/60;
|
|
539 tss = (tns%60);
|
|
540 playtime = g_strdup_printf("%02d:%02d:%02d", thh, tmm, tss);
|
|
541 } else
|
|
542 playtime = g_strdup("N/A");
|
|
543
|
|
544 /* samplerate */
|
|
545 samplerate = g_strdup_printf("%d Hz", s->sample_rate);
|
|
546
|
|
547 /* filesize */
|
|
548 f = vfs_fopen(filename, "rb");
|
|
549
|
|
550 if (f == NULL)
|
|
551 return;
|
|
552
|
|
553 vfs_fseek(f, 0, SEEK_END);
|
|
554 filesize = g_strdup_printf("%lu Bytes", vfs_ftell(f));
|
|
555 vfs_fclose(f);
|
|
556
|
|
557 dialog = gtk_dialog_new();
|
|
558
|
|
559 gtk_signal_connect(GTK_OBJECT(dialog), "destroy",
|
|
560 GTK_SIGNAL_FUNC(gtk_widget_destroyed), &dialog);
|
|
561
|
|
562 gtk_window_set_title(GTK_WINDOW(dialog), title);
|
|
563 gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
|
|
564 gtk_window_set_policy(GTK_WINDOW(dialog), FALSE, FALSE, FALSE);
|
|
565
|
|
566 dialog_vbox1 = GTK_DIALOG(dialog)->vbox;
|
|
567 gtk_widget_show(dialog_vbox1);
|
|
568
|
|
569 vbox1 = gtk_vbox_new(FALSE, 0);
|
|
570 gtk_widget_show(vbox1);
|
|
571 gtk_box_pack_start(GTK_BOX(dialog_vbox1), vbox1, TRUE, TRUE, 0);
|
|
572
|
|
573 hbox1 = gtk_hbox_new (FALSE, 0);
|
|
574 gtk_widget_show (hbox1);
|
|
575 gtk_box_pack_start(GTK_BOX(vbox1), hbox1, FALSE, FALSE, 0);
|
|
576
|
|
577 label_name = gtk_label_new("<b>Name:</b>");
|
|
578 gtk_widget_show(label_name);
|
|
579 gtk_box_pack_start(GTK_BOX (hbox1), label_name, FALSE, FALSE, 0);
|
|
580 gtk_misc_set_alignment(GTK_MISC (label_name), 0.48, 0.51);
|
|
581 gtk_misc_set_padding(GTK_MISC (label_name), 10, 10);
|
|
582 gtk_label_set_use_markup(GTK_LABEL(label_name), TRUE);
|
|
583
|
|
584 entry_filename = gtk_entry_new();
|
|
585 gtk_widget_show(entry_filename);
|
|
586 gtk_box_pack_start(GTK_BOX(hbox1), entry_filename, TRUE, TRUE, 4);
|
|
587 gtk_editable_set_editable(GTK_EDITABLE(entry_filename), FALSE);
|
|
588 gtk_entry_set_text(GTK_ENTRY(entry_filename), filename);
|
|
589
|
|
590 hbox2 = gtk_hbox_new(FALSE, 0);
|
|
591 gtk_widget_show(hbox2);
|
|
592 gtk_box_pack_start(GTK_BOX(vbox1), hbox2, TRUE, TRUE, 0);
|
|
593
|
|
594 frame_wma_info = gtk_frame_new(NULL);
|
|
595 gtk_widget_show(frame_wma_info);
|
|
596 gtk_box_pack_start(GTK_BOX(hbox2), frame_wma_info, TRUE, TRUE, 0);
|
|
597 gtk_frame_set_shadow_type(GTK_FRAME (frame_wma_info), GTK_SHADOW_ETCHED_IN);
|
|
598 gtk_container_set_border_width (GTK_CONTAINER(frame_wma_info), 10);
|
|
599
|
|
600 alignment1 = gtk_alignment_new(0.5, 0.5, 1, 1);
|
|
601 gtk_widget_show(alignment1);
|
|
602 gtk_container_add(GTK_CONTAINER(frame_wma_info), alignment1);
|
|
603 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment1), 0, 0, 0, 0);
|
|
604 gtk_container_set_border_width(GTK_CONTAINER(alignment1), 2);
|
|
605
|
|
606 table1 = gtk_table_new(6, 2, FALSE);
|
|
607 gtk_widget_show(table1);
|
|
608 gtk_container_add(GTK_CONTAINER(alignment1), table1);
|
|
609 gtk_container_set_border_width(GTK_CONTAINER(table1), 6);
|
|
610 gtk_table_set_row_spacings(GTK_TABLE(table1), 3);
|
|
611 gtk_table_set_col_spacings(GTK_TABLE(table1), 8);
|
|
612
|
|
613 /* WMA Version label */
|
|
614 label_wma_version = gtk_label_new("<b>WMA Version:</b>");
|
|
615 gtk_widget_show(label_wma_version);
|
|
616 gtk_table_attach(GTK_TABLE(table1), label_wma_version, 0, 1, 0, 1,
|
|
617 (GtkAttachOptions) (GTK_FILL),
|
|
618 (GtkAttachOptions) (0), 0, 0);
|
|
619 gtk_misc_set_alignment(GTK_MISC(label_wma_version), 0, 0.5);
|
|
620 gtk_label_set_use_markup(GTK_LABEL(label_wma_version), TRUE);
|
|
621
|
|
622 /* Bitrate */
|
|
623 label_bitrate = gtk_label_new("<b>Bitrate:</b>");
|
|
624 gtk_widget_show(label_bitrate);
|
|
625 gtk_table_attach(GTK_TABLE(table1), label_bitrate, 0, 1, 1, 2,
|
|
626 (GtkAttachOptions) (GTK_FILL),
|
|
627 (GtkAttachOptions) (0), 0, 0);
|
|
628 gtk_misc_set_alignment(GTK_MISC(label_bitrate), 0, 0.5);
|
|
629 gtk_label_set_use_markup(GTK_LABEL(label_bitrate), TRUE);
|
|
630
|
|
631 /* Samplerate */
|
|
632 label_rate = gtk_label_new("<b>Samplerate:</b>");
|
|
633 gtk_widget_show(label_rate);
|
|
634 gtk_table_attach(GTK_TABLE(table1), label_rate, 0, 1, 2, 3,
|
|
635 (GtkAttachOptions) (GTK_FILL),
|
|
636 (GtkAttachOptions) (0), 0, 0);
|
|
637 gtk_misc_set_alignment(GTK_MISC(label_rate), 0, 0.5);
|
|
638 gtk_label_set_use_markup(GTK_LABEL(label_rate), TRUE);
|
|
639
|
|
640 /* Channels */
|
|
641 label_chans = gtk_label_new("<b>Channels:</b>");
|
|
642 gtk_widget_show(label_chans);
|
|
643 gtk_table_attach(GTK_TABLE (table1), label_chans, 0, 1, 3, 4,
|
|
644 (GtkAttachOptions) (GTK_FILL),
|
|
645 (GtkAttachOptions) (0), 0, 0);
|
|
646 gtk_misc_set_alignment(GTK_MISC(label_chans), 0, 0.5);
|
|
647 gtk_label_set_use_markup(GTK_LABEL(label_chans), TRUE);
|
|
648
|
|
649 /* Play time */
|
|
650 label_play_time = gtk_label_new("<b>Play time:</b>");
|
|
651 gtk_widget_show(label_play_time);
|
|
652 gtk_table_attach(GTK_TABLE (table1), label_play_time, 0, 1, 4, 5,
|
|
653 (GtkAttachOptions) (GTK_FILL),
|
|
654 (GtkAttachOptions) (0), 0, 0);
|
|
655 gtk_misc_set_alignment(GTK_MISC(label_play_time), 0, 0.5);
|
|
656 gtk_label_set_use_markup(GTK_LABEL(label_play_time), TRUE);
|
|
657
|
|
658 /* Filesize */
|
|
659 label_filesize = gtk_label_new("<b>Filesize:</b>");
|
|
660 gtk_widget_show(label_filesize);
|
|
661 gtk_table_attach(GTK_TABLE(table1), label_filesize, 0, 1, 5, 6,
|
|
662 (GtkAttachOptions) (GTK_FILL),
|
|
663 (GtkAttachOptions) (0), 0, 0);
|
|
664 gtk_misc_set_alignment(GTK_MISC(label_filesize), 0, 0.5);
|
|
665 gtk_label_set_use_markup(GTK_LABEL(label_filesize), TRUE);
|
|
666
|
|
667
|
|
668 label_wma_vers_val = gtk_label_new(codec->name);
|
|
669 gtk_widget_show(label_wma_vers_val);
|
|
670 gtk_table_attach(GTK_TABLE(table1), label_wma_vers_val, 1, 2, 0, 1,
|
|
671 (GtkAttachOptions)(GTK_FILL),
|
|
672 (GtkAttachOptions) (0), 0, 0);
|
|
673 gtk_misc_set_alignment(GTK_MISC(label_wma_vers_val), 0, 0.5);
|
|
674
|
|
675 label_bitrate_val = gtk_label_new(bitrate);
|
|
676 gtk_widget_show(label_bitrate_val);
|
|
677 gtk_table_attach(GTK_TABLE(table1), label_bitrate_val, 1, 2, 1, 2,
|
|
678 (GtkAttachOptions)(GTK_FILL),
|
|
679 (GtkAttachOptions) (0), 0, 0);
|
|
680 gtk_misc_set_alignment(GTK_MISC(label_bitrate_val), 0, 0.5);
|
|
681
|
|
682 label_rate_val = gtk_label_new(samplerate);
|
|
683 gtk_widget_show(label_rate_val);
|
|
684 gtk_table_attach(GTK_TABLE(table1), label_rate_val, 1, 2, 2, 3,
|
|
685 (GtkAttachOptions)(GTK_FILL),
|
|
686 (GtkAttachOptions) (0), 0, 0);
|
|
687 gtk_misc_set_alignment(GTK_MISC(label_rate_val), 0, 0.5);
|
|
688
|
|
689 label_chans_val = gtk_label_new(channels);
|
|
690 gtk_widget_show(label_chans_val);
|
|
691 gtk_table_attach(GTK_TABLE(table1), label_chans_val, 1, 2, 3, 4,
|
|
692 (GtkAttachOptions)(GTK_FILL),
|
|
693 (GtkAttachOptions) (0), 0, 0);
|
|
694 gtk_misc_set_alignment(GTK_MISC (label_chans_val), 0, 0.5);
|
|
695
|
|
696 label_playtime_val = gtk_label_new(playtime);
|
|
697 gtk_widget_show(label_playtime_val);
|
|
698 gtk_table_attach(GTK_TABLE(table1), label_playtime_val, 1, 2, 4, 5,
|
|
699 (GtkAttachOptions)(GTK_FILL),
|
|
700 (GtkAttachOptions) (0), 0, 0);
|
|
701 gtk_misc_set_alignment(GTK_MISC(label_playtime_val), 0, 0.5);
|
|
702
|
|
703 label_filesize_val = gtk_label_new(filesize);
|
|
704 gtk_widget_show(label_filesize_val);
|
|
705 gtk_table_attach(GTK_TABLE (table1), label_filesize_val, 1, 2, 5, 6,
|
|
706 (GtkAttachOptions)(GTK_FILL),
|
|
707 (GtkAttachOptions) (0), 0, 0);
|
|
708 gtk_misc_set_alignment(GTK_MISC(label_filesize_val), 0, 0.5);
|
|
709
|
|
710 label4 = gtk_label_new ("WMA Info");
|
|
711 gtk_widget_show(label4);
|
|
712 gtk_frame_set_label_widget(GTK_FRAME(frame_wma_info), label4);
|
|
713
|
|
714 frame_tags = gtk_frame_new (NULL);
|
|
715 gtk_widget_show (frame_tags);
|
|
716 gtk_box_pack_start (GTK_BOX (hbox2), frame_tags, TRUE, TRUE, 0);
|
|
717 gtk_frame_set_shadow_type (GTK_FRAME (frame_tags), GTK_SHADOW_ETCHED_IN);
|
|
718 gtk_container_set_border_width (GTK_CONTAINER (frame_tags), 10);
|
|
719
|
|
720
|
|
721 alignment2 = gtk_alignment_new (0.5, 0.5, 1, 1);
|
|
722 gtk_widget_show (alignment2);
|
|
723 gtk_container_add (GTK_CONTAINER (frame_tags), alignment2);
|
|
724 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment2), 0, 0, 12, 0);
|
|
725 gtk_container_set_border_width (GTK_CONTAINER (alignment2), 2);
|
|
726
|
|
727
|
|
728 table2 = gtk_table_new(8, 2, FALSE);
|
|
729 gtk_widget_show(table2);
|
|
730 gtk_container_add(GTK_CONTAINER(alignment2), table2);
|
|
731 gtk_container_set_border_width(GTK_CONTAINER(table2), 6);
|
|
732 gtk_table_set_row_spacings(GTK_TABLE(table2), 3);
|
|
733 gtk_table_set_col_spacings(GTK_TABLE(table2), 8);
|
|
734
|
|
735 /* Artist */
|
|
736 label_artist = gtk_label_new("<b>Artist:</b>");
|
|
737 gtk_widget_show(label_artist);
|
|
738 gtk_table_attach(GTK_TABLE (table2), label_artist, 0, 1, 0, 1,
|
|
739 (GtkAttachOptions) (GTK_FILL),
|
|
740 (GtkAttachOptions) (0), 0, 0);
|
|
741 gtk_misc_set_alignment(GTK_MISC(label_artist), 0, 0.5);
|
|
742 gtk_label_set_use_markup(GTK_LABEL(label_artist), TRUE);
|
|
743
|
|
744 /* Title */
|
|
745 label_title = gtk_label_new("<b>Title:</b>");
|
|
746 gtk_widget_show(label_title);
|
|
747 gtk_table_attach(GTK_TABLE (table2), label_title, 0, 1, 1, 2,
|
|
748 (GtkAttachOptions) (GTK_FILL),
|
|
749 (GtkAttachOptions) (0), 0, 0);
|
|
750 gtk_misc_set_alignment(GTK_MISC(label_title), 0, 0.5);
|
|
751 gtk_label_set_use_markup(GTK_LABEL(label_title), TRUE);
|
|
752
|
|
753 /* Album */
|
|
754 label_album = gtk_label_new("<b>Album:</b>");
|
|
755 gtk_widget_show(label_album);
|
|
756 gtk_table_attach(GTK_TABLE (table2), label_album, 0, 1, 2, 3,
|
|
757 (GtkAttachOptions) (GTK_FILL),
|
|
758 (GtkAttachOptions) (0), 0, 0);
|
|
759 gtk_misc_set_alignment(GTK_MISC(label_album), 0, 0.5);
|
|
760 gtk_label_set_use_markup(GTK_LABEL(label_album), TRUE);
|
|
761
|
|
762 /* Comments */
|
|
763 label_comments = gtk_label_new("<b>Comments:</b>");
|
|
764 gtk_widget_show(label_comments);
|
|
765 gtk_table_attach(GTK_TABLE(table2), label_comments, 0, 1, 3, 4,
|
|
766 (GtkAttachOptions) (GTK_FILL),
|
|
767 (GtkAttachOptions) (0), 0, 0);
|
|
768 gtk_misc_set_alignment(GTK_MISC(label_comments), 0, 0.5);
|
|
769 gtk_label_set_use_markup(GTK_LABEL(label_comments), TRUE);
|
|
770
|
|
771 /* Year */
|
|
772 label_year = gtk_label_new("<b>Year:</b>");
|
|
773 gtk_widget_show(label_year);
|
|
774 gtk_table_attach(GTK_TABLE (table2), label_year, 0, 1, 4, 5,
|
|
775 (GtkAttachOptions) (GTK_FILL),
|
|
776 (GtkAttachOptions) (0), 0, 0);
|
|
777 gtk_misc_set_alignment(GTK_MISC(label_year), 0, 0.5);
|
|
778 gtk_label_set_use_markup(GTK_LABEL(label_year), TRUE);
|
|
779
|
|
780 /* Track */
|
|
781 label_track = gtk_label_new("<b>Track:</b>");
|
|
782 gtk_widget_show(label_track);
|
|
783 gtk_table_attach(GTK_TABLE (table2), label_track, 0, 1, 5, 6,
|
|
784 (GtkAttachOptions) (GTK_FILL),
|
|
785 (GtkAttachOptions) (0), 0, 0);
|
|
786 gtk_misc_set_alignment(GTK_MISC(label_track), 0, 0.5);
|
|
787 gtk_label_set_use_markup(GTK_LABEL(label_track), TRUE);
|
|
788
|
|
789 /* Genre */
|
|
790 label_genre = gtk_label_new("<b>Genre:</b>");
|
|
791 gtk_widget_show(label_genre);
|
|
792 gtk_table_attach(GTK_TABLE (table2), label_genre, 0, 1, 6, 7,
|
|
793 (GtkAttachOptions) (GTK_FILL),
|
|
794 (GtkAttachOptions) (0), 0, 0);
|
|
795 gtk_misc_set_alignment(GTK_MISC (label_genre), 0, 0.5);
|
|
796 gtk_label_set_use_markup(GTK_LABEL(label_genre), TRUE);
|
|
797
|
|
798
|
|
799 entry_artist = gtk_entry_new();
|
|
800 gtk_widget_show (entry_artist);
|
|
801 gtk_table_attach (GTK_TABLE (table2), entry_artist, 1, 2, 0, 1,
|
|
802 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
803 (GtkAttachOptions) (0), 0, 0);
|
|
804 gtk_editable_set_editable (GTK_EDITABLE (entry_artist), FALSE);
|
|
805 gtk_entry_set_text(GTK_ENTRY(entry_artist), in->author);
|
|
806
|
|
807 entry_title = gtk_entry_new();
|
|
808 gtk_widget_show(entry_title);
|
|
809 gtk_table_attach (GTK_TABLE (table2), entry_title, 1, 2, 1, 2,
|
|
810 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
811 (GtkAttachOptions) (0), 0, 0);
|
|
812 gtk_editable_set_editable(GTK_EDITABLE (entry_title), FALSE);
|
|
813 gtk_entry_set_text(GTK_ENTRY(entry_title), in->title);
|
|
814
|
|
815 entry_album = gtk_entry_new();
|
|
816 gtk_widget_show(entry_album);
|
|
817 gtk_table_attach(GTK_TABLE (table2), entry_album, 1, 2, 2, 3,
|
|
818 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
819 (GtkAttachOptions) (0), 0, 0);
|
|
820 gtk_editable_set_editable(GTK_EDITABLE (entry_album), FALSE);
|
|
821 gtk_entry_set_text(GTK_ENTRY(entry_album), in->album);
|
|
822
|
|
823 entry_comments = gtk_entry_new();
|
|
824 gtk_widget_show(entry_comments);
|
|
825 gtk_table_attach(GTK_TABLE (table2), entry_comments, 1, 2, 3, 4,
|
|
826 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
827 (GtkAttachOptions) (0), 0, 0);
|
|
828 gtk_editable_set_editable(GTK_EDITABLE (entry_comments), FALSE);
|
|
829 gtk_entry_set_text(GTK_ENTRY(entry_comments), in->comment);
|
|
830
|
|
831 entry_year = gtk_entry_new();
|
|
832 gtk_widget_show(entry_year);
|
|
833 gtk_table_attach(GTK_TABLE (table2), entry_year, 1, 2, 4, 5,
|
|
834 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
835 (GtkAttachOptions) (0), 0, 0);
|
|
836 gtk_editable_set_editable(GTK_EDITABLE (entry_year), FALSE);
|
|
837 gtk_entry_set_text(GTK_ENTRY(entry_year), g_strdup_printf("%d", in->year));
|
|
838
|
|
839 entry_track = gtk_entry_new();
|
|
840 gtk_widget_show(entry_track);
|
|
841 gtk_table_attach(GTK_TABLE (table2), entry_track, 1, 2, 5, 6,
|
|
842 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
843 (GtkAttachOptions) (0), 0, 0);
|
|
844 gtk_editable_set_editable(GTK_EDITABLE (entry_track), FALSE);
|
|
845 gtk_entry_set_text(GTK_ENTRY(entry_track), g_strdup_printf("%d", in->track));
|
|
846
|
|
847 entry_genre = gtk_entry_new();
|
|
848 gtk_widget_show(entry_genre);
|
|
849 gtk_table_attach(GTK_TABLE (table2), entry_genre, 1, 2, 6, 7,
|
|
850 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
851 (GtkAttachOptions) (0), 0, 0);
|
|
852 gtk_editable_set_editable(GTK_EDITABLE (entry_genre), FALSE);
|
|
853 gtk_entry_set_text(GTK_ENTRY(entry_genre), in->genre);
|
|
854
|
|
855
|
|
856 label5 = gtk_label_new("Tags");
|
|
857 gtk_widget_show(label5);
|
|
858 gtk_frame_set_label_widget(GTK_FRAME(frame_tags), label5);
|
|
859
|
|
860
|
|
861 dialog_action_area1 = GTK_DIALOG(dialog)->action_area;
|
|
862 gtk_widget_show(dialog_action_area1);
|
|
863 gtk_button_box_set_layout(GTK_BUTTON_BOX(dialog_action_area1), GTK_BUTTONBOX_END);
|
|
864
|
|
865 okbutton = gtk_button_new_from_stock("gtk-ok");
|
|
866 gtk_widget_show(okbutton);
|
|
867 gtk_dialog_add_action_widget(GTK_DIALOG(dialog), okbutton, GTK_RESPONSE_OK);
|
|
868 GTK_WIDGET_SET_FLAGS(okbutton, GTK_CAN_DEFAULT);
|
|
869
|
|
870 gtk_signal_connect_object(GTK_OBJECT(okbutton), "clicked",
|
|
871 GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(dialog));
|
|
872
|
|
873 gtk_widget_show(dialog);
|
|
874
|
|
875 g_free(title);
|
|
876 g_free(channels);
|
|
877 g_free(bitrate);
|
|
878 g_free(playtime);
|
|
879 g_free(samplerate);
|
|
880 g_free(filesize);
|
|
881 }
|
|
882
|