Mercurial > audlegacy-plugins
annotate src/flac112/plugin.c @ 677:5860f8d93fbc trunk
[svn] - fix missing names in the ChangeLog.
author | nenolod |
---|---|
date | Tue, 20 Feb 2007 02:18:49 -0800 |
parents | 914c96de3244 |
children |
rev | line source |
---|---|
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
1 /* libxmms-flac - XMMS FLAC input plugin |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
2 * Copyright (C) 2000,2001,2002,2003,2004,2005 Josh Coalson |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
3 * |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
4 * This program is free software; you can redistribute it and/or |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
5 * modify it under the terms of the GNU General Public License |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
6 * as published by the Free Software Foundation; either version 2 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
7 * of the License, or (at your option) any later version. |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
8 * |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
9 * This program is distributed in the hope that it will be useful, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
12 * GNU General Public License for more details. |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
13 * |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
14 * You should have received a copy of the GNU General Public License |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
15 * along with this program; if not, write to the Free Software |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
17 */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
18 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
19 #include <stdlib.h> |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
20 #include <string.h> |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
21 #include <stdio.h> |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
22 #include <glib.h> |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
23 #include <pwd.h> |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
24 #include <sys/types.h> |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
25 #include <unistd.h> |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
26 |
489
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
27 #include <audacious/plugin.h> |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
28 #include <audacious/output.h> |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
29 #include <audacious/util.h> |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
30 #include <audacious/configdb.h> |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
31 #include <audacious/titlestring.h> |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
32 #include <audacious/vfs.h> |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
33 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
34 #ifdef HAVE_CONFIG_H |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
35 #include <config.h> |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
36 #endif |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
37 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
38 #ifdef HAVE_LANGINFO_CODESET |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
39 #include <langinfo.h> |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
40 #endif |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
41 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
42 #include "FLAC/all.h" |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
43 #include "plugin_common/all.h" |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
44 #include "grabbag.h" |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
45 #include "replaygain_synthesis.h" |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
46 #include "configure.h" |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
47 #include "charset.h" |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
48 #include "tag.h" |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
49 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
50 #ifdef min |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
51 #undef min |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
52 #endif |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
53 #define min(x,y) ((x)<(y)?(x):(y)) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
54 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
55 /* adjust for compilers that can't understand using LLU suffix for uint64_t literals */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
56 #ifdef _MSC_VER |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
57 #define FLAC__U64L(x) x |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
58 #else |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
59 #define FLAC__U64L(x) x##LLU |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
60 #endif |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
61 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
62 extern void FLAC_XMMS__file_info_box(char *filename); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
63 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
64 typedef struct { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
65 FLAC__bool abort_flag; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
66 FLAC__bool is_playing; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
67 FLAC__bool eof; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
68 FLAC__bool play_thread_open; /* if true, is_playing must also be true */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
69 unsigned total_samples; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
70 unsigned bits_per_sample; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
71 unsigned channels; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
72 unsigned sample_rate; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
73 unsigned length_in_msec; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
74 gchar *title; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
75 AFormat sample_format; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
76 unsigned sample_format_bytes_per_sample; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
77 int seek_to_in_sec; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
78 FLAC__bool has_replaygain; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
79 double replay_scale; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
80 DitherContext dither_context; |
489
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
81 VFSFile *vfsfile; |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
82 } file_info_struct; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
83 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
84 typedef FLAC__StreamDecoderWriteStatus (*WriteCallback) (const void *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
85 typedef void (*MetadataCallback) (const void *decoder, const FLAC__StreamMetadata *metadata, void *client_data); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
86 typedef void (*ErrorCallback) (const void *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
87 |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
88 #define NUM_DECODER_TYPES 1 |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
89 typedef enum { |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
90 DECODER_FILE |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
91 } decoder_t; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
92 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
93 static void FLAC_XMMS__init(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
94 static int FLAC_XMMS__is_our_file(char *filename); |
489
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
95 static int FLAC_XMMS__is_our_file_from_vfs(char *filename, VFSFile *vfsfile); |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
96 static void FLAC_XMMS__play_file(InputPlayback *playback); |
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
97 static void FLAC_XMMS__stop(InputPlayback *playback); |
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
98 static void FLAC_XMMS__pause(InputPlayback *playback, short p); |
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
99 static void FLAC_XMMS__seek(InputPlayback *playback, int time); |
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
100 static int FLAC_XMMS__get_time(InputPlayback *playback); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
101 static void FLAC_XMMS__cleanup(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
102 static void FLAC_XMMS__get_song_info(char *filename, char **title, int *length); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
103 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
104 static void *play_loop_(void *arg); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
105 |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
106 static FLAC__bool safe_decoder_init_(const char *filename, void *decoder); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
107 static void file_decoder_safe_decoder_finish_(void *decoder); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
108 static void file_decoder_safe_decoder_delete_(void *decoder); |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
109 static FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__SeekableStreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data); |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
110 static void metadata_callback_(const FLAC__SeekableStreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data); |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
111 static void error_callback_(const FLAC__SeekableStreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data); |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
112 static FLAC__bool file_decoder_is_eof(void *decoder); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
113 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
114 static decoder_t source_to_decoder_type (const char *source); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
115 |
372
a157306caf03
[svn] - finalize the plugin-side of the extension-assist ABI
nenolod
parents:
368
diff
changeset
|
116 gchar *flac_fmts[] = { "flac", NULL }; |
a157306caf03
[svn] - finalize the plugin-side of the extension-assist ABI
nenolod
parents:
368
diff
changeset
|
117 |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
118 InputPlugin flac_ip = |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
119 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
120 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
121 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
122 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
123 FLAC_XMMS__init, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
124 FLAC_XMMS__aboutbox, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
125 FLAC_XMMS__configure, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
126 FLAC_XMMS__is_our_file, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
127 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
128 FLAC_XMMS__play_file, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
129 FLAC_XMMS__stop, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
130 FLAC_XMMS__pause, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
131 FLAC_XMMS__seek, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
132 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
133 FLAC_XMMS__get_time, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
134 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
135 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
136 FLAC_XMMS__cleanup, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
137 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
138 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
139 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
140 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
141 FLAC_XMMS__get_song_info, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
142 FLAC_XMMS__file_info_box, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
143 NULL, |
372
a157306caf03
[svn] - finalize the plugin-side of the extension-assist ABI
nenolod
parents:
368
diff
changeset
|
144 flac_get_tuple, |
a157306caf03
[svn] - finalize the plugin-side of the extension-assist ABI
nenolod
parents:
368
diff
changeset
|
145 NULL, // set tuple |
368
c812e846b84e
[svn] - add support for extension probing to many plugins.
nenolod
parents:
207
diff
changeset
|
146 NULL, |
489
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
147 FLAC_XMMS__is_our_file_from_vfs, |
372
a157306caf03
[svn] - finalize the plugin-side of the extension-assist ABI
nenolod
parents:
368
diff
changeset
|
148 flac_fmts, |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
149 }; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
150 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
151 #define SAMPLES_PER_WRITE 512 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
152 #define SAMPLE_BUFFER_SIZE ((FLAC__MAX_BLOCK_SIZE + SAMPLES_PER_WRITE) * FLAC_PLUGIN__MAX_SUPPORTED_CHANNELS * (24/8)) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
153 static FLAC__byte sample_buffer_[SAMPLE_BUFFER_SIZE]; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
154 static unsigned sample_buffer_first_, sample_buffer_last_; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
155 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
156 static void *decoder_ = 0, *decoder2 = 0; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
157 static file_info_struct file_info_; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
158 static GThread *decode_thread_; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
159 static FLAC__bool audio_error_ = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
160 static FLAC__bool is_big_endian_host_; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
161 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
162 #define BITRATE_HIST_SEGMENT_MSEC 500 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
163 /* 500ms * 50 = 25s should be enough */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
164 #define BITRATE_HIST_SIZE 50 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
165 static unsigned bitrate_history_[BITRATE_HIST_SIZE]; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
166 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
167 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
168 InputPlugin *get_iplugin_info() |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
169 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
170 flac_ip.description = g_strdup_printf(_("FLAC Audio Plugin")); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
171 return &flac_ip; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
172 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
173 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
174 void set_track_info(const char* title, int length_in_msec) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
175 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
176 if (file_info_.is_playing) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
177 flac_ip.set_info((char*) title, length_in_msec, file_info_.sample_rate * file_info_.channels * file_info_.bits_per_sample, file_info_.sample_rate, file_info_.channels); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
178 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
179 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
180 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
181 static gchar* homedir() |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
182 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
183 gchar *result; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
184 char *env_home = getenv("HOME"); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
185 if (env_home) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
186 result = g_strdup (env_home); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
187 } else { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
188 uid_t uid = getuid(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
189 struct passwd *pwent; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
190 do { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
191 pwent = getpwent(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
192 } while (pwent && pwent->pw_uid != uid); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
193 result = pwent ? g_strdup (pwent->pw_dir) : NULL; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
194 endpwent(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
195 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
196 return result; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
197 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
198 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
199 void FLAC_XMMS__init() |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
200 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
201 ConfigDb *db; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
202 FLAC__uint32 test = 1; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
203 gchar *tmp = NULL; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
204 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
205 is_big_endian_host_ = (*((FLAC__byte*)(&test)))? false : true; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
206 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
207 memset(&flac_cfg, 0, sizeof(flac_cfg)); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
208 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
209 db = bmp_cfg_db_open(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
210 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
211 /* title */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
212 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
213 bmp_cfg_db_get_bool(db, "flac", "title.tag_override", &flac_cfg.title.tag_override); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
214 |
492
0dd1ff7e5ba7
[svn] flac 112 plugin: stability fixes and a new option to disable bitrate update in player window during playback (saves cpu, this is the solution for most people playing flac and reporting high cpu usage)
giacomo
parents:
490
diff
changeset
|
215 bmp_cfg_db_get_bool(db, "flac", "title.disable_bitrate_update", &flac_cfg.title.disable_bitrate_update); |
0dd1ff7e5ba7
[svn] flac 112 plugin: stability fixes and a new option to disable bitrate update in player window during playback (saves cpu, this is the solution for most people playing flac and reporting high cpu usage)
giacomo
parents:
490
diff
changeset
|
216 |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
217 if(!bmp_cfg_db_get_string(db, "flac", "title.tag_format", &flac_cfg.title.tag_format)) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
218 flac_cfg.title.tag_format = g_strdup("%p - %t"); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
219 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
220 bmp_cfg_db_get_bool(db, "flac", "title.convert_char_set", &flac_cfg.title.convert_char_set); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
221 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
222 if(!bmp_cfg_db_get_string(db, "flac", "title.user_char_set", &flac_cfg.title.user_char_set)) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
223 flac_cfg.title.user_char_set = FLAC_plugin__charset_get_current(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
224 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
225 /* replaygain */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
226 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
227 bmp_cfg_db_get_bool(db, "flac", "output.replaygain.enable", &flac_cfg.output.replaygain.enable); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
228 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
229 bmp_cfg_db_get_bool(db, "flac", "output.replaygain.album_mode", &flac_cfg.output.replaygain.album_mode); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
230 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
231 if(!bmp_cfg_db_get_int(db, "flac", "output.replaygain.preamp", &flac_cfg.output.replaygain.preamp)) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
232 flac_cfg.output.replaygain.preamp = 0; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
233 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
234 bmp_cfg_db_get_bool(db, "flac", "output.replaygain.hard_limit", &flac_cfg.output.replaygain.hard_limit); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
235 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
236 bmp_cfg_db_get_bool(db, "flac", "output.resolution.normal.dither_24_to_16", &flac_cfg.output.resolution.normal.dither_24_to_16); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
237 bmp_cfg_db_get_bool(db, "flac", "output.resolution.replaygain.dither", &flac_cfg.output.resolution.replaygain.dither); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
238 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
239 if(!bmp_cfg_db_get_int(db, "flac", "output.resolution.replaygain.noise_shaping", &flac_cfg.output.resolution.replaygain.noise_shaping)) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
240 flac_cfg.output.resolution.replaygain.noise_shaping = 1; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
241 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
242 if(!bmp_cfg_db_get_int(db, "flac", "output.resolution.replaygain.bps_out", &flac_cfg.output.resolution.replaygain.bps_out)) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
243 flac_cfg.output.resolution.replaygain.bps_out = 16; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
244 |
513
77012d414f58
[svn] - flac 112 plugin: removed ui options related to old http support
giacomo
parents:
512
diff
changeset
|
245 bmp_cfg_db_close(db); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
246 |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
247 decoder_ = FLAC__seekable_stream_decoder_new(); |
520
8f1785471613
[svn] - add missing inclusion of audacious/strings.h where necessary
giacomo
parents:
513
diff
changeset
|
248 file_info_.vfsfile = NULL; |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
249 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
250 |
489
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
251 int FLAC_XMMS__is_our_file_from_vfs( gchar * filename , VFSFile * vfsfile ) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
252 { |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
253 gchar magic_bytes[4]; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
254 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
255 if ( vfsfile == NULL ) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
256 return 0; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
257 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
258 if ( vfs_fread( magic_bytes , 1 , 4 , vfsfile ) != 4 ) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
259 return 0; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
260 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
261 if ( !strncmp( magic_bytes , "fLaC" , 4 ) ) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
262 return 1; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
263 else |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
264 return 0; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
265 } |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
266 |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
267 int FLAC_XMMS__is_our_file(char *filename) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
268 { |
489
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
269 VFSFile *vfsfile; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
270 gint result = 0; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
271 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
272 vfsfile = vfs_fopen( filename , "rb" ); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
273 |
489
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
274 if ( vfsfile == NULL ) return 0; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
275 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
276 result = FLAC_XMMS__is_our_file_from_vfs( filename , vfsfile ); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
277 |
489
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
278 vfs_fclose( vfsfile ); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
279 |
489
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
280 return result; |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
281 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
282 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
283 void FLAC_XMMS__play_file(InputPlayback *playback) |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
284 { |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
285 char *filename = playback->filename; |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
286 sample_buffer_first_ = sample_buffer_last_ = 0; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
287 audio_error_ = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
288 file_info_.abort_flag = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
289 file_info_.is_playing = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
290 file_info_.eof = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
291 file_info_.play_thread_open = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
292 file_info_.has_replaygain = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
293 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
294 if(decoder_ == 0) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
295 return; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
296 |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
297 if(!safe_decoder_init_(filename, decoder_)) |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
298 return; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
299 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
300 if(file_info_.has_replaygain && flac_cfg.output.replaygain.enable) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
301 if(flac_cfg.output.resolution.replaygain.bps_out == 8) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
302 file_info_.sample_format = FMT_U8; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
303 file_info_.sample_format_bytes_per_sample = 1; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
304 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
305 else if(flac_cfg.output.resolution.replaygain.bps_out == 16) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
306 file_info_.sample_format = (is_big_endian_host_) ? FMT_S16_BE : FMT_S16_LE; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
307 file_info_.sample_format_bytes_per_sample = 2; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
308 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
309 else { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
310 /*@@@ need some error here like wa2: MessageBox(mod_.hMainWindow, "ERROR: plugin can only handle 8/16-bit samples\n", "ERROR: plugin can only handle 8/16-bit samples", 0); */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
311 fprintf(stderr, "libxmms-flac: can't handle %d bit output\n", flac_cfg.output.resolution.replaygain.bps_out); |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
312 file_decoder_safe_decoder_finish_(decoder_); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
313 return; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
314 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
315 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
316 else { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
317 if(file_info_.bits_per_sample == 8) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
318 file_info_.sample_format = FMT_U8; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
319 file_info_.sample_format_bytes_per_sample = 1; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
320 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
321 else if(file_info_.bits_per_sample == 16 || (file_info_.bits_per_sample == 24 && flac_cfg.output.resolution.normal.dither_24_to_16)) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
322 file_info_.sample_format = (is_big_endian_host_) ? FMT_S16_BE : FMT_S16_LE; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
323 file_info_.sample_format_bytes_per_sample = 2; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
324 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
325 else { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
326 /*@@@ need some error here like wa2: MessageBox(mod_.hMainWindow, "ERROR: plugin can only handle 8/16-bit samples\n", "ERROR: plugin can only handle 8/16-bit samples", 0); */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
327 fprintf(stderr, "libxmms-flac: can't handle %d bit output\n", file_info_.bits_per_sample); |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
328 file_decoder_safe_decoder_finish_(decoder_); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
329 return; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
330 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
331 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
332 FLAC__replaygain_synthesis__init_dither_context(&file_info_.dither_context, file_info_.sample_format_bytes_per_sample * 8, flac_cfg.output.resolution.replaygain.noise_shaping); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
333 file_info_.is_playing = true; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
334 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
335 if(playback->output->open_audio(file_info_.sample_format, file_info_.sample_rate, file_info_.channels) == 0) { |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
336 audio_error_ = true; |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
337 file_decoder_safe_decoder_finish_(decoder_); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
338 return; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
339 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
340 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
341 file_info_.title = flac_format_song_title(filename); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
342 flac_ip.set_info(file_info_.title, file_info_.length_in_msec, file_info_.sample_rate * file_info_.channels * file_info_.bits_per_sample, file_info_.sample_rate, file_info_.channels); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
343 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
344 file_info_.seek_to_in_sec = -1; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
345 file_info_.play_thread_open = true; |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
346 decode_thread_ = g_thread_create((GThreadFunc)play_loop_, playback, TRUE, NULL); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
347 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
348 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
349 void FLAC_XMMS__stop(InputPlayback *playback) |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
350 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
351 if(file_info_.is_playing) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
352 file_info_.is_playing = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
353 if(file_info_.play_thread_open) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
354 file_info_.play_thread_open = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
355 g_thread_join(decode_thread_); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
356 } |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
357 playback->output->close_audio(); |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
358 file_decoder_safe_decoder_finish_(decoder_); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
359 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
360 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
361 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
362 void FLAC_XMMS__pause(InputPlayback *playback, short p) |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
363 { |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
364 playback->output->pause(p); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
365 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
366 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
367 void FLAC_XMMS__seek(InputPlayback *playback, int time) |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
368 { |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
369 file_info_.seek_to_in_sec = time; |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
370 file_info_.eof = false; |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
371 |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
372 while(file_info_.seek_to_in_sec != -1) |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
373 xmms_usleep(10000); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
374 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
375 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
376 int FLAC_XMMS__get_time(InputPlayback *playback) |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
377 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
378 if(audio_error_) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
379 return -2; |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
380 if(!file_info_.is_playing || (file_info_.eof && !playback->output->buffer_playing())) |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
381 return -1; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
382 else |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
383 return playback->output->output_time(); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
384 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
385 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
386 void FLAC_XMMS__cleanup() |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
387 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
388 g_free(flac_ip.description); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
389 flac_ip.description = NULL; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
390 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
391 if (flac_cfg.title.tag_format) { |
492
0dd1ff7e5ba7
[svn] flac 112 plugin: stability fixes and a new option to disable bitrate update in player window during playback (saves cpu, this is the solution for most people playing flac and reporting high cpu usage)
giacomo
parents:
490
diff
changeset
|
392 g_free(flac_cfg.title.tag_format); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
393 flac_cfg.title.tag_format = NULL; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
394 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
395 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
396 if (flac_cfg.title.user_char_set) { |
492
0dd1ff7e5ba7
[svn] flac 112 plugin: stability fixes and a new option to disable bitrate update in player window during playback (saves cpu, this is the solution for most people playing flac and reporting high cpu usage)
giacomo
parents:
490
diff
changeset
|
397 g_free(flac_cfg.title.user_char_set); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
398 flac_cfg.title.user_char_set = NULL; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
399 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
400 |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
401 file_decoder_safe_decoder_delete_(decoder_); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
402 decoder_ = 0; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
403 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
404 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
405 void FLAC_XMMS__get_song_info(char *filename, char **title, int *length_in_msec) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
406 { |
524
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
407 FLAC__StreamMetadata streaminfo; |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
408 |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
409 /* NOTE vfs is not used here, so only try |
522
2d3fad6a3842
[svn] - flac 112 plugin: do not try to pick tuple from file if file is not accessible via stdio (and stop crashing when such attempts are done); TODO: pick tags from flac via vfs
giacomo
parents:
520
diff
changeset
|
410 to pick tags if you can do it with flac library stdio */ |
2d3fad6a3842
[svn] - flac 112 plugin: do not try to pick tuple from file if file is not accessible via stdio (and stop crashing when such attempts are done); TODO: pick tags from flac via vfs
giacomo
parents:
520
diff
changeset
|
411 if ( strncmp(filename,"/",1) ) |
2d3fad6a3842
[svn] - flac 112 plugin: do not try to pick tuple from file if file is not accessible via stdio (and stop crashing when such attempts are done); TODO: pick tags from flac via vfs
giacomo
parents:
520
diff
changeset
|
412 { |
524
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
413 *title = g_strdup(filename); |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
414 *length_in_msec = -1; |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
415 return; |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
416 } |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
417 |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
418 if(!FLAC__metadata_get_streaminfo(filename, &streaminfo)) { |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
419 /* @@@ how to report the error? */ |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
420 if(title) { |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
421 if (source_to_decoder_type (filename) == DECODER_FILE) { |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
422 static const char *errtitle = "Invalid FLAC File: "; |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
423 *title = g_malloc(strlen(errtitle) + 1 + strlen(filename) + 1 + 1); |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
424 sprintf(*title, "%s\"%s\"", errtitle, filename); |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
425 } else { |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
426 *title = NULL; |
522
2d3fad6a3842
[svn] - flac 112 plugin: do not try to pick tuple from file if file is not accessible via stdio (and stop crashing when such attempts are done); TODO: pick tags from flac via vfs
giacomo
parents:
520
diff
changeset
|
427 } |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
428 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
429 if(length_in_msec) |
524
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
430 *length_in_msec = -1; |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
431 return; |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
432 } |
524
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
433 |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
434 if(title) { |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
435 *title = flac_format_song_title(filename); |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
436 } |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
437 if(length_in_msec) |
bb7312f3ec1a
[svn] - flac 112 plugin: last fix; hopefully, everything is ok now; for both 112 and 113 playback works and http stream works
giacomo
parents:
522
diff
changeset
|
438 *length_in_msec = (unsigned)((double)streaminfo.data.stream_info.total_samples / (double)streaminfo.data.stream_info.sample_rate * 1000.0 + 0.5); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
439 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
440 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
441 /*********************************************************************** |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
442 * local routines |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
443 **********************************************************************/ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
444 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
445 void *play_loop_(void *arg) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
446 { |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
447 InputPlayback *playback = arg; |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
448 unsigned written_time_last = 0, bh_index_last_w = 0, bh_index_last_o = BITRATE_HIST_SIZE, blocksize = 1; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
449 FLAC__uint64 decode_position_last = 0, decode_position_frame_last = 0, decode_position_frame = 0; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
450 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
451 while(file_info_.is_playing) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
452 if(!file_info_.eof) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
453 while(sample_buffer_last_ - sample_buffer_first_ < SAMPLES_PER_WRITE) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
454 unsigned s; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
455 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
456 s = sample_buffer_last_ - sample_buffer_first_; |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
457 if(file_decoder_is_eof(decoder_)) { |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
458 file_info_.eof = true; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
459 break; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
460 } |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
461 else if (!FLAC__seekable_stream_decoder_process_single(decoder_)) { |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
462 /*@@@ this should probably be a dialog */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
463 fprintf(stderr, "libxmms-flac: READ ERROR processing frame\n"); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
464 file_info_.eof = true; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
465 break; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
466 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
467 blocksize = sample_buffer_last_ - sample_buffer_first_ - s; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
468 decode_position_frame_last = decode_position_frame; |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
469 if(!FLAC__seekable_stream_decoder_get_decode_position(decoder_, &decode_position_frame)) |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
470 decode_position_frame = 0; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
471 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
472 if(sample_buffer_last_ - sample_buffer_first_ > 0) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
473 const unsigned n = min(sample_buffer_last_ - sample_buffer_first_, SAMPLES_PER_WRITE); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
474 int bytes = n * file_info_.channels * file_info_.sample_format_bytes_per_sample; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
475 FLAC__byte *sample_buffer_start = sample_buffer_ + sample_buffer_first_ * file_info_.channels * file_info_.sample_format_bytes_per_sample; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
476 unsigned written_time, bh_index_w; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
477 FLAC__uint64 decode_position; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
478 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
479 sample_buffer_first_ += n; |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
480 while(playback->output->buffer_free() < (int)bytes && file_info_.is_playing && file_info_.seek_to_in_sec == -1) |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
481 xmms_usleep(10000); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
482 if(file_info_.is_playing && file_info_.seek_to_in_sec == -1) |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
483 produce_audio(playback->output->written_time(), file_info_.sample_format, |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
484 file_info_.channels, bytes, sample_buffer_start, NULL); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
485 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
486 /* compute current bitrate */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
487 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
488 written_time = playback->output->written_time(); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
489 bh_index_w = written_time / BITRATE_HIST_SEGMENT_MSEC % BITRATE_HIST_SIZE; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
490 if(bh_index_w != bh_index_last_w) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
491 bh_index_last_w = bh_index_w; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
492 decode_position = decode_position_frame - (double)(sample_buffer_last_ - sample_buffer_first_) * (double)(decode_position_frame - decode_position_frame_last) / (double)blocksize; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
493 bitrate_history_[(bh_index_w + BITRATE_HIST_SIZE - 1) % BITRATE_HIST_SIZE] = |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
494 decode_position > decode_position_last && written_time > written_time_last ? |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
495 8000 * (decode_position - decode_position_last) / (written_time - written_time_last) : |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
496 file_info_.sample_rate * file_info_.channels * file_info_.bits_per_sample; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
497 decode_position_last = decode_position; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
498 written_time_last = written_time; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
499 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
500 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
501 else { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
502 file_info_.eof = true; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
503 xmms_usleep(10000); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
504 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
505 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
506 else |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
507 xmms_usleep(10000); |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
508 if(file_info_.seek_to_in_sec != -1) { |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
509 const double distance = (double)file_info_.seek_to_in_sec * 1000.0 / (double)file_info_.length_in_msec; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
510 unsigned target_sample = (unsigned)(distance * (double)file_info_.total_samples); |
489
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
511 if(FLAC__seekable_stream_decoder_seek_absolute(decoder_, (FLAC__uint64)target_sample)) { |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
512 playback->output->flush(file_info_.seek_to_in_sec * 1000); |
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
513 bh_index_last_w = bh_index_last_o = playback->output->output_time() / BITRATE_HIST_SEGMENT_MSEC % BITRATE_HIST_SIZE; |
489
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
514 if(!FLAC__seekable_stream_decoder_get_decode_position(decoder_, &decode_position_frame)) |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
515 decode_position_frame = 0; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
516 file_info_.seek_to_in_sec = -1; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
517 file_info_.eof = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
518 sample_buffer_first_ = sample_buffer_last_ = 0; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
519 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
520 } |
492
0dd1ff7e5ba7
[svn] flac 112 plugin: stability fixes and a new option to disable bitrate update in player window during playback (saves cpu, this is the solution for most people playing flac and reporting high cpu usage)
giacomo
parents:
490
diff
changeset
|
521 else if ( !flac_cfg.title.disable_bitrate_update ) |
0dd1ff7e5ba7
[svn] flac 112 plugin: stability fixes and a new option to disable bitrate update in player window during playback (saves cpu, this is the solution for most people playing flac and reporting high cpu usage)
giacomo
parents:
490
diff
changeset
|
522 { |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
523 /* display the right bitrate from history */ |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
524 unsigned bh_index_o = playback->output->output_time() / BITRATE_HIST_SEGMENT_MSEC % BITRATE_HIST_SIZE; |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
525 if(bh_index_o != bh_index_last_o && bh_index_o != bh_index_last_w && bh_index_o != (bh_index_last_w + 1) % BITRATE_HIST_SIZE) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
526 bh_index_last_o = bh_index_o; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
527 flac_ip.set_info(file_info_.title, file_info_.length_in_msec, bitrate_history_[bh_index_o], file_info_.sample_rate, file_info_.channels); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
528 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
529 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
530 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
531 |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
532 file_decoder_safe_decoder_finish_(decoder_); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
533 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
534 /* are these two calls necessary? */ |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
535 playback->output->buffer_free(); |
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
524
diff
changeset
|
536 playback->output->buffer_free(); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
537 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
538 g_free(file_info_.title); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
539 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
540 g_thread_exit(NULL); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
541 return 0; /* to silence the compiler warning about not returning a value */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
542 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
543 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
544 /*********** File decoder functions */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
545 |
489
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
546 static FLAC__bool file_decoder_unset_source(void *decoder) |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
547 { |
489
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
548 if ( file_info_.vfsfile != NULL ) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
549 { |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
550 vfs_fclose( file_info_.vfsfile ); |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
551 file_info_.vfsfile = NULL; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
552 } |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
553 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
554 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
555 static void file_decoder_safe_decoder_finish_(void *decoder) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
556 { |
489
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
557 file_decoder_unset_source(decoder); |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
558 if(decoder && FLAC__seekable_stream_decoder_get_state((FLAC__SeekableStreamDecoder *) decoder) != FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
559 FLAC__seekable_stream_decoder_finish((FLAC__SeekableStreamDecoder *) decoder); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
560 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
561 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
562 static void file_decoder_safe_decoder_delete_(void *decoder) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
563 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
564 if(decoder) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
565 file_decoder_safe_decoder_finish_(decoder); |
489
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
566 FLAC__seekable_stream_decoder_delete( (FLAC__SeekableStreamDecoder *) decoder); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
567 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
568 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
569 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
570 static FLAC__bool file_decoder_is_eof(void *decoder) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
571 { |
489
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
572 return FLAC__seekable_stream_decoder_get_state((FLAC__SeekableStreamDecoder *) decoder) == FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
573 } |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
574 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
575 static FLAC__bool file_decoder_set_source(void *decoder, const char *filename) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
576 { |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
577 if ( ( file_info_.vfsfile = vfs_fopen( filename , "rb" ) ) == NULL ) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
578 return false; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
579 else |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
580 return true; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
581 } |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
582 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
583 static FLAC__SeekableStreamDecoderReadStatus file_decoder_read_callback (const FLAC__SeekableStreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
584 { |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
585 file_info_struct *file_info = (file_info_struct *)client_data; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
586 (void) decoder; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
587 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
588 if( *bytes > 0 ) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
589 { |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
590 *bytes = vfs_fread( buffer , sizeof(FLAC__byte) , *bytes , file_info->vfsfile ); |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
591 if ( *bytes == 0 ) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
592 return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
593 else |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
594 return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
595 } |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
596 else |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
597 return FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
598 } |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
599 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
600 static FLAC__SeekableStreamDecoderSeekStatus file_decoder_seek_callback(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
601 { |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
602 file_info_struct *file_info = (file_info_struct *)client_data; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
603 (void) decoder; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
604 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
605 if ( vfs_fseek( file_info->vfsfile , (glong)absolute_byte_offset , SEEK_SET ) < 0 ) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
606 return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
607 else |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
608 return FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
609 } |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
610 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
611 static FLAC__SeekableStreamDecoderTellStatus file_decoder_tell_callback(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
612 { |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
613 file_info_struct *file_info = (file_info_struct *)client_data; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
614 glong pos; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
615 (void)decoder; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
616 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
617 if ( (pos = vfs_ftell(file_info->vfsfile)) < 0 ) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
618 return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
619 else |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
620 { |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
621 *absolute_byte_offset = (FLAC__uint64)pos; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
622 return FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
623 } |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
624 } |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
625 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
626 static FLAC__SeekableStreamDecoderLengthStatus file_decoder_length_callback(const FLAC__SeekableStreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
627 { |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
628 file_info_struct *file_info = (file_info_struct *)client_data; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
629 glong current_pos = 0; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
630 glong length = 0; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
631 (void)decoder; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
632 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
633 current_pos = vfs_ftell(file_info->vfsfile); |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
634 if ( current_pos < 0 ) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
635 return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
636 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
637 if ( vfs_fseek( file_info->vfsfile , 0 , SEEK_END ) < 0 ) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
638 return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
639 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
640 length = vfs_ftell(file_info->vfsfile); |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
641 if ( length < 0 ) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
642 return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
643 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
644 /* put back stream position */ |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
645 if ( vfs_fseek( file_info->vfsfile , current_pos , SEEK_SET ) < 0 ) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
646 return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
647 else |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
648 { |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
649 *stream_length = (FLAC__uint64)length; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
650 return FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
651 } |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
652 } |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
653 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
654 static FLAC__bool file_decoder_eof_callback (const FLAC__SeekableStreamDecoder *decoder, void *client_data) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
655 { |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
656 file_info_struct *file_info = (file_info_struct *)client_data; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
657 (void)decoder; |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
658 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
659 return vfs_feof( file_info->vfsfile ); |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
660 } |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
661 |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
662 static FLAC__bool file_decoder_init (void *decoder) |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
663 { |
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
664 return FLAC__seekable_stream_decoder_init( (FLAC__SeekableStreamDecoder*) decoder) == FLAC__SEEKABLE_STREAM_DECODER_OK; |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
665 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
666 |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
667 static decoder_t source_to_decoder_type (const char *source) |
489
ce4efa148521
[svn] flac 112 plugin: playback and detection use vfs; current situation is pretty similar to the one of flac 113 plugin
giacomo
parents:
372
diff
changeset
|
668 { |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
669 /* NOTE: in Audacious, always use DECODER_FILE to pick files via VFS */ |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
670 return DECODER_FILE; |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
671 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
672 |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
673 FLAC__bool safe_decoder_init_(const char *filename, void *decoder) |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
674 { |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
675 if(decoder == 0) |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
676 return false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
677 |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
678 file_decoder_safe_decoder_finish_(decoder); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
679 |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
680 file_decoder_set_source(decoder,filename); |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
681 FLAC__seekable_stream_decoder_set_md5_checking(decoder,false); |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
682 FLAC__seekable_stream_decoder_set_metadata_ignore_all(decoder); |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
683 FLAC__seekable_stream_decoder_set_metadata_respond(decoder, FLAC__METADATA_TYPE_STREAMINFO); |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
684 FLAC__seekable_stream_decoder_set_metadata_respond(decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT); |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
685 FLAC__seekable_stream_decoder_set_write_callback(decoder, write_callback_); |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
686 FLAC__seekable_stream_decoder_set_metadata_callback(decoder, metadata_callback_); |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
687 FLAC__seekable_stream_decoder_set_error_callback(decoder, error_callback_); |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
688 FLAC__seekable_stream_decoder_set_client_data(decoder, &file_info_); |
512
5be9b8f7ac03
[svn] - flac 112 plugin: removed http.c and http.h, plus some fixes
giacomo
parents:
511
diff
changeset
|
689 FLAC__seekable_stream_decoder_set_read_callback(decoder, file_decoder_read_callback); |
5be9b8f7ac03
[svn] - flac 112 plugin: removed http.c and http.h, plus some fixes
giacomo
parents:
511
diff
changeset
|
690 FLAC__seekable_stream_decoder_set_seek_callback(decoder, file_decoder_seek_callback); |
5be9b8f7ac03
[svn] - flac 112 plugin: removed http.c and http.h, plus some fixes
giacomo
parents:
511
diff
changeset
|
691 FLAC__seekable_stream_decoder_set_tell_callback(decoder, file_decoder_tell_callback); |
5be9b8f7ac03
[svn] - flac 112 plugin: removed http.c and http.h, plus some fixes
giacomo
parents:
511
diff
changeset
|
692 FLAC__seekable_stream_decoder_set_length_callback(decoder, file_decoder_length_callback); |
5be9b8f7ac03
[svn] - flac 112 plugin: removed http.c and http.h, plus some fixes
giacomo
parents:
511
diff
changeset
|
693 FLAC__seekable_stream_decoder_set_eof_callback(decoder, file_decoder_eof_callback); |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
694 |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
695 if ( !file_decoder_init(decoder) ) |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
696 { |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
697 file_decoder_unset_source(decoder); |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
698 return false; |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
699 } |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
700 |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
701 if(!FLAC__seekable_stream_decoder_process_until_end_of_metadata(decoder)) |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
702 { |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
703 file_decoder_unset_source(decoder); |
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
704 return false; |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
705 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
706 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
707 return true; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
708 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
709 |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
710 FLAC__StreamDecoderWriteStatus write_callback_(const FLAC__SeekableStreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
711 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
712 file_info_struct *file_info = (file_info_struct *)client_data; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
713 const unsigned channels = file_info->channels, wide_samples = frame->header.blocksize; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
714 const unsigned bits_per_sample = file_info->bits_per_sample; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
715 FLAC__byte *sample_buffer_start; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
716 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
717 (void)decoder; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
718 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
719 if(file_info->abort_flag) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
720 return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
721 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
722 if((sample_buffer_last_ + wide_samples) > (SAMPLE_BUFFER_SIZE / (channels * file_info->sample_format_bytes_per_sample))) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
723 memmove(sample_buffer_, sample_buffer_ + sample_buffer_first_ * channels * file_info->sample_format_bytes_per_sample, (sample_buffer_last_ - sample_buffer_first_) * channels * file_info->sample_format_bytes_per_sample); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
724 sample_buffer_last_ -= sample_buffer_first_; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
725 sample_buffer_first_ = 0; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
726 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
727 sample_buffer_start = sample_buffer_ + sample_buffer_last_ * channels * file_info->sample_format_bytes_per_sample; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
728 if(file_info->has_replaygain && flac_cfg.output.replaygain.enable) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
729 FLAC__replaygain_synthesis__apply_gain( |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
730 sample_buffer_start, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
731 !is_big_endian_host_, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
732 file_info->sample_format_bytes_per_sample == 1, /* unsigned_data_out */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
733 buffer, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
734 wide_samples, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
735 channels, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
736 bits_per_sample, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
737 file_info->sample_format_bytes_per_sample * 8, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
738 file_info->replay_scale, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
739 flac_cfg.output.replaygain.hard_limit, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
740 flac_cfg.output.resolution.replaygain.dither, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
741 &file_info->dither_context |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
742 ); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
743 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
744 else if(is_big_endian_host_) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
745 FLAC__plugin_common__pack_pcm_signed_big_endian( |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
746 sample_buffer_start, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
747 buffer, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
748 wide_samples, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
749 channels, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
750 bits_per_sample, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
751 file_info->sample_format_bytes_per_sample * 8 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
752 ); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
753 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
754 else { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
755 FLAC__plugin_common__pack_pcm_signed_little_endian( |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
756 sample_buffer_start, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
757 buffer, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
758 wide_samples, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
759 channels, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
760 bits_per_sample, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
761 file_info->sample_format_bytes_per_sample * 8 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
762 ); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
763 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
764 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
765 sample_buffer_last_ += wide_samples; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
766 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
767 return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
768 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
769 |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
770 void metadata_callback_(const FLAC__SeekableStreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
771 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
772 file_info_struct *file_info = (file_info_struct *)client_data; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
773 (void)decoder; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
774 if(metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
775 FLAC__ASSERT(metadata->data.stream_info.total_samples < FLAC__U64L(0x100000000)); /* this plugin can only handle < 4 gigasamples */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
776 file_info->total_samples = (unsigned)(metadata->data.stream_info.total_samples&0xffffffff); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
777 file_info->bits_per_sample = metadata->data.stream_info.bits_per_sample; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
778 file_info->channels = metadata->data.stream_info.channels; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
779 file_info->sample_rate = metadata->data.stream_info.sample_rate; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
780 file_info->length_in_msec = (unsigned)((double)file_info->total_samples / (double)file_info->sample_rate * 1000.0 + 0.5); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
781 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
782 else if(metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
783 double gain, peak; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
784 if(grabbag__replaygain_load_from_vorbiscomment(metadata, flac_cfg.output.replaygain.album_mode, &gain, &peak)) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
785 file_info->has_replaygain = true; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
786 file_info->replay_scale = grabbag__replaygain_compute_scale_factor(peak, gain, (double)flac_cfg.output.replaygain.preamp, /*prevent_clipping=*/!flac_cfg.output.replaygain.hard_limit); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
787 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
788 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
789 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
790 |
511
5f2145032f46
[svn] - removed http code from flac 112 plugin; still have to remove http options from gui
giacomo
parents:
492
diff
changeset
|
791 void error_callback_(const FLAC__SeekableStreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
792 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
793 file_info_struct *file_info = (file_info_struct *)client_data; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
794 (void)decoder; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
795 if(status != FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
796 file_info->abort_flag = true; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
797 } |