annotate src/wav/wav-sndfile.c @ 1950:2ebeb7816c5e

Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
author chainsaw@localhost
date Mon, 01 Oct 2007 23:01:22 +0100
parents e75a4add2e4b
children 17a6441c71b6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
1 /* Audacious - Cross-platform multimedia player
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
2 * Copyright (C) 2005 Audacious development team.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
3 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
4 * Based on the xmms_sndfile input plugin:
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
5 * Copyright (C) 2000, 2002 Erik de Castro Lopo
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
6 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
10 * (at your option) any later version.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
11 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
16 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
20 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
21
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
22 /*
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
23 * Rewritten 17-Feb-2007 (nenolod):
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
24 * - now uses conditional variables to ensure that sndfile mutex is
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
25 * entirely protected.
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
26 * - pausing works now
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
27 * - fixed some potential race conditions when dealing with NFS.
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
28 * - TITLE_LEN removed
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
29 */
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
30
1768
e75a4add2e4b wav: HAVE_CONFIG_H removal.
William Pitcock <nenolod@atheme.org>
parents: 1757
diff changeset
31 #include "config.h"
528
4d8b92b55acf [svn] - add config.h includes where needed
nenolod
parents: 527
diff changeset
32
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
33 #include <glib.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
34 #include <string.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
35 #include <math.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
36
1950
2ebeb7816c5e Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents: 1768
diff changeset
37 #include <audacious/plugin.h>
2ebeb7816c5e Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents: 1768
diff changeset
38 #include <audacious/util.h>
1430
bf7d4c236d9f Start using tuple_new_from_filename.
Tony Vroon <chainsaw@gentoo.org>
parents: 1413
diff changeset
39 #include "audacious/i18n.h"
1950
2ebeb7816c5e Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents: 1768
diff changeset
40 #include <audacious/main.h>
2ebeb7816c5e Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents: 1768
diff changeset
41 #include <audacious/tuple.h>
1430
bf7d4c236d9f Start using tuple_new_from_filename.
Tony Vroon <chainsaw@gentoo.org>
parents: 1413
diff changeset
42 #include "audacious/tuple_formatter.h"
1950
2ebeb7816c5e Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents: 1768
diff changeset
43 #include <audacious/output.h>
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
44 #include "wav-sndfile.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
45
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
46 #include <sndfile.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
47
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
48 static SNDFILE *sndfile = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
49 static SF_INFO sfinfo;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
50
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
51 static int song_length;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
52 static int bit_rate = 0;
862
baa22cb0216d [svn] - add mseek support.
yaz
parents: 667
diff changeset
53 static glong seek_time = -1;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
54
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
55 static GThread *decode_thread;
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
56 static GMutex *decode_mutex;
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
57 static GCond *decode_cond;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
58
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
59 InputPlugin wav_ip = {
1614
cf7124d464f9 wav, wav-sndfile: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1519
diff changeset
60 .init = plugin_init,
cf7124d464f9 wav, wav-sndfile: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1519
diff changeset
61 .about = wav_about,
cf7124d464f9 wav, wav-sndfile: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1519
diff changeset
62 .is_our_file = is_our_file,
cf7124d464f9 wav, wav-sndfile: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1519
diff changeset
63 .play_file = play_start,
cf7124d464f9 wav, wav-sndfile: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1519
diff changeset
64 .stop = play_stop,
cf7124d464f9 wav, wav-sndfile: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1519
diff changeset
65 .pause = play_pause,
cf7124d464f9 wav, wav-sndfile: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1519
diff changeset
66 .seek = file_seek,
cf7124d464f9 wav, wav-sndfile: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1519
diff changeset
67 .cleanup = plugin_cleanup,
cf7124d464f9 wav, wav-sndfile: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1519
diff changeset
68 .get_song_info = get_song_info,
cf7124d464f9 wav, wav-sndfile: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1519
diff changeset
69 .get_song_tuple = get_song_tuple,
cf7124d464f9 wav, wav-sndfile: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1519
diff changeset
70 .mseek = file_mseek,
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
71 };
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
72
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
73 static int
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
74 get_song_length (char *filename)
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
75 {
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
76 SNDFILE *tmp_sndfile;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
77 SF_INFO tmp_sfinfo;
1283
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
78 gchar *realfn = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
79
1283
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
80 realfn = g_filename_from_uri(filename, NULL, NULL);
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
81 tmp_sndfile = sf_open (realfn ? realfn : filename, SFM_READ, &tmp_sfinfo);
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
82 g_free(realfn); realfn = NULL;
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
83
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
84 if (!tmp_sndfile) {
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
85 return 0;
1283
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
86 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
87
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
88 sf_close (tmp_sndfile);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
89 tmp_sndfile = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
90
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
91 if (tmp_sfinfo.samplerate <= 0)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
92 return 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
93
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
94 return (int) ceil (1000.0 * tmp_sfinfo.frames / tmp_sfinfo.samplerate);
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
95 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
96
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
97 static void
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
98 fill_song_tuple (char *filename, Tuple *ti)
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
99 {
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
100 SNDFILE *tmp_sndfile;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
101 SF_INFO tmp_sfinfo;
1511
48fcdaa29159 Report lossless/lossy quality and the filename as the title. This plugin still shows mutex-related lockups for me though.
Tony Vroon <chainsaw@gentoo.org>
parents: 1504
diff changeset
102 unsigned int lossy = 0;
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
103 gchar *realfn = NULL, *codec = NULL, *format, *subformat = NULL;
1504
47612fdac429 Replaced asprintf with gstring (which is probably more portable anyway).
Giacomo Lozito <james@develia.org>
parents: 1503
diff changeset
104 GString *codec_gs = NULL;
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
105
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
106 realfn = g_filename_from_uri(filename, NULL, NULL);
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
107 tmp_sndfile = sf_open (realfn ? realfn : filename, SFM_READ, &tmp_sfinfo);
1519
9e7980b7abad Actually read string-based metadata for tuplez.
Tony Vroon <chainsaw@gentoo.org>
parents: 1515
diff changeset
108 if ( sf_get_string(tmp_sndfile, SF_STR_TITLE) == NULL)
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1519
diff changeset
109 tuple_associate_string(ti, FIELD_TITLE, NULL, g_path_get_basename(realfn ? realfn : filename));
1519
9e7980b7abad Actually read string-based metadata for tuplez.
Tony Vroon <chainsaw@gentoo.org>
parents: 1515
diff changeset
110 else
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1519
diff changeset
111 tuple_associate_string(ti, FIELD_TITLE, NULL, sf_get_string(tmp_sndfile, SF_STR_TITLE));
1519
9e7980b7abad Actually read string-based metadata for tuplez.
Tony Vroon <chainsaw@gentoo.org>
parents: 1515
diff changeset
112
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1519
diff changeset
113 tuple_associate_string(ti, FIELD_ARTIST, NULL, sf_get_string(tmp_sndfile, SF_STR_ARTIST));
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1519
diff changeset
114 tuple_associate_string(ti, FIELD_COMMENT, NULL, sf_get_string(tmp_sndfile, SF_STR_COMMENT));
1757
3c43d2d5acd9 Use FIELD_DATE.
Matti Hamalainen <ccr@tnsp.org>
parents: 1697
diff changeset
115 tuple_associate_string(ti, FIELD_DATE, NULL, sf_get_string(tmp_sndfile, SF_STR_DATE));
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1519
diff changeset
116 tuple_associate_string(ti, -1, "software", sf_get_string(tmp_sndfile, SF_STR_SOFTWARE));
1519
9e7980b7abad Actually read string-based metadata for tuplez.
Tony Vroon <chainsaw@gentoo.org>
parents: 1515
diff changeset
117
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
118 g_free(realfn); realfn = NULL;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
119
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
120 if (!tmp_sndfile)
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
121 return;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
122
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
123 sf_close (tmp_sndfile);
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
124 tmp_sndfile = NULL;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
125
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
126 if (tmp_sfinfo.samplerate > 0)
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1519
diff changeset
127 tuple_associate_int(ti, FIELD_LENGTH, NULL, (int) ceil (1000.0 * tmp_sfinfo.frames / tmp_sfinfo.samplerate));
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
128
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
129 switch (tmp_sfinfo.format & SF_FORMAT_TYPEMASK)
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
130 {
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
131 case SF_FORMAT_WAV:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
132 case SF_FORMAT_WAVEX:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
133 format = "Microsoft WAV";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
134 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
135 case SF_FORMAT_AIFF:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
136 format = "Apple/SGI AIFF";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
137 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
138 case SF_FORMAT_AU:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
139 format = "Sun/NeXT AU";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
140 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
141 case SF_FORMAT_RAW:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
142 format = "Raw PCM data";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
143 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
144 case SF_FORMAT_PAF:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
145 format = "Ensoniq PARIS";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
146 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
147 case SF_FORMAT_SVX:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
148 format = "Amiga IFF / SVX8 / SV16";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
149 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
150 case SF_FORMAT_NIST:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
151 format = "Sphere NIST";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
152 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
153 case SF_FORMAT_VOC:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
154 format = "Creative VOC";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
155 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
156 case SF_FORMAT_IRCAM:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
157 format = "Berkeley/IRCAM/CARL";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
158 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
159 case SF_FORMAT_W64:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
160 format = "Sonic Foundry's 64 bit RIFF/WAV";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
161 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
162 case SF_FORMAT_MAT4:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
163 format = "Matlab (tm) V4.2 / GNU Octave 2.0";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
164 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
165 case SF_FORMAT_MAT5:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
166 format = "Matlab (tm) V5.0 / GNU Octave 2.1";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
167 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
168 case SF_FORMAT_PVF:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
169 format = "Portable Voice Format";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
170 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
171 case SF_FORMAT_XI:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
172 format = "Fasttracker 2 Extended Instrument";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
173 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
174 case SF_FORMAT_HTK:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
175 format = "HMM Tool Kit";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
176 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
177 case SF_FORMAT_SDS:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
178 format = "Midi Sample Dump Standard";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
179 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
180 case SF_FORMAT_AVR:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
181 format = "Audio Visual Research";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
182 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
183 case SF_FORMAT_SD2:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
184 format = "Sound Designer 2";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
185 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
186 case SF_FORMAT_FLAC:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
187 format = "Free Lossless Audio Codec";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
188 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
189 case SF_FORMAT_CAF:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
190 format = "Core Audio File";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
191 break;
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
192 default:
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
193 format = "unknown sndfile";
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
194 }
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
195 switch (tmp_sfinfo.format & SF_FORMAT_SUBMASK)
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
196 {
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
197 case SF_FORMAT_PCM_S8:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
198 subformat = "signed 8 bit";
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
199 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
200 case SF_FORMAT_PCM_16:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
201 subformat = "signed 16 bit";
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
202 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
203 case SF_FORMAT_PCM_24:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
204 subformat = "signed 24 bit";
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
205 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
206 case SF_FORMAT_PCM_32:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
207 subformat = "signed 32 bit";
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
208 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
209 case SF_FORMAT_PCM_U8:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
210 subformat = "unsigned 8 bit";
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
211 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
212 case SF_FORMAT_FLOAT:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
213 subformat = "32 bit float";
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
214 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
215 case SF_FORMAT_DOUBLE:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
216 subformat = "64 bit float";
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
217 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
218 case SF_FORMAT_ULAW:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
219 subformat = "U-Law";
1511
48fcdaa29159 Report lossless/lossy quality and the filename as the title. This plugin still shows mutex-related lockups for me though.
Tony Vroon <chainsaw@gentoo.org>
parents: 1504
diff changeset
220 lossy = 1;
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
221 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
222 case SF_FORMAT_ALAW:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
223 subformat = "A-Law";
1511
48fcdaa29159 Report lossless/lossy quality and the filename as the title. This plugin still shows mutex-related lockups for me though.
Tony Vroon <chainsaw@gentoo.org>
parents: 1504
diff changeset
224 lossy = 1;
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
225 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
226 case SF_FORMAT_IMA_ADPCM:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
227 subformat = "IMA ADPCM";
1511
48fcdaa29159 Report lossless/lossy quality and the filename as the title. This plugin still shows mutex-related lockups for me though.
Tony Vroon <chainsaw@gentoo.org>
parents: 1504
diff changeset
228 lossy = 1;
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
229 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
230 case SF_FORMAT_MS_ADPCM:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
231 subformat = "MS ADPCM";
1511
48fcdaa29159 Report lossless/lossy quality and the filename as the title. This plugin still shows mutex-related lockups for me though.
Tony Vroon <chainsaw@gentoo.org>
parents: 1504
diff changeset
232 lossy = 1;
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
233 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
234 case SF_FORMAT_GSM610:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
235 subformat = "GSM 6.10";
1511
48fcdaa29159 Report lossless/lossy quality and the filename as the title. This plugin still shows mutex-related lockups for me though.
Tony Vroon <chainsaw@gentoo.org>
parents: 1504
diff changeset
236 lossy = 1;
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
237 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
238 case SF_FORMAT_VOX_ADPCM:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
239 subformat = "Oki Dialogic ADPCM";
1511
48fcdaa29159 Report lossless/lossy quality and the filename as the title. This plugin still shows mutex-related lockups for me though.
Tony Vroon <chainsaw@gentoo.org>
parents: 1504
diff changeset
240 lossy = 1;
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
241 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
242 case SF_FORMAT_G721_32:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
243 subformat = "32kbs G721 ADPCM";
1511
48fcdaa29159 Report lossless/lossy quality and the filename as the title. This plugin still shows mutex-related lockups for me though.
Tony Vroon <chainsaw@gentoo.org>
parents: 1504
diff changeset
244 lossy = 1;
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
245 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
246 case SF_FORMAT_G723_24:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
247 subformat = "24kbs G723 ADPCM";
1511
48fcdaa29159 Report lossless/lossy quality and the filename as the title. This plugin still shows mutex-related lockups for me though.
Tony Vroon <chainsaw@gentoo.org>
parents: 1504
diff changeset
248 lossy = 1;
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
249 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
250 case SF_FORMAT_G723_40:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
251 subformat = "40kbs G723 ADPCM";
1511
48fcdaa29159 Report lossless/lossy quality and the filename as the title. This plugin still shows mutex-related lockups for me though.
Tony Vroon <chainsaw@gentoo.org>
parents: 1504
diff changeset
252 lossy = 1;
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
253 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
254 case SF_FORMAT_DWVW_12:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
255 subformat = "12 bit Delta Width Variable Word";
1511
48fcdaa29159 Report lossless/lossy quality and the filename as the title. This plugin still shows mutex-related lockups for me though.
Tony Vroon <chainsaw@gentoo.org>
parents: 1504
diff changeset
256 lossy = 1;
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
257 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
258 case SF_FORMAT_DWVW_16:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
259 subformat = "16 bit Delta Width Variable Word";
1511
48fcdaa29159 Report lossless/lossy quality and the filename as the title. This plugin still shows mutex-related lockups for me though.
Tony Vroon <chainsaw@gentoo.org>
parents: 1504
diff changeset
260 lossy = 1;
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
261 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
262 case SF_FORMAT_DWVW_24:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
263 subformat = "24 bit Delta Width Variable Word";
1511
48fcdaa29159 Report lossless/lossy quality and the filename as the title. This plugin still shows mutex-related lockups for me though.
Tony Vroon <chainsaw@gentoo.org>
parents: 1504
diff changeset
264 lossy = 1;
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
265 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
266 case SF_FORMAT_DWVW_N:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
267 subformat = "N bit Delta Width Variable Word";
1511
48fcdaa29159 Report lossless/lossy quality and the filename as the title. This plugin still shows mutex-related lockups for me though.
Tony Vroon <chainsaw@gentoo.org>
parents: 1504
diff changeset
268 lossy = 1;
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
269 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
270 case SF_FORMAT_DPCM_8:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
271 subformat = "8 bit differential PCM";
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
272 break;
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
273 case SF_FORMAT_DPCM_16:
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
274 subformat = "16 bit differential PCM";
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
275 }
1504
47612fdac429 Replaced asprintf with gstring (which is probably more portable anyway).
Giacomo Lozito <james@develia.org>
parents: 1503
diff changeset
276
47612fdac429 Replaced asprintf with gstring (which is probably more portable anyway).
Giacomo Lozito <james@develia.org>
parents: 1503
diff changeset
277 codec_gs = g_string_new("");
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
278 if (subformat != NULL)
1504
47612fdac429 Replaced asprintf with gstring (which is probably more portable anyway).
Giacomo Lozito <james@develia.org>
parents: 1503
diff changeset
279 g_string_append_printf(codec_gs, "%s (%s)", format, subformat);
1503
d0e39fd56c78 Format and subformat detection. Needs some asprintf love. Or something.
Tony Vroon <chainsaw@gentoo.org>
parents: 1470
diff changeset
280 else
1504
47612fdac429 Replaced asprintf with gstring (which is probably more portable anyway).
Giacomo Lozito <james@develia.org>
parents: 1503
diff changeset
281 g_string_append_printf(codec_gs, "%s", format);
47612fdac429 Replaced asprintf with gstring (which is probably more portable anyway).
Giacomo Lozito <james@develia.org>
parents: 1503
diff changeset
282 codec = g_strdup(codec_gs->str);
47612fdac429 Replaced asprintf with gstring (which is probably more portable anyway).
Giacomo Lozito <james@develia.org>
parents: 1503
diff changeset
283 g_string_free(codec_gs, TRUE);
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1519
diff changeset
284 tuple_associate_string(ti, FIELD_CODEC, NULL, codec);
1504
47612fdac429 Replaced asprintf with gstring (which is probably more portable anyway).
Giacomo Lozito <james@develia.org>
parents: 1503
diff changeset
285
1511
48fcdaa29159 Report lossless/lossy quality and the filename as the title. This plugin still shows mutex-related lockups for me though.
Tony Vroon <chainsaw@gentoo.org>
parents: 1504
diff changeset
286 if (lossy != 0)
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1519
diff changeset
287 tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossy");
1511
48fcdaa29159 Report lossless/lossy quality and the filename as the title. This plugin still shows mutex-related lockups for me though.
Tony Vroon <chainsaw@gentoo.org>
parents: 1504
diff changeset
288 else
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1519
diff changeset
289 tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossless");
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
290 }
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
291
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
292 static gchar *get_title(char *filename)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
293 {
1515
fc1b025e6900 Report the title properly, as in all the other plugins in the tree. Poor ignored and unloved plugin...
Tony Vroon <chainsaw@gentoo.org>
parents: 1513
diff changeset
294 Tuple *tuple;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
295 gchar *title;
1283
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
296
1515
fc1b025e6900 Report the title properly, as in all the other plugins in the tree. Poor ignored and unloved plugin...
Tony Vroon <chainsaw@gentoo.org>
parents: 1513
diff changeset
297 tuple = tuple_new_from_filename(filename);
fc1b025e6900 Report the title properly, as in all the other plugins in the tree. Poor ignored and unloved plugin...
Tony Vroon <chainsaw@gentoo.org>
parents: 1513
diff changeset
298 fill_song_tuple(filename, tuple);
fc1b025e6900 Report the title properly, as in all the other plugins in the tree. Poor ignored and unloved plugin...
Tony Vroon <chainsaw@gentoo.org>
parents: 1513
diff changeset
299 title = tuple_formatter_make_title_string(tuple, get_gentitle_format());
fc1b025e6900 Report the title properly, as in all the other plugins in the tree. Poor ignored and unloved plugin...
Tony Vroon <chainsaw@gentoo.org>
parents: 1513
diff changeset
300 if (*title == '\0')
fc1b025e6900 Report the title properly, as in all the other plugins in the tree. Poor ignored and unloved plugin...
Tony Vroon <chainsaw@gentoo.org>
parents: 1513
diff changeset
301 {
fc1b025e6900 Report the title properly, as in all the other plugins in the tree. Poor ignored and unloved plugin...
Tony Vroon <chainsaw@gentoo.org>
parents: 1513
diff changeset
302 g_free(title);
1687
d158ce84fda7 Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 1519
diff changeset
303 title = g_strdup(tuple_get_string(tuple, FIELD_FILE_NAME, NULL));
1515
fc1b025e6900 Report the title properly, as in all the other plugins in the tree. Poor ignored and unloved plugin...
Tony Vroon <chainsaw@gentoo.org>
parents: 1513
diff changeset
304 }
fc1b025e6900 Report the title properly, as in all the other plugins in the tree. Poor ignored and unloved plugin...
Tony Vroon <chainsaw@gentoo.org>
parents: 1513
diff changeset
305
fc1b025e6900 Report the title properly, as in all the other plugins in the tree. Poor ignored and unloved plugin...
Tony Vroon <chainsaw@gentoo.org>
parents: 1513
diff changeset
306 tuple_free(tuple);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
307 return title;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
308 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
309
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
310 static void
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
311 plugin_init (void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
312 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
313 seek_time = -1;
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
314
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
315 decode_mutex = g_mutex_new();
921
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
316 decode_cond = g_cond_new();
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
317 }
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
318
921
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
319 static void
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
320 plugin_cleanup (void)
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
321 {
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
322 g_cond_free(decode_cond);
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
323 g_mutex_free(decode_mutex);
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
324 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
325
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
326 static int
1283
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
327 is_our_file (char *filename)
664
52b8efa55fcf [svn] - wav-sndfile engine: correctly compute the bitrate
nenolod
parents: 565
diff changeset
328 {
52b8efa55fcf [svn] - wav-sndfile engine: correctly compute the bitrate
nenolod
parents: 565
diff changeset
329 SNDFILE *tmp_sndfile;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
330 SF_INFO tmp_sfinfo;
1283
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
331 gchar *realfn = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
332
1283
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
333 realfn = g_filename_from_uri(filename, NULL, NULL);
1263
458d46e65a86 wav-sndfile: in is_our_file, ensure that filename is not NULL before passing it to sf_open
Giacomo Lozito <james@develia.org>
parents: 1242
diff changeset
334
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
335 /* Have to open the file to see if libsndfile can handle it. */
1283
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
336 tmp_sndfile = sf_open (realfn ? realfn : filename, SFM_READ, &tmp_sfinfo);
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
337 g_free(realfn); realfn = NULL;
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
338
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
339 if (!tmp_sndfile) {
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
340 return FALSE;
1263
458d46e65a86 wav-sndfile: in is_our_file, ensure that filename is not NULL before passing it to sf_open
Giacomo Lozito <james@develia.org>
parents: 1242
diff changeset
341 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
342
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
343 /* It can so close file and return TRUE. */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
344 sf_close (tmp_sndfile);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
345 tmp_sndfile = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
346
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
347 return TRUE;
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
348 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
349
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
350 static gpointer
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
351 play_loop (gpointer arg)
664
52b8efa55fcf [svn] - wav-sndfile engine: correctly compute the bitrate
nenolod
parents: 565
diff changeset
352 {
52b8efa55fcf [svn] - wav-sndfile engine: correctly compute the bitrate
nenolod
parents: 565
diff changeset
353 static short buffer [BUFFER_SIZE];
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
354 int samples;
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 528
diff changeset
355 InputPlayback *playback = arg;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
356
666
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
357 for (;;)
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
358 {
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
359 GTimeVal sleeptime;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
360
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
361 /* sf_read_short will return 0 for all reads at EOF. */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
362 samples = sf_read_short (sndfile, buffer, BUFFER_SIZE);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
363
921
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
364 if (samples > 0 && playback->playing == TRUE) {
862
baa22cb0216d [svn] - add mseek support.
yaz
parents: 667
diff changeset
365 while ((playback->output->buffer_free () < samples) &&
921
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
366 playback->playing == TRUE) {
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
367 g_get_current_time(&sleeptime);
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
368 g_time_val_add(&sleeptime, 500000);
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
369 g_mutex_lock(decode_mutex);
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
370 g_cond_timed_wait(decode_cond, decode_mutex, &sleeptime);
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
371 g_mutex_unlock(decode_mutex);
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
372
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
373 if (playback->playing == FALSE)
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
374 break;
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
375 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
376
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 528
diff changeset
377 produce_audio (playback->output->written_time (), FMT_S16_NE, sfinfo.channels,
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
378 samples * sizeof (short), buffer, &playback->playing);
921
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
379 }
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
380 else {
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
381 while(playback->output->buffer_playing()) {
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
382 g_get_current_time(&sleeptime);
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
383 g_time_val_add(&sleeptime, 500000);
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
384 g_mutex_lock(decode_mutex);
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
385 g_cond_timed_wait(decode_cond, decode_mutex, &sleeptime);
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
386 g_mutex_unlock(decode_mutex);
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
387
921
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
388 if(playback->playing == FALSE)
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
389 break;
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
390 }
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
391
667
836cbe95ec5d [svn] - make use of playlist->eof effectively.
nenolod
parents: 666
diff changeset
392 playback->eof = TRUE;
836cbe95ec5d [svn] - make use of playlist->eof effectively.
nenolod
parents: 666
diff changeset
393 playback->playing = FALSE;
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
394
667
836cbe95ec5d [svn] - make use of playlist->eof effectively.
nenolod
parents: 666
diff changeset
395 g_mutex_unlock(decode_mutex);
836cbe95ec5d [svn] - make use of playlist->eof effectively.
nenolod
parents: 666
diff changeset
396 break;
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
397 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
398
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
399 /* Do seek if seek_time is valid. */
921
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
400 if (seek_time >= 0) {
862
baa22cb0216d [svn] - add mseek support.
yaz
parents: 667
diff changeset
401 sf_seek (sndfile, (sf_count_t)((gint64)seek_time * (gint64)sfinfo.samplerate / 1000L),
baa22cb0216d [svn] - add mseek support.
yaz
parents: 667
diff changeset
402 SEEK_SET);
baa22cb0216d [svn] - add mseek support.
yaz
parents: 667
diff changeset
403 playback->output->flush (seek_time);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
404 seek_time = -1;
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
405 }
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
406
666
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
407 if (playback->playing == FALSE)
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
408 break;
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
409 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
410
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
411 sf_close (sndfile);
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
412 sndfile = NULL;
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
413 seek_time = -1;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
414
666
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
415 playback->output->close_audio();
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
416
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
417 return NULL;
666
a06edd6bfde6 [svn] - some further adjustments
nenolod
parents: 665
diff changeset
418 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
419
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
420 static void
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 528
diff changeset
421 play_start (InputPlayback *playback)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
422 {
1283
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
423 gchar *realfn = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
424 int pcmbitwidth;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
425 gchar *song_title;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
426
1283
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
427 if (sndfile) /* already opened */
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
428 return;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
429
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
430 pcmbitwidth = 32;
1283
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
431 song_title = get_title(playback->filename);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
432
1283
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
433 realfn = g_filename_from_uri(playback->filename, NULL, NULL);
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
434 sndfile = sf_open (realfn ? realfn : playback->filename, SFM_READ, &sfinfo);
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
435 g_free(realfn); realfn = NULL;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
436
1283
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
437 if (!sndfile)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
438 return;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
439
664
52b8efa55fcf [svn] - wav-sndfile engine: correctly compute the bitrate
nenolod
parents: 565
diff changeset
440 bit_rate = sfinfo.samplerate * pcmbitwidth;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
441
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
442 if (sfinfo.samplerate > 0)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
443 song_length = (int) ceil (1000.0 * sfinfo.frames / sfinfo.samplerate);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
444 else
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
445 song_length = 0;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
446
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 528
diff changeset
447 if (! playback->output->open_audio (FMT_S16_NE, sfinfo.samplerate, sfinfo.channels))
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
448 {
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
449 sf_close (sndfile);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
450 sndfile = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
451 return;
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
452 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
453
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
454 wav_ip.set_info (song_title, song_length, bit_rate, sfinfo.samplerate, sfinfo.channels);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
455 g_free (song_title);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
456
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
457 playback->playing = TRUE;
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
458
1367
c75fd6894758 wav-sndfile, wav: convert to new threading model
William Pitcock <nenolod@atheme-project.org>
parents: 1283
diff changeset
459 decode_thread = g_thread_self();
1513
a3e002f56bd6 wav-sndfile.c, added missing playback->set_pb_ready(playback)
Giacomo Lozito <james@develia.org>
parents: 1511
diff changeset
460 playback->set_pb_ready(playback);
a3e002f56bd6 wav-sndfile.c, added missing playback->set_pb_ready(playback)
Giacomo Lozito <james@develia.org>
parents: 1511
diff changeset
461 play_loop(playback);
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
462 }
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
463
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
464 static void
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
465 play_pause (InputPlayback *playback, gshort p)
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
466 {
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
467 playback->output->pause(p);
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
468 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
469
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
470 static void
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 528
diff changeset
471 play_stop (InputPlayback *playback)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
472 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
473 if (decode_thread == NULL)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
474 return;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
475
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
476 g_mutex_lock(decode_mutex);
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
477 playback->playing = FALSE;
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
478 g_mutex_unlock(decode_mutex);
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
479 g_cond_signal(decode_cond);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
480
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
481 g_thread_join (decode_thread);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
482
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
483 sndfile = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
484 decode_thread = NULL;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
485 seek_time = -1;
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
486 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
487
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
488 static void
862
baa22cb0216d [svn] - add mseek support.
yaz
parents: 667
diff changeset
489 file_mseek (InputPlayback *playback, gulong millisecond)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
490 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
491 if (! sfinfo.seekable)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
492 return;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
493
862
baa22cb0216d [svn] - add mseek support.
yaz
parents: 667
diff changeset
494 seek_time = (glong)millisecond;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
495
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
496 while (seek_time != -1)
1676
aee4ebea943a xmms_usleep() was removed, use g_usleep()
Matti Hamalainen <ccr@tnsp.org>
parents: 1614
diff changeset
497 g_usleep (80000);
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
498 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
499
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
500 static void
862
baa22cb0216d [svn] - add mseek support.
yaz
parents: 667
diff changeset
501 file_seek (InputPlayback *playback, int time)
baa22cb0216d [svn] - add mseek support.
yaz
parents: 667
diff changeset
502 {
1515
fc1b025e6900 Report the title properly, as in all the other plugins in the tree. Poor ignored and unloved plugin...
Tony Vroon <chainsaw@gentoo.org>
parents: 1513
diff changeset
503 gulong millisecond = time * 1000;
fc1b025e6900 Report the title properly, as in all the other plugins in the tree. Poor ignored and unloved plugin...
Tony Vroon <chainsaw@gentoo.org>
parents: 1513
diff changeset
504 file_mseek(playback, millisecond);
862
baa22cb0216d [svn] - add mseek support.
yaz
parents: 667
diff changeset
505 }
baa22cb0216d [svn] - add mseek support.
yaz
parents: 667
diff changeset
506
baa22cb0216d [svn] - add mseek support.
yaz
parents: 667
diff changeset
507 static void
1283
ef8c6b02bdf7 more adaptation for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1264
diff changeset
508 get_song_info (char *filename, char **title, int *length)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
509 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
510 (*length) = get_song_length(filename);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
511 (*title) = get_title(filename);
665
86570de2f4e6 [svn] Rewrote the entire plugin:
nenolod
parents: 664
diff changeset
512 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
513
1430
bf7d4c236d9f Start using tuple_new_from_filename.
Tony Vroon <chainsaw@gentoo.org>
parents: 1413
diff changeset
514 static Tuple*
1412
6a424e6ff59c playlist_get_songtime wanted a tuple, but was afraid to ask
Tony Vroon <chainsaw@gentoo.org>
parents: 1395
diff changeset
515 get_song_tuple (gchar *filename)
6a424e6ff59c playlist_get_songtime wanted a tuple, but was afraid to ask
Tony Vroon <chainsaw@gentoo.org>
parents: 1395
diff changeset
516 {
1430
bf7d4c236d9f Start using tuple_new_from_filename.
Tony Vroon <chainsaw@gentoo.org>
parents: 1413
diff changeset
517 Tuple *ti = tuple_new_from_filename(filename);
1470
429b29e8004c Add actual codec information to wav-sndfile tuple. Untested.
Tony Vroon <chainsaw@gentoo.org>
parents: 1430
diff changeset
518 fill_song_tuple(filename, ti);
1430
bf7d4c236d9f Start using tuple_new_from_filename.
Tony Vroon <chainsaw@gentoo.org>
parents: 1413
diff changeset
519 return ti;
1412
6a424e6ff59c playlist_get_songtime wanted a tuple, but was afraid to ask
Tony Vroon <chainsaw@gentoo.org>
parents: 1395
diff changeset
520 }
6a424e6ff59c playlist_get_songtime wanted a tuple, but was afraid to ask
Tony Vroon <chainsaw@gentoo.org>
parents: 1395
diff changeset
521
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
522 static void wav_about(void)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
523 {
921
8b0850943335 [svn] - now wav plugin can handle remaining buffered data at the end of playing.
yaz
parents: 862
diff changeset
524 static GtkWidget *box;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
525 if (!box)
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
526 {
1677
f6f5603a0954 xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents: 1676
diff changeset
527 box = audacious_info_dialog(
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
528 _("About sndfile WAV support"),
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
529 _("Adapted for Audacious usage by Tony Vroon <chainsaw@gentoo.org>\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
530 "from the xmms_sndfile plugin which is:\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
531 "Copyright (C) 2000, 2002 Erik de Castro Lopo\n\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
532 "This program is free software ; you can redistribute it and/or modify \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
533 "it under the terms of the GNU General Public License as published by \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
534 "the Free Software Foundation ; either version 2 of the License, or \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
535 "(at your option) any later version. \n \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
536 "This program is distributed in the hope that it will be useful, \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
537 "but WITHOUT ANY WARRANTY ; without even the implied warranty of \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
538 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
539 "See the GNU General Public License for more details. \n\n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
540 "You should have received a copy of the GNU General Public \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
541 "License along with this program ; if not, write to \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
542 "the Free Software Foundation, Inc., \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
543 "51 Franklin Street, Fifth Floor, \n"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
544 "Boston, MA 02110-1301 USA"),
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
545 _("Ok"), FALSE, NULL, NULL);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
546 g_signal_connect(G_OBJECT(box), "destroy",
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
547 (GCallback)gtk_widget_destroyed, &box);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
548 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
549 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
550
1063
872a2f7d3f6e [svn] - port to plugin2 API
nenolod
parents: 921
diff changeset
551 void init(void)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
552 {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
553 wav_ip.description = g_strdup_printf(_("sndfile WAV plugin"));
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
554 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
555
1063
872a2f7d3f6e [svn] - port to plugin2 API
nenolod
parents: 921
diff changeset
556 void fini(void)
872a2f7d3f6e [svn] - port to plugin2 API
nenolod
parents: 921
diff changeset
557 {
872a2f7d3f6e [svn] - port to plugin2 API
nenolod
parents: 921
diff changeset
558 g_free(wav_ip.description);
872a2f7d3f6e [svn] - port to plugin2 API
nenolod
parents: 921
diff changeset
559 }
872a2f7d3f6e [svn] - port to plugin2 API
nenolod
parents: 921
diff changeset
560
872a2f7d3f6e [svn] - port to plugin2 API
nenolod
parents: 921
diff changeset
561 InputPlugin *wav_iplist[] = { &wav_ip, NULL };
872a2f7d3f6e [svn] - port to plugin2 API
nenolod
parents: 921
diff changeset
562
1395
761e17b23e0c added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents: 1381
diff changeset
563 DECLARE_PLUGIN(wav-sndfile, init, fini, wav_iplist, NULL, NULL, NULL, NULL, NULL)