Mercurial > audlegacy-plugins
annotate src/sndfile/plugin.c @ 2854:43557eb3180f
playback
author | Paula Stanciu <paula.stanciu@gmail.com> |
---|---|
date | Wed, 30 Jul 2008 17:49:43 +0300 |
parents | bd3a24b39058 |
children | 3134a0987162 |
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/i18n.h> |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
39 #include <audacious/output.h> |
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 | 47 static gint song_length; |
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; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
50 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
51 static GThread *decode_thread; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
52 static GMutex *decode_mutex; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
53 static GCond *decode_cond; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
54 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
55 |
2551
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
56 static sf_count_t |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
57 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
|
58 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
59 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
|
60 } |
2551
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
61 |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
62 static sf_count_t |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
63 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
|
64 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
65 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
|
66 } |
2551
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
67 |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
68 static sf_count_t |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
69 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
|
70 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
71 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
|
72 } |
2551
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
73 |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
74 static sf_count_t |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
75 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
|
76 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
77 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
|
78 } |
2551
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
79 |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
80 static sf_count_t |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
81 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
|
82 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
83 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
|
84 } |
2551
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
85 |
2303
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
86 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
|
87 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
88 sf_get_filelen, |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
89 sf_vseek, |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
90 sf_vread, |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
91 sf_vwrite, |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
92 sf_tell |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
93 }; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
94 |
2551
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
95 |
2303
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
96 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
|
97 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
|
98 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
99 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
|
100 *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
|
101 |
2555
04b1b020be88
VFS file handle was not correctly closed and freed in certain situations,
Matti Hamalainen <ccr@tnsp.org>
parents:
2554
diff
changeset
|
102 if (*vfsfile == NULL) |
2303
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
103 return NULL; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
104 |
2555
04b1b020be88
VFS file handle was not correctly closed and freed in certain situations,
Matti Hamalainen <ccr@tnsp.org>
parents:
2554
diff
changeset
|
105 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
|
106 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
|
107 aud_vfs_fclose(*vfsfile); |
2303
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
108 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
109 return snd_file; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
110 } |
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 static void |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
113 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
|
114 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
115 sf_close(snd_file); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
116 aud_vfs_fclose(vfsfile); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
117 } |
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 static void |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
121 plugin_init (void) |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
122 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
123 seek_time = -1; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
124 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
125 decode_mutex = g_mutex_new(); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
126 decode_cond = g_cond_new(); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
127 } |
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 static void |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
130 plugin_cleanup (void) |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
131 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
132 g_cond_free(decode_cond); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
133 g_mutex_free(decode_mutex); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
134 } |
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 static void |
2550 | 137 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
|
138 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
139 VFSFile *vfsfile = NULL; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
140 SNDFILE *tmp_sndfile; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
141 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
|
142 gboolean lossy = FALSE; |
7d7f7d9ae98e
Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents:
2551
diff
changeset
|
143 gchar *codec, *format, *subformat; |
2303
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
144 |
2555
04b1b020be88
VFS file handle was not correctly closed and freed in certain situations,
Matti Hamalainen <ccr@tnsp.org>
parents:
2554
diff
changeset
|
145 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
|
146 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
|
147 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
|
148 else |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
149 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
|
150 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
151 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
|
152 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
|
153 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
|
154 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
|
155 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
156 if (!tmp_sndfile) |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
157 return; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
158 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
159 close_sndfile (tmp_sndfile, vfsfile); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
160 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
161 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
|
162 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
|
163 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
164 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
|
165 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
166 case SF_FORMAT_WAV: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
167 case SF_FORMAT_WAVEX: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
168 format = "Microsoft WAV"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
169 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
170 case SF_FORMAT_AIFF: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
171 format = "Apple/SGI AIFF"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
172 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
173 case SF_FORMAT_AU: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
174 format = "Sun/NeXT AU"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
175 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
176 case SF_FORMAT_RAW: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
177 format = "Raw PCM data"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
178 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
179 case SF_FORMAT_PAF: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
180 format = "Ensoniq PARIS"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
181 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
182 case SF_FORMAT_SVX: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
183 format = "Amiga IFF / SVX8 / SV16"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
184 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
185 case SF_FORMAT_NIST: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
186 format = "Sphere NIST"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
187 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
188 case SF_FORMAT_VOC: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
189 format = "Creative VOC"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
190 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
191 case SF_FORMAT_IRCAM: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
192 format = "Berkeley/IRCAM/CARL"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
193 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
194 case SF_FORMAT_W64: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
195 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
|
196 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
197 case SF_FORMAT_MAT4: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
198 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
|
199 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
200 case SF_FORMAT_MAT5: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
201 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
|
202 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
203 case SF_FORMAT_PVF: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
204 format = "Portable Voice Format"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
205 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
206 case SF_FORMAT_XI: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
207 format = "Fasttracker 2 Extended Instrument"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
208 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
209 case SF_FORMAT_HTK: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
210 format = "HMM Tool Kit"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
211 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
212 case SF_FORMAT_SDS: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
213 format = "Midi Sample Dump Standard"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
214 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
215 case SF_FORMAT_AVR: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
216 format = "Audio Visual Research"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
217 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
218 case SF_FORMAT_SD2: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
219 format = "Sound Designer 2"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
220 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
221 case SF_FORMAT_FLAC: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
222 format = "Free Lossless Audio Codec"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
223 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
224 case SF_FORMAT_CAF: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
225 format = "Core Audio File"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
226 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
227 default: |
2553 | 228 format = "Unknown sndfile"; |
2303
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
229 } |
2553 | 230 |
2303
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
231 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
|
232 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
233 case SF_FORMAT_PCM_S8: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
234 subformat = "signed 8 bit"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
235 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
236 case SF_FORMAT_PCM_16: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
237 subformat = "signed 16 bit"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
238 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
239 case SF_FORMAT_PCM_24: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
240 subformat = "signed 24 bit"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
241 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
242 case SF_FORMAT_PCM_32: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
243 subformat = "signed 32 bit"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
244 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
245 case SF_FORMAT_PCM_U8: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
246 subformat = "unsigned 8 bit"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
247 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
248 case SF_FORMAT_FLOAT: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
249 subformat = "32 bit float"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
250 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
251 case SF_FORMAT_DOUBLE: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
252 subformat = "64 bit float"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
253 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
254 case SF_FORMAT_ULAW: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
255 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
|
256 lossy = TRUE; |
2303
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_ALAW: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
259 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
|
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_IMA_ADPCM: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
263 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
|
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_MS_ADPCM: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
267 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
|
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_GSM610: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
271 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
|
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_VOX_ADPCM: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
275 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
|
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_G721_32: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
279 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
|
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_G723_24: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
283 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
|
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_40: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
287 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
|
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_DWVW_12: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
291 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
|
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_16: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
295 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
|
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_24: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
299 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
|
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_N: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
303 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
|
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_DPCM_8: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
307 subformat = "8 bit differential PCM"; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
308 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
309 case SF_FORMAT_DPCM_16: |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
310 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
|
311 break; |
7d7f7d9ae98e
Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents:
2551
diff
changeset
|
312 default: |
7d7f7d9ae98e
Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents:
2551
diff
changeset
|
313 subformat = NULL; |
2303
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
314 } |
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 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
|
317 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
|
318 else |
2552
7d7f7d9ae98e
Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents:
2551
diff
changeset
|
319 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
|
320 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
|
321 g_free(codec); |
2553 | 322 |
2552
7d7f7d9ae98e
Sanitize Tuple creation, remove useless usage of GString and string duplications.
Matti Hamalainen <ccr@tnsp.org>
parents:
2551
diff
changeset
|
323 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
|
324 } |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
325 |
2551
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
326 static gchar * |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
327 get_title(gchar *filename) |
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 Tuple *tuple; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
330 gchar *title; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
331 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
332 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
|
333 fill_song_tuple(filename, tuple); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
334 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
|
335 if (*title == '\0') |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
336 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
337 g_free(title); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
338 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
|
339 } |
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 aud_tuple_free(tuple); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
342 return title; |
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 |
2550 | 345 static gint |
346 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
|
347 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
348 VFSFile *vfsfile = NULL; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
349 SNDFILE *tmp_sndfile; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
350 SF_INFO tmp_sfinfo; |
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 /* 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
|
353 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
|
354 |
2553 | 355 if (!tmp_sndfile) |
2303
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
356 return FALSE; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
357 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
358 /* 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
|
359 close_sndfile (tmp_sndfile, vfsfile); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
360 tmp_sndfile = NULL; |
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 return TRUE; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
363 } |
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 static gpointer |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
366 play_loop (gpointer arg) |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
367 { |
2554
8d09a4d017ea
Using a static buffer, eh? Don't. Just don't.
Matti Hamalainen <ccr@tnsp.org>
parents:
2553
diff
changeset
|
368 gshort buffer[BUFFER_SIZE]; |
2550 | 369 gint samples; |
2303
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
370 InputPlayback *playback = arg; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
371 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
372 for (;;) |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
373 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
374 GTimeVal sleeptime; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
375 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
376 /* 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
|
377 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
|
378 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
379 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
|
380 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
|
381 playback->playing == TRUE) { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
382 g_get_current_time(&sleeptime); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
383 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
|
384 g_mutex_lock(decode_mutex); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
385 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
|
386 g_mutex_unlock(decode_mutex); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
387 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
388 if (playback->playing == FALSE) |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
389 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
390 } |
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 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
|
393 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
|
394 } |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
395 else { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
396 while(playback->output->buffer_playing()) { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
397 g_get_current_time(&sleeptime); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
398 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
|
399 g_mutex_lock(decode_mutex); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
400 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
|
401 g_mutex_unlock(decode_mutex); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
402 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
403 if(playback->playing == FALSE) |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
404 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
405 } |
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 playback->eof = TRUE; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
408 playback->playing = FALSE; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
409 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
410 g_mutex_unlock(decode_mutex); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
411 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
412 } |
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 /* 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
|
415 if (seek_time >= 0) { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
416 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
|
417 SEEK_SET); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
418 playback->output->flush (seek_time); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
419 seek_time = -1; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
420 } |
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 if (playback->playing == FALSE) |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
423 break; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
424 } |
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 sf_close (sndfile); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
427 sndfile = NULL; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
428 seek_time = -1; |
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 playback->output->close_audio(); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
431 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
432 return NULL; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
433 } |
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 static void |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
436 play_start (InputPlayback *playback) |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
437 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
438 VFSFile *vfsfile = NULL; |
2550 | 439 gint pcmbitwidth; |
2303
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
440 gchar *song_title; |
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 if (sndfile) /* already opened */ |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
443 return; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
444 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
445 pcmbitwidth = 32; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
446 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
|
447 |
2555
04b1b020be88
VFS file handle was not correctly closed and freed in certain situations,
Matti Hamalainen <ccr@tnsp.org>
parents:
2554
diff
changeset
|
448 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
|
449 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
450 if (!sndfile) |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
451 return; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
452 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
453 bit_rate = sfinfo.samplerate * pcmbitwidth; |
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 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
|
456 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
|
457 else |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
458 song_length = 0; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
459 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
460 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
|
461 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
462 close_sndfile (sndfile, vfsfile); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
463 sndfile = NULL; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
464 return; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
465 } |
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 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
|
468 g_free (song_title); |
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 playback->playing = TRUE; |
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 decode_thread = g_thread_self(); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
473 playback->set_pb_ready(playback); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
474 play_loop(playback); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
475 } |
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 static void |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
478 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
|
479 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
480 playback->output->pause(p); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
481 } |
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 static void |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
484 play_stop (InputPlayback *playback) |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
485 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
486 if (decode_thread == NULL) |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
487 return; |
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 g_mutex_lock(decode_mutex); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
490 playback->playing = FALSE; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
491 g_mutex_unlock(decode_mutex); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
492 g_cond_signal(decode_cond); |
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 g_thread_join (decode_thread); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
495 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
496 sndfile = NULL; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
497 decode_thread = NULL; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
498 seek_time = -1; |
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 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
501 static void |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
502 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
|
503 { |
2553 | 504 if (!sfinfo.seekable) |
2303
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
505 return; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
506 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
507 seek_time = (glong)millisecond; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
508 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
509 while (seek_time != -1) |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
510 g_usleep (80000); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
511 } |
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 static void |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
514 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
|
515 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
516 gulong millisecond = time * 1000; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
517 file_mseek(playback, millisecond); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
518 } |
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 static Tuple* |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
521 get_song_tuple (gchar *filename) |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
522 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
523 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
|
524 fill_song_tuple(filename, ti); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
525 return ti; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
526 } |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
527 |
2551
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
528 static gint |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
529 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
|
530 { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
531 SNDFILE *tmp_sndfile; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
532 SF_INFO tmp_sfinfo; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
533 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
534 /* 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
|
535 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
|
536 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
537 if (!tmp_sndfile) |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
538 return FALSE; |
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 /* 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
|
541 sf_close (tmp_sndfile); |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
542 tmp_sndfile = NULL; |
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 return TRUE; |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
545 } |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
546 |
2549
f6efe94f2793
Fix uninitialied GtkWidget variable in about box creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2500
diff
changeset
|
547 static GtkWidget *sndfile_about_box = NULL; |
f6efe94f2793
Fix uninitialied GtkWidget variable in about box creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2500
diff
changeset
|
548 |
2303
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
549 static void plugin_about(void) |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
550 { |
2549
f6efe94f2793
Fix uninitialied GtkWidget variable in about box creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2500
diff
changeset
|
551 if (!sndfile_about_box) |
2303
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
552 { |
2551
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
553 sndfile_about_box = audacious_info_dialog( |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
554 _("About sndfile plugin"), |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
555 _("Adapted for Audacious usage by Tony Vroon <chainsaw@gentoo.org>\n" |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
556 "from the xmms_sndfile plugin which is:\n" |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
557 "Copyright (C) 2000, 2002 Erik de Castro Lopo\n\n" |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
558 "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
|
559 "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
|
560 "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
|
561 "(at your option) any later version. \n \n" |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
562 "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
|
563 "but WITHOUT ANY WARRANTY ; without even the implied warranty of \n" |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
564 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \n" |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
565 "See the GNU General Public License for more details. \n\n" |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
566 "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
|
567 "License along with this program ; if not, write to \n" |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
568 "the Free Software Foundation, Inc., \n" |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
569 "51 Franklin Street, Fifth Floor, \n" |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
570 "Boston, MA 02110-1301 USA"), |
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
571 _("Ok"), FALSE, NULL, NULL); |
2549
f6efe94f2793
Fix uninitialied GtkWidget variable in about box creation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2500
diff
changeset
|
572 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
|
573 (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
|
574 } |
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 |
2551
92300fe06f15
Cosmetic cleanups / indentation.
Matti Hamalainen <ccr@tnsp.org>
parents:
2550
diff
changeset
|
577 |
2303
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
578 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
|
579 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
580 InputPlugin sndfile_ip = { |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
581 .description = "sndfile plugin", |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
582 .init = plugin_init, |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
583 .about = plugin_about, |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
584 .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
|
585 .play_file = play_start, |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
586 .stop = play_stop, |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
587 .pause = play_pause, |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
588 .seek = file_seek, |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
589 .cleanup = plugin_cleanup, |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
590 .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
|
591 .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
|
592 .vfs_extensions = fmts, |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
593 .mseek = file_mseek, |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
594 }; |
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 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
|
597 |
5561e63e9133
threw out the WAV plugin in favour of the sndfile plugin
mf0102 <0102@gmx.at>
parents:
diff
changeset
|
598 SIMPLE_INPUT_PLUGIN(sndfile, sndfile_iplist) |