annotate src/sndfile/plugin.c @ 2999:e2e8f927a08a

Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
author Tony Vroon <chainsaw@gentoo.org>
date Wed, 04 Mar 2009 12:48:20 +0000
parents 4d778b7a19c6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
1 /* Audacious - Cross-platform multimedia player
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
2 * Copyright (C) 2005 Audacious development team.
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
3 *
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
4 * Based on the xmms_sndfile input plugin:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
5 * Copyright (C) 2000, 2002 Erik de Castro Lopo
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
6 *
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
10 * (at your option) any later version.
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
11 *
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
15 * GNU General Public License for more details.
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
16 *
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
20 */
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
21
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
22 /*
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
23 * Rewritten 17-Feb-2007 (nenolod):
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
24 * - now uses conditional variables to ensure that sndfile mutex is
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
25 * entirely protected.
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
26 * - pausing works now
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
27 * - fixed some potential race conditions when dealing with NFS.
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
28 * - TITLE_LEN removed
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
29 */
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
30
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
31 #include "config.h"
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
32
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
33 #include <glib.h>
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
34 #include <string.h>
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
35 #include <math.h>
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
36
2971
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2576
diff changeset
37 #include <audlegacy/plugin.h>
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2576
diff changeset
38 #include <audlegacy/i18n.h>
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2576
diff changeset
39 #include <audlegacy/output.h>
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
40 #include "plugin.h"
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
41
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
42 #include <sndfile.h>
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
43
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
44 static SNDFILE *sndfile = NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
45 static SF_INFO sfinfo;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
46
2550
6fdb69f0f169 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2549
diff changeset
47 static gint song_length;
6fdb69f0f169 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2549
diff changeset
48 static gint bit_rate = 0;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
49 static glong seek_time = -1;
2999
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
50 static volatile char pause_flag;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
51
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
52 static GThread *decode_thread;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
53 static GMutex *decode_mutex;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
54 static GCond *decode_cond;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
55
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
56
2551
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
57 static sf_count_t
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
58 sf_get_filelen (void *user_data)
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
59 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
60 return aud_vfs_fsize (user_data);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
61 }
2551
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
62
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
63 static sf_count_t
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
64 sf_vseek (sf_count_t offset, int whence, void *user_data)
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
65 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
66 return aud_vfs_fseek(user_data, offset, whence);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
67 }
2551
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
68
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
69 static sf_count_t
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
70 sf_vread (void *ptr, sf_count_t count, void *user_data)
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
71 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
72 return aud_vfs_fread(ptr, 1, count, user_data);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
73 }
2551
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
74
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
75 static sf_count_t
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
76 sf_vwrite (const void *ptr, sf_count_t count, void *user_data)
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
77 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
78 return aud_vfs_fwrite(ptr, 1, count, user_data);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
79 }
2551
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
80
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
81 static sf_count_t
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
82 sf_tell (void *user_data)
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
83 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
84 return aud_vfs_ftell(user_data);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
85 }
2551
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
86
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
87 static SF_VIRTUAL_IO sf_virtual_io =
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
88 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
89 sf_get_filelen,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
90 sf_vseek,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
91 sf_vread,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
92 sf_vwrite,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
93 sf_tell
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
94 };
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
95
2551
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
96
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
97 static SNDFILE *
2555
04b1b020be88 VFS file handle was not correctly closed and freed in certain situations,
Matti Hamalainen <ccr@tnsp.org>
parents: 2554
diff changeset
98 open_sndfile_from_uri(gchar *filename, VFSFile **vfsfile, SF_INFO *tmp_sfinfo)
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
99 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
100 SNDFILE *snd_file = NULL;
2555
04b1b020be88 VFS file handle was not correctly closed and freed in certain situations,
Matti Hamalainen <ccr@tnsp.org>
parents: 2554
diff changeset
101 *vfsfile = aud_vfs_fopen(filename, "rb");
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
102
2555
04b1b020be88 VFS file handle was not correctly closed and freed in certain situations,
Matti Hamalainen <ccr@tnsp.org>
parents: 2554
diff changeset
103 if (*vfsfile == NULL)
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
104 return NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
105
2555
04b1b020be88 VFS file handle was not correctly closed and freed in certain situations,
Matti Hamalainen <ccr@tnsp.org>
parents: 2554
diff changeset
106 snd_file = sf_open_virtual (&sf_virtual_io, SFM_READ, tmp_sfinfo, *vfsfile);
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
107 if (snd_file == NULL)
2555
04b1b020be88 VFS file handle was not correctly closed and freed in certain situations,
Matti Hamalainen <ccr@tnsp.org>
parents: 2554
diff changeset
108 aud_vfs_fclose(*vfsfile);
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
109
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
110 return snd_file;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
111 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
112
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
113 static void
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
114 close_sndfile(SNDFILE *snd_file, VFSFile *vfsfile)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
115 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
116 sf_close(snd_file);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
117 aud_vfs_fclose(vfsfile);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
118 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
119
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
120
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
121 static void
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
122 plugin_init (void)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
123 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
124 seek_time = -1;
2999
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
125 pause_flag = 0;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
126
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
127 decode_mutex = g_mutex_new();
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
128 decode_cond = g_cond_new();
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
129 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
130
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
131 static void
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
132 plugin_cleanup (void)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
133 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
134 g_cond_free(decode_cond);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
135 g_mutex_free(decode_mutex);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
136 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
137
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
138 static void
2550
6fdb69f0f169 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2549
diff changeset
139 fill_song_tuple (gchar *filename, Tuple *ti)
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
140 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
141 VFSFile *vfsfile = NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
142 SNDFILE *tmp_sndfile;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
143 SF_INFO tmp_sfinfo;
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
144 gboolean lossy = FALSE;
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
145 gchar *codec, *format, *subformat;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
146
2555
04b1b020be88 VFS file handle was not correctly closed and freed in certain situations,
Matti Hamalainen <ccr@tnsp.org>
parents: 2554
diff changeset
147 tmp_sndfile = open_sndfile_from_uri(filename, &vfsfile, &tmp_sfinfo);
2975
4d778b7a19c6 now sndfile can display Japanese file name.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2971
diff changeset
148 if ( sf_get_string(tmp_sndfile, SF_STR_TITLE) == NULL) {
4d778b7a19c6 now sndfile can display Japanese file name.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2971
diff changeset
149 gchar *utfname = aud_uri_to_display_basename(filename);
4d778b7a19c6 now sndfile can display Japanese file name.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2971
diff changeset
150 aud_tuple_associate_string(ti, FIELD_TITLE, NULL, utfname);
4d778b7a19c6 now sndfile can display Japanese file name.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2971
diff changeset
151 }
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
152 else
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
153 aud_tuple_associate_string(ti, FIELD_TITLE, NULL, sf_get_string(tmp_sndfile, SF_STR_TITLE));
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
154
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
155 aud_tuple_associate_string(ti, FIELD_ARTIST, NULL, sf_get_string(tmp_sndfile, SF_STR_ARTIST));
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
156 aud_tuple_associate_string(ti, FIELD_COMMENT, NULL, sf_get_string(tmp_sndfile, SF_STR_COMMENT));
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
157 aud_tuple_associate_string(ti, FIELD_DATE, NULL, sf_get_string(tmp_sndfile, SF_STR_DATE));
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
158 aud_tuple_associate_string(ti, -1, "software", sf_get_string(tmp_sndfile, SF_STR_SOFTWARE));
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
159
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
160 if (!tmp_sndfile)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
161 return;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
162
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
163 close_sndfile (tmp_sndfile, vfsfile);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
164
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
165 if (tmp_sfinfo.samplerate > 0)
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
166 aud_tuple_associate_int(ti, FIELD_LENGTH, NULL, (gint) ceil (1000.0 * tmp_sfinfo.frames / tmp_sfinfo.samplerate));
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
167
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
168 switch (tmp_sfinfo.format & SF_FORMAT_TYPEMASK)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
169 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
170 case SF_FORMAT_WAV:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
171 case SF_FORMAT_WAVEX:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
172 format = "Microsoft WAV";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
173 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
174 case SF_FORMAT_AIFF:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
175 format = "Apple/SGI AIFF";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
176 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
177 case SF_FORMAT_AU:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
178 format = "Sun/NeXT AU";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
179 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
180 case SF_FORMAT_RAW:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
181 format = "Raw PCM data";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
182 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
183 case SF_FORMAT_PAF:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
184 format = "Ensoniq PARIS";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
185 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
186 case SF_FORMAT_SVX:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
187 format = "Amiga IFF / SVX8 / SV16";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
188 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
189 case SF_FORMAT_NIST:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
190 format = "Sphere NIST";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
191 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
192 case SF_FORMAT_VOC:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
193 format = "Creative VOC";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
194 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
195 case SF_FORMAT_IRCAM:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
196 format = "Berkeley/IRCAM/CARL";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
197 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
198 case SF_FORMAT_W64:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
199 format = "Sonic Foundry's 64 bit RIFF/WAV";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
200 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
201 case SF_FORMAT_MAT4:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
202 format = "Matlab (tm) V4.2 / GNU Octave 2.0";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
203 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
204 case SF_FORMAT_MAT5:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
205 format = "Matlab (tm) V5.0 / GNU Octave 2.1";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
206 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
207 case SF_FORMAT_PVF:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
208 format = "Portable Voice Format";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
209 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
210 case SF_FORMAT_XI:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
211 format = "Fasttracker 2 Extended Instrument";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
212 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
213 case SF_FORMAT_HTK:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
214 format = "HMM Tool Kit";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
215 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
216 case SF_FORMAT_SDS:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
217 format = "Midi Sample Dump Standard";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
218 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
219 case SF_FORMAT_AVR:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
220 format = "Audio Visual Research";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
221 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
222 case SF_FORMAT_SD2:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
223 format = "Sound Designer 2";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
224 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
225 case SF_FORMAT_FLAC:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
226 format = "Free Lossless Audio Codec";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
227 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
228 case SF_FORMAT_CAF:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
229 format = "Core Audio File";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
230 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
231 default:
2553
b119d6f2e6c8 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2552
diff changeset
232 format = "Unknown sndfile";
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
233 }
2975
4d778b7a19c6 now sndfile can display Japanese file name.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2971
diff changeset
234
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
235 switch (tmp_sfinfo.format & SF_FORMAT_SUBMASK)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
236 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
237 case SF_FORMAT_PCM_S8:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
238 subformat = "signed 8 bit";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
239 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
240 case SF_FORMAT_PCM_16:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
241 subformat = "signed 16 bit";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
242 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
243 case SF_FORMAT_PCM_24:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
244 subformat = "signed 24 bit";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
245 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
246 case SF_FORMAT_PCM_32:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
247 subformat = "signed 32 bit";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
248 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
249 case SF_FORMAT_PCM_U8:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
250 subformat = "unsigned 8 bit";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
251 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
252 case SF_FORMAT_FLOAT:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
253 subformat = "32 bit float";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
254 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
255 case SF_FORMAT_DOUBLE:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
256 subformat = "64 bit float";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
257 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
258 case SF_FORMAT_ULAW:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
259 subformat = "U-Law";
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
260 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
261 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
262 case SF_FORMAT_ALAW:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
263 subformat = "A-Law";
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
264 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
265 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
266 case SF_FORMAT_IMA_ADPCM:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
267 subformat = "IMA ADPCM";
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
268 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
269 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
270 case SF_FORMAT_MS_ADPCM:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
271 subformat = "MS ADPCM";
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
272 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
273 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
274 case SF_FORMAT_GSM610:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
275 subformat = "GSM 6.10";
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
276 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
277 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
278 case SF_FORMAT_VOX_ADPCM:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
279 subformat = "Oki Dialogic ADPCM";
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
280 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
281 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
282 case SF_FORMAT_G721_32:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
283 subformat = "32kbs G721 ADPCM";
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
284 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
285 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
286 case SF_FORMAT_G723_24:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
287 subformat = "24kbs G723 ADPCM";
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
288 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
289 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
290 case SF_FORMAT_G723_40:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
291 subformat = "40kbs G723 ADPCM";
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
292 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
293 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
294 case SF_FORMAT_DWVW_12:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
295 subformat = "12 bit Delta Width Variable Word";
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
296 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
297 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
298 case SF_FORMAT_DWVW_16:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
299 subformat = "16 bit Delta Width Variable Word";
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
300 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
301 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
302 case SF_FORMAT_DWVW_24:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
303 subformat = "24 bit Delta Width Variable Word";
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
304 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
305 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
306 case SF_FORMAT_DWVW_N:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
307 subformat = "N bit Delta Width Variable Word";
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
308 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
309 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
310 case SF_FORMAT_DPCM_8:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
311 subformat = "8 bit differential PCM";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
312 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
313 case SF_FORMAT_DPCM_16:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
314 subformat = "16 bit differential PCM";
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
315 break;
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
316 default:
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
317 subformat = NULL;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
318 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
319
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
320 if (subformat != NULL)
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
321 codec = g_strdup_printf("%s (%s)", format, subformat);
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
322 else
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
323 codec = g_strdup_printf("%s", format);
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
324 aud_tuple_associate_string(ti, FIELD_CODEC, NULL, codec);
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
325 g_free(codec);
2975
4d778b7a19c6 now sndfile can display Japanese file name.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2971
diff changeset
326
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
327 aud_tuple_associate_string(ti, FIELD_QUALITY, NULL, lossy ? "lossy" : "lossless");
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
328 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
329
2551
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
330 static gchar *
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
331 get_title(gchar *filename)
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
332 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
333 Tuple *tuple;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
334 gchar *title;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
335
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
336 tuple = aud_tuple_new_from_filename(filename);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
337 fill_song_tuple(filename, tuple);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
338 title = aud_tuple_formatter_make_title_string(tuple, aud_get_gentitle_format());
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
339 if (*title == '\0')
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
340 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
341 g_free(title);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
342 title = g_strdup(aud_tuple_get_string(tuple, FIELD_FILE_NAME, NULL));
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
343 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
344
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
345 aud_tuple_free(tuple);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
346 return title;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
347 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
348
2550
6fdb69f0f169 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2549
diff changeset
349 static gint
6fdb69f0f169 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2549
diff changeset
350 is_our_file (gchar *filename)
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
351 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
352 VFSFile *vfsfile = NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
353 SNDFILE *tmp_sndfile;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
354 SF_INFO tmp_sfinfo;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
355
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
356 /* Have to open the file to see if libsndfile can handle it. */
2555
04b1b020be88 VFS file handle was not correctly closed and freed in certain situations,
Matti Hamalainen <ccr@tnsp.org>
parents: 2554
diff changeset
357 tmp_sndfile = open_sndfile_from_uri(filename, &vfsfile, &tmp_sfinfo);
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
358
2553
b119d6f2e6c8 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2552
diff changeset
359 if (!tmp_sndfile)
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
360 return FALSE;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
361
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
362 /* It can so close file and return TRUE. */
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
363 close_sndfile (tmp_sndfile, vfsfile);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
364 tmp_sndfile = NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
365
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
366 return TRUE;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
367 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
368
2999
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
369 static void do_seek (InputPlayback * playback) {
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
370 playback->output->flush (seek_time);
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
371 sf_seek (sndfile, (long long) seek_time * sfinfo.samplerate / 1000, SEEK_SET);
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
372 seek_time = -1;
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
373 }
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
374
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
375 static void do_pause (InputPlayback * playback) {
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
376 playback->output->pause (1);
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
377 while (pause_flag) {
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
378 if (seek_time != -1)
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
379 do_seek (playback);
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
380 g_usleep(50000);
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
381 }
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
382 playback->output->pause (0);
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
383 }
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
384
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
385 static gpointer
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
386 play_loop (gpointer arg)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
387 {
2554
8d09a4d017ea Using a static buffer, eh? Don't. Just don't.
Matti Hamalainen <ccr@tnsp.org>
parents: 2553
diff changeset
388 gshort buffer[BUFFER_SIZE];
2550
6fdb69f0f169 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2549
diff changeset
389 gint samples;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
390 InputPlayback *playback = arg;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
391
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
392 for (;;)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
393 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
394 GTimeVal sleeptime;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
395
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
396 /* sf_read_short will return 0 for all reads at EOF. */
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
397 samples = sf_read_short (sndfile, buffer, BUFFER_SIZE);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
398
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
399 if (samples > 0 && playback->playing == TRUE) {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
400 while ((playback->output->buffer_free () < samples) &&
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
401 playback->playing == TRUE) {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
402 g_get_current_time(&sleeptime);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
403 g_time_val_add(&sleeptime, 500000);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
404 g_mutex_lock(decode_mutex);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
405 g_cond_timed_wait(decode_cond, decode_mutex, &sleeptime);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
406 g_mutex_unlock(decode_mutex);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
407
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
408 if (playback->playing == FALSE)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
409 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
410 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
411
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
412 playback->pass_audio(playback, FMT_S16_NE, sfinfo.channels,
2554
8d09a4d017ea Using a static buffer, eh? Don't. Just don't.
Matti Hamalainen <ccr@tnsp.org>
parents: 2553
diff changeset
413 samples * sizeof(buffer[0]), buffer, &playback->playing);
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
414 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
415 else {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
416 while(playback->output->buffer_playing()) {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
417 g_get_current_time(&sleeptime);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
418 g_time_val_add(&sleeptime, 500000);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
419 g_mutex_lock(decode_mutex);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
420 g_cond_timed_wait(decode_cond, decode_mutex, &sleeptime);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
421 g_mutex_unlock(decode_mutex);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
422
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
423 if(playback->playing == FALSE)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
424 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
425 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
426
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
427 playback->eof = TRUE;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
428 playback->playing = FALSE;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
429
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
430 g_mutex_unlock(decode_mutex);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
431 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
432 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
433
2999
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
434 if (seek_time != -1)
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
435 do_seek (playback);
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
436 if (pause_flag)
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
437 do_pause (playback);
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
438
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
439 if (playback->playing == FALSE)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
440 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
441 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
442
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
443 sf_close (sndfile);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
444 sndfile = NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
445 seek_time = -1;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
446
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
447 playback->output->close_audio();
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
448
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
449 return NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
450 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
451
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
452 static void
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
453 play_start (InputPlayback *playback)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
454 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
455 VFSFile *vfsfile = NULL;
2550
6fdb69f0f169 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2549
diff changeset
456 gint pcmbitwidth;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
457 gchar *song_title;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
458
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
459 if (sndfile) /* already opened */
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
460 return;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
461
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
462 pcmbitwidth = 32;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
463 song_title = get_title(playback->filename);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
464
2555
04b1b020be88 VFS file handle was not correctly closed and freed in certain situations,
Matti Hamalainen <ccr@tnsp.org>
parents: 2554
diff changeset
465 sndfile = open_sndfile_from_uri(playback->filename, &vfsfile, &sfinfo);
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
466
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
467 if (!sndfile)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
468 return;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
469
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
470 bit_rate = sfinfo.samplerate * pcmbitwidth;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
471
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
472 if (sfinfo.samplerate > 0)
2554
8d09a4d017ea Using a static buffer, eh? Don't. Just don't.
Matti Hamalainen <ccr@tnsp.org>
parents: 2553
diff changeset
473 song_length = (gint) ceil (1000.0 * sfinfo.frames / sfinfo.samplerate);
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
474 else
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
475 song_length = 0;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
476
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
477 if (! playback->output->open_audio (FMT_S16_NE, sfinfo.samplerate, sfinfo.channels))
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
478 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
479 close_sndfile (sndfile, vfsfile);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
480 sndfile = NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
481 return;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
482 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
483
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
484 playback->set_params(playback, song_title, song_length, bit_rate, sfinfo.samplerate, sfinfo.channels);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
485 g_free (song_title);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
486
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
487 playback->playing = TRUE;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
488
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
489 decode_thread = g_thread_self();
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
490 playback->set_pb_ready(playback);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
491 play_loop(playback);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
492 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
493
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
494 static void
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
495 play_pause (InputPlayback *playback, gshort p)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
496 {
2999
e2e8f927a08a Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2975
diff changeset
497 pause_flag = p;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
498 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
499
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
500 static void
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
501 play_stop (InputPlayback *playback)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
502 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
503 if (decode_thread == NULL)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
504 return;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
505
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
506 g_mutex_lock(decode_mutex);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
507 playback->playing = FALSE;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
508 g_mutex_unlock(decode_mutex);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
509 g_cond_signal(decode_cond);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
510
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
511 g_thread_join (decode_thread);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
512
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
513 sndfile = NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
514 decode_thread = NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
515 seek_time = -1;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
516 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
517
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
518 static void
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
519 file_mseek (InputPlayback *playback, gulong millisecond)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
520 {
2553
b119d6f2e6c8 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2552
diff changeset
521 if (!sfinfo.seekable)
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
522 return;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
523
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
524 seek_time = (glong)millisecond;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
525
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
526 while (seek_time != -1)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
527 g_usleep (80000);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
528 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
529
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
530 static void
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
531 file_seek (InputPlayback *playback, gint time)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
532 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
533 gulong millisecond = time * 1000;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
534 file_mseek(playback, millisecond);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
535 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
536
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
537 static Tuple*
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
538 get_song_tuple (gchar *filename)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
539 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
540 Tuple *ti = aud_tuple_new_from_filename(filename);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
541 fill_song_tuple(filename, ti);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
542 return ti;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
543 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
544
2551
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
545 static gint
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
546 is_our_file_from_vfs(gchar *filename, VFSFile *fin)
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
547 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
548 SNDFILE *tmp_sndfile;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
549 SF_INFO tmp_sfinfo;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
550
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
551 /* Have to open the file to see if libsndfile can handle it. */
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
552 tmp_sndfile = sf_open_virtual (&sf_virtual_io, SFM_READ, &tmp_sfinfo, fin);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
553
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
554 if (!tmp_sndfile)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
555 return FALSE;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
556
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
557 /* It can so close file and return TRUE. */
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
558 sf_close (tmp_sndfile);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
559 tmp_sndfile = NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
560
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
561 return TRUE;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
562 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
563
2549
f6efe94f2793 Fix uninitialied GtkWidget variable in about box creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2500
diff changeset
564 static GtkWidget *sndfile_about_box = NULL;
f6efe94f2793 Fix uninitialied GtkWidget variable in about box creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2500
diff changeset
565
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
566 static void plugin_about(void)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
567 {
2549
f6efe94f2793 Fix uninitialied GtkWidget variable in about box creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2500
diff changeset
568 if (!sndfile_about_box)
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
569 {
2551
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
570 sndfile_about_box = audacious_info_dialog(
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
571 _("About sndfile plugin"),
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
572 _("Adapted for Audacious usage by Tony Vroon <chainsaw@gentoo.org>\n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
573 "from the xmms_sndfile plugin which is:\n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
574 "Copyright (C) 2000, 2002 Erik de Castro Lopo\n\n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
575 "This program is free software ; you can redistribute it and/or modify \n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
576 "it under the terms of the GNU General Public License as published by \n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
577 "the Free Software Foundation ; either version 2 of the License, or \n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
578 "(at your option) any later version. \n \n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
579 "This program is distributed in the hope that it will be useful, \n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
580 "but WITHOUT ANY WARRANTY ; without even the implied warranty of \n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
581 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
582 "See the GNU General Public License for more details. \n\n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
583 "You should have received a copy of the GNU General Public \n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
584 "License along with this program ; if not, write to \n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
585 "the Free Software Foundation, Inc., \n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
586 "51 Franklin Street, Fifth Floor, \n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
587 "Boston, MA 02110-1301 USA"),
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
588 _("Ok"), FALSE, NULL, NULL);
2549
f6efe94f2793 Fix uninitialied GtkWidget variable in about box creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2500
diff changeset
589 g_signal_connect(G_OBJECT(sndfile_about_box), "destroy",
f6efe94f2793 Fix uninitialied GtkWidget variable in about box creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2500
diff changeset
590 (GCallback)gtk_widget_destroyed, &sndfile_about_box);
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
591 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
592 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
593
2551
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
594
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
595 static gchar *fmts[] = { "aiff", "au", "raw", "wav", NULL };
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
596
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
597 InputPlugin sndfile_ip = {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
598 .description = "sndfile plugin",
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
599 .init = plugin_init,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
600 .about = plugin_about,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
601 .is_our_file = is_our_file,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
602 .play_file = play_start,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
603 .stop = play_stop,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
604 .pause = play_pause,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
605 .seek = file_seek,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
606 .cleanup = plugin_cleanup,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
607 .get_song_tuple = get_song_tuple,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
608 .is_our_file_from_vfs = is_our_file_from_vfs,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
609 .vfs_extensions = fmts,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
610 .mseek = file_mseek,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
611 };
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
612
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
613 InputPlugin *sndfile_iplist[] = { &sndfile_ip, NULL };
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
614
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
615 SIMPLE_INPUT_PLUGIN(sndfile, sndfile_iplist)