annotate src/vorbis/vorbis.c @ 2133:bba61e3fe881

vf.seekable hack is no longer needed. Pointed out by Brain.
author William Pitcock <nenolod@atheme.org>
date Sat, 27 Oct 2007 07:55:08 -0500
parents 3aa95f65c24d
children fd0d5615f674
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
1 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
2 * Copyright (C) Tony Arcieri <bascule@inferno.tusculum.edu>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
3 * Copyright (C) 2001-2002 Haavard Kvaalen <havardk@xmms.org>
545
f9dc3d58207a [svn] - display the stream title if it's available, like in mp3 streams
nenolod
parents: 544
diff changeset
4 * Copyright (C) 2007 William Pitcock <nenolod@sacredspiral.co.uk>
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
5 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
6 * ReplayGain processing Copyright (C) 2002 Gian-Carlo Pascutto <gcp@sjeng.org>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
7 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
10 * as published by the Free Software Foundation; either version 2
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
11 * of the License, or (at your option) any later version.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
12 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
16 * GNU General Public License for more details.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
17 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
21 * 02110-1301, USA.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
22 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
23 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
24
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
25 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
26 * 2002-01-11 ReplayGain processing added by Gian-Carlo Pascutto <gcp@sjeng.org>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
27 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
28
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
29 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
30 * Note that this uses vorbisfile, which is not (currently)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
31 * thread-safe.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
32 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
33
1777
4a200593472d vorbis: Mk2
William Pitcock <nenolod@atheme.org>
parents: 1697
diff changeset
34 #include "config.h"
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
35
537
e55f789573e3 [svn] - treat all failures the same. this is XIPH. we're not going to ever be
nenolod
parents: 536
diff changeset
36 #define DEBUG
e55f789573e3 [svn] - treat all failures the same. this is XIPH. we're not going to ever be
nenolod
parents: 536
diff changeset
37
615
1fb44c12a812 [svn] - avoid NULL dereference. closes mandriva #28603.
nenolod
parents: 608
diff changeset
38 #define REMOVE_NONEXISTANT_TAG(x) if (x != NULL && !*x) { x = NULL; }
608
621e6ec66973 [svn] Obliterate empty tags, just like in mpg123.
chainsaw
parents: 564
diff changeset
39
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
40 #include <glib.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
41 #include <gtk/gtk.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
42
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
43 #include <stdlib.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
44 #include <math.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
45 #include <string.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
46
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
47 #include <fcntl.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
48
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
49 #include <ogg/ogg.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
50 #include <vorbis/codec.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
51 #include <vorbis/vorbisfile.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
52
1950
2ebeb7816c5e Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents: 1777
diff changeset
53 #include <audacious/plugin.h>
2ebeb7816c5e Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents: 1777
diff changeset
54 #include <audacious/output.h>
2ebeb7816c5e Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents: 1777
diff changeset
55 #include <audacious/util.h>
2ebeb7816c5e Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents: 1777
diff changeset
56 #include <audacious/configdb.h>
2ebeb7816c5e Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents: 1777
diff changeset
57 #include <audacious/main.h>
527
d124034ebea3 [svn] - glib/gi18n.h -> audacious/i18n.h for automatic dgettext support
nenolod
parents: 484
diff changeset
58 #include <audacious/i18n.h>
772
18dd1dd2d232 [svn] - include strings.h
yaz
parents: 767
diff changeset
59 #include <audacious/strings.h>
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
60
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
61 #include "vorbis.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
62
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
63 extern vorbis_config_t vorbis_cfg;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
64
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
65 static Tuple *get_song_tuple(gchar *filename);
475
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
66 static int vorbis_check_fd(char *filename, VFSFile *stream);
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 558
diff changeset
67 static void vorbis_play(InputPlayback *data);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 558
diff changeset
68 static void vorbis_stop(InputPlayback *data);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 558
diff changeset
69 static void vorbis_pause(InputPlayback *data, short p);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 558
diff changeset
70 static void vorbis_seek(InputPlayback *data, int time);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
71 static void vorbis_get_song_info(char *filename, char **title, int *length);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
72 static gchar *vorbis_generate_title(OggVorbis_File * vorbisfile, gchar * fn);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
73 static void vorbis_aboutbox(void);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
74 static void vorbis_init(void);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
75 static void vorbis_cleanup(void);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
76 static long vorbis_process_replaygain(float **pcm, int samples, int ch,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
77 char *pcmout, float rg_scale);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
78 static gboolean vorbis_update_replaygain(float *scale);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
79
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
80 static size_t ovcb_read(void *ptr, size_t size, size_t nmemb,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
81 void *datasource);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
82 static int ovcb_seek(void *datasource, int64_t offset, int whence);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
83 static int ovcb_close(void *datasource);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
84 static long ovcb_tell(void *datasource);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
85
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
86 ov_callbacks vorbis_callbacks = {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
87 ovcb_read,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
88 ovcb_seek,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
89 ovcb_close,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
90 ovcb_tell
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
91 };
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
92
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
93 ov_callbacks vorbis_callbacks_stream = {
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
94 ovcb_read,
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
95 NULL,
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
96 ovcb_close,
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
97 NULL
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
98 };
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
99
375
e3cb9d1a8414 [svn] - fix vorbis exttable
nenolod
parents: 372
diff changeset
100 gchar *vorbis_fmts[] = { "ogg", "ogm", NULL };
e3cb9d1a8414 [svn] - fix vorbis exttable
nenolod
parents: 372
diff changeset
101
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
102 InputPlugin vorbis_ip = {
1618
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
103 .description = "Ogg Vorbis Audio Plugin", /* description */
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
104 .init = vorbis_init, /* init */
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
105 .about = vorbis_aboutbox, /* aboutbox */
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
106 .configure = vorbis_configure, /* configure */
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
107 .play_file = vorbis_play,
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
108 .stop = vorbis_stop,
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
109 .pause = vorbis_pause,
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
110 .seek = vorbis_seek,
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
111 .cleanup = vorbis_cleanup,
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
112 .get_song_info = vorbis_get_song_info,
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
113 .file_info_box = vorbis_file_info_box, /* file info box, tag editing */
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
114 .get_song_tuple = get_song_tuple,
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
115 .is_our_file_from_vfs = vorbis_check_fd,
1979
839804c3b3a4 aud_vfs_extensions -> vfs_extensions, some vtable fixes
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
116 .vfs_extensions = vorbis_fmts,
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
117 };
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
118
1078
094fa3026e3d [svn] - vorbis: transition to plugin API v2
nenolod
parents: 772
diff changeset
119 InputPlugin *vorbis_iplist[] = { &vorbis_ip, NULL };
094fa3026e3d [svn] - vorbis: transition to plugin API v2
nenolod
parents: 772
diff changeset
120
1395
761e17b23e0c added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents: 1373
diff changeset
121 DECLARE_PLUGIN(vorbis, NULL, NULL, vorbis_iplist, NULL, NULL, NULL, NULL, NULL);
1078
094fa3026e3d [svn] - vorbis: transition to plugin API v2
nenolod
parents: 772
diff changeset
122
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
123 static OggVorbis_File vf;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
124
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
125 static GThread *thread;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
126 static volatile int seekneeded = -1;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
127 static int samplerate, channels;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
128 GMutex *vf_mutex;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
129
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
130 gchar **vorbis_tag_encoding_list = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
131
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
132 static int
475
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
133 vorbis_check_fd(char *filename, VFSFile *stream)
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
134 {
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
135 OggVorbis_File vfile; /* avoid thread interaction */
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
136 gint result;
478
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
137 VFSVorbisFile *fd;
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
138
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
139 fd = g_new0(VFSVorbisFile, 1);
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
140 fd->fd = stream;
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
141 fd->probe = TRUE;
475
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
142
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
143 /*
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
144 * The open function performs full stream detection and machine
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
145 * initialization. If it returns zero, the stream *is* Vorbis and
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
146 * we're fully ready to decode.
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
147 */
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
148
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
149 /* libvorbisfile isn't thread safe... */
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
150 memset(&vfile, 0, sizeof(vfile));
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
151 g_mutex_lock(vf_mutex);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
152
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
153 result = ov_test_callbacks(fd, &vfile, NULL, 0, aud_vfs_is_streaming(stream) ? vorbis_callbacks_stream : vorbis_callbacks);
475
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
154
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
155 switch (result) {
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
156 case OV_EREAD:
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
157 #ifdef DEBUG
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
158 g_message("** vorbis.c: Media read error: %s", filename);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
159 #endif
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
160 g_mutex_unlock(vf_mutex);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
161 return FALSE;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
162 break;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
163 case OV_ENOTVORBIS:
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
164 #ifdef DEBUG
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
165 g_message("** vorbis.c: Not Vorbis data: %s", filename);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
166 #endif
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
167 g_mutex_unlock(vf_mutex);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
168 return FALSE;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
169 break;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
170 case OV_EVERSION:
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
171 #ifdef DEBUG
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
172 g_message("** vorbis.c: Version mismatch: %s", filename);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
173 #endif
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
174 g_mutex_unlock(vf_mutex);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
175 return FALSE;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
176 break;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
177 case OV_EBADHEADER:
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
178 #ifdef DEBUG
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
179 g_message("** vorbis.c: Invalid Vorbis bistream header: %s",
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
180 filename);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
181 #endif
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
182 g_mutex_unlock(vf_mutex);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
183 return FALSE;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
184 break;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
185 case OV_EFAULT:
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
186 #ifdef DEBUG
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
187 g_message("** vorbis.c: Internal logic fault while reading %s",
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
188 filename);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
189 #endif
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
190 g_mutex_unlock(vf_mutex);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
191 return FALSE;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
192 break;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
193 case 0:
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
194 break;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
195 default:
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
196 break;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
197 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
198
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
199 ov_clear(&vfile); /* once the ov_open succeeds, the stream belongs to
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
200 vorbisfile.a. ov_clear will fclose it */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
201 g_mutex_unlock(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
202 return TRUE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
203 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
204
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
205 static void
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
206 vorbis_jump_to_time(InputPlayback *playback, long time)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
207 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
208 g_mutex_lock(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
209
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
210 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
211 * We need to guard against seeking to the end, or things
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
212 * don't work right. Instead, just seek to one second prior
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
213 * to this
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
214 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
215 if (time == ov_time_total(&vf, -1))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
216 time--;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
217
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
218 playback->output->flush(time * 1000);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
219 ov_time_seek(&vf, time);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
220
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
221 g_mutex_unlock(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
222 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
223
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
224 static void
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
225 do_seek(InputPlayback *playback)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
226 {
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
227 if (seekneeded != -1) {
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
228 vorbis_jump_to_time(playback, seekneeded);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
229 seekneeded = -1;
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
230 playback->eof = FALSE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
231 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
232 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
233
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
234 static int
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
235 vorbis_process_data(InputPlayback *playback, int last_section,
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
236 gboolean use_rg, float rg_scale)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
237 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
238 char pcmout[4096];
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
239 int bytes;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
240 float **pcm;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
241
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
242 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
243 * A vorbis physical bitstream may consist of many logical
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
244 * sections (information for each of which may be fetched from
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
245 * the vf structure). This value is filled in by ov_read to
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
246 * alert us what section we're currently decoding in case we
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
247 * need to change playback settings at a section boundary
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
248 */
533
2fa253251598 [svn] - fix uninitialized value conditional jump, maybe it will help
nenolod
parents: 527
diff changeset
249 int current_section = last_section;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
250
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
251 g_mutex_lock(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
252 if (use_rg) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
253 bytes =
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
254 ov_read_float(&vf, &pcm, sizeof(pcmout) / 2 / channels,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
255 &current_section);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
256 if (bytes > 0)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
257 bytes = vorbis_process_replaygain(pcm, bytes, channels,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
258 pcmout, rg_scale);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
259 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
260 else {
544
e045af8665c6 [svn] - fix a warning
nenolod
parents: 540
diff changeset
261 bytes = ov_read(&vf, pcmout, sizeof(pcmout),
540
62c4c304a997 [svn] - handle OV_HOLE gracefully
nenolod
parents: 539
diff changeset
262 (int) (G_BYTE_ORDER == G_BIG_ENDIAN),
544
e045af8665c6 [svn] - fix a warning
nenolod
parents: 540
diff changeset
263 2, 1, &current_section);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
264 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
265
539
f17fb87c0288 [svn] - some tweaks
nenolod
parents: 538
diff changeset
266 /*
f17fb87c0288 [svn] - some tweaks
nenolod
parents: 538
diff changeset
267 * We got some sort of error. Bail.
f17fb87c0288 [svn] - some tweaks
nenolod
parents: 538
diff changeset
268 */
544
e045af8665c6 [svn] - fix a warning
nenolod
parents: 540
diff changeset
269 if (bytes <= 0 && bytes != OV_HOLE) {
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
270 g_mutex_unlock(vf_mutex);
1417
59f2c23810bc Fix hang problem on EOF.
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
271 playback->playing = 0;
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
272 playback->output->buffer_free();
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
273 playback->output->buffer_free();
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
274 playback->eof = TRUE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
275 return last_section;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
276 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
277
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
278 if (current_section != last_section) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
279 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
280 * The info struct is different in each section. vf
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
281 * holds them all for the given bitstream. This
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
282 * requests the current one
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
283 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
284 vorbis_info *vi = ov_info(&vf, -1);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
285
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
286 if (vi->channels > 2) {
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
287 playback->eof = TRUE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
288 g_mutex_unlock(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
289 return current_section;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
290 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
291
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
292
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
293 if (vi->rate != samplerate || vi->channels != channels) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
294 samplerate = vi->rate;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
295 channels = vi->channels;
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
296 playback->output->buffer_free();
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
297 playback->output->buffer_free();
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
298 playback->output->close_audio();
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
299 if (!playback->output->
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
300 open_audio(FMT_S16_NE, vi->rate, vi->channels)) {
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
301 playback->error = TRUE;
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
302 playback->eof = TRUE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
303 g_mutex_unlock(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
304 return current_section;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
305 }
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
306 playback->output->flush(ov_time_tell(&vf) * 1000);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
307 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
308 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
309
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
310 g_mutex_unlock(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
311
2033
a616624be493 move InputPlayback::pass_audio() call to avoid cutting off last 5 seconds.
William Pitcock <nenolod@atheme.org>
parents: 2032
diff changeset
312 playback->pass_audio(playback, FMT_S16_NE, channels, bytes, pcmout, &playback->playing);
a616624be493 move InputPlayback::pass_audio() call to avoid cutting off last 5 seconds.
William Pitcock <nenolod@atheme.org>
parents: 2032
diff changeset
313
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
314 if (!playback->playing)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
315 return current_section;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
316
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
317 if (seekneeded != -1)
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
318 do_seek(playback);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
319
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
320 return current_section;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
321 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
322
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
323 static gpointer
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
324 vorbis_play_loop(gpointer arg)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
325 {
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
326 InputPlayback *playback = arg;
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
327 char *filename = playback->filename;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
328 gchar *title = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
329 double time;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
330 long timercount = 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
331 vorbis_info *vi;
1372
495825028a70 Division by 1000 is not necessary.
William Pitcock <nenolod@atheme-project.org>
parents: 1370
diff changeset
332 gint br;
478
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
333 VFSVorbisFile *fd = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
334
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
335 int last_section = -1;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
336
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
337 VFSFile *stream = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
338 void *datasource = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
339
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
340 gboolean use_rg;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
341 float rg_scale = 1.0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
342
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
343 memset(&vf, 0, sizeof(vf));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
344
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
345 if ((stream = aud_vfs_fopen(filename, "r")) == NULL) {
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
346 playback->eof = TRUE;
478
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
347 goto play_cleanup;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
348 }
478
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
349
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
350 fd = g_new0(VFSVorbisFile, 1);
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
351 fd->fd = stream;
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
352 datasource = (void *) fd;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
353
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
354 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
355 * The open function performs full stream detection and
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
356 * machine initialization. None of the rest of ov_xx() works
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
357 * without it
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
358 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
359
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
360 g_mutex_lock(vf_mutex);
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
361 if (ov_open_callbacks(datasource, &vf, NULL, 0, aud_vfs_is_streaming(fd->fd) ? vorbis_callbacks_stream : vorbis_callbacks) < 0) {
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
362 vorbis_callbacks.close_func(datasource);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
363 g_mutex_unlock(vf_mutex);
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
364 playback->eof = TRUE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
365 goto play_cleanup;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
366 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
367 vi = ov_info(&vf, -1);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
368
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
369 if (aud_vfs_is_streaming(fd->fd))
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
370 time = -1;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
371
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
372 if (vi->channels > 2) {
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
373 playback->eof = TRUE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
374 g_mutex_unlock(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
375 goto play_cleanup;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
376 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
377
1372
495825028a70 Division by 1000 is not necessary.
William Pitcock <nenolod@atheme-project.org>
parents: 1370
diff changeset
378 title = vorbis_generate_title(&vf, filename);
495825028a70 Division by 1000 is not necessary.
William Pitcock <nenolod@atheme-project.org>
parents: 1370
diff changeset
379 use_rg = vorbis_update_replaygain(&rg_scale);
495825028a70 Division by 1000 is not necessary.
William Pitcock <nenolod@atheme-project.org>
parents: 1370
diff changeset
380
495825028a70 Division by 1000 is not necessary.
William Pitcock <nenolod@atheme-project.org>
parents: 1370
diff changeset
381 vi = ov_info(&vf, -1);
495825028a70 Division by 1000 is not necessary.
William Pitcock <nenolod@atheme-project.org>
parents: 1370
diff changeset
382
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
383 samplerate = vi->rate;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
384 channels = vi->channels;
1372
495825028a70 Division by 1000 is not necessary.
William Pitcock <nenolod@atheme-project.org>
parents: 1370
diff changeset
385 br = vi->bitrate_nominal;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
386
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
387 g_mutex_unlock(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
388
1987
b7bb2753677c only four to go!
William Pitcock <nenolod@atheme.org>
parents: 1979
diff changeset
389 playback->set_params(playback, title, time, br, samplerate, channels);
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
390 if (!playback->output->open_audio(FMT_S16_NE, vi->rate, vi->channels)) {
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
391 playback->error = TRUE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
392 goto play_cleanup;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
393 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
394
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
395 seekneeded = -1;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
396
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
397 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
398 * Note that chaining changes things here; A vorbis file may
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
399 * be a mix of different channels, bitrates and sample rates.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
400 * You can fetch the information for any section of the file
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
401 * using the ov_ interface.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
402 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
403
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
404 while (playback->playing) {
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
405 int current_section;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
406
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
407 if (seekneeded != -1)
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
408 do_seek(playback);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
409
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
410 if (playback->eof) {
1676
aee4ebea943a xmms_usleep() was removed, use g_usleep()
Matti Hamalainen <ccr@tnsp.org>
parents: 1618
diff changeset
411 g_usleep(20000);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
412 continue;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
413 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
414
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
415 current_section = vorbis_process_data(playback, last_section,
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
416 use_rg, rg_scale);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
417
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
418 if (current_section != last_section) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
419 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
420 * set total play time, bitrate, rate, and channels of
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
421 * current section
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
422 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
423 if (title)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
424 g_free(title);
533
2fa253251598 [svn] - fix uninitialized value conditional jump, maybe it will help
nenolod
parents: 527
diff changeset
425
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
426 g_mutex_lock(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
427 title = vorbis_generate_title(&vf, filename);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
428 use_rg = vorbis_update_replaygain(&rg_scale);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
429
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
430 if (time != -1)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
431 time = ov_time_total(&vf, -1) * 1000;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
432
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
433 g_mutex_unlock(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
434
1987
b7bb2753677c only four to go!
William Pitcock <nenolod@atheme.org>
parents: 1979
diff changeset
435 playback->set_params(playback, title, time, br, samplerate, channels);
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
436 timercount = playback->output->output_time();
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
437
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
438 last_section = current_section;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
439 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
440 }
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
441 if (!playback->error)
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
442 playback->output->close_audio();
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
443 /* fall through intentional */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
444
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
445 play_cleanup:
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
446 g_free(title);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
447
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
448 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
449 * ov_clear closes the stream if its open. Safe to call on an
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
450 * uninitialized structure as long as we've zeroed it
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
451 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
452 g_mutex_lock(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
453 ov_clear(&vf);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
454 g_mutex_unlock(vf_mutex);
1373
85ffec632924 Use InputPlayback.playing properly.
William Pitcock <nenolod@atheme-project.org>
parents: 1372
diff changeset
455 playback->playing = 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
456 return NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
457 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
458
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
459 static void
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
460 vorbis_play(InputPlayback *playback)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
461 {
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
462 playback->playing = 1;
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
463 playback->eof = 0;
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
464 playback->error = FALSE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
465
1352
ab66f3ee7a11 vorbis: new threading model
William Pitcock <nenolod@atheme-project.org>
parents: 1279
diff changeset
466 thread = g_thread_self();
1447
195b5657303e updated input plugins to use set_pb_ready to signal to the core that they're ready for playback
Giacomo Lozito <james@develia.org>
parents: 1433
diff changeset
467 playback->set_pb_ready(playback);
1352
ab66f3ee7a11 vorbis: new threading model
William Pitcock <nenolod@atheme-project.org>
parents: 1279
diff changeset
468 vorbis_play_loop(playback);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
469 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
470
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
471 static void
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
472 vorbis_stop(InputPlayback *playback)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
473 {
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
474 if (playback->playing) {
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
475 playback->playing = 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
476 g_thread_join(thread);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
477 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
478 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
479
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
480 static void
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
481 vorbis_pause(InputPlayback *playback, short p)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
482 {
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
483 playback->output->pause(p);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
484 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
485
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
486 static void
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 558
diff changeset
487 vorbis_seek(InputPlayback *data, int time)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
488 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
489 seekneeded = time;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
490
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
491 while (seekneeded != -1)
1676
aee4ebea943a xmms_usleep() was removed, use g_usleep()
Matti Hamalainen <ccr@tnsp.org>
parents: 1618
diff changeset
492 g_usleep(20000);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
493 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
494
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
495 static void
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
496 vorbis_get_song_info(char *filename, char **title, int *length)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
497 {
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
498 Tuple *tuple = get_song_tuple(filename);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
499
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
500 *length = aud_tuple_get_int(tuple, FIELD_LENGTH, NULL);
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
501 *title = aud_tuple_formatter_make_title_string(tuple, vorbis_cfg.tag_override ?
2055
2f2ffbc2d04d gentitle changes
William Pitcock <nenolod@atheme.org>
parents: 2050
diff changeset
502 vorbis_cfg.tag_format : aud_get_gentitle_format());
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
503
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
504 aud_tuple_free(tuple);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
505 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
506
1973
f86cb7fc1d4f Add -pipe -Wall if gcc and fix a few warnings.
Jonathan Schleifer <js@h3c.de>
parents: 1950
diff changeset
507 /*
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
508 static const gchar *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
509 get_extension(const gchar * filename)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
510 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
511 const gchar *ext;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
512 if ((ext = strrchr(filename, '.')))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
513 ++ext;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
514 return ext;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
515 }
1973
f86cb7fc1d4f Add -pipe -Wall if gcc and fix a few warnings.
Jonathan Schleifer <js@h3c.de>
parents: 1950
diff changeset
516 */
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
517
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
518 /* Make sure you've locked vf_mutex */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
519 static gboolean
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
520 vorbis_update_replaygain(float *scale)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
521 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
522 vorbis_comment *comment;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
523 char *rg_gain = NULL, *rg_peak_str = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
524 float rg_peak;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
525
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
526 if (!vorbis_cfg.use_replaygain && !vorbis_cfg.use_anticlip)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
527 return FALSE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
528 if ((comment = ov_comment(&vf, -1)) == NULL)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
529 return FALSE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
530
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
531 *scale = 1.0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
532
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
533 if (vorbis_cfg.use_replaygain) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
534 if (vorbis_cfg.replaygain_mode == REPLAYGAIN_MODE_ALBUM) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
535 rg_gain =
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
536 vorbis_comment_query(comment, "replaygain_album_gain", 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
537 if (!rg_gain)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
538 rg_gain = vorbis_comment_query(comment, "rg_audiophile", 0); /* Old */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
539 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
540
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
541 if (!rg_gain)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
542 rg_gain =
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
543 vorbis_comment_query(comment, "replaygain_track_gain", 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
544 if (!rg_gain)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
545 rg_gain = vorbis_comment_query(comment, "rg_radio", 0); /* Old */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
546
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
547 /* FIXME: Make sure this string is the correct format first? */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
548 if (rg_gain)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
549 *scale = pow(10., atof(rg_gain) / 20);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
550 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
551
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
552 if (vorbis_cfg.use_anticlip) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
553 if (vorbis_cfg.replaygain_mode == REPLAYGAIN_MODE_ALBUM)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
554 rg_peak_str =
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
555 vorbis_comment_query(comment, "replaygain_album_peak", 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
556
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
557 if (!rg_peak_str)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
558 rg_peak_str =
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
559 vorbis_comment_query(comment, "replaygain_track_peak", 0);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
560 if (!rg_peak_str)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
561 rg_peak_str = vorbis_comment_query(comment, "rg_peak", 0); /* Old */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
562
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
563 if (rg_peak_str)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
564 rg_peak = atof(rg_peak_str);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
565 else
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
566 rg_peak = 1;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
567
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
568 if (*scale * rg_peak > 1.0)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
569 *scale = 1.0 / rg_peak;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
570 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
571
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
572 if (*scale != 1.0 || vorbis_cfg.use_booster) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
573 /* safety */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
574 if (*scale > 15.0)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
575 *scale = 15.0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
576
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
577 return TRUE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
578 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
579
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
580 return FALSE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
581 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
582
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
583 #if (G_BYTE_ORDER == G_BIG_ENDIAN)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
584 # define GET_BYTE1(val) ((val) >> 8)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
585 # define GET_BYTE2(val) ((val) & 0xff)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
586 #else
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
587 # define GET_BYTE1(val) ((val) & 0xff)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
588 # define GET_BYTE2(val) ((val) >> 8)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
589 #endif
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
590
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
591 static long
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
592 vorbis_process_replaygain(float **pcm, int samples, int ch,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
593 char *pcmout, float rg_scale)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
594 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
595 int i, j;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
596 /* ReplayGain processing */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
597 for (i = 0; i < samples; i++)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
598 for (j = 0; j < ch; j++) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
599 float sample = pcm[j][i] * rg_scale;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
600 int value;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
601
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
602 if (vorbis_cfg.use_booster) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
603 sample *= 2;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
604
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
605 /* hard 6dB limiting */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
606 if (sample < -0.5)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
607 sample = tanh((sample + 0.5) / 0.5) * 0.5 - 0.5;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
608 else if (sample > 0.5)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
609 sample = tanh((sample - 0.5) / 0.5) * 0.5 + 0.5;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
610 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
611
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
612 value = sample * 32767;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
613 if (value > 32767)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
614 value = 32767;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
615 else if (value < -32767)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
616 value = -32767;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
617
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
618 *pcmout++ = GET_BYTE1(value);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
619 *pcmout++ = GET_BYTE2(value);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
620 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
621
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
622 return 2 * ch * samples;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
623 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
624
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
625 static void _aud_tuple_associate_string(Tuple *tuple, const gint nfield, const gchar *field, const gchar *string)
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
626 {
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1489
diff changeset
627 if (string) {
2050
2ffc6a69fcd1 string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents: 2033
diff changeset
628 gchar *str = aud_str_to_utf8(string);
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
629 aud_tuple_associate_string(tuple, nfield, field, str);
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1489
diff changeset
630 g_free(str);
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1489
diff changeset
631 }
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
632 }
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
633
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
634 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
635 * Ok, nhjm449! Are you *happy* now?! -nenolod
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
636 */
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
637 static Tuple *
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
638 get_aud_tuple_for_vorbisfile(OggVorbis_File * vorbisfile, gchar *filename)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
639 {
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
640 VFSVorbisFile *vfd = (VFSVorbisFile *) vorbisfile->datasource;
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
641 Tuple *tuple = NULL;
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
642 gboolean is_stream;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
643 vorbis_comment *comment;
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
644
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
645 tuple = aud_tuple_new_from_filename(filename);
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
646 is_stream = aud_vfs_is_streaming(vfd->fd);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
647
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
648 /* Retrieve the length */
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
649 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL,
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1489
diff changeset
650 is_stream ? -1 : (ov_time_total(vorbisfile, -1) * 1000));
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
651
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
652 if ((comment = ov_comment(vorbisfile, -1))) {
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1489
diff changeset
653 gchar *tmps;
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
654 _aud_tuple_associate_string(tuple, FIELD_TITLE, NULL, vorbis_comment_query(comment, "title", 0));
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
655 _aud_tuple_associate_string(tuple, FIELD_ARTIST, NULL, vorbis_comment_query(comment, "artist", 0));
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
656 _aud_tuple_associate_string(tuple, FIELD_ALBUM, NULL, vorbis_comment_query(comment, "album", 0));
2106
06d2b14562c4 Use FIELD_DATE.
Matti Hamalainen <ccr@tnsp.org>
parents: 2055
diff changeset
657 _aud_tuple_associate_string(tuple, FIELD_DATE, NULL, vorbis_comment_query(comment, "date", 0));
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
658 _aud_tuple_associate_string(tuple, FIELD_GENRE, NULL, vorbis_comment_query(comment, "genre", 0));
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
659 _aud_tuple_associate_string(tuple, FIELD_COMMENT, NULL, vorbis_comment_query(comment, "comment", 0));
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
660
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1489
diff changeset
661 if ((tmps = vorbis_comment_query(comment, "tracknumber", 0)) != NULL)
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
662 aud_tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi(tmps));
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
663
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
664 aud_tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossy");
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1489
diff changeset
665
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
666 if (comment && comment->vendor)
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
667 {
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
668 gchar *codec = g_strdup_printf("Ogg Vorbis [%s]", comment->vendor);
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
669 aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, codec);
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
670 g_free(codec);
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
671 }
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
672 else
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
673 aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, "Ogg Vorbis");
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
674 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
675
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
676 return tuple;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
677 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
678
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
679 static Tuple *
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
680 get_song_tuple(gchar *filename)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
681 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
682 VFSFile *stream = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
683 OggVorbis_File vfile; /* avoid thread interaction */
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
684 Tuple *tuple = NULL;
481
8b7576001358 [svn] - use VFSVorbisFile class for tuple builder
nenolod
parents: 478
diff changeset
685 VFSVorbisFile *fd = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
686
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
687 if ((stream = aud_vfs_fopen(filename, "r")) == NULL)
481
8b7576001358 [svn] - use VFSVorbisFile class for tuple builder
nenolod
parents: 478
diff changeset
688 return NULL;
8b7576001358 [svn] - use VFSVorbisFile class for tuple builder
nenolod
parents: 478
diff changeset
689
8b7576001358 [svn] - use VFSVorbisFile class for tuple builder
nenolod
parents: 478
diff changeset
690 fd = g_new0(VFSVorbisFile, 1);
8b7576001358 [svn] - use VFSVorbisFile class for tuple builder
nenolod
parents: 478
diff changeset
691 fd->fd = stream;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
692
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
693 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
694 * The open function performs full stream detection and
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
695 * machine initialization. If it returns zero, the stream
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
696 * *is* Vorbis and we're fully ready to decode.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
697 */
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
698 if (ov_open_callbacks(fd, &vfile, NULL, 0, aud_vfs_is_streaming(stream) ? vorbis_callbacks_stream : vorbis_callbacks) < 0) {
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
699 aud_vfs_fclose(stream);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
700 return NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
701 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
702
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
703 tuple = get_aud_tuple_for_vorbisfile(&vfile, filename);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
704
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
705 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
706 * once the ov_open succeeds, the stream belongs to
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
707 * vorbisfile.a. ov_clear will fclose it
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
708 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
709 ov_clear(&vfile);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
710
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
711 return tuple;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
712 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
713
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
714 static gchar *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
715 vorbis_generate_title(OggVorbis_File * vorbisfile, gchar * filename)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
716 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
717 /* Caller should hold vf_mutex */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
718 gchar *displaytitle = NULL;
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
719 Tuple *input;
545
f9dc3d58207a [svn] - display the stream title if it's available, like in mp3 streams
nenolod
parents: 544
diff changeset
720 gchar *tmp;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
721
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
722 input = get_aud_tuple_for_vorbisfile(vorbisfile, filename);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
723
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
724 displaytitle = aud_tuple_formatter_make_title_string(input, vorbis_cfg.tag_override ?
2055
2f2ffbc2d04d gentitle changes
William Pitcock <nenolod@atheme.org>
parents: 2050
diff changeset
725 vorbis_cfg.tag_format : aud_get_gentitle_format());
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
726
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
727 if ((tmp = aud_vfs_get_metadata(((VFSVorbisFile *) vorbisfile->datasource)->fd, "stream-name")) != NULL)
545
f9dc3d58207a [svn] - display the stream title if it's available, like in mp3 streams
nenolod
parents: 544
diff changeset
728 {
f9dc3d58207a [svn] - display the stream title if it's available, like in mp3 streams
nenolod
parents: 544
diff changeset
729 gchar *old = displaytitle;
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
730
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
731 aud_tuple_associate_string(input, -1, "stream", tmp);
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
732 aud_tuple_associate_string(input, FIELD_TITLE, NULL, old);
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
733
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
734 displaytitle = aud_tuple_formatter_process_string(input, "${?title:${title}}${?stream: (${stream})}");
545
f9dc3d58207a [svn] - display the stream title if it's available, like in mp3 streams
nenolod
parents: 544
diff changeset
735
f9dc3d58207a [svn] - display the stream title if it's available, like in mp3 streams
nenolod
parents: 544
diff changeset
736 g_free(old);
f9dc3d58207a [svn] - display the stream title if it's available, like in mp3 streams
nenolod
parents: 544
diff changeset
737 g_free(tmp);
f9dc3d58207a [svn] - display the stream title if it's available, like in mp3 streams
nenolod
parents: 544
diff changeset
738 }
f9dc3d58207a [svn] - display the stream title if it's available, like in mp3 streams
nenolod
parents: 544
diff changeset
739
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
740 aud_tuple_free(input);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
741
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
742 return displaytitle;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
743 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
744
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
745 static void
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
746 vorbis_aboutbox(void)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
747 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
748 static GtkWidget *about_window;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
749
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
750 if (about_window)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
751 gdk_window_raise(about_window->window);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
752 else
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
753 {
1677
f6f5603a0954 xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents: 1676
diff changeset
754 about_window = audacious_info_dialog(_("About Ogg Vorbis Audio Plugin"),
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
755 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
756 * I18N: UTF-8 Translation: "Haavard Kvaalen" ->
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
757 * "H\303\245vard Kv\303\245len"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
758 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
759 _
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
760 ("Ogg Vorbis Plugin by the Xiph.org Foundation\n\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
761 "Original code by\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
762 "Tony Arcieri <bascule@inferno.tusculum.edu>\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
763 "Contributions from\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
764 "Chris Montgomery <monty@xiph.org>\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
765 "Peter Alm <peter@xmms.org>\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
766 "Michael Smith <msmith@labyrinth.edu.au>\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
767 "Jack Moffitt <jack@icecast.org>\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
768 "Jorn Baayen <jorn@nl.linux.org>\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
769 "Haavard Kvaalen <havardk@xmms.org>\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
770 "Gian-Carlo Pascutto <gcp@sjeng.org>\n\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
771 "Visit the Xiph.org Foundation at http://www.xiph.org/\n"),
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
772 _("Ok"), FALSE, NULL, NULL);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
773 g_signal_connect(G_OBJECT(about_window), "destroy",
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
774 G_CALLBACK(gtk_widget_destroyed), &about_window);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
775 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
776 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
777
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
778
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
779 static void
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
780 vorbis_init(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
781 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
782 ConfigDb *db;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
783 gchar *tmp = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
784
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
785 memset(&vorbis_cfg, 0, sizeof(vorbis_config_t));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
786 vorbis_cfg.http_buffer_size = 128;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
787 vorbis_cfg.http_prebuffer = 25;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
788 vorbis_cfg.proxy_port = 8080;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
789 vorbis_cfg.proxy_use_auth = FALSE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
790 vorbis_cfg.proxy_user = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
791 vorbis_cfg.proxy_pass = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
792 vorbis_cfg.tag_override = FALSE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
793 vorbis_cfg.tag_format = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
794 vorbis_cfg.use_anticlip = FALSE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
795 vorbis_cfg.use_replaygain = FALSE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
796 vorbis_cfg.replaygain_mode = REPLAYGAIN_MODE_TRACK;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
797 vorbis_cfg.use_booster = FALSE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
798
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
799 db = aud_cfg_db_open();
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
800 aud_cfg_db_get_int(db, "vorbis", "http_buffer_size",
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
801 &vorbis_cfg.http_buffer_size);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
802 aud_cfg_db_get_int(db, "vorbis", "http_prebuffer",
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
803 &vorbis_cfg.http_prebuffer);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
804 aud_cfg_db_get_bool(db, "vorbis", "save_http_stream",
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
805 &vorbis_cfg.save_http_stream);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
806 if (!aud_cfg_db_get_string(db, "vorbis", "save_http_path",
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
807 &vorbis_cfg.save_http_path))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
808 vorbis_cfg.save_http_path = g_strdup(g_get_home_dir());
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
809
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
810 aud_cfg_db_get_bool(db, "vorbis", "tag_override",
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
811 &vorbis_cfg.tag_override);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
812 if (!aud_cfg_db_get_string(db, "vorbis", "tag_format",
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
813 &vorbis_cfg.tag_format))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
814 vorbis_cfg.tag_format = g_strdup("%p - %t");
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
815 aud_cfg_db_get_bool(db, "vorbis", "use_anticlip",
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
816 &vorbis_cfg.use_anticlip);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
817 aud_cfg_db_get_bool(db, "vorbis", "use_replaygain",
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
818 &vorbis_cfg.use_replaygain);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
819 aud_cfg_db_get_int(db, "vorbis", "replaygain_mode",
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
820 &vorbis_cfg.replaygain_mode);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
821 aud_cfg_db_get_bool(db, "vorbis", "use_booster", &vorbis_cfg.use_booster);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
822
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
823 aud_cfg_db_get_bool(db, NULL, "use_proxy", &vorbis_cfg.use_proxy);
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
824 aud_cfg_db_get_string(db, NULL, "proxy_host", &vorbis_cfg.proxy_host);
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
825 aud_cfg_db_get_string(db, NULL, "proxy_port", &tmp);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
826
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
827 if (tmp != NULL)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
828 vorbis_cfg.proxy_port = atoi(tmp);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
829
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
830 aud_cfg_db_get_bool(db, NULL, "proxy_use_auth", &vorbis_cfg.proxy_use_auth);
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
831 aud_cfg_db_get_string(db, NULL, "proxy_user", &vorbis_cfg.proxy_user);
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
832 aud_cfg_db_get_string(db, NULL, "proxy_pass", &vorbis_cfg.proxy_pass);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
833
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
834 aud_cfg_db_close(db);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
835
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
836 vf_mutex = g_mutex_new();
2032
55f2fd232291 associate with application/ogg mimetype.
William Pitcock <nenolod@atheme.org>
parents: 1998
diff changeset
837
55f2fd232291 associate with application/ogg mimetype.
William Pitcock <nenolod@atheme.org>
parents: 1998
diff changeset
838 aud_mime_set_plugin("application/ogg", &vorbis_ip);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
839 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
840
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
841 static void
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
842 vorbis_cleanup(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
843 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
844 if (vorbis_cfg.save_http_path) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
845 free(vorbis_cfg.save_http_path);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
846 vorbis_cfg.save_http_path = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
847 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
848
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
849 if (vorbis_cfg.proxy_host) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
850 free(vorbis_cfg.proxy_host);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
851 vorbis_cfg.proxy_host = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
852 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
853
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
854 if (vorbis_cfg.proxy_user) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
855 free(vorbis_cfg.proxy_user);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
856 vorbis_cfg.proxy_user = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
857 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
858
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
859 if (vorbis_cfg.proxy_pass) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
860 free(vorbis_cfg.proxy_pass);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
861 vorbis_cfg.proxy_pass = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
862 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
863
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
864 if (vorbis_cfg.tag_format) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
865 free(vorbis_cfg.tag_format);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
866 vorbis_cfg.tag_format = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
867 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
868
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
869 if (vorbis_cfg.title_encoding) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
870 free(vorbis_cfg.title_encoding);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
871 vorbis_cfg.title_encoding = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
872 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
873
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
874 g_strfreev(vorbis_tag_encoding_list);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
875 g_mutex_free(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
876 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
877
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
878 static size_t
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
879 ovcb_read(void *ptr, size_t size, size_t nmemb, void *datasource)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
880 {
478
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
881 VFSVorbisFile *handle = (VFSVorbisFile *) datasource;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
882
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
883 return aud_vfs_fread(ptr, size, nmemb, handle->fd);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
884 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
885
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
886 static int
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
887 ovcb_seek(void *datasource, int64_t offset, int whence)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
888 {
478
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
889 VFSVorbisFile *handle = (VFSVorbisFile *) datasource;
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
890
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
891 return aud_vfs_fseek(handle->fd, offset, whence);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
892 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
893
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
894 static int
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
895 ovcb_close(void *datasource)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
896 {
478
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
897 VFSVorbisFile *handle = (VFSVorbisFile *) datasource;
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
898
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
899 gint ret = 0;
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
900
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
901 if (handle->probe == FALSE)
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
902 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
903 ret = aud_vfs_fclose(handle->fd);
655
6a656a7f40fa [svn] - fix double free bug in vorbis fileinfo.
yaz
parents: 615
diff changeset
904 // g_free(handle); // it causes double free. i'm not really sure that commenting out at here is correct. --yaz
478
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
905 }
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
906
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
907 return ret;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
908 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
909
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
910 static long
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
911 ovcb_tell(void *datasource)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
912 {
478
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
913 VFSVorbisFile *handle = (VFSVorbisFile *) datasource;
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
914
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
915 return aud_vfs_ftell(handle->fd);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
916 }