Mercurial > audlegacy-plugins
annotate src/madplug/plugin.c @ 916:a8494c2a87eb trunk
[svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
- 1. time count will be recorded and restored on reopen. this seems to be right way, but it causes a short stoppage of playback.
- 2. introduce a new plugin option "force_reopen_audio". if this is set to FALSE (default), decoder will not reopen output. this is a bit rude, but does not cause any interruption.
author | yaz |
---|---|
date | Thu, 05 Apr 2007 21:12:59 -0700 |
parents | 44a922a4a591 |
children | 7e14701aef54 |
rev | line source |
---|---|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
1 /* |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
2 * mad plugin for audacious |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
3 * Copyright (C) 2005-2007 William Pitcock, Yoshiki Yazawa |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
4 * |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
5 * Portions derived from xmms-mad: |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
6 * Copyright (C) 2001-2002 Sam Clegg - See COPYING |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
7 * |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
10 * the Free Software Foundation; under version 2 of the License. |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
11 * |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
15 * GNU General Public License for more details. |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
16 * |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
18 * along with this program; if not, write to the Free Software |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
20 */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
21 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
22 #include "config.h" |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
23 #include "plugin.h" |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
24 #include "input.h" |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
25 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
26 #include <math.h> |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
27 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
28 #include <gtk/gtk.h> |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
29 #include <audacious/util.h> |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
30 #include <audacious/configdb.h> |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
31 #include <stdarg.h> |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
32 #include <fcntl.h> |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
33 #include <audacious/vfs.h> |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
34 #include <sys/stat.h> |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
35 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
36 /* |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
37 * Global variables |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
38 */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
39 struct audmad_config_t audmad_config; /**< global configuration */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
40 InputPlugin *mad_plugin = NULL; |
611 | 41 GMutex *mad_mutex; |
42 GMutex *pb_mutex; | |
43 GCond *mad_cond; | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
44 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
45 /* |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
46 * static variables |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
47 */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
48 static GThread *decode_thread; /**< the single decoder thread */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
49 static struct mad_info_t info; /**< info for current track */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
50 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
51 #ifndef NOGUI |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
52 static GtkWidget *error_dialog = 0; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
53 #endif |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
54 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
55 extern gboolean scan_file(struct mad_info_t *info, gboolean fast); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
56 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
57 static gint mp3_bitrate_table[5][16] = { |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
58 { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, -1 }, /* MPEG1 L1 */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
59 { 0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, -1 }, /* MPEG1 L2 */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
60 { 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1 }, /* MPEG1 L3 */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
61 { 0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, -1 }, /* MPEG2(.5) L1 */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
62 { 0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, -1 } /* MPEG2(.5) L2,L3 */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
63 }; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
64 |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
65 static gint mp3_samplerate_table[4][4] = { |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
66 { 11025, 12000, 8000, -1 }, /* MPEG2.5 */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
67 { -1, -1, -1, -1 }, /* Reserved */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
68 { 22050, 24000, 16000, -1 }, /* MPEG2 */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
69 { 44100, 48000, 32000, -1 } /* MPEG1 */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
70 }; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
71 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
72 /* |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
73 * Function extname (filename) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
74 * |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
75 * Return pointer within filename to its extenstion, or NULL if |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
76 * filename has no extension. |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
77 * |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
78 */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
79 static gchar *extname(const char *filename) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
80 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
81 gchar *ext = strrchr(filename, '.'); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
82 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
83 if (ext != NULL) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
84 ++ext; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
85 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
86 return ext; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
87 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
88 |
611 | 89 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
90 void audmad_config_compute(struct audmad_config_t *config) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
91 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
92 /* set some config parameters by parsing text fields |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
93 (RG default gain, etc..) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
94 */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
95 const gchar *text; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
96 gdouble x; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
97 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
98 text = config->pregain_db; |
653
638b290641f3
[svn] - madplug: check that text is not null before using g_strtod
giacomo
parents:
651
diff
changeset
|
99 if ( text != NULL ) |
638b290641f3
[svn] - madplug: check that text is not null before using g_strtod
giacomo
parents:
651
diff
changeset
|
100 x = g_strtod(text, NULL); |
638b290641f3
[svn] - madplug: check that text is not null before using g_strtod
giacomo
parents:
651
diff
changeset
|
101 else |
638b290641f3
[svn] - madplug: check that text is not null before using g_strtod
giacomo
parents:
651
diff
changeset
|
102 x = 0; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
103 config->pregain_scale = (x != 0) ? pow(10.0, x / 20) : 1; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
104 #ifdef DEBUG |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
105 g_message("pregain=[%s] -> %g -> %g", text, x, config->pregain_scale); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
106 #endif |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
107 text = config->replaygain.default_db; |
653
638b290641f3
[svn] - madplug: check that text is not null before using g_strtod
giacomo
parents:
651
diff
changeset
|
108 if ( text != NULL ) |
638b290641f3
[svn] - madplug: check that text is not null before using g_strtod
giacomo
parents:
651
diff
changeset
|
109 x = g_strtod(text, NULL); |
638b290641f3
[svn] - madplug: check that text is not null before using g_strtod
giacomo
parents:
651
diff
changeset
|
110 else |
638b290641f3
[svn] - madplug: check that text is not null before using g_strtod
giacomo
parents:
651
diff
changeset
|
111 x = 0; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
112 config->replaygain.default_scale = (x != 0) ? pow(10.0, x / 20) : 1; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
113 #ifdef DEBUG |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
114 g_message("RG.default=[%s] -> %g -> %g", text, x, |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
115 config->replaygain.default_scale); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
116 #endif |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
117 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
118 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
119 static void audmad_init() |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
120 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
121 ConfigDb *db = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
122 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
123 audmad_config.fast_play_time_calc = TRUE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
124 audmad_config.use_xing = TRUE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
125 audmad_config.dither = TRUE; |
611 | 126 audmad_config.sjis = FALSE; |
651
b9167008fc3f
[svn] - strings in audmad_config should be freed before update. thus constant initializer has been replaced with g_strdup().
yaz
parents:
650
diff
changeset
|
127 audmad_config.hard_limit = FALSE; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
128 audmad_config.replaygain.enable = TRUE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
129 audmad_config.replaygain.track_mode = FALSE; |
651
b9167008fc3f
[svn] - strings in audmad_config should be freed before update. thus constant initializer has been replaced with g_strdup().
yaz
parents:
650
diff
changeset
|
130 audmad_config.title_override = FALSE; |
676
1733b12ef974
[svn] - show dynamic bitrate for vbr is off by default. now it is configurable from preferences.
yaz
parents:
674
diff
changeset
|
131 audmad_config.show_avg_vbr_bitrate = TRUE; |
916
a8494c2a87eb
[svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents:
897
diff
changeset
|
132 audmad_config.force_reopen_audio = FALSE; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
133 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
134 db = bmp_cfg_db_open(); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
135 if (db) { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
136 bmp_cfg_db_get_bool(db, "MAD", "fast_play_time_calc", |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
137 &audmad_config.fast_play_time_calc); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
138 bmp_cfg_db_get_bool(db, "MAD", "use_xing", |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
139 &audmad_config.use_xing); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
140 bmp_cfg_db_get_bool(db, "MAD", "dither", &audmad_config.dither); |
611 | 141 bmp_cfg_db_get_bool(db, "MAD", "sjis", &audmad_config.sjis); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
142 bmp_cfg_db_get_bool(db, "MAD", "hard_limit", |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
143 &audmad_config.hard_limit); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
144 bmp_cfg_db_get_string(db, "MAD", "pregain_db", |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
145 &audmad_config.pregain_db); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
146 bmp_cfg_db_get_bool(db, "MAD", "RG.enable", |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
147 &audmad_config.replaygain.enable); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
148 bmp_cfg_db_get_bool(db, "MAD", "RG.track_mode", |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
149 &audmad_config.replaygain.track_mode); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
150 bmp_cfg_db_get_string(db, "MAD", "RG.default_db", |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
151 &audmad_config.replaygain.default_db); |
618
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
152 bmp_cfg_db_get_bool(db, "MAD", "title_override", |
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
153 &audmad_config.title_override); |
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
154 bmp_cfg_db_get_string(db, "MAD", "id3_format", |
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
155 &audmad_config.id3_format); |
676
1733b12ef974
[svn] - show dynamic bitrate for vbr is off by default. now it is configurable from preferences.
yaz
parents:
674
diff
changeset
|
156 bmp_cfg_db_get_bool(db, "MAD", "show_avg_vbr_bitrate", |
1733b12ef974
[svn] - show dynamic bitrate for vbr is off by default. now it is configurable from preferences.
yaz
parents:
674
diff
changeset
|
157 &audmad_config.show_avg_vbr_bitrate); |
916
a8494c2a87eb
[svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents:
897
diff
changeset
|
158 bmp_cfg_db_get_bool(db, "MAD", "force_reopen_audio", |
a8494c2a87eb
[svn] revise reopen output code for #880. time count would be reset if output was closed. so I took two measures for it.
yaz
parents:
897
diff
changeset
|
159 &audmad_config.force_reopen_audio); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
160 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
161 bmp_cfg_db_close(db); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
162 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
163 |
611 | 164 mad_mutex = g_mutex_new(); |
165 pb_mutex = g_mutex_new(); | |
166 mad_cond = g_cond_new(); | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
167 audmad_config_compute(&audmad_config); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
168 |
651
b9167008fc3f
[svn] - strings in audmad_config should be freed before update. thus constant initializer has been replaced with g_strdup().
yaz
parents:
650
diff
changeset
|
169 if (!audmad_config.pregain_db) |
b9167008fc3f
[svn] - strings in audmad_config should be freed before update. thus constant initializer has been replaced with g_strdup().
yaz
parents:
650
diff
changeset
|
170 audmad_config.pregain_db = g_strdup("+0.00"); |
b9167008fc3f
[svn] - strings in audmad_config should be freed before update. thus constant initializer has been replaced with g_strdup().
yaz
parents:
650
diff
changeset
|
171 |
b9167008fc3f
[svn] - strings in audmad_config should be freed before update. thus constant initializer has been replaced with g_strdup().
yaz
parents:
650
diff
changeset
|
172 if (!audmad_config.replaygain.default_db) |
b9167008fc3f
[svn] - strings in audmad_config should be freed before update. thus constant initializer has been replaced with g_strdup().
yaz
parents:
650
diff
changeset
|
173 audmad_config.replaygain.default_db = g_strdup("-9.00"); |
b9167008fc3f
[svn] - strings in audmad_config should be freed before update. thus constant initializer has been replaced with g_strdup().
yaz
parents:
650
diff
changeset
|
174 |
b9167008fc3f
[svn] - strings in audmad_config should be freed before update. thus constant initializer has been replaced with g_strdup().
yaz
parents:
650
diff
changeset
|
175 if (!audmad_config.id3_format) |
650
8b9ef7a32e47
[svn] - make sure audmad_config.id3_format is not NULL. closes #795.
nenolod
parents:
646
diff
changeset
|
176 audmad_config.id3_format = g_strdup(""); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
177 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
178 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
179 static void audmad_cleanup() |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
180 { |
802 | 181 g_free(audmad_config.pregain_db); |
182 g_free(audmad_config.replaygain.default_db); | |
183 g_free(audmad_config.id3_format); | |
184 | |
185 g_cond_free(mad_cond); | |
186 g_mutex_free(mad_mutex); | |
187 g_mutex_free(pb_mutex); | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
188 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
189 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
190 static gboolean mp3_head_check(guint32 head, gint *frameSize) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
191 { |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
192 gint version, layer, bitIndex, bitRate, sampleIndex, sampleRate, padding; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
193 |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
194 /* http://www.mp3-tech.org/programmer/frame_header.html |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
195 * Bits 21-31 must be set (frame sync) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
196 */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
197 if ((head & 0xffe00000) != 0xffe00000) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
198 return FALSE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
199 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
200 /* check if layer bits (17-18) are good */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
201 layer = (head >> 17) & 0x3; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
202 if (!layer) |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
203 return FALSE; /* 00 = reserved */ |
897 | 204 layer = 4 - layer; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
205 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
206 /* check if bitrate index bits (12-15) are acceptable */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
207 bitIndex = (head >> 12) & 0xf; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
208 |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
209 /* 1111 and 0000 are reserved values for all layers */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
210 if (bitIndex == 0xf || bitIndex == 0) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
211 return FALSE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
212 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
213 /* check samplerate index bits (10-11) */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
214 sampleIndex = (head >> 10) & 0x3; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
215 if (sampleIndex == 0x3) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
216 return FALSE; |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
217 |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
218 /* check version bits (19-20) and get bitRate */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
219 version = (head >> 19) & 0x03; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
220 switch (version) { |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
221 case 0: /* 00 = MPEG Version 2.5 */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
222 case 2: /* 10 = MPEG Version 2 */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
223 if (layer == 1) |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
224 bitRate = mp3_bitrate_table[3][bitIndex]; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
225 else |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
226 bitRate = mp3_bitrate_table[4][bitIndex]; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
227 break; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
228 |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
229 case 1: /* 01 = reserved */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
230 return FALSE; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
231 |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
232 case 3: /* 11 = MPEG Version 1 */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
233 bitRate = mp3_bitrate_table[layer][bitIndex]; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
234 break; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
235 |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
236 default: |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
237 return FALSE; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
238 } |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
239 |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
240 /* check layer II restrictions vs. bitrate */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
241 if (layer == 2) { |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
242 gint chanMode = (head >> 6) & 0x3; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
243 |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
244 if (chanMode == 0x3) { |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
245 /* single channel with bitrate > 192 */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
246 if (bitRate > 192) |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
247 return FALSE; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
248 } else { |
897 | 249 /* any other mode with bitrates 32-56 and 80. |
250 * NOTICE! this check is not entirely correct, but I think | |
251 * it is sufficient in most cases. | |
252 */ | |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
253 if (((bitRate >= 32 && bitRate <= 56) || bitRate == 80)) |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
254 return FALSE; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
255 } |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
256 } |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
257 |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
258 /* calculate approx. frame size */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
259 padding = (head >> 9) & 1; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
260 sampleRate = mp3_samplerate_table[version][sampleIndex]; |
897 | 261 if (layer == 1) |
262 *frameSize = ((12 * bitRate * 1000 / sampleRate) + padding) * 4; | |
263 else | |
264 *frameSize = (144 * bitRate * 1000) / (sampleRate + padding); | |
265 | |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
266 /* check if bits 16 - 19 are all set (MPEG 1 Layer I, not protected?) */ |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
267 if (((head >> 19) & 1) == 1 && |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
268 ((head >> 17) & 3) == 3 && ((head >> 16) & 1) == 1) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
269 return FALSE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
270 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
271 /* not sure why we check this, but ok! */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
272 if ((head & 0xffff0000) == 0xfffe0000) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
273 return FALSE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
274 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
275 return TRUE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
276 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
277 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
278 static int mp3_head_convert(const guchar * hbuf) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
279 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
280 return ((unsigned long) hbuf[0] << 24) | |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
281 ((unsigned long) hbuf[1] << 16) | |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
282 ((unsigned long) hbuf[2] << 8) | (unsigned long) hbuf[3]; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
283 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
284 |
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
285 gboolean audmad_is_remote(gchar *url) |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
286 { |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
287 if (!strncasecmp("http://", url, 7) || !strncasecmp("https://", url, 8)) |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
288 return TRUE; |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
289 else |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
290 return FALSE; |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
291 } |
612 | 292 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
293 // audacious vfs fast version |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
294 static int audmad_is_our_fd(char *filename, VFSFile *fin) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
295 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
296 guint32 check; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
297 gchar *ext = extname(filename); |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
298 gint cyc = 0, chkcount = 0, chksize = 4096; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
299 guchar buf[4]; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
300 guchar tmp[4096]; |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
301 gint ret, i, frameSize; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
302 |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
303 info.remote = FALSE; |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
304 |
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
305 if(audmad_is_remote(filename)) |
612 | 306 info.remote = TRUE; |
307 | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
308 /* I've seen some flac files beginning with id3 frames.. |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
309 so let's exclude known non-mp3 filename extensions */ |
671
e6a1ba5185ba
[svn] - Tweak to check we found a file extension before using it to prevent segfault
nazca
parents:
653
diff
changeset
|
310 if ((ext != NULL) && |
e6a1ba5185ba
[svn] - Tweak to check we found a file extension before using it to prevent segfault
nazca
parents:
653
diff
changeset
|
311 (!strcasecmp("flac", ext) || !strcasecmp("mpc", ext) || |
e6a1ba5185ba
[svn] - Tweak to check we found a file extension before using it to prevent segfault
nazca
parents:
653
diff
changeset
|
312 !strcasecmp("tta", ext) || !strcasecmp("ogg", ext) || |
e6a1ba5185ba
[svn] - Tweak to check we found a file extension before using it to prevent segfault
nazca
parents:
653
diff
changeset
|
313 !strcasecmp("wma", ext) ) |
789 | 314 ) |
315 return 0; | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
316 |
789 | 317 if (fin == NULL) { |
318 g_message("fin = NULL"); | |
319 return 0; | |
320 } | |
788 | 321 |
789 | 322 if(vfs_fread(buf, 1, 4, fin) == 0) { |
799 | 323 gchar *tmp = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); |
324 g_message("vfs_fread failed @1 %s", tmp); | |
325 g_free(tmp); | |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
326 return 0; |
789 | 327 } |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
328 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
329 check = mp3_head_convert(buf); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
330 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
331 if (memcmp(buf, "ID3", 3) == 0) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
332 return 1; |
782 | 333 else if (memcmp(buf, "OggS", 4) == 0) |
334 return 0; | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
335 else if (memcmp(buf, "RIFF", 4) == 0) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
336 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
337 vfs_fseek(fin, 4, SEEK_CUR); |
789 | 338 if(vfs_fread(buf, 1, 4, fin) == 0) { |
799 | 339 gchar *tmp = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); |
340 g_message("vfs_fread failed @2 %s", tmp); | |
341 g_free(tmp); | |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
342 return 0; |
789 | 343 } |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
344 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
345 if (memcmp(buf, "RMP3", 4) == 0) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
346 return 1; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
347 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
348 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
349 // check data for frame header |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
350 while (!mp3_head_check(check, &frameSize)) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
351 { |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
352 if((ret = vfs_fread(tmp, 1, chksize, fin)) == 0){ |
799 | 353 gchar *tmp = g_filename_to_utf8(filename, -1, NULL, NULL, NULL); |
354 g_message("vfs_fread failed @3 %s", tmp); | |
355 g_free(tmp); | |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
356 return 0; |
789 | 357 } |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
358 for (i = 0; i < ret; i++) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
359 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
360 check <<= 8; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
361 check |= tmp[i]; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
362 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
363 if (mp3_head_check(check, &frameSize)) { |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
364 /* when the first matching frame header is found, we check for |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
365 * another frame by seeking to the approximate start of the |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
366 * next header ... also reduce the check size. |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
367 */ |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
368 if (++chkcount >= 3) return 1; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
369 vfs_fseek(fin, frameSize-4, SEEK_CUR); |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
370 check = 0; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
371 chksize = 8; |
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
372 } |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
373 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
374 |
801
dd06b14a43a9
[svn] - implement stricter detection rules for MP3. patch by Matti Hamalainen (ccr).
nenolod
parents:
799
diff
changeset
|
375 if (++cyc > 32) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
376 return 0; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
377 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
378 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
379 return 1; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
380 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
381 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
382 // audacious vfs version |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
383 static int audmad_is_our_file(char *filename) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
384 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
385 VFSFile *fin = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
386 gint rtn; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
387 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
388 fin = vfs_fopen(filename, "rb"); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
389 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
390 if (fin == NULL) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
391 return 0; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
392 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
393 rtn = audmad_is_our_fd(filename, fin); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
394 vfs_fclose(fin); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
395 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
396 return rtn; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
397 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
398 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
399 static void audmad_stop(InputPlayback *playback) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
400 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
401 #ifdef DEBUG |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
402 g_message("f: audmad_stop"); |
612 | 403 #endif |
611 | 404 g_mutex_lock(mad_mutex); |
405 info.playback = playback; | |
406 g_mutex_unlock(mad_mutex); | |
407 | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
408 if (decode_thread) { |
611 | 409 |
410 g_mutex_lock(mad_mutex); | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
411 info.playback->playing = 0; |
611 | 412 g_mutex_unlock(mad_mutex); |
413 g_cond_signal(mad_cond); | |
414 | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
415 #ifdef DEBUG |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
416 g_message("waiting for thread"); |
612 | 417 #endif |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
418 g_thread_join(decode_thread); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
419 #ifdef DEBUG |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
420 g_message("thread done"); |
612 | 421 #endif |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
422 input_term(&info); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
423 decode_thread = NULL; |
611 | 424 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
425 } |
611 | 426 #ifdef DEBUG |
427 g_message("e: audmad_stop"); | |
612 | 428 #endif |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
429 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
430 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
431 static void audmad_play_file(InputPlayback *playback) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
432 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
433 gboolean rtn; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
434 gchar *url = playback->filename; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
435 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
436 #ifdef DEBUG |
799 | 437 { |
438 gchar *tmp = g_filename_to_utf8(url, -1, NULL, NULL, NULL); | |
439 g_message("playing %s", tmp); | |
440 g_free(tmp); | |
441 } | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
442 #endif /* DEBUG */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
443 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
444 if (input_init(&info, url) == FALSE) { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
445 g_message("error initialising input"); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
446 return; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
447 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
448 |
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
449 // remote access must use fast scan. |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
450 rtn = input_get_info(&info, audmad_is_remote(url) ? TRUE : audmad_config.fast_play_time_calc); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
451 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
452 if (rtn == FALSE) { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
453 g_message("error reading input info"); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
454 return; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
455 } |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
456 g_mutex_lock(pb_mutex); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
457 info.playback = playback; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
458 info.playback->playing = 1; |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
459 g_mutex_unlock(pb_mutex); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
460 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
461 decode_thread = g_thread_create(decode_loop, (void *) &info, TRUE, NULL); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
462 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
463 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
464 static void audmad_pause(InputPlayback *playback, short paused) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
465 { |
611 | 466 g_mutex_lock(pb_mutex); |
467 info.playback = playback; | |
468 g_mutex_unlock(pb_mutex); | |
469 playback->output->pause(paused); | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
470 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
471 |
807 | 472 static void audmad_mseek(InputPlayback *playback, gulong millisecond) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
473 { |
611 | 474 g_mutex_lock(pb_mutex); |
475 info.playback = playback; | |
807 | 476 info.seek = millisecond; |
611 | 477 g_mutex_unlock(pb_mutex); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
478 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
479 |
807 | 480 static void audmad_seek(InputPlayback *playback, gint time) |
481 { | |
482 audmad_mseek(playback, time * 1000); | |
483 } | |
484 | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
485 /** |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
486 * Scan the given file or URL. |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
487 * Fills in the title string and the track length in milliseconds. |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
488 */ |
611 | 489 static void |
490 audmad_get_song_info(char *url, char **title, int *length) | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
491 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
492 struct mad_info_t myinfo; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
493 #ifdef DEBUG |
799 | 494 gchar *tmp = g_filename_to_utf8(url, -1, NULL, NULL, NULL); |
495 g_message("f: audmad_get_song_info: %s", tmp); | |
496 g_free(tmp); | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
497 #endif /* DEBUG */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
498 |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
499 if (input_init(&myinfo, url) == FALSE) { |
773 | 500 #ifdef DEBUG |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
501 g_message("error initialising input"); |
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
502 #endif |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
503 return; |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
504 } |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
505 |
611 | 506 if (input_get_info(&myinfo, info.remote ? TRUE : audmad_config.fast_play_time_calc) == TRUE) { |
507 if(myinfo.tuple->track_name) | |
508 *title = strdup(myinfo.tuple->track_name); | |
509 else | |
510 *title = strdup(url); | |
738 | 511 if(myinfo.tuple->length == -1) |
512 *length = mad_timer_count(myinfo.duration, MAD_UNITS_MILLISECONDS); | |
513 else | |
514 *length = myinfo.tuple->length; | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
515 } |
611 | 516 else { |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
517 *title = strdup(url); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
518 *length = -1; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
519 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
520 input_term(&myinfo); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
521 #ifdef DEBUG |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
522 g_message("e: audmad_get_song_info"); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
523 #endif /* DEBUG */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
524 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
525 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
526 static void audmad_about() |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
527 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
528 static GtkWidget *aboutbox; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
529 gchar *scratch; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
530 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
531 if (aboutbox != NULL) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
532 return; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
533 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
534 scratch = g_strdup_printf( |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
535 "Audacious MPEG Audio Plugin\n" |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
536 "\n" |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
537 "Compiled against libMAD version: %d.%d.%d%s\n" |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
538 "\n" |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
539 "Written by:\n" |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
540 " William Pitcock <nenolod@sacredspiral.co.uk>\n" |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
541 " Yoshiki Yazawa <yaz@cc.rim.or.jp>\n" |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
542 "\n" |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
543 "Portions derived from XMMS-MAD by:\n" |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
544 " Sam Clegg\n" |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
545 "\n" |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
546 "ReplayGain support by:\n" |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
547 " Samuel Krempp", |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
548 MAD_VERSION_MAJOR, MAD_VERSION_MINOR, MAD_VERSION_PATCH, |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
549 MAD_VERSION_EXTRA); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
550 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
551 aboutbox = xmms_show_message("About MPEG Audio Plugin", |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
552 scratch, |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
553 "Ok", FALSE, NULL, NULL); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
554 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
555 g_free(scratch); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
556 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
557 g_signal_connect(G_OBJECT(aboutbox), "destroy", |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
558 G_CALLBACK(gtk_widget_destroyed), &aboutbox); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
559 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
560 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
561 /** |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
562 * Display a GTK box containing the given error message. |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
563 * Taken from mpg123 plugin. |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
564 */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
565 void audmad_error(char *error, ...) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
566 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
567 #ifndef NOGUI |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
568 if (!error_dialog) { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
569 va_list args; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
570 char string[256]; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
571 va_start(args, error); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
572 vsnprintf(string, 256, error, args); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
573 va_end(args); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
574 GDK_THREADS_ENTER(); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
575 error_dialog = |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
576 xmms_show_message("Error", string, "Ok", FALSE, 0, 0); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
577 gtk_signal_connect(GTK_OBJECT(error_dialog), "destroy", |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
578 GTK_SIGNAL_FUNC(gtk_widget_destroyed), |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
579 &error_dialog); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
580 GDK_THREADS_LEAVE(); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
581 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
582 #endif /* !NOGUI */ |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
583 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
584 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
585 extern void audmad_get_file_info(char *filename); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
586 extern void audmad_configure(); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
587 |
611 | 588 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
589 // tuple stuff |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
590 static TitleInput *audmad_get_song_tuple(char *filename) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
591 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
592 TitleInput *tuple = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
593 gchar *string = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
594 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
595 struct id3_file *id3file = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
596 struct id3_tag *tag = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
597 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
598 #ifdef DEBUG |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
599 string = str_to_utf8(filename); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
600 g_message("f: mad: audmad_get_song_tuple: %s", string); |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
601 g_free(string); |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
602 string = NULL; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
603 #endif |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
604 |
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
605 if(info.remote && mad_timer_count(info.duration, MAD_UNITS_SECONDS) <= 0){ |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
606 if(info.playback && info.playback->playing) { |
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
607 gchar *tmp = NULL; |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
608 tuple = bmp_title_input_new(); |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
609 #ifdef DEBUG |
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
610 g_message("info.playback->playing = %d",info.playback->playing); |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
611 #endif |
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
612 tmp = vfs_get_metadata(info.infile, "track-name"); |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
613 if(tmp){ |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
614 tuple->track_name = str_to_utf8(tmp); |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
615 g_free(tmp); |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
616 tmp = NULL; |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
617 } |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
618 tmp = vfs_get_metadata(info.infile, "stream-name"); |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
619 if(tmp){ |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
620 tuple->album_name = str_to_utf8(tmp); |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
621 g_free(tmp); |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
622 tmp = NULL; |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
623 } |
611 | 624 #ifdef DEBUG |
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
625 g_message("audmad_get_song_tuple: track_name = %s", tuple->track_name); |
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
626 g_message("audmad_get_song_tuple: stream_name = %s", tuple->album_name); |
611 | 627 #endif |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
628 tuple->file_name = g_path_get_basename(filename); |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
629 tuple->file_path = g_path_get_dirname(filename); |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
630 tuple->file_ext = extname(filename); |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
631 tuple->length = -1; |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
632 tuple->mtime = 0; // this indicates streaming |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
633 #ifdef DEBUG |
773 | 634 g_message("get_song_tuple: remote: tuple"); |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
635 #endif |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
636 return tuple; |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
637 } |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
638 #ifdef DEBUG |
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
639 g_message("get_song_tuple: remote: NULL"); |
613
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
640 #endif |
85a70ace8c02
[svn] - press F5 on not yet played stream no longer hangs.
yaz
parents:
612
diff
changeset
|
641 return NULL; |
611 | 642 } |
643 | |
773 | 644 tuple = bmp_title_input_new(); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
645 |
773 | 646 id3file = id3_file_open(filename, ID3_FILE_MODE_READONLY); |
647 if (id3file) { | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
648 |
773 | 649 tag = id3_file_tag(id3file); |
650 if (tag) { | |
651 tuple->performer = | |
652 input_id3_get_string(tag, ID3_FRAME_ARTIST); | |
653 tuple->album_name = | |
654 input_id3_get_string(tag, ID3_FRAME_ALBUM); | |
655 tuple->track_name = | |
656 input_id3_get_string(tag, ID3_FRAME_TITLE); | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
657 |
773 | 658 // year |
659 string = NULL; | |
660 string = input_id3_get_string(tag, ID3_FRAME_YEAR); //TDRC | |
661 if (!string) | |
662 string = input_id3_get_string(tag, "TYER"); | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
663 |
773 | 664 if (string) { |
665 tuple->year = atoi(string); | |
666 g_free(string); | |
667 string = NULL; | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
668 } |
773 | 669 |
611 | 670 tuple->file_name = g_path_get_basename(filename); |
671 tuple->file_path = g_path_get_dirname(filename); | |
672 tuple->file_ext = extname(filename); | |
773 | 673 |
611 | 674 // length |
773 | 675 tuple->length = -1; |
676 string = input_id3_get_string(tag, "TLEN"); | |
677 if (string) { | |
678 tuple->length = atoi(string); | |
679 #ifdef DEBUG | |
680 g_message("get_song_tuple: TLEN = %d", tuple->length); | |
681 #endif | |
682 g_free(string); | |
683 string = NULL; | |
684 } | |
685 else { | |
611 | 686 char *dummy = NULL; |
687 int length = 0; | |
773 | 688 audmad_get_song_info(filename, &dummy, &length); |
689 tuple->length = length; | |
611 | 690 g_free(dummy); |
691 } | |
773 | 692 |
693 // track number | |
694 string = input_id3_get_string(tag, ID3_FRAME_TRACK); | |
695 if (string) { | |
696 tuple->track_number = atoi(string); | |
697 g_free(string); | |
698 string = NULL; | |
699 } | |
700 // genre | |
701 tuple->genre = input_id3_get_string(tag, ID3_FRAME_GENRE); | |
702 #ifdef DEBUG | |
703 g_message("genre = %s", tuple->genre); | |
704 #endif | |
705 // comment | |
706 tuple->comment = | |
707 input_id3_get_string(tag, ID3_FRAME_COMMENT); | |
708 | |
611 | 709 } |
773 | 710 id3_file_close(id3file); |
711 } | |
712 else { // no id3tag | |
713 tuple->file_name = g_path_get_basename(filename); | |
714 tuple->file_path = g_path_get_dirname(filename); | |
715 tuple->file_ext = extname(filename); | |
716 // length | |
717 { | |
718 char *dummy = NULL; | |
719 int length = 0; | |
720 if(tuple->length == -1) { | |
721 audmad_get_song_info(filename, &dummy, &length); | |
722 tuple->length = length; | |
723 } | |
724 g_free(dummy); | |
725 } | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
726 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
727 #ifdef DEBUG |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
728 g_message("e: mad: audmad_get_song_tuple"); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
729 #endif |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
730 return tuple; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
731 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
732 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
733 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
734 static gchar *fmts[] = { "mp3", "mp2", "mpg", NULL }; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
735 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
736 InputPlugin *get_iplugin_info(void) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
737 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
738 if (mad_plugin != NULL) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
739 return mad_plugin; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
740 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
741 mad_plugin = g_new0(InputPlugin, 1); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
742 mad_plugin->description = g_strdup(_("MPEG Audio Plugin")); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
743 mad_plugin->init = audmad_init; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
744 mad_plugin->about = audmad_about; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
745 mad_plugin->configure = audmad_configure; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
746 mad_plugin->is_our_file = audmad_is_our_file; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
747 mad_plugin->play_file = audmad_play_file; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
748 mad_plugin->stop = audmad_stop; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
749 mad_plugin->pause = audmad_pause; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
750 mad_plugin->seek = audmad_seek; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
751 mad_plugin->cleanup = audmad_cleanup; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
752 mad_plugin->get_song_info = audmad_get_song_info; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
753 mad_plugin->file_info_box = audmad_get_file_info; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
754 mad_plugin->get_song_tuple = audmad_get_song_tuple; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
755 mad_plugin->is_our_file_from_vfs = audmad_is_our_fd; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
756 mad_plugin->vfs_extensions = fmts; |
807 | 757 mad_plugin->mseek = audmad_mseek; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
758 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
759 return mad_plugin; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
760 } |