annotate src/flacng/plugin.c @ 3145:76f5bcf547d5

crossfade: remove unused config variable
author Michal Lipski <tallica@o2.pl>
date Sat, 09 May 2009 18:51:03 +0200
parents b7c181d0b325
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
1 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
2 * A FLAC decoder plugin for the Audacious Media Player
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
3 * Copyright (C) 2005 Ralf Ertzinger
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
4 *
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
5 * This program is free software; you can redistribute it and/or modify
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
7 * the Free Software Foundation; either version 2 of the License, or
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
8 * (at your option) any later version.
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
9 *
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
13 * GNU General Public License for more details.
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
14 *
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
16 * along with this program; if not, write to the Free Software
2835
f1b6f1b2cdb3 fixed FSF address
Andrew O. Shadoura <bugzilla@tut.by>
parents: 2709
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
18 */
2360
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
19 /* #define FLACNG_DEBUG */
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
20
1961
e8ea3a76a84e Various #include cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 1677
diff changeset
21 #include "flacng.h"
2971
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2835
diff changeset
22 #include <audlegacy/output.h>
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2835
diff changeset
23 #include <audlegacy/i18n.h>
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
24 #include "tools.h"
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
25 #include "plugin.h"
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
26 #include "seekable_stream_callbacks.h"
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
27 #include "version.h"
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
28 #include "debug.h"
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
29
2204
43da009d6e76 add "fla" to the extension list. fix #6.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2192
diff changeset
30 static gchar *flac_fmts[] = { "flac", "fla", NULL };
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
31
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
32 InputPlugin flac_ip = {
1619
6ee8e5653f7b flacng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1447
diff changeset
33 .description = "FLACng Audio Plugin",
6ee8e5653f7b flacng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1447
diff changeset
34 .init = flac_init,
2266
5395c85a8724 Make flacng plugin to clean up after itself (Bugzilla #19)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2204
diff changeset
35 .cleanup = flac_cleanup,
1619
6ee8e5653f7b flacng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1447
diff changeset
36 .about = flac_aboutbox,
6ee8e5653f7b flacng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1447
diff changeset
37 .is_our_file = flac_is_our_file,
6ee8e5653f7b flacng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1447
diff changeset
38 .play_file = flac_play_file,
6ee8e5653f7b flacng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1447
diff changeset
39 .stop = flac_stop,
6ee8e5653f7b flacng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1447
diff changeset
40 .pause = flac_pause,
2417
0427c5d07a66 added mseek support to flacng. patch by Piotr Garus. thanks Piotr!
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2360
diff changeset
41 .mseek = flac_mseek,
1619
6ee8e5653f7b flacng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1447
diff changeset
42 .seek = flac_seek,
6ee8e5653f7b flacng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1447
diff changeset
43 .get_song_info = flac_get_song_info,
6ee8e5653f7b flacng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1447
diff changeset
44 .get_song_tuple = flac_get_song_tuple, // get a tuple
6ee8e5653f7b flacng: C99 initialisers
William Pitcock <nenolod@atheme.org>
parents: 1447
diff changeset
45 .is_our_file_from_vfs = flac_is_our_fd, // version of is_our_file which is handed an FD
1979
839804c3b3a4 aud_vfs_extensions -> vfs_extensions, some vtable fixes
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
46 .vfs_extensions = flac_fmts // vector of fileextensions allowed by the plugin
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
47 };
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
48
1092
085c579ba08a [svn] - flacng: convert to plugin API v2
nenolod
parents: 1044
diff changeset
49 InputPlugin *flac_iplist[] = { &flac_ip, NULL };
085c579ba08a [svn] - flacng: convert to plugin API v2
nenolod
parents: 1044
diff changeset
50
1395
761e17b23e0c added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents: 1344
diff changeset
51 DECLARE_PLUGIN(flacng, NULL, NULL, flac_iplist, NULL, NULL, NULL, NULL, NULL);
1092
085c579ba08a [svn] - flacng: convert to plugin API v2
nenolod
parents: 1044
diff changeset
52
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
53 FLAC__StreamDecoder* test_decoder;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
54 FLAC__StreamDecoder* main_decoder;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
55 callback_info* test_info;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
56 callback_info* main_info;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
57 gboolean plugin_initialized = FALSE;
2417
0427c5d07a66 added mseek support to flacng. patch by Piotr Garus. thanks Piotr!
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2360
diff changeset
58 glong seek_to = -1;
2996
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
59 static volatile char pause_flag = 0;
969
ertzing
parents: 931
diff changeset
60 static GThread* thread = NULL;
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
61
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
62 /* === */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
63
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
64 void flac_init(void) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
65
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
66 FLAC__StreamDecoderInitStatus ret;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
67
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
68 _ENTER;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
69
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
70 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
71 * Callback structure and decoder for file test
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
72 * purposes
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
73 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
74 if (NULL == (test_info = init_callback_info("test"))) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
75 _ERROR("Could not initialize the test callback structure!");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
76 _LEAVE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
77 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
78 _DEBUG("Test callback structure at %p", test_info);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
79
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
80 if (NULL == (test_decoder = FLAC__stream_decoder_new())) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
81 _ERROR("Could not create the test FLAC decoder instance!");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
82 _LEAVE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
83 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
84
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
85
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
86 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
87 * We want the VORBISCOMMENT metadata, for the file tags
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
88 * and SEEKTABLE
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
89 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
90 FLAC__stream_decoder_set_metadata_respond(test_decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
91 FLAC__stream_decoder_set_metadata_respond(test_decoder, FLAC__METADATA_TYPE_SEEKTABLE);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
92
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
93 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
94 * Callback structure and decoder for main decoding
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
95 * loop
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
96 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
97 if (NULL == (main_info = init_callback_info("main"))) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
98 _ERROR("Could not initialize the main callback structure!");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
99 _LEAVE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
100 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
101 _DEBUG("Main callback structure at %p", main_info);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
102
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
103 if (NULL == (main_decoder = FLAC__stream_decoder_new())) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
104 _ERROR("Could not create the main FLAC decoder instance!");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
105 _LEAVE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
106 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
107
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
108
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
109 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
110 * We want the VORBISCOMMENT metadata, for the file tags
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
111 * and SEEKTABLE
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
112 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
113 FLAC__stream_decoder_set_metadata_respond(main_decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
114 FLAC__stream_decoder_set_metadata_respond(main_decoder, FLAC__METADATA_TYPE_SEEKTABLE);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
115
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
116 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
117 * Initialize decoders
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
118 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
119 if (FLAC__STREAM_DECODER_INIT_STATUS_OK != (ret = FLAC__stream_decoder_init_stream(
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
120 test_decoder,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
121 read_callback,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
122 seek_callback,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
123 tell_callback,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
124 length_callback,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
125 eof_callback,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
126 write_callback,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
127 metadata_callback,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
128 error_callback,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
129 test_info))) {
1246
626f78ff2439 - Add FLAC 1.1.2 compatibility
sun@fc5-buildsys
parents: 1092
diff changeset
130 _ERROR("Could not initialize test FLAC decoder: %s(%d)",
626f78ff2439 - Add FLAC 1.1.2 compatibility
sun@fc5-buildsys
parents: 1092
diff changeset
131 FLAC__StreamDecoderInitStatusString[ret], ret);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
132 _LEAVE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
133 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
134
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
135 if (FLAC__STREAM_DECODER_INIT_STATUS_OK != (ret = FLAC__stream_decoder_init_stream(
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
136 main_decoder,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
137 read_callback,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
138 seek_callback,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
139 tell_callback,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
140 length_callback,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
141 eof_callback,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
142 write_callback,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
143 metadata_callback,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
144 error_callback,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
145 main_info))) {
1246
626f78ff2439 - Add FLAC 1.1.2 compatibility
sun@fc5-buildsys
parents: 1092
diff changeset
146 _ERROR("Could not initialize main FLAC decoder: %s(%d)",
626f78ff2439 - Add FLAC 1.1.2 compatibility
sun@fc5-buildsys
parents: 1092
diff changeset
147 FLAC__StreamDecoderInitStatusString[ret], ret);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
148 _LEAVE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
149 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
150
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
151 _DEBUG("plugin initialized OK!");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
152 plugin_initialized = TRUE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
153 _LEAVE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
154 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
155
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
156 /* --- */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
157
2266
5395c85a8724 Make flacng plugin to clean up after itself (Bugzilla #19)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2204
diff changeset
158 void flac_cleanup(void)
5395c85a8724 Make flacng plugin to clean up after itself (Bugzilla #19)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2204
diff changeset
159 {
5395c85a8724 Make flacng plugin to clean up after itself (Bugzilla #19)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2204
diff changeset
160 _ENTER;
5395c85a8724 Make flacng plugin to clean up after itself (Bugzilla #19)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2204
diff changeset
161
5395c85a8724 Make flacng plugin to clean up after itself (Bugzilla #19)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2204
diff changeset
162 FLAC__stream_decoder_delete(main_decoder);
5395c85a8724 Make flacng plugin to clean up after itself (Bugzilla #19)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2204
diff changeset
163 clean_callback_info(main_info);
5395c85a8724 Make flacng plugin to clean up after itself (Bugzilla #19)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2204
diff changeset
164
5395c85a8724 Make flacng plugin to clean up after itself (Bugzilla #19)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2204
diff changeset
165 FLAC__stream_decoder_delete(test_decoder);
5395c85a8724 Make flacng plugin to clean up after itself (Bugzilla #19)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2204
diff changeset
166 clean_callback_info(test_info);
5395c85a8724 Make flacng plugin to clean up after itself (Bugzilla #19)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2204
diff changeset
167
5395c85a8724 Make flacng plugin to clean up after itself (Bugzilla #19)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2204
diff changeset
168 plugin_initialized = FALSE;
5395c85a8724 Make flacng plugin to clean up after itself (Bugzilla #19)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2204
diff changeset
169
5395c85a8724 Make flacng plugin to clean up after itself (Bugzilla #19)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2204
diff changeset
170 _LEAVE;
5395c85a8724 Make flacng plugin to clean up after itself (Bugzilla #19)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2204
diff changeset
171 }
5395c85a8724 Make flacng plugin to clean up after itself (Bugzilla #19)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2204
diff changeset
172
5395c85a8724 Make flacng plugin to clean up after itself (Bugzilla #19)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2204
diff changeset
173 /* --- */
5395c85a8724 Make flacng plugin to clean up after itself (Bugzilla #19)
Jussi Judin <jjudin+audacious@iki.fi>
parents: 2204
diff changeset
174
1255
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
175 gboolean flac_is_our_fd(gchar* filename, VFSFile* fd) {
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
176
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
177 _ENTER;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
178
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
179 if (!plugin_initialized) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
180 _ERROR("Plugin not initialized!");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
181 _LEAVE FALSE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
182 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
183
1272
47559538ce3d - stop read_metadata from stomping on the wrong file descriptors
Ralf Ertzinger <ralf@skytale.net>
parents: 1257
diff changeset
184 _DEBUG("Testing fd for file: %s", filename);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
185
1401
263d72004333 - Introduce a mutex for test_info and lock appropriately
Ralf Ertzinger <ralf@skytale.net>
parents: 1396
diff changeset
186 INFO_LOCK(test_info);
263d72004333 - Introduce a mutex for test_info and lock appropriately
Ralf Ertzinger <ralf@skytale.net>
parents: 1396
diff changeset
187
1255
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
188 if (FALSE == read_metadata(fd, test_decoder, test_info)) {
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
189 _DEBUG("File not handled by this plugin!");
1401
263d72004333 - Introduce a mutex for test_info and lock appropriately
Ralf Ertzinger <ralf@skytale.net>
parents: 1396
diff changeset
190 INFO_UNLOCK(test_info);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
191 _LEAVE FALSE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
192 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
193
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
194 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
195 * See if the metadata has changed
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
196 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
197 if (FALSE == test_info->metadata_changed) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
198 _DEBUG("No metadata found in stream");
1401
263d72004333 - Introduce a mutex for test_info and lock appropriately
Ralf Ertzinger <ralf@skytale.net>
parents: 1396
diff changeset
199 INFO_UNLOCK(test_info);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
200 _LEAVE FALSE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
201 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
202
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
203 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
204 * If we get here, the file is supported by FLAC.
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
205 * The stream characteristics have been filled in by
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
206 * the metadata callback.
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
207 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
208
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
209 _DEBUG("Stream encoded at %d Hz, %d bps, %d channels",
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
210 test_info->stream.samplerate,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
211 test_info->stream.bits_per_sample,
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
212 test_info->stream.channels);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
213
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
214 if (MAX_SUPPORTED_CHANNELS < test_info->stream.channels) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
215 _ERROR("This number of channels (%d) is currently not supported, stream not handled by this plugin",
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
216 test_info->stream.channels);
1401
263d72004333 - Introduce a mutex for test_info and lock appropriately
Ralf Ertzinger <ralf@skytale.net>
parents: 1396
diff changeset
217 INFO_UNLOCK(test_info);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
218 _LEAVE FALSE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
219 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
220
2360
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
221 if ((8 != test_info->stream.bits_per_sample) &&
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
222 (16 != test_info->stream.bits_per_sample) &&
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
223 (24 != test_info->stream.bits_per_sample) &&
2360
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
224 (32 != test_info->stream.bits_per_sample)) {
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
225 _ERROR("This number of bits (%d) is currently not supported, stream not handled by this plugin",
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
226 test_info->stream.bits_per_sample);
1401
263d72004333 - Introduce a mutex for test_info and lock appropriately
Ralf Ertzinger <ralf@skytale.net>
parents: 1396
diff changeset
227 INFO_UNLOCK(test_info);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
228 _LEAVE FALSE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
229 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
230
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
231 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
232 * Looks good.
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
233 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
234
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
235 _DEBUG("Accepting file %s", filename);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
236
1272
47559538ce3d - stop read_metadata from stomping on the wrong file descriptors
Ralf Ertzinger <ralf@skytale.net>
parents: 1257
diff changeset
237 reset_info(test_info, FALSE);
1401
263d72004333 - Introduce a mutex for test_info and lock appropriately
Ralf Ertzinger <ralf@skytale.net>
parents: 1396
diff changeset
238 INFO_UNLOCK(test_info);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
239
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
240 _LEAVE TRUE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
241 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
242
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
243 /* --- */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
244
1255
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
245 gboolean flac_is_our_file(gchar* filename) {
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
246
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
247 VFSFile* fd;
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
248 gboolean ret;
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
249
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
250 _ENTER;
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
251
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
252 _DEBUG("Testing file: %s", filename);
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
253 /*
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
254 * Open the file
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
255 */
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
256 if (NULL == (fd = aud_vfs_fopen(filename, "rb"))) {
1255
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
257 _ERROR("Could not open file for reading! (%s)", filename);
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
258 _LEAVE FALSE;
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
259 }
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
260
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
261 ret = flac_is_our_fd(filename, fd);
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
262
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
263 aud_vfs_fclose(fd);
1255
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
264
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
265 _LEAVE ret;
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
266 }
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
267
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
268 /* --- */
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
269
2360
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
270 void squeeze_audio(gint32* src, void* dst, guint count, guint res) {
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
271
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
272 gint i;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
273 gint32* rp = src;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
274 gint8* wp = dst;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
275 gint16* wp2 = dst;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
276 gint32* wp4 = dst;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
277
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
278 _ENTER;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
279
2360
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
280 _DEBUG("Converting %d samples to %d bit", count, res);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
281
2360
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
282 if (res % 8 != 0) {
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
283 _ERROR("Can not convert to %d bps: not a multiple of 8", res);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
284 _LEAVE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
285 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
286
2360
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
287 if (res == 8) {
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
288 for (i=0; i<count; i++, wp++, rp++) {
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
289 *wp = *rp & 0xff;
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
290 }
2360
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
291 } else if (res == 16) {
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
292 for (i=0; i<count; i++, wp2++, rp++) {
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
293 *wp2 = *rp & 0xffff;
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
294 }
2360
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
295 } else if (res == 24 || res == 32) { /* 24bit value stored in lowest 3 bytes */
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
296 for (i=0; i<count; i++, wp4++, rp++) {
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
297 *wp4 = *rp;
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
298 }
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
299 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
300
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
301 _LEAVE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
302 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
303
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
304 /* --- */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
305
2996
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
306 static void do_seek (InputPlayback * playback) {
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
307 playback->output->flush (seek_to);
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
308 FLAC__stream_decoder_seek_absolute (main_decoder, (long long) seek_to * main_info->stream.samplerate / 1000);
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
309 seek_to = -1;
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
310 }
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
311
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
312 static void do_pause (InputPlayback * playback) {
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
313 playback->output->pause (1);
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
314 while (pause_flag) {
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
315 if (seek_to != -1)
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
316 do_seek (playback);
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
317 g_usleep(50000);
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
318 }
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
319 playback->output->pause (0);
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
320 }
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
321
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
322 static gpointer flac_play_loop(gpointer arg) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
323
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
324 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
325 * The main play loop.
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
326 * Decode a frame, push the decoded data to the output plugin
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
327 * chunkwise. Repeat until finished.
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
328 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
329
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
330 gint32* read_pointer;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
331 gint elements_left;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
332 FLAC__StreamDecoderState state;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
333 struct stream_info stream_info;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
334 guint sample_count;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
335 void* play_buffer;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
336 InputPlayback* playback = (InputPlayback *) arg;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
337
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
338 _ENTER;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
339
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
340 if (NULL == (play_buffer = malloc(BUFFER_SIZE_BYTE))) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
341 _ERROR("Could not allocate conversion buffer");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
342 playback->playing = FALSE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
343 _LEAVE NULL;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
344 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
345
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
346 stream_info.samplerate = main_info->stream.samplerate;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
347 stream_info.channels = main_info->stream.channels;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
348 main_info->metadata_changed = FALSE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
349
2991
2cdf6400594c flacng: enable replaygain
Teemu Torma <teemu@torma.org>
parents: 2971
diff changeset
350 ReplayGainInfo rg_info = get_replay_gain(main_info);
2cdf6400594c flacng: enable replaygain
Teemu Torma <teemu@torma.org>
parents: 2971
diff changeset
351 playback->set_replaygain_info(playback, &rg_info);
2cdf6400594c flacng: enable replaygain
Teemu Torma <teemu@torma.org>
parents: 2971
diff changeset
352
2360
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
353 if (!playback->output->open_audio(SAMPLE_FMT(main_info->stream.bits_per_sample),
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
354 main_info->stream.samplerate,
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
355 main_info->stream.channels)) {
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
356 playback->playing = FALSE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
357 _ERROR("Could not open output plugin!");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
358 _LEAVE NULL;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
359 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
360
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
361 while (TRUE == playback->playing) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
362
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
363 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
364 * Try to decode a single frame of audio
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
365 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
366 if (FALSE == FLAC__stream_decoder_process_single(main_decoder)) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
367 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
368 * Something went wrong
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
369 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
370 _ERROR("Error while decoding!");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
371 break;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
372 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
373
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
374 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
375 * Maybe the metadata changed midstream. Check.
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
376 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
377
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
378 if (main_info->metadata_changed) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
379 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
380 * Samplerate and channels are important
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
381 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
382 if (stream_info.samplerate != main_info->stream.samplerate) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
383 _ERROR("Samplerate changed midstream (now: %d, was: %d). This is not supported yet.",
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
384 main_info->stream.samplerate, stream_info.samplerate);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
385 break;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
386 }
1318
a9a97179a1f9 I will be ready for Audacious 2...
Stany HENRY <StrassBoy@gmail.com>
parents: 1272
diff changeset
387
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
388 if (stream_info.channels != main_info->stream.channels) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
389 _ERROR("Number of channels changed midstream (now: %d, was: %d). This is not supported yet.",
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
390 main_info->stream.channels, stream_info.channels);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
391 break;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
392 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
393
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
394 main_info->metadata_changed = FALSE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
395 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
396
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
397 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
398 * Compare the frame metadata to the current stream metadata
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
399 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
400 if (main_info->stream.samplerate != main_info->frame.samplerate) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
401 _ERROR("Frame samplerate mismatch (stream: %d, frame: %d)!",
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
402 main_info->stream.samplerate, main_info->frame.samplerate);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
403 break;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
404 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
405
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
406 if (main_info->stream.channels != main_info->frame.channels) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
407 _ERROR("Frame channel mismatch (stream: %d, frame: %d)!",
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
408 main_info->stream.channels, main_info->frame.channels);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
409 break;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
410 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
411
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
412 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
413 * If the frame decoded was an audio frame we now
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
414 * have data in info->output_buffer
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
415 *
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
416 * The data in this buffer is in 32 bit wide samples, even if the
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
417 * real sample width is smaller. It has to be converted before
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
418 * feeding it to he output plugin.
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
419 *
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
420 * Feed the data in chunks of OUTPUT_BLOCK_SIZE elements to the output
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
421 * plugin
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
422 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
423 read_pointer = main_info->output_buffer;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
424 elements_left = main_info->buffer_used;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
425
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
426 while ((TRUE == playback->playing) && (0 != elements_left)) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
427
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
428 sample_count = MIN(OUTPUT_BLOCK_SIZE, elements_left);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
429
2360
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
430 squeeze_audio(read_pointer, play_buffer, sample_count, main_info->stream.bits_per_sample);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
431
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
432 _DEBUG("Copying %d samples to output plugin", sample_count);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
433
2360
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
434 playback->pass_audio(playback,
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
435 SAMPLE_FMT(main_info->stream.bits_per_sample),
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
436 main_info->stream.channels,
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
437 sample_count * SAMPLE_SIZE(main_info->stream.bits_per_sample),
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
438 play_buffer,
ead24454f4b7 native 24bit output for FLAC
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2266
diff changeset
439 NULL);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
440
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
441 read_pointer += sample_count;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
442 elements_left -= sample_count;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
443
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
444 _DEBUG("%d elements left to be output", elements_left);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
445 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
446
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
447 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
448 * Clear the buffer.
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
449 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
450 main_info->write_pointer = main_info->output_buffer;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
451 main_info->buffer_free = BUFFER_SIZE_SAMP;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
452 main_info->buffer_used = 0;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
453
2996
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
454 if (seek_to != -1)
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
455 do_seek (playback);
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
456 if (pause_flag)
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
457 do_pause (playback);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
458
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
459 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
460 * Have we reached the end of the stream?
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
461 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
462 state = FLAC__stream_decoder_get_state(main_decoder);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
463 if (0 == elements_left && (FLAC__STREAM_DECODER_END_OF_STREAM == state)) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
464 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
465 * Yes. Drain the output buffer and stop playing.
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
466 */
1318
a9a97179a1f9 I will be ready for Audacious 2...
Stany HENRY <StrassBoy@gmail.com>
parents: 1272
diff changeset
467
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
468 _DEBUG("End of stream reached, draining output buffer");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
469
2709
04249b58c738 Remove references to output plugin field in InputPlugins (hopefully I didn't
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
470 while((-1 == seek_to) && playback->output->buffer_playing() && playback->playing == TRUE) {
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
471 g_usleep(40000);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
472 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
473
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
474 if (-1 == seek_to) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
475 _DEBUG("Output buffer empty.");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
476 playback->playing = FALSE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
477 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
478 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
479 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
480
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
481 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
482 * Clean up a bit
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
483 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
484 playback->playing = FALSE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
485 _DEBUG("Closing audio device");
2709
04249b58c738 Remove references to output plugin field in InputPlugins (hopefully I didn't
Matti Hamalainen <ccr@tnsp.org>
parents: 2576
diff changeset
486 playback->output->close_audio();
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
487 _DEBUG("Audio device closed");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
488
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
489 free(play_buffer);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
490
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
491 if (FALSE == FLAC__stream_decoder_flush(main_decoder)) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
492 _ERROR("Could not flush decoder state!");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
493 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
494
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
495 _LEAVE NULL;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
496 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
497
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
498 /* --- */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
499
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
500 void flac_play_file (InputPlayback* input) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
501
1255
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
502 VFSFile* fd;
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
503 gint l;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
504
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
505 _ENTER;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
506
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
507 if (!plugin_initialized) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
508 _ERROR("plugin not initialized!");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
509 _LEAVE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
510 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
511
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
512 /*
1255
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
513 * Open the file
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
514 */
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
515 if (NULL == (fd = aud_vfs_fopen(input->filename, "rb"))) {
1257
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
516 _ERROR("Could not open file for reading! (%s)", input->filename);
1255
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
517 _LEAVE;
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
518 }
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
519
37598c8f4425 - Add flac_is_our_fd()
Ralf Ertzinger <ralf@skytale.net>
parents: 1246
diff changeset
520 if (FALSE == read_metadata(fd, main_decoder, main_info)) {
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
521 _ERROR("Could not prepare file for playing!");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
522 _LEAVE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
523 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
524
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
525 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
526 * Calculate the length
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
527 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
528 if (0 == main_info->stream.samplerate) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
529 _ERROR("Invalid sample rate for stream!");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
530 l = -1;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
531 } else {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
532 l = (main_info->stream.samples / main_info->stream.samplerate) * 1000;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
533 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
534
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
535 input->playing = TRUE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
536
1984
489e32a8e106 change some places to use set_params() instead of set_info() directly
William Pitcock <nenolod@atheme.org>
parents: 1983
diff changeset
537 input->set_params(input, get_title(input->filename, main_info), l, -1, main_info->stream.samplerate, main_info->stream.channels);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
538
1343
36364adc29cd flacng: Update plugin for new threading model.
William Pitcock <nenolod@atheme-project.org>
parents: 1325
diff changeset
539 thread = g_thread_self();
1447
195b5657303e updated input plugins to use set_pb_ready to signal to the core that they're ready for playback
Giacomo Lozito <james@develia.org>
parents: 1435
diff changeset
540 input->set_pb_ready(input);
1343
36364adc29cd flacng: Update plugin for new threading model.
William Pitcock <nenolod@atheme-project.org>
parents: 1325
diff changeset
541 flac_play_loop(input);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
542
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
543 _LEAVE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
544 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
545
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
546 /* --- */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
547
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
548 void flac_stop(InputPlayback* input) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
549
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
550 _ENTER;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
551
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
552 input->playing = FALSE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
553
969
ertzing
parents: 931
diff changeset
554 if (NULL != thread) {
ertzing
parents: 931
diff changeset
555 /*
ertzing
parents: 931
diff changeset
556 * Wait for the decoder thread to finish
ertzing
parents: 931
diff changeset
557 */
ertzing
parents: 931
diff changeset
558 _DEBUG("Waiting for decoder thread to die...");
ertzing
parents: 931
diff changeset
559 g_thread_join(thread);
ertzing
parents: 931
diff changeset
560 thread = NULL;
ertzing
parents: 931
diff changeset
561 _DEBUG("Decoder thread has finished");
ertzing
parents: 931
diff changeset
562 }
ertzing
parents: 931
diff changeset
563
2155
69c9f138611b - Fix files being left open after playing
Ralf Ertzinger <ralf@skytale.net>
parents: 1998
diff changeset
564 reset_info(main_info, TRUE);
69c9f138611b - Fix files being left open after playing
Ralf Ertzinger <ralf@skytale.net>
parents: 1998
diff changeset
565
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
566 _LEAVE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
567 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
568
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
569 /* --- */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
570
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
571 void flac_pause(InputPlayback* input, gshort p) {
2996
b7c181d0b325 Patch from John Lindgren <john.lindgren@tds.net> to support seeking whilst paused, Debian bug #517692.
Tony Vroon <chainsaw@gentoo.org>
parents: 2991
diff changeset
572 pause_flag = p;
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
573 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
574
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
575 /* --- */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
576
2421
6c272f46fa99 - Fix spelling errors
Ralf Ertzinger <ralf@skytale.net>
parents: 2417
diff changeset
577 void flac_mseek(InputPlayback* input, gulong millisecond) {
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
578
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
579 _ENTER;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
580
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
581 if (!input->playing) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
582 _DEBUG("Can not seek while not playing");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
583 _LEAVE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
584 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
585
2421
6c272f46fa99 - Fix spelling errors
Ralf Ertzinger <ralf@skytale.net>
parents: 2417
diff changeset
586 _DEBUG("Requesting seek to %d", millisecond);
6c272f46fa99 - Fix spelling errors
Ralf Ertzinger <ralf@skytale.net>
parents: 2417
diff changeset
587 seek_to = millisecond;
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
588
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
589 while (-1 != seek_to) {
1676
aee4ebea943a xmms_usleep() was removed, use g_usleep()
Matti Hamalainen <ccr@tnsp.org>
parents: 1619
diff changeset
590 g_usleep(10000);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
591 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
592
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
593 _LEAVE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
594 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
595
2417
0427c5d07a66 added mseek support to flacng. patch by Piotr Garus. thanks Piotr!
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2360
diff changeset
596 void flac_seek(InputPlayback* input, gint time) {
2421
6c272f46fa99 - Fix spelling errors
Ralf Ertzinger <ralf@skytale.net>
parents: 2417
diff changeset
597 gulong millisecond = time * 1000;
6c272f46fa99 - Fix spelling errors
Ralf Ertzinger <ralf@skytale.net>
parents: 2417
diff changeset
598 flac_mseek(input, millisecond);
2417
0427c5d07a66 added mseek support to flacng. patch by Piotr Garus. thanks Piotr!
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2360
diff changeset
599 }
0427c5d07a66 added mseek support to flacng. patch by Piotr Garus. thanks Piotr!
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 2360
diff changeset
600
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
601 /* --- */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
602
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
603 void flac_get_song_info(gchar* filename, gchar** title, gint* length) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
604
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
605 gint l;
1257
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
606 VFSFile* fd;
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
607
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
608 _ENTER;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
609
1257
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
610 _DEBUG("Testing file: %s", filename);
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
611 /*
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
612 * Open the file
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
613 */
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
614 if (NULL == (fd = aud_vfs_fopen(filename, "rb"))) {
1257
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
615 _ERROR("Could not open file for reading! (%s)", filename);
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
616 _LEAVE;
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
617 }
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
618
1401
263d72004333 - Introduce a mutex for test_info and lock appropriately
Ralf Ertzinger <ralf@skytale.net>
parents: 1396
diff changeset
619 INFO_LOCK(test_info);
263d72004333 - Introduce a mutex for test_info and lock appropriately
Ralf Ertzinger <ralf@skytale.net>
parents: 1396
diff changeset
620
1257
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
621 if (FALSE == read_metadata(fd, test_decoder, test_info)) {
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
622 _ERROR("Could not read file info!");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
623 *length = -1;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
624 *title = g_strdup("");
1272
47559538ce3d - stop read_metadata from stomping on the wrong file descriptors
Ralf Ertzinger <ralf@skytale.net>
parents: 1257
diff changeset
625 reset_info(test_info, TRUE);
1401
263d72004333 - Introduce a mutex for test_info and lock appropriately
Ralf Ertzinger <ralf@skytale.net>
parents: 1396
diff changeset
626 INFO_UNLOCK(test_info);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
627 _LEAVE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
628 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
629
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
630 /*
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
631 * Calculate the stream length (milliseconds)
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
632 */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
633 if (0 == test_info->stream.samplerate) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
634 _ERROR("Invalid sample rate for stream!");
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
635 l = -1;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
636 } else {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
637 l = (test_info->stream.samples / test_info->stream.samplerate) * 1000;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
638 _DEBUG("Stream length: %d seconds", l/1000);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
639 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
640
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
641 *length = l;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
642 *title = get_title(filename, test_info);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
643
1272
47559538ce3d - stop read_metadata from stomping on the wrong file descriptors
Ralf Ertzinger <ralf@skytale.net>
parents: 1257
diff changeset
644 reset_info(test_info, TRUE);
1401
263d72004333 - Introduce a mutex for test_info and lock appropriately
Ralf Ertzinger <ralf@skytale.net>
parents: 1396
diff changeset
645 INFO_UNLOCK(test_info);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
646
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
647 _LEAVE;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
648 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
649
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
650 /* --- */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
651
1435
654aa79e43ef flacng: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1401
diff changeset
652 Tuple *flac_get_song_tuple(gchar* filename) {
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
653
1257
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
654 VFSFile *fd;
1435
654aa79e43ef flacng: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1401
diff changeset
655 Tuple *tuple;
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
656
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
657 _ENTER;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
658
1257
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
659 _DEBUG("Testing file: %s", filename);
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
660 /*
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
661 * Open the file
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
662 */
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1961
diff changeset
663 if (NULL == (fd = aud_vfs_fopen(filename, "rb"))) {
1257
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
664 _ERROR("Could not open file for reading! (%s)", filename);
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
665 _LEAVE NULL;
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
666 }
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
667
1401
263d72004333 - Introduce a mutex for test_info and lock appropriately
Ralf Ertzinger <ralf@skytale.net>
parents: 1396
diff changeset
668 INFO_LOCK(test_info);
263d72004333 - Introduce a mutex for test_info and lock appropriately
Ralf Ertzinger <ralf@skytale.net>
parents: 1396
diff changeset
669
1257
574ee15195f3 - Fixes for flac_is_our_fd
Ralf Ertzinger <ralf@skytale.net>
parents: 1255
diff changeset
670 if (FALSE == read_metadata(fd, test_decoder, test_info)) {
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
671 _ERROR("Could not read metadata tuple for file <%s>", filename);
1272
47559538ce3d - stop read_metadata from stomping on the wrong file descriptors
Ralf Ertzinger <ralf@skytale.net>
parents: 1257
diff changeset
672 reset_info(test_info, TRUE);
1401
263d72004333 - Introduce a mutex for test_info and lock appropriately
Ralf Ertzinger <ralf@skytale.net>
parents: 1396
diff changeset
673 INFO_UNLOCK(test_info);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
674 _LEAVE NULL;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
675 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
676
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
677 tuple = get_tuple(filename, test_info);
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
678
1272
47559538ce3d - stop read_metadata from stomping on the wrong file descriptors
Ralf Ertzinger <ralf@skytale.net>
parents: 1257
diff changeset
679 reset_info(test_info, TRUE);
1401
263d72004333 - Introduce a mutex for test_info and lock appropriately
Ralf Ertzinger <ralf@skytale.net>
parents: 1396
diff changeset
680 INFO_UNLOCK(test_info);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
681
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
682 _LEAVE tuple;
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
683 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
684
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
685 /* --- */
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
686
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
687 void flac_aboutbox(void) {
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
688
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
689 static GtkWidget* about_window;
1318
a9a97179a1f9 I will be ready for Audacious 2...
Stany HENRY <StrassBoy@gmail.com>
parents: 1272
diff changeset
690 gchar *about_text;
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
691
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
692 if (about_window) {
2192
e5401b6c4665 the same thing in many plugins
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2155
diff changeset
693 gtk_window_present(GTK_WINDOW(about_window));
e5401b6c4665 the same thing in many plugins
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2155
diff changeset
694 return;
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
695 }
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
696
1318
a9a97179a1f9 I will be ready for Audacious 2...
Stany HENRY <StrassBoy@gmail.com>
parents: 1272
diff changeset
697 about_text = g_strjoin("", _("FLAC Audio Plugin "), _VERSION,
a9a97179a1f9 I will be ready for Audacious 2...
Stany HENRY <StrassBoy@gmail.com>
parents: 1272
diff changeset
698 _("\n\nOriginal code by\n"
a9a97179a1f9 I will be ready for Audacious 2...
Stany HENRY <StrassBoy@gmail.com>
parents: 1272
diff changeset
699 "Ralf Ertzinger <ralf@skytale.net>\n"
a9a97179a1f9 I will be ready for Audacious 2...
Stany HENRY <StrassBoy@gmail.com>
parents: 1272
diff changeset
700 "\n"
a9a97179a1f9 I will be ready for Audacious 2...
Stany HENRY <StrassBoy@gmail.com>
parents: 1272
diff changeset
701 "http://www.skytale.net/projects/bmp-flac2/"), NULL);
a9a97179a1f9 I will be ready for Audacious 2...
Stany HENRY <StrassBoy@gmail.com>
parents: 1272
diff changeset
702
1677
f6f5603a0954 xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents: 1676
diff changeset
703 about_window = audacious_info_dialog(_("About FLAC Audio Plugin"),
1318
a9a97179a1f9 I will be ready for Audacious 2...
Stany HENRY <StrassBoy@gmail.com>
parents: 1272
diff changeset
704 about_text,
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
705 _("OK"), FALSE, NULL, NULL);
1318
a9a97179a1f9 I will be ready for Audacious 2...
Stany HENRY <StrassBoy@gmail.com>
parents: 1272
diff changeset
706
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
707 g_signal_connect(G_OBJECT(about_window), "destroy",
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
708 G_CALLBACK(gtk_widget_destroyed), &about_window);
1325
a33da9237bed Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents: 1321
diff changeset
709 g_free(about_text);
930
2f742d127b3e [svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff changeset
710 }