Mercurial > audlegacy-plugins
comparison src/flac/fileinfo.c @ 96:63bde7ca7ad0 trunk
[svn] First attempt at porting our FLAC plugin to API 1.1.3 (completely incompatible, as usual!). Needs more work and a version-sensitize FLAC checker.
author | chainsaw |
---|---|
date | Sat, 21 Oct 2006 09:21:12 -0700 |
parents | 3da1b8942b8b |
children |
comparison
equal
deleted
inserted
replaced
95:b5a1b762f586 | 96:63bde7ca7ad0 |
---|---|
1 /* XMMS - Cross-platform multimedia player | 1 /* XMMS - Cross-platform multimedia player |
2 * Copyright (C) 1998-2000 Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies | 2 * Copyright (C) 1998-2000 Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies |
3 * Copyright (C) 1999,2000 Håvard Kvålen | 3 * Copyright (C) 1999,2000 Håvard Kvålen |
4 * Copyright (C) 2002,2003,2004,2005 Daisuke Shimamura | 4 * Copyright (C) 2002,2003,2004,2005,2006 Daisuke Shimamura |
5 * | 5 * |
6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License as published by | 7 * it under the terms of the GNU General Public License as published by |
8 * the Free Software Foundation; either version 2 of the License, or | 8 * the Free Software Foundation; either version 2 of the License, or |
9 * (at your option) any later version. | 9 * (at your option) any later version. |
28 | 28 |
29 #include "audacious/util.h" | 29 #include "audacious/util.h" |
30 #include "FLAC/metadata.h" | 30 #include "FLAC/metadata.h" |
31 #include "charset.h" | 31 #include "charset.h" |
32 #include "configure.h" | 32 #include "configure.h" |
33 #include "plugin_common/locale_hack.h" | |
34 #include "plugin_common/replaygain.h" | |
33 #include "plugin_common/tags.h" | 35 #include "plugin_common/tags.h" |
34 #include "plugin_common/locale_hack.h" | |
35 | 36 |
36 static GtkWidget *window = NULL; | 37 static GtkWidget *window = NULL; |
37 static GList *genre_list = NULL; | 38 static GList *genre_list = NULL; |
38 static GtkWidget *filename_entry, *tag_frame; | 39 static GtkWidget *filename_entry, *tag_frame; |
39 static GtkWidget *title_entry, *artist_entry, *album_entry, *date_entry, *tracknum_entry, *comment_entry; | 40 static GtkWidget *title_entry, *artist_entry, *album_entry, *date_entry, *tracknum_entry, *comment_entry; |
41 static GtkWidget *replaygain_reference, *replaygain_track_gain, *replaygain_album_gain, *replaygain_track_peak, *replaygain_album_peak; | |
40 static GtkWidget *genre_combo; | 42 static GtkWidget *genre_combo; |
41 static GtkWidget *flac_samplerate, *flac_channels, *flac_bits_per_sample, *flac_blocksize, *flac_filesize, *flac_samples, *flac_bitrate; | 43 static GtkWidget *flac_samplerate, *flac_channels, *flac_bits_per_sample, *flac_blocksize, *flac_filesize, *flac_samples, *flac_bitrate; |
42 | 44 |
43 static gchar *current_filename = NULL; | 45 static gchar *current_filename = NULL; |
44 static FLAC__StreamMetadata *tags_ = NULL; | 46 static FLAC__StreamMetadata *tags_ = NULL; |
224 streaminfo.data.stream_info.total_samples, | 226 streaminfo.data.stream_info.total_samples, |
225 (int)(streaminfo.data.stream_info.total_samples / streaminfo.data.stream_info.sample_rate / 60), | 227 (int)(streaminfo.data.stream_info.total_samples / streaminfo.data.stream_info.sample_rate / 60), |
226 (int)(streaminfo.data.stream_info.total_samples / streaminfo.data.stream_info.sample_rate % 60)); | 228 (int)(streaminfo.data.stream_info.total_samples / streaminfo.data.stream_info.sample_rate % 60)); |
227 | 229 |
228 if(!stat(current_filename, &_stat) && S_ISREG(_stat.st_mode)) { | 230 if(!stat(current_filename, &_stat) && S_ISREG(_stat.st_mode)) { |
231 #if _FILE_OFFSET_BITS == 64 | |
232 label_set_text(flac_filesize, _("Filesize: %lld B"), _stat.st_size); | |
233 #else | |
229 label_set_text(flac_filesize, _("Filesize: %ld B"), _stat.st_size); | 234 label_set_text(flac_filesize, _("Filesize: %ld B"), _stat.st_size); |
235 #endif | |
230 if (streaminfo.data.stream_info.total_samples) | 236 if (streaminfo.data.stream_info.total_samples) |
231 label_set_text(flac_bitrate, _("Avg. bitrate: %.1f kb/s\nCompression ratio: %.1f%%"), | 237 label_set_text(flac_bitrate, _("Avg. bitrate: %.1f kb/s\nCompression ratio: %.1f%%"), |
232 8.0 * (float)(_stat.st_size) / (1000.0 * (float)streaminfo.data.stream_info.total_samples / (float)streaminfo.data.stream_info.sample_rate), | 238 8.0 * (float)(_stat.st_size) / (1000.0 * (float)streaminfo.data.stream_info.total_samples / (float)streaminfo.data.stream_info.sample_rate), |
233 100.0 * (float)_stat.st_size / (float)(streaminfo.data.stream_info.bits_per_sample / 8 * streaminfo.data.stream_info.channels * streaminfo.data.stream_info.total_samples)); | 239 100.0 * (float)_stat.st_size / (float)(streaminfo.data.stream_info.bits_per_sample / 8 * streaminfo.data.stream_info.channels * streaminfo.data.stream_info.total_samples)); |
234 } | 240 } |
241 } | |
242 | |
243 static void show_replaygain() | |
244 { | |
245 /* known limitation: If only one of gain and peak is set, neither will be shown. This is true for | |
246 * both track and album replaygain tags. Written so it will be easy to fix, with some trouble. */ | |
247 | |
248 gtk_label_set_text(GTK_LABEL(replaygain_reference), ""); | |
249 gtk_label_set_text(GTK_LABEL(replaygain_track_gain), ""); | |
250 gtk_label_set_text(GTK_LABEL(replaygain_album_gain), ""); | |
251 gtk_label_set_text(GTK_LABEL(replaygain_track_peak), ""); | |
252 gtk_label_set_text(GTK_LABEL(replaygain_album_peak), ""); | |
253 | |
254 double reference, track_gain, track_peak, album_gain, album_peak; | |
255 FLAC__bool reference_set, track_gain_set, track_peak_set, album_gain_set, album_peak_set; | |
256 | |
257 FLAC_plugin__replaygain_get_from_file( | |
258 current_filename, | |
259 &reference, &reference_set, | |
260 &track_gain, &track_gain_set, | |
261 &album_gain, &album_gain_set, | |
262 &track_peak, &track_peak_set, | |
263 &album_peak, &album_peak_set | |
264 ); | |
265 | |
266 if(reference_set) | |
267 label_set_text(replaygain_reference, _("ReplayGain Reference Loudness: %2.1f dB"), reference); | |
268 if(track_gain_set) | |
269 label_set_text(replaygain_track_gain, _("ReplayGain Track Gain: %+2.2f dB"), track_gain); | |
270 if(album_gain_set) | |
271 label_set_text(replaygain_album_gain, _("ReplayGain Album Gain: %+2.2f dB"), album_gain); | |
272 if(track_peak_set) | |
273 label_set_text(replaygain_track_peak, _("ReplayGain Track Peak: %1.8f"), track_peak); | |
274 if(album_peak_set) | |
275 label_set_text(replaygain_album_peak, _("ReplayGain Album Peak: %1.8f"), album_peak); | |
235 } | 276 } |
236 | 277 |
237 void FLAC_XMMS__file_info_box(char *filename) | 278 void FLAC_XMMS__file_info_box(char *filename) |
238 { | 279 { |
239 unsigned i; | 280 unsigned i; |
401 flac_bitrate = gtk_label_new(""); | 442 flac_bitrate = gtk_label_new(""); |
402 gtk_misc_set_alignment(GTK_MISC(flac_bitrate), 0, 0); | 443 gtk_misc_set_alignment(GTK_MISC(flac_bitrate), 0, 0); |
403 gtk_label_set_justify(GTK_LABEL(flac_bitrate), GTK_JUSTIFY_LEFT); | 444 gtk_label_set_justify(GTK_LABEL(flac_bitrate), GTK_JUSTIFY_LEFT); |
404 gtk_box_pack_start(GTK_BOX(flac_box), flac_bitrate, FALSE, FALSE, 0); | 445 gtk_box_pack_start(GTK_BOX(flac_box), flac_bitrate, FALSE, FALSE, 0); |
405 | 446 |
447 replaygain_reference = gtk_label_new(""); | |
448 gtk_misc_set_alignment(GTK_MISC(replaygain_reference), 0, 0); | |
449 gtk_label_set_justify(GTK_LABEL(replaygain_reference), GTK_JUSTIFY_LEFT); | |
450 gtk_box_pack_start(GTK_BOX(flac_box), replaygain_reference, FALSE, FALSE, 0); | |
451 | |
452 replaygain_track_gain = gtk_label_new(""); | |
453 gtk_misc_set_alignment(GTK_MISC(replaygain_track_gain), 0, 0); | |
454 gtk_label_set_justify(GTK_LABEL(replaygain_track_gain), GTK_JUSTIFY_LEFT); | |
455 gtk_box_pack_start(GTK_BOX(flac_box), replaygain_track_gain, FALSE, FALSE, 0); | |
456 | |
457 replaygain_album_gain = gtk_label_new(""); | |
458 gtk_misc_set_alignment(GTK_MISC(replaygain_album_gain), 0, 0); | |
459 gtk_label_set_justify(GTK_LABEL(replaygain_album_gain), GTK_JUSTIFY_LEFT); | |
460 gtk_box_pack_start(GTK_BOX(flac_box), replaygain_album_gain, FALSE, FALSE, 0); | |
461 | |
462 replaygain_track_peak = gtk_label_new(""); | |
463 gtk_misc_set_alignment(GTK_MISC(replaygain_track_peak), 0, 0); | |
464 gtk_label_set_justify(GTK_LABEL(replaygain_track_peak), GTK_JUSTIFY_LEFT); | |
465 gtk_box_pack_start(GTK_BOX(flac_box), replaygain_track_peak, FALSE, FALSE, 0); | |
466 | |
467 replaygain_album_peak = gtk_label_new(""); | |
468 gtk_misc_set_alignment(GTK_MISC(replaygain_album_peak), 0, 0); | |
469 gtk_label_set_justify(GTK_LABEL(replaygain_album_peak), GTK_JUSTIFY_LEFT); | |
470 gtk_box_pack_start(GTK_BOX(flac_box), replaygain_album_peak, FALSE, FALSE, 0); | |
471 | |
406 gtk_widget_show_all(window); | 472 gtk_widget_show_all(window); |
407 } | 473 } |
408 | 474 |
409 if(current_filename) | 475 if(current_filename) |
410 g_free(current_filename); | 476 g_free(current_filename); |
426 | 492 |
427 FLAC_plugin__tags_get(current_filename, &tags_); | 493 FLAC_plugin__tags_get(current_filename, &tags_); |
428 | 494 |
429 show_tag(); | 495 show_tag(); |
430 show_file_info(); | 496 show_file_info(); |
497 show_replaygain(); | |
431 | 498 |
432 gtk_widget_set_sensitive(tag_frame, TRUE); | 499 gtk_widget_set_sensitive(tag_frame, TRUE); |
433 } | 500 } |