annotate src/vorbis/vorbis.c @ 2375:22641735c9b1

- fixed freezing on track end - remember that buffer_free() returns _free_ space, not used.
author Eugene Zagidullin <e.asphyx@gmail.com>
date Sun, 10 Feb 2008 14:46:28 +0300
parents db02ad480056
children 9056897525e1
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>
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
5 * Copyright (C) 2008 Cristi Măgherușan <majeru@gentoo.ro>
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
6 * Copyright (C) 2008 Eugene Zagidullin <e.asphyx@gmail.com>
0
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 * 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
9 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
10 * 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
11 * 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
12 * 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
13 * 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
14 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
15 * 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
16 * 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
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
18 * GNU General Public License for more details.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
19 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
20 * 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
21 * 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
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
23 * 02110-1301, USA.
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
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 * 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
29 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
30
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
31 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
32 * Note that this uses vorbisfile, which is not (currently)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
33 * thread-safe.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
34 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
35
1777
4a200593472d vorbis: Mk2
William Pitcock <nenolod@atheme.org>
parents: 1697
diff changeset
36 #include "config.h"
2375
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
37 /*
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
38 #define AUD_DEBUG
537
e55f789573e3 [svn] - treat all failures the same. this is XIPH. we're not going to ever be
nenolod
parents: 536
diff changeset
39 #define DEBUG
2375
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
40 */
537
e55f789573e3 [svn] - treat all failures the same. this is XIPH. we're not going to ever be
nenolod
parents: 536
diff changeset
41
615
1fb44c12a812 [svn] - avoid NULL dereference. closes mandriva #28603.
nenolod
parents: 608
diff changeset
42 #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
43
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
44 #include <glib.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
45 #include <gtk/gtk.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 <stdlib.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
48 #include <math.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
49 #include <string.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
50
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
51 #include <fcntl.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
52
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
53 #include <ogg/ogg.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
54 #include <vorbis/codec.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
55 #include <vorbis/vorbisfile.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
56
1950
2ebeb7816c5e Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents: 1777
diff changeset
57 #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
58 #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
59 #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
60 #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
61 #include <audacious/main.h>
527
d124034ebea3 [svn] - glib/gi18n.h -> audacious/i18n.h for automatic dgettext support
nenolod
parents: 484
diff changeset
62 #include <audacious/i18n.h>
772
18dd1dd2d232 [svn] - include strings.h
yaz
parents: 767
diff changeset
63 #include <audacious/strings.h>
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
64
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
65 #include "vorbis.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
66
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
67 extern vorbis_config_t vorbis_cfg;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
68
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
69 static Tuple *get_song_tuple(gchar *filename);
475
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
70 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
71 static void vorbis_play(InputPlayback *data);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 558
diff changeset
72 static void vorbis_stop(InputPlayback *data);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 558
diff changeset
73 static void vorbis_pause(InputPlayback *data, short p);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 558
diff changeset
74 static void vorbis_seek(InputPlayback *data, int time);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
75 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
76 static void vorbis_aboutbox(void);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
77 static void vorbis_init(void);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
78 static void vorbis_cleanup(void);
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
79 static long vorbis_interleave_buffer(float **pcm, int samples, int ch,
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
80 float *pcmout);
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
81 static gboolean vorbis_update_replaygain(ReplayGainInfo *rg_info);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
82
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
83 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
84 void *datasource);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
85 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
86 static int ovcb_close(void *datasource);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
87 static long ovcb_tell(void *datasource);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
88
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
89 ov_callbacks vorbis_callbacks = {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
90 ovcb_read,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
91 ovcb_seek,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
92 ovcb_close,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
93 ovcb_tell
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
94 };
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
95
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
96 ov_callbacks vorbis_callbacks_stream = {
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
97 ovcb_read,
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
98 NULL,
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
99 ovcb_close,
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
100 NULL
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
101 };
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
102
375
e3cb9d1a8414 [svn] - fix vorbis exttable
nenolod
parents: 372
diff changeset
103 gchar *vorbis_fmts[] = { "ogg", "ogm", NULL };
e3cb9d1a8414 [svn] - fix vorbis exttable
nenolod
parents: 372
diff changeset
104
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
105 InputPlugin vorbis_ip = {
1618
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
106 .description = "Ogg Vorbis Audio Plugin", /* description */
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
107 .init = vorbis_init, /* init */
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
108 .about = vorbis_aboutbox, /* aboutbox */
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
109 .configure = vorbis_configure, /* configure */
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
110 .play_file = vorbis_play,
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
111 .stop = vorbis_stop,
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
112 .pause = vorbis_pause,
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
113 .seek = vorbis_seek,
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
114 .cleanup = vorbis_cleanup,
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
115 .get_song_tuple = get_song_tuple,
177aec41b238 vorbis: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1489
diff changeset
116 .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
117 .vfs_extensions = vorbis_fmts,
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2191
diff changeset
118 .update_song_tuple = vorbis_update_song_tuple,
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
119 };
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
120
1078
094fa3026e3d [svn] - vorbis: transition to plugin API v2
nenolod
parents: 772
diff changeset
121 InputPlugin *vorbis_iplist[] = { &vorbis_ip, NULL };
094fa3026e3d [svn] - vorbis: transition to plugin API v2
nenolod
parents: 772
diff changeset
122
1395
761e17b23e0c added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents: 1373
diff changeset
123 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
124
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
125 static OggVorbis_File vf;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
126
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
127 static GThread *thread;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
128 static volatile int seekneeded = -1;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
129 static int samplerate, channels;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
130 GMutex *vf_mutex;
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 gchar **vorbis_tag_encoding_list = NULL;
2191
329267b09658 get rid of talking with GDK directly
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2134
diff changeset
133 static GtkWidget *about_window;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
134
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
135 static int
475
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
136 vorbis_check_fd(char *filename, VFSFile *stream)
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
137 {
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
138 OggVorbis_File vfile; /* avoid thread interaction */
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
139 gint result;
478
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
140 VFSVorbisFile *fd;
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
141
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
142 fd = g_new0(VFSVorbisFile, 1);
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
143 fd->fd = stream;
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
144 fd->probe = TRUE;
475
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
145
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
146 /*
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
147 * The open function performs full stream detection and machine
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
148 * initialization. If it returns zero, the stream *is* Vorbis and
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
149 * we're fully ready to decode.
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
150 */
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
151
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
152 /* libvorbisfile isn't thread safe... */
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
153 memset(&vfile, 0, sizeof(vfile));
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
154 g_mutex_lock(vf_mutex);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
155
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
156 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
157
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
158 switch (result) {
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
159 case OV_EREAD:
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
160 #ifdef DEBUG
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
161 g_message("** vorbis.c: Media read error: %s", filename);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
162 #endif
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
163 g_mutex_unlock(vf_mutex);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
164 return FALSE;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
165 break;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
166 case OV_ENOTVORBIS:
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
167 #ifdef DEBUG
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
168 g_message("** vorbis.c: Not Vorbis data: %s", filename);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
169 #endif
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
170 g_mutex_unlock(vf_mutex);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
171 return FALSE;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
172 break;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
173 case OV_EVERSION:
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
174 #ifdef DEBUG
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
175 g_message("** vorbis.c: Version mismatch: %s", filename);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
176 #endif
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
177 g_mutex_unlock(vf_mutex);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
178 return FALSE;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
179 break;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
180 case OV_EBADHEADER:
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
181 #ifdef DEBUG
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
182 g_message("** vorbis.c: Invalid Vorbis bistream header: %s",
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
183 filename);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
184 #endif
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
185 g_mutex_unlock(vf_mutex);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
186 return FALSE;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
187 break;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
188 case OV_EFAULT:
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
189 #ifdef DEBUG
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
190 g_message("** vorbis.c: Internal logic fault while reading %s",
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
191 filename);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
192 #endif
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
193 g_mutex_unlock(vf_mutex);
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
194 return FALSE;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
195 break;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
196 case 0:
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
197 break;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
198 default:
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
199 break;
90e4ac2189fe [svn] - newvfs probing support
nenolod
parents: 375
diff changeset
200 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
201
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
202 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
203 vorbisfile.a. ov_clear will fclose it */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
204 g_mutex_unlock(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
205 return TRUE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
206 }
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 static void
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
209 vorbis_jump_to_time(InputPlayback *playback, long time)
0
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 g_mutex_lock(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
212
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
213 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
214 * 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
215 * 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
216 * to this
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
217 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
218 if (time == ov_time_total(&vf, -1))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
219 time--;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
220
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
221 playback->output->flush(time * 1000);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
222 ov_time_seek(&vf, time);
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 g_mutex_unlock(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
225 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
226
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
227 static void
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
228 do_seek(InputPlayback *playback)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
229 {
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
230 if (seekneeded != -1) {
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
231 vorbis_jump_to_time(playback, seekneeded);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
232 seekneeded = -1;
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
233 playback->eof = FALSE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
234 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
235 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
236
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
237 #define PCM_FRAMES 1024
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
238 #define PCM_BUFSIZE PCM_FRAMES*2
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
239
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
240 static gpointer
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
241 vorbis_play_loop(gpointer arg)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
242 {
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
243 InputPlayback *playback = arg;
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
244 char *filename = playback->filename;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
245 gchar *title = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
246 double time;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
247 long timercount = 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
248 vorbis_info *vi;
1372
495825028a70 Division by 1000 is not necessary.
William Pitcock <nenolod@atheme-project.org>
parents: 1370
diff changeset
249 gint br;
478
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
250 VFSVorbisFile *fd = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
251
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
252 int last_section = -1;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
253
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
254 VFSFile *stream = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
255 void *datasource = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
256
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
257 /*gboolean use_rg;
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
258 /float rg_scale = 1.0;*/
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
259
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
260 ReplayGainInfo rg_info;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
261
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
262 memset(&vf, 0, sizeof(vf));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
263
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
264 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
265 playback->eof = TRUE;
478
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
266 goto play_cleanup;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
267 }
478
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
268
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
269 fd = g_new0(VFSVorbisFile, 1);
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
270 fd->fd = stream;
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
271 datasource = (void *) fd;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
272
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
273 /*char pcmout[4096];*/
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
274 float pcmout[PCM_BUFSIZE*sizeof(float)];
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
275 int bytes;
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
276 float **pcm;
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
277
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
278 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
279 * The open function performs full stream detection and
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
280 * 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
281 * without it
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
282 *
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
283 * A vorbis physical bitstream may consist of many logical
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
284 * sections (information for each of which may be fetched from
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
285 * the vf structure). This value is filled in by ov_read to
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
286 * alert us what section we're currently decoding in case we
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
287 * need to change playback settings at a section boundary
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
288 */
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
289
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
290
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
291 g_mutex_lock(vf_mutex);
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
292 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
293 vorbis_callbacks.close_func(datasource);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
294 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
295 playback->eof = TRUE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
296 goto play_cleanup;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
297 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
298 vi = ov_info(&vf, -1);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
299
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
300 if (aud_vfs_is_streaming(fd->fd))
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
301 time = -1;
2134
fd0d5615f674 Fix seeking for non-streamed files.
William Pitcock <nenolod@atheme.org>
parents: 2133
diff changeset
302 else
fd0d5615f674 Fix seeking for non-streamed files.
William Pitcock <nenolod@atheme.org>
parents: 2133
diff changeset
303 time = ov_time_total(&vf, -1) * 1000;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
304
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
305 if (vi->channels > 2) {
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
306 playback->eof = TRUE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
307 g_mutex_unlock(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
308 goto play_cleanup;
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
1372
495825028a70 Division by 1000 is not necessary.
William Pitcock <nenolod@atheme-project.org>
parents: 1370
diff changeset
311 title = vorbis_generate_title(&vf, filename);
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
312 vorbis_update_replaygain(&rg_info);
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
313 playback->set_replaygain_info(playback, &rg_info);
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
314
1372
495825028a70 Division by 1000 is not necessary.
William Pitcock <nenolod@atheme-project.org>
parents: 1370
diff changeset
315 vi = ov_info(&vf, -1);
495825028a70 Division by 1000 is not necessary.
William Pitcock <nenolod@atheme-project.org>
parents: 1370
diff changeset
316
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
317 samplerate = vi->rate;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
318 channels = vi->channels;
1372
495825028a70 Division by 1000 is not necessary.
William Pitcock <nenolod@atheme-project.org>
parents: 1370
diff changeset
319 br = vi->bitrate_nominal;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
320
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
321 g_mutex_unlock(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
322
1987
b7bb2753677c only four to go!
William Pitcock <nenolod@atheme.org>
parents: 1979
diff changeset
323 playback->set_params(playback, title, time, br, samplerate, channels);
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
324 if (!playback->output->open_audio(FMT_FLOAT, vi->rate, vi->channels)) {
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
325 playback->error = TRUE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
326 goto play_cleanup;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
327 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
328
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
329 seekneeded = -1;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
330
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
331 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
332 * 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
333 * 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
334 * 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
335 * using the ov_ interface.
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
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
338 while (playback->playing) {
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
339
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
340 if (playback->eof) {
1676
aee4ebea943a xmms_usleep() was removed, use g_usleep()
Matti Hamalainen <ccr@tnsp.org>
parents: 1618
diff changeset
341 g_usleep(20000);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
342 continue;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
343 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
344
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
345 if (seekneeded != -1)
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
346 do_seek(playback);
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
347
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
348
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
349 int current_section = last_section;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
350
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
351 g_mutex_lock(vf_mutex);
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
352
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
353 bytes = ov_read_float(&vf, &pcm, PCM_FRAMES, &current_section);
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
354
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
355 if (bytes > 0)
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
356 bytes = vorbis_interleave_buffer(pcm, bytes, channels, pcmout);
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
357
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
358 /*
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
359 * We got some sort of error. Bail.
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
360 */
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
361 if (bytes <= 0 && bytes != OV_HOLE) {
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
362 /*
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
363 * EOF
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
364 */
2375
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
365 AUDDBG("EOF\n");
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
366 playback->playing = 0;
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
367 playback->eof = TRUE;
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
368 current_section = last_section;
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
369 }
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
370
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
371 if (current_section <= last_section) {
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
372 /*
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
373 * The info struct is different in each section. vf
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
374 * holds them all for the given bitstream. This
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
375 * requests the current one
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
376 */
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
377 vorbis_info *vi = ov_info(&vf, -1);
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
378
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
379 if (vi->channels > 2) {
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
380 playback->eof = TRUE;
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
381 g_mutex_unlock(vf_mutex);
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
382 goto stop_processing;
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
383 }
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
384
533
2fa253251598 [svn] - fix uninitialized value conditional jump, maybe it will help
nenolod
parents: 527
diff changeset
385
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
386 if (vi->rate != samplerate || vi->channels != channels) {
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
387 samplerate = vi->rate;
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
388 channels = vi->channels;
2375
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
389 while(playback->output->buffer_playing()) g_usleep(50000);
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
390 playback->output->close_audio();
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
391 if (!playback->output->
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
392 open_audio(FMT_FLOAT, vi->rate, vi->channels)) {
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
393 playback->error = TRUE;
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
394 playback->eof = TRUE;
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
395 g_mutex_unlock(vf_mutex);
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
396 goto stop_processing;
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
397 }
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
398 playback->output->flush(ov_time_tell(&vf) * 1000);
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
399 vorbis_update_replaygain(&rg_info);
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
400 playback->set_replaygain_info(playback, &rg_info); /* audio reopened */
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
401 }
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
402 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
403
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
404 g_mutex_unlock(vf_mutex);
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
405
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
406 playback->pass_audio(playback, FMT_FLOAT, channels, bytes, pcmout, &playback->playing);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
407
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
408 if (!playback->playing)
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
409 goto stop_processing;
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
410
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
411 if (seekneeded != -1)
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
412 do_seek(playback);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
413
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
414 stop_processing:
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
415
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
416 if (current_section <= last_section) {
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
417 /*
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
418 * set total play time, bitrate, rate, and channels of
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
419 * current section
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
420 */
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
421 if (title)
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
422 g_free(title);
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
423
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
424 g_mutex_lock(vf_mutex);
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
425 title = vorbis_generate_title(&vf, filename);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
426
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
427 if (time != -1)
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
428 time = ov_time_total(&vf, -1) * 1000;
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
429
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
430 g_mutex_unlock(vf_mutex);
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
431
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
432 playback->set_params(playback, title, time, br, samplerate, channels);
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
433
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
434 timercount = playback->output->output_time();
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
435
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
436 last_section = current_section;
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
437
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
438 }
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
439 } /* main loop */
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
440
2375
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
441 if (!playback->error) {
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
442 /*this loop makes it not skip the last ~4 seconds, but the playback
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
443 * timer isn't updated in this period, so it still needs a bit of work
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
444 *
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
445 * majeru
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
446 */
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
447 if(playback->eof) /* do it only on EOF --asphyx */
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
448 while(playback->output->buffer_playing()) {
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
449 AUDDBG("waiting for empty output buffer\n");
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
450 g_usleep(50000);
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
451 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
452
2375
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
453 playback->output->close_audio();
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
454 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
455
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
456
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
457 play_cleanup:
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
458 g_free(title);
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
459
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
460 /*
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
461 * ov_clear closes the stream if its open. Safe to call on an
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
462 * uninitialized structure as long as we've zeroed it
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
463 */
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
464 g_mutex_lock(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
465 ov_clear(&vf);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
466 g_mutex_unlock(vf_mutex);
1373
85ffec632924 Use InputPlayback.playing properly.
William Pitcock <nenolod@atheme-project.org>
parents: 1372
diff changeset
467 playback->playing = 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
468 return NULL;
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
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
472 vorbis_play(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 playback->playing = 1;
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
475 playback->eof = 0;
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
476 playback->error = FALSE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
477
1352
ab66f3ee7a11 vorbis: new threading model
William Pitcock <nenolod@atheme-project.org>
parents: 1279
diff changeset
478 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
479 playback->set_pb_ready(playback);
1352
ab66f3ee7a11 vorbis: new threading model
William Pitcock <nenolod@atheme-project.org>
parents: 1279
diff changeset
480 vorbis_play_loop(playback);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
481 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
482
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
483 static void
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
484 vorbis_stop(InputPlayback *playback)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
485 {
564
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
486 if (playback->playing) {
6b959c9914a7 [svn] Fix a dumb mistake, and also use generic flags and get_time.
iabervon
parents: 561
diff changeset
487 playback->playing = 0;
2375
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
488 AUDDBG("waiting for playback thread finished\n");
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
489 g_thread_join(thread);
2375
22641735c9b1 - fixed freezing on track end
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2351
diff changeset
490 AUDDBG("playback finished\n");
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
491 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
492 }
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 static void
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
495 vorbis_pause(InputPlayback *playback, short p)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
496 {
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
497 playback->output->pause(p);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
498 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
499
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
500 static void
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 558
diff changeset
501 vorbis_seek(InputPlayback *data, int time)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
502 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
503 seekneeded = time;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
504
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
505 while (seekneeded != -1)
1676
aee4ebea943a xmms_usleep() was removed, use g_usleep()
Matti Hamalainen <ccr@tnsp.org>
parents: 1618
diff changeset
506 g_usleep(20000);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
507 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
508
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
509 /* Make sure you've locked vf_mutex */
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
510
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
511 static gboolean
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
512 vorbis_update_replaygain(ReplayGainInfo *rg_info)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
513 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
514 vorbis_comment *comment;
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
515 char *rg_gain = NULL, *rg_peak = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
516
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
517 if (rg_info == NULL || (comment = ov_comment(&vf, -1)) == NULL)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
518 return FALSE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
519
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
520 rg_gain = vorbis_comment_query(comment, "replaygain_album_gain", 0);
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
521 if (!rg_gain) rg_gain = vorbis_comment_query(comment, "rg_audiophile", 0); /* Old */
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
522 rg_info->album_gain = rg_gain != NULL ? atof(rg_gain) : 0.0;
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
523
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
524 rg_gain = vorbis_comment_query(comment, "replaygain_track_gain", 0);
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
525 if (!rg_gain) rg_gain = vorbis_comment_query(comment, "rg_radio", 0); /* Old */
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
526 rg_info->track_gain = rg_gain != NULL ? atof(rg_gain) : 0.0;
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
527
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
528 rg_peak = vorbis_comment_query(comment, "replaygain_album_peak", 0);
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
529 rg_info->album_peak = rg_peak != NULL ? atof(rg_peak) : 0.0;
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
530
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
531 rg_peak = vorbis_comment_query(comment, "replaygain_track_peak", 0);
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
532 if (!rg_peak) rg_peak = vorbis_comment_query(comment, "rg_peak", 0); /* Old */
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
533 rg_info->track_peak = rg_peak != NULL ? atof(rg_peak) : 0.0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
534
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
535 return TRUE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
536 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
537
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
538 static long
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
539 vorbis_interleave_buffer(float **pcm, int samples, int ch, float *pcmout)
0
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 int i, j;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
542 for (i = 0; i < samples; i++)
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
543 for (j = 0; j < ch; j++)
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
544 *pcmout++ = pcm[j][i];
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
545
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
546 return ch * samples * sizeof(float);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
547 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
548
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
549 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
550 {
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1489
diff changeset
551 if (string) {
2050
2ffc6a69fcd1 string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents: 2033
diff changeset
552 gchar *str = aud_str_to_utf8(string);
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
553 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
554 g_free(str);
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1489
diff changeset
555 }
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
556 }
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
557
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
558 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
559 * Ok, nhjm449! Are you *happy* now?! -nenolod
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
560 */
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
561 static Tuple *
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
562 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
563 {
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
564 VFSVorbisFile *vfd = (VFSVorbisFile *) vorbisfile->datasource;
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
565 Tuple *tuple = NULL;
2134
fd0d5615f674 Fix seeking for non-streamed files.
William Pitcock <nenolod@atheme.org>
parents: 2133
diff changeset
566 gint length;
2212
a13b8f308dce vorbis: mimetype field added. also little fix
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2211
diff changeset
567 vorbis_comment *comment = NULL;
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
568
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
569 tuple = aud_tuple_new_from_filename(filename);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
570
2134
fd0d5615f674 Fix seeking for non-streamed files.
William Pitcock <nenolod@atheme.org>
parents: 2133
diff changeset
571 if (aud_vfs_is_streaming(vfd->fd))
fd0d5615f674 Fix seeking for non-streamed files.
William Pitcock <nenolod@atheme.org>
parents: 2133
diff changeset
572 length = -1;
fd0d5615f674 Fix seeking for non-streamed files.
William Pitcock <nenolod@atheme.org>
parents: 2133
diff changeset
573 else
fd0d5615f674 Fix seeking for non-streamed files.
William Pitcock <nenolod@atheme.org>
parents: 2133
diff changeset
574 length = ov_time_total(vorbisfile, -1) * 1000;
fd0d5615f674 Fix seeking for non-streamed files.
William Pitcock <nenolod@atheme.org>
parents: 2133
diff changeset
575
fd0d5615f674 Fix seeking for non-streamed files.
William Pitcock <nenolod@atheme.org>
parents: 2133
diff changeset
576 /* associate with tuple */
fd0d5615f674 Fix seeking for non-streamed files.
William Pitcock <nenolod@atheme.org>
parents: 2133
diff changeset
577 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, length);
2211
2a13a038987c vorbis: bitrate field added
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2210
diff changeset
578 /* maybe, it would be better to display nominal bitrate (like in main win), not average? --eugene */
2a13a038987c vorbis: bitrate field added
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2210
diff changeset
579 aud_tuple_associate_int(tuple, FIELD_BITRATE, NULL, ov_bitrate(vorbisfile, -1)/1000);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
580
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
581 if ((comment = ov_comment(vorbisfile, -1))) {
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1489
diff changeset
582 gchar *tmps;
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
583 _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
584 _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
585 _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
586 _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
587 _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
588 _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
589
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1489
diff changeset
590 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
591 aud_tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi(tmps));
2212
a13b8f308dce vorbis: mimetype field added. also little fix
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2211
diff changeset
592 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
593
2212
a13b8f308dce vorbis: mimetype field added. also little fix
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2211
diff changeset
594 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
595
2212
a13b8f308dce vorbis: mimetype field added. also little fix
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2211
diff changeset
596 if (comment && comment->vendor)
a13b8f308dce vorbis: mimetype field added. also little fix
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2211
diff changeset
597 {
a13b8f308dce vorbis: mimetype field added. also little fix
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2211
diff changeset
598 gchar *codec = g_strdup_printf("Ogg Vorbis [%s]", comment->vendor);
a13b8f308dce vorbis: mimetype field added. also little fix
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2211
diff changeset
599 aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, codec);
a13b8f308dce vorbis: mimetype field added. also little fix
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2211
diff changeset
600 g_free(codec);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
601 }
2212
a13b8f308dce vorbis: mimetype field added. also little fix
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2211
diff changeset
602 else
a13b8f308dce vorbis: mimetype field added. also little fix
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2211
diff changeset
603 aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, "Ogg Vorbis");
a13b8f308dce vorbis: mimetype field added. also little fix
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2211
diff changeset
604
a13b8f308dce vorbis: mimetype field added. also little fix
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2211
diff changeset
605 aud_tuple_associate_string(tuple, FIELD_MIMETYPE, NULL, "application/ogg");
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
606
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
607 return tuple;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
608 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
609
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
610 static Tuple *
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
611 get_song_tuple(gchar *filename)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
612 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
613 VFSFile *stream = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
614 OggVorbis_File vfile; /* avoid thread interaction */
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
615 Tuple *tuple = NULL;
481
8b7576001358 [svn] - use VFSVorbisFile class for tuple builder
nenolod
parents: 478
diff changeset
616 VFSVorbisFile *fd = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
617
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
618 if ((stream = aud_vfs_fopen(filename, "r")) == NULL)
481
8b7576001358 [svn] - use VFSVorbisFile class for tuple builder
nenolod
parents: 478
diff changeset
619 return NULL;
8b7576001358 [svn] - use VFSVorbisFile class for tuple builder
nenolod
parents: 478
diff changeset
620
8b7576001358 [svn] - use VFSVorbisFile class for tuple builder
nenolod
parents: 478
diff changeset
621 fd = g_new0(VFSVorbisFile, 1);
8b7576001358 [svn] - use VFSVorbisFile class for tuple builder
nenolod
parents: 478
diff changeset
622 fd->fd = stream;
0
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 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
625 * The open function performs full stream detection and
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
626 * machine initialization. If it returns zero, the stream
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
627 * *is* Vorbis and we're fully ready to decode.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
628 */
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
629 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
630 aud_vfs_fclose(stream);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
631 return NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
632 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
633
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
634 tuple = get_aud_tuple_for_vorbisfile(&vfile, filename);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
635
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
636 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
637 * once the ov_open succeeds, the stream belongs to
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
638 * vorbisfile.a. ov_clear will fclose it
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
639 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
640 ov_clear(&vfile);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
641
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
642 return tuple;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
643 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
644
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
645 static gchar *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
646 vorbis_generate_title(OggVorbis_File * vorbisfile, gchar * filename)
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 /* Caller should hold vf_mutex */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
649 gchar *displaytitle = NULL;
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
650 Tuple *input;
545
f9dc3d58207a [svn] - display the stream title if it's available, like in mp3 streams
nenolod
parents: 544
diff changeset
651 gchar *tmp;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
652
2131
c162b6a0f11f majorly decraq the code
William Pitcock <nenolod@atheme.org>
parents: 2130
diff changeset
653 input = get_aud_tuple_for_vorbisfile(vorbisfile, filename);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
654
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
655 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
656 vorbis_cfg.tag_format : aud_get_gentitle_format());
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
657
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
658 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
659 {
f9dc3d58207a [svn] - display the stream title if it's available, like in mp3 streams
nenolod
parents: 544
diff changeset
660 gchar *old = displaytitle;
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
661
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
662 aud_tuple_associate_string(input, -1, "stream", tmp);
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
663 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
664
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
665 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
666
f9dc3d58207a [svn] - display the stream title if it's available, like in mp3 streams
nenolod
parents: 544
diff changeset
667 g_free(old);
f9dc3d58207a [svn] - display the stream title if it's available, like in mp3 streams
nenolod
parents: 544
diff changeset
668 g_free(tmp);
f9dc3d58207a [svn] - display the stream title if it's available, like in mp3 streams
nenolod
parents: 544
diff changeset
669 }
f9dc3d58207a [svn] - display the stream title if it's available, like in mp3 streams
nenolod
parents: 544
diff changeset
670
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
671 aud_tuple_free(input);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
672
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
673 return displaytitle;
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 static void
1433
d557d987e42d vorbis: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1417
diff changeset
677 vorbis_aboutbox(void)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
678 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
679 if (about_window)
2191
329267b09658 get rid of talking with GDK directly
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2134
diff changeset
680 gtk_window_present(GTK_WINDOW(about_window));
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
681 else
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
682 {
1677
f6f5603a0954 xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents: 1676
diff changeset
683 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
684 /*
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
685 * I18N: UTF-8 Translation: "Haavard Kvaalen" ->
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
686 * "H\303\245vard Kv\303\245len"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
687 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
688 _
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
689 ("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
690 "Original code by\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
691 "Tony Arcieri <bascule@inferno.tusculum.edu>\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
692 "Contributions from\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
693 "Chris Montgomery <monty@xiph.org>\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
694 "Peter Alm <peter@xmms.org>\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
695 "Michael Smith <msmith@labyrinth.edu.au>\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
696 "Jack Moffitt <jack@icecast.org>\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
697 "Jorn Baayen <jorn@nl.linux.org>\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
698 "Haavard Kvaalen <havardk@xmms.org>\n"
2351
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
699 "Gian-Carlo Pascutto <gcp@sjeng.org>\n"
db02ad480056 vorbis switched to floating-point output. RG stuff removed
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2329
diff changeset
700 "Eugene Zagidullin <e.asphyx@gmail.com>\n\n"
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
701 "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
702 _("Ok"), FALSE, NULL, NULL);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
703 g_signal_connect(G_OBJECT(about_window), "destroy",
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
704 G_CALLBACK(gtk_widget_destroyed), &about_window);
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 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
707
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 static void
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
710 vorbis_init(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
711 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
712 ConfigDb *db;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
713 gchar *tmp = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
714
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
715 memset(&vorbis_cfg, 0, sizeof(vorbis_config_t));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
716 vorbis_cfg.http_buffer_size = 128;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
717 vorbis_cfg.http_prebuffer = 25;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
718 vorbis_cfg.proxy_port = 8080;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
719 vorbis_cfg.proxy_use_auth = FALSE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
720 vorbis_cfg.proxy_user = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
721 vorbis_cfg.proxy_pass = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
722 vorbis_cfg.tag_override = FALSE;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
723 vorbis_cfg.tag_format = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
724
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
725 db = aud_cfg_db_open();
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
726 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
727 &vorbis_cfg.http_buffer_size);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
728 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
729 &vorbis_cfg.http_prebuffer);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
730 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
731 &vorbis_cfg.save_http_stream);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
732 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
733 &vorbis_cfg.save_http_path))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
734 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
735
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
736 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
737 &vorbis_cfg.tag_override);
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
738 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
739 &vorbis_cfg.tag_format))
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
740 vorbis_cfg.tag_format = g_strdup("%p - %t");
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
741
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
742 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
743 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
744 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
745
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
746 if (tmp != NULL)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
747 vorbis_cfg.proxy_port = atoi(tmp);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
748
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
749 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
750 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
751 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
752
2124
b8da6a0b0da2 s/bmp_cfg_/aud_cfg_/g
Matti Hamalainen <ccr@tnsp.org>
parents: 2106
diff changeset
753 aud_cfg_db_close(db);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
754
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
755 vf_mutex = g_mutex_new();
2032
55f2fd232291 associate with application/ogg mimetype.
William Pitcock <nenolod@atheme.org>
parents: 1998
diff changeset
756
55f2fd232291 associate with application/ogg mimetype.
William Pitcock <nenolod@atheme.org>
parents: 1998
diff changeset
757 aud_mime_set_plugin("application/ogg", &vorbis_ip);
0
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 static void
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
761 vorbis_cleanup(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
762 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
763 if (vorbis_cfg.save_http_path) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
764 free(vorbis_cfg.save_http_path);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
765 vorbis_cfg.save_http_path = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
766 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
767
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
768 if (vorbis_cfg.proxy_host) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
769 free(vorbis_cfg.proxy_host);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
770 vorbis_cfg.proxy_host = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
771 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
772
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
773 if (vorbis_cfg.proxy_user) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
774 free(vorbis_cfg.proxy_user);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
775 vorbis_cfg.proxy_user = NULL;
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 if (vorbis_cfg.proxy_pass) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
779 free(vorbis_cfg.proxy_pass);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
780 vorbis_cfg.proxy_pass = NULL;
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
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
783 if (vorbis_cfg.tag_format) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
784 free(vorbis_cfg.tag_format);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
785 vorbis_cfg.tag_format = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
786 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
787
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
788 if (vorbis_cfg.title_encoding) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
789 free(vorbis_cfg.title_encoding);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
790 vorbis_cfg.title_encoding = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
791 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
792
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
793 g_strfreev(vorbis_tag_encoding_list);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
794 g_mutex_free(vf_mutex);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
795 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
796
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
797 static size_t
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
798 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
799 {
478
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
800 VFSVorbisFile *handle = (VFSVorbisFile *) datasource;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
801
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
802 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
803 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
804
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
805 static int
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
806 ovcb_seek(void *datasource, int64_t offset, int whence)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
807 {
478
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
808 VFSVorbisFile *handle = (VFSVorbisFile *) datasource;
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
809
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
810 return aud_vfs_fseek(handle->fd, offset, whence);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
811 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
812
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
813 static int
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
814 ovcb_close(void *datasource)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
815 {
478
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
816 VFSVorbisFile *handle = (VFSVorbisFile *) datasource;
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
817
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
818 gint ret = 0;
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
819
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
820 if (handle->probe == FALSE)
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
821 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
822 ret = aud_vfs_fclose(handle->fd);
2329
7b38e28464ee Modified the playback loop to fix the last seconds skip (fixes bug #87)
Cristi Magherusan <majeru@atheme.org>
parents: 2212
diff changeset
823 /* 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
824 }
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
825
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
826 return ret;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
827 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
828
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
829 static long
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
830 ovcb_tell(void *datasource)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
831 {
478
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
832 VFSVorbisFile *handle = (VFSVorbisFile *) datasource;
a415ef9d663f [svn] - whoever wrote this plugin was a jerk
nenolod
parents: 477
diff changeset
833
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
834 return aud_vfs_ftell(handle->fd);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
835 }