annotate src/sndfile/plugin.c @ 2555:04b1b020be88

VFS file handle was not correctly closed and freed in certain situations, causing a filehandle shortage and crash. Fixed, based on patch and report by Teru KAMOGASHIRA.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 08 May 2008 22:16:12 +0300
parents 8d09a4d017ea
children bd3a24b39058
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
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
37 #include <audacious/plugin.h>
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
38 #include <audacious/util.h>
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
39 #include <audacious/i18n.h>
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
40 #include <audacious/output.h>
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
41 #include "plugin.h"
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
42
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
43 #include <sndfile.h>
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
44
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
45 static SNDFILE *sndfile = NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
46 static SF_INFO sfinfo;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
47
2550
6fdb69f0f169 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2549
diff changeset
48 static gint song_length;
6fdb69f0f169 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2549
diff changeset
49 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
50 static glong seek_time = -1;
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;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
125
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
126 decode_mutex = g_mutex_new();
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
127 decode_cond = g_cond_new();
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
128 }
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 static void
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
131 plugin_cleanup (void)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
132 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
133 g_cond_free(decode_cond);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
134 g_mutex_free(decode_mutex);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
135 }
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 static void
2550
6fdb69f0f169 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2549
diff changeset
138 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
139 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
140 VFSFile *vfsfile = NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
141 SNDFILE *tmp_sndfile;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
142 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
143 gboolean lossy = FALSE;
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
144 gchar *codec, *format, *subformat;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
145
2555
04b1b020be88 VFS file handle was not correctly closed and freed in certain situations,
Matti Hamalainen <ccr@tnsp.org>
parents: 2554
diff changeset
146 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
147 if ( sf_get_string(tmp_sndfile, SF_STR_TITLE) == NULL)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
148 aud_tuple_associate_string(ti, FIELD_TITLE, NULL, g_path_get_basename(filename));
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
149 else
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
150 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
151
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
152 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
153 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
154 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
155 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
156
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
157 if (!tmp_sndfile)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
158 return;
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 close_sndfile (tmp_sndfile, vfsfile);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
161
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
162 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
163 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
164
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
165 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
166 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
167 case SF_FORMAT_WAV:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
168 case SF_FORMAT_WAVEX:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
169 format = "Microsoft WAV";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
170 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
171 case SF_FORMAT_AIFF:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
172 format = "Apple/SGI AIFF";
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_AU:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
175 format = "Sun/NeXT AU";
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_RAW:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
178 format = "Raw PCM data";
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_PAF:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
181 format = "Ensoniq PARIS";
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_SVX:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
184 format = "Amiga IFF / SVX8 / SV16";
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_NIST:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
187 format = "Sphere NIST";
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_VOC:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
190 format = "Creative VOC";
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_IRCAM:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
193 format = "Berkeley/IRCAM/CARL";
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_W64:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
196 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
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_MAT4:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
199 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
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_MAT5:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
202 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
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_PVF:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
205 format = "Portable Voice Format";
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_XI:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
208 format = "Fasttracker 2 Extended Instrument";
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_HTK:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
211 format = "HMM Tool Kit";
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_SDS:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
214 format = "Midi Sample Dump Standard";
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_AVR:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
217 format = "Audio Visual Research";
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_SD2:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
220 format = "Sound Designer 2";
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_FLAC:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
223 format = "Free Lossless Audio Codec";
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_CAF:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
226 format = "Core Audio File";
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 default:
2553
b119d6f2e6c8 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2552
diff changeset
229 format = "Unknown sndfile";
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
230 }
2553
b119d6f2e6c8 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2552
diff changeset
231
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
232 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
233 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
234 case SF_FORMAT_PCM_S8:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
235 subformat = "signed 8 bit";
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
236 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
237 case SF_FORMAT_PCM_16:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
238 subformat = "signed 16 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_24:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
241 subformat = "signed 24 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_32:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
244 subformat = "signed 32 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_U8:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
247 subformat = "unsigned 8 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_FLOAT:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
250 subformat = "32 bit float";
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_DOUBLE:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
253 subformat = "64 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_ULAW:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
256 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
257 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
258 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
259 case SF_FORMAT_ALAW:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
260 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
261 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
262 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
263 case SF_FORMAT_IMA_ADPCM:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
264 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
265 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
266 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
267 case SF_FORMAT_MS_ADPCM:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
268 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
269 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
270 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
271 case SF_FORMAT_GSM610:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
272 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
273 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
274 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
275 case SF_FORMAT_VOX_ADPCM:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
276 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
277 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
278 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
279 case SF_FORMAT_G721_32:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
280 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
281 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
282 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
283 case SF_FORMAT_G723_24:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
284 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
285 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
286 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
287 case SF_FORMAT_G723_40:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
288 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
289 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
290 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
291 case SF_FORMAT_DWVW_12:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
292 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
293 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
294 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
295 case SF_FORMAT_DWVW_16:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
296 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
297 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
298 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
299 case SF_FORMAT_DWVW_24:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
300 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
301 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
302 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
303 case SF_FORMAT_DWVW_N:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
304 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
305 lossy = TRUE;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
306 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
307 case SF_FORMAT_DPCM_8:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
308 subformat = "8 bit differential PCM";
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_16:
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
311 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
312 break;
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
313 default:
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
314 subformat = NULL;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
315 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
316
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
317 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
318 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
319 else
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
320 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
321 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
322 g_free(codec);
2553
b119d6f2e6c8 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2552
diff changeset
323
2552
7d7f7d9ae98e Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents: 2551
diff changeset
324 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
325 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
326
2551
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
327 static gchar *
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
328 get_title(gchar *filename)
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
329 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
330 Tuple *tuple;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
331 gchar *title;
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 = 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
334 fill_song_tuple(filename, tuple);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
335 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
336 if (*title == '\0')
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
337 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
338 g_free(title);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
339 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
340 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
341
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
342 aud_tuple_free(tuple);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
343 return title;
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
2550
6fdb69f0f169 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2549
diff changeset
346 static gint
6fdb69f0f169 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2549
diff changeset
347 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
348 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
349 VFSFile *vfsfile = NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
350 SNDFILE *tmp_sndfile;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
351 SF_INFO tmp_sfinfo;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
352
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
353 /* 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
354 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
355
2553
b119d6f2e6c8 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2552
diff changeset
356 if (!tmp_sndfile)
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
357 return FALSE;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
358
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
359 /* 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
360 close_sndfile (tmp_sndfile, vfsfile);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
361 tmp_sndfile = NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
362
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
363 return TRUE;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
364 }
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 static gpointer
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
367 play_loop (gpointer arg)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
368 {
2554
8d09a4d017ea Using a static buffer, eh? Don't. Just don't.
Matti Hamalainen <ccr@tnsp.org>
parents: 2553
diff changeset
369 gshort buffer[BUFFER_SIZE];
2550
6fdb69f0f169 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2549
diff changeset
370 gint samples;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
371 InputPlayback *playback = arg;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
372
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
373 for (;;)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
374 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
375 GTimeVal sleeptime;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
376
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
377 /* 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
378 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
379
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
380 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
381 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
382 playback->playing == TRUE) {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
383 g_get_current_time(&sleeptime);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
384 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
385 g_mutex_lock(decode_mutex);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
386 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
387 g_mutex_unlock(decode_mutex);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
388
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
389 if (playback->playing == FALSE)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
390 break;
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
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
393 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
394 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
395 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
396 else {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
397 while(playback->output->buffer_playing()) {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
398 g_get_current_time(&sleeptime);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
399 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
400 g_mutex_lock(decode_mutex);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
401 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
402 g_mutex_unlock(decode_mutex);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
403
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
404 if(playback->playing == FALSE)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
405 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
406 }
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 playback->eof = TRUE;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
409 playback->playing = FALSE;
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 g_mutex_unlock(decode_mutex);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
412 break;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
413 }
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 /* Do seek if seek_time is valid. */
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
416 if (seek_time >= 0) {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
417 sf_seek (sndfile, (sf_count_t)((gint64)seek_time * (gint64)sfinfo.samplerate / 1000L),
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
418 SEEK_SET);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
419 playback->output->flush (seek_time);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
420 seek_time = -1;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
421 }
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 sf_close (sndfile);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
428 sndfile = NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
429 seek_time = -1;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
430
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
431 playback->output->close_audio();
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 return NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
434 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
435
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
436 static void
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
437 play_start (InputPlayback *playback)
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 VFSFile *vfsfile = NULL;
2550
6fdb69f0f169 Use Glib types.
Matti Hamalainen <ccr@tnsp.org>
parents: 2549
diff changeset
440 gint pcmbitwidth;
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
441 gchar *song_title;
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 if (sndfile) /* already opened */
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
444 return;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
445
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
446 pcmbitwidth = 32;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
447 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
448
2555
04b1b020be88 VFS file handle was not correctly closed and freed in certain situations,
Matti Hamalainen <ccr@tnsp.org>
parents: 2554
diff changeset
449 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
450
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
451 if (!sndfile)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
452 return;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
453
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
454 bit_rate = sfinfo.samplerate * pcmbitwidth;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
455
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
456 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
457 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
458 else
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
459 song_length = 0;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
460
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
461 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
462 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
463 close_sndfile (sndfile, vfsfile);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
464 sndfile = NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
465 return;
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
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
468 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
469 g_free (song_title);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
470
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
471 playback->playing = TRUE;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
472
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
473 decode_thread = g_thread_self();
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
474 playback->set_pb_ready(playback);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
475 play_loop(playback);
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
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
478 static void
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
479 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
480 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
481 playback->output->pause(p);
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 static void
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
485 play_stop (InputPlayback *playback)
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 if (decode_thread == NULL)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
488 return;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
489
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
490 g_mutex_lock(decode_mutex);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
491 playback->playing = FALSE;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
492 g_mutex_unlock(decode_mutex);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
493 g_cond_signal(decode_cond);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
494
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
495 g_thread_join (decode_thread);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
496
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
497 sndfile = NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
498 decode_thread = NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
499 seek_time = -1;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
500 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
501
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
502 static void
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
503 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
504 {
2553
b119d6f2e6c8 Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 2552
diff changeset
505 if (!sfinfo.seekable)
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
506 return;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
507
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
508 seek_time = (glong)millisecond;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
509
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
510 while (seek_time != -1)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
511 g_usleep (80000);
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
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
514 static void
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
515 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
516 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
517 gulong millisecond = time * 1000;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
518 file_mseek(playback, millisecond);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
519 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
520
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
521 static Tuple*
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
522 get_song_tuple (gchar *filename)
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 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
525 fill_song_tuple(filename, ti);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
526 return ti;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
527 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
528
2551
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
529 static gint
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
530 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
531 {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
532 SNDFILE *tmp_sndfile;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
533 SF_INFO tmp_sfinfo;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
534
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
535 /* 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
536 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
537
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
538 if (!tmp_sndfile)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
539 return FALSE;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
540
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
541 /* 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
542 sf_close (tmp_sndfile);
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
543 tmp_sndfile = NULL;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
544
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
545 return TRUE;
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
546 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
547
2549
f6efe94f2793 Fix uninitialied GtkWidget variable in about box creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2500
diff changeset
548 static GtkWidget *sndfile_about_box = NULL;
f6efe94f2793 Fix uninitialied GtkWidget variable in about box creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2500
diff changeset
549
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
550 static void plugin_about(void)
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
551 {
2549
f6efe94f2793 Fix uninitialied GtkWidget variable in about box creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2500
diff changeset
552 if (!sndfile_about_box)
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
553 {
2551
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
554 sndfile_about_box = audacious_info_dialog(
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
555 _("About sndfile plugin"),
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
556 _("Adapted for Audacious usage by Tony Vroon <chainsaw@gentoo.org>\n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
557 "from the xmms_sndfile plugin which is:\n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
558 "Copyright (C) 2000, 2002 Erik de Castro Lopo\n\n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
559 "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
560 "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
561 "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
562 "(at your option) any later version. \n \n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
563 "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
564 "but WITHOUT ANY WARRANTY ; without even the implied warranty of \n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
565 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
566 "See the GNU General Public License for more details. \n\n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
567 "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
568 "License along with this program ; if not, write to \n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
569 "the Free Software Foundation, Inc., \n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
570 "51 Franklin Street, Fifth Floor, \n"
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
571 "Boston, MA 02110-1301 USA"),
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
572 _("Ok"), FALSE, NULL, NULL);
2549
f6efe94f2793 Fix uninitialied GtkWidget variable in about box creation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2500
diff changeset
573 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
574 (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
575 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
576 }
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
577
2551
92300fe06f15 Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 2550
diff changeset
578
2303
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
579 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
580
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
581 InputPlugin sndfile_ip = {
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
582 .description = "sndfile plugin",
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
583 .init = plugin_init,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
584 .about = plugin_about,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
585 .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
586 .play_file = play_start,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
587 .stop = play_stop,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
588 .pause = play_pause,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
589 .seek = file_seek,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
590 .cleanup = plugin_cleanup,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
591 .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
592 .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
593 .vfs_extensions = fmts,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
594 .mseek = file_mseek,
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
595 };
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_iplist[] = { &sndfile_ip, NULL };
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
598
5561e63e9133 threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff changeset
599 SIMPLE_INPUT_PLUGIN(sndfile, sndfile_iplist)