Mercurial > audlegacy-plugins
annotate src/flac112/plugin.c @ 323:230decbfe9be trunk
[svn] - what would we have ever done without Aerdan?
author | nenolod |
---|---|
date | Thu, 30 Nov 2006 23:02:05 -0800 |
parents | 063e31ae8f92 |
children | c812e846b84e |
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 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
27 #include "audacious/plugin.h" |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
28 #include "audacious/output.h" |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
29 #include "audacious/util.h" |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
30 #include "audacious/configdb.h" |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
31 #include "audacious/titlestring.h" |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
32 #include "audacious/vfs.h" |
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 "http.h" |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
49 #include "tag.h" |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
50 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
51 #ifdef min |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
52 #undef min |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
53 #endif |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
54 #define min(x,y) ((x)<(y)?(x):(y)) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
55 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
56 /* 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
|
57 #ifdef _MSC_VER |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
58 #define FLAC__U64L(x) x |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
59 #else |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
60 #define FLAC__U64L(x) x##LLU |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
61 #endif |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
62 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
63 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
|
64 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
65 typedef struct { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
66 FLAC__bool abort_flag; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
67 FLAC__bool is_playing; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
68 FLAC__bool eof; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
69 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
|
70 unsigned total_samples; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
71 unsigned bits_per_sample; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
72 unsigned channels; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
73 unsigned sample_rate; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
74 unsigned length_in_msec; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
75 gchar *title; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
76 AFormat sample_format; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
77 unsigned sample_format_bytes_per_sample; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
78 int seek_to_in_sec; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
79 FLAC__bool has_replaygain; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
80 double replay_scale; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
81 DitherContext dither_context; |
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 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
88 typedef struct { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
89 FLAC__bool seekable; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
90 void* (*new_decoder) (void); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
91 FLAC__bool (*set_md5_checking) (void *decoder, FLAC__bool value); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
92 FLAC__bool (*set_source) (void *decoder, const char* source); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
93 FLAC__bool (*set_metadata_ignore_all) (void *decoder); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
94 FLAC__bool (*set_metadata_respond) (void *decoder, FLAC__MetadataType type); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
95 FLAC__bool (*set_write_callback) (void *decoder, WriteCallback value); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
96 FLAC__bool (*set_metadata_callback) (void *decoder, MetadataCallback value); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
97 FLAC__bool (*set_error_callback) (void *decoder, ErrorCallback value); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
98 FLAC__bool (*set_client_data) (void *decoder, void *value); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
99 FLAC__bool (*decoder_init) (void *decoder); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
100 void (*safe_decoder_finish) (void *decoder); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
101 void (*safe_decoder_delete) (void *decoder); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
102 FLAC__bool (*process_until_end_of_metadata) (void *decoder); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
103 FLAC__bool (*process_single) (void *decoder); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
104 FLAC__bool (*is_eof) (void *decoder); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
105 } decoder_funcs_t; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
106 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
107 #define NUM_DECODER_TYPES 2 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
108 typedef enum { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
109 DECODER_FILE, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
110 DECODER_HTTP |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
111 } decoder_t; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
112 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
113 static void FLAC_XMMS__init(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
114 static int FLAC_XMMS__is_our_file(char *filename); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
115 static void FLAC_XMMS__play_file(char *filename); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
116 static void FLAC_XMMS__stop(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
117 static void FLAC_XMMS__pause(short p); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
118 static void FLAC_XMMS__seek(int time); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
119 static int FLAC_XMMS__get_time(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
120 static void FLAC_XMMS__cleanup(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
121 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
|
122 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
123 static void *play_loop_(void *arg); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
124 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
125 static FLAC__bool safe_decoder_init_(const char *filename, void **decoderp, decoder_funcs_t const ** fnsp); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
126 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
|
127 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
|
128 static FLAC__StreamDecoderWriteStatus write_callback_(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
|
129 static void metadata_callback_(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
|
130 static void error_callback_(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
|
131 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
132 static void init_decoder_func_tables(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
133 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
|
134 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
135 InputPlugin flac_ip = |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
136 { |
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 FLAC_XMMS__init, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
141 FLAC_XMMS__aboutbox, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
142 FLAC_XMMS__configure, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
143 FLAC_XMMS__is_our_file, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
144 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
145 FLAC_XMMS__play_file, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
146 FLAC_XMMS__stop, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
147 FLAC_XMMS__pause, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
148 FLAC_XMMS__seek, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
149 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
150 FLAC_XMMS__get_time, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
151 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
152 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
153 FLAC_XMMS__cleanup, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
154 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
155 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
156 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
157 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
158 FLAC_XMMS__get_song_info, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
159 FLAC_XMMS__file_info_box, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
160 NULL, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
161 flac_get_tuple |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
162 }; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
163 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
164 #define SAMPLES_PER_WRITE 512 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
165 #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
|
166 static FLAC__byte sample_buffer_[SAMPLE_BUFFER_SIZE]; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
167 static unsigned sample_buffer_first_, sample_buffer_last_; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
168 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
169 static void *decoder_ = 0, *decoder2 = 0; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
170 static file_info_struct file_info_; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
171 static GThread *decode_thread_; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
172 static FLAC__bool audio_error_ = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
173 static FLAC__bool is_big_endian_host_; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
174 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
175 #define BITRATE_HIST_SEGMENT_MSEC 500 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
176 /* 500ms * 50 = 25s should be enough */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
177 #define BITRATE_HIST_SIZE 50 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
178 static unsigned bitrate_history_[BITRATE_HIST_SIZE]; |
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 /* A table of sets of decoder functions, indexed by decoder_t */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
181 static const decoder_funcs_t* DECODER_FUNCS[NUM_DECODER_TYPES]; |
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 static decoder_funcs_t const * decoder_func_table_, * decoder_func_table2; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
184 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
185 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
186 InputPlugin *get_iplugin_info() |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
187 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
188 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
|
189 return &flac_ip; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
190 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
191 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
192 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
|
193 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
194 if (file_info_.is_playing) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
195 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
|
196 } |
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 static gchar* homedir() |
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 gchar *result; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
202 char *env_home = getenv("HOME"); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
203 if (env_home) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
204 result = g_strdup (env_home); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
205 } else { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
206 uid_t uid = getuid(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
207 struct passwd *pwent; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
208 do { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
209 pwent = getpwent(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
210 } while (pwent && pwent->pw_uid != uid); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
211 result = pwent ? g_strdup (pwent->pw_dir) : NULL; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
212 endpwent(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
213 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
214 return result; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
215 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
216 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
217 void FLAC_XMMS__init() |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
218 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
219 ConfigDb *db; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
220 FLAC__uint32 test = 1; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
221 gchar *tmp = NULL; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
222 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
223 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
|
224 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
225 memset(&flac_cfg, 0, sizeof(flac_cfg)); |
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 db = bmp_cfg_db_open(); |
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 /* title */ |
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 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
|
232 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
233 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
|
234 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
|
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", "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
|
237 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
238 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
|
239 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
|
240 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
241 /* replaygain */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
242 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
243 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
|
244 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
245 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
|
246 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
247 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
|
248 flac_cfg.output.replaygain.preamp = 0; |
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 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
|
251 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
252 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
|
253 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
|
254 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
255 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
|
256 flac_cfg.output.resolution.replaygain.noise_shaping = 1; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
257 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
258 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
|
259 flac_cfg.output.resolution.replaygain.bps_out = 16; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
260 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
261 /* stream */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
262 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
263 bmp_cfg_db_get_int(db, "flac", "stream.http_buffer_size", &flac_cfg.stream.http_buffer_size); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
264 bmp_cfg_db_get_int(db, "flac", "stream.http_prebuffer", &flac_cfg.stream.http_prebuffer); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
265 bmp_cfg_db_get_bool(db, "flac", "stream.save_http_stream", &flac_cfg.stream.save_http_stream); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
266 if (!bmp_cfg_db_get_string(db, "flac", "stream.save_http_path", &flac_cfg.stream.save_http_path) || |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
267 ! *flac_cfg.stream.save_http_path) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
268 /* TODO: Is this a memory leak ?? */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
269 /* |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
270 if (flac_cfg.stream.save_http_path) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
271 g_free (flac_cfg.stream.save_http_path); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
272 */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
273 flac_cfg.stream.save_http_path = homedir(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
274 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
275 bmp_cfg_db_get_bool(db, "flac", "stream.cast_title_streaming", &flac_cfg.stream.cast_title_streaming); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
276 bmp_cfg_db_get_bool(db, "flac", "stream.use_udp_channel", &flac_cfg.stream.use_udp_channel); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
277 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
278 init_decoder_func_tables(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
279 decoder_func_table_ = DECODER_FUNCS [DECODER_FILE]; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
280 decoder_ = decoder_func_table_ -> new_decoder(); |
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 bmp_cfg_db_get_bool(db, NULL, "use_proxy", &flac_cfg.stream.use_proxy); |
207
063e31ae8f92
[svn] Properly zero out proxy configuration strings if no value is retrieved, otherwise we crash and burn on shutdown.
chainsaw
parents:
104
diff
changeset
|
283 if(!bmp_cfg_db_get_string(db, NULL, "proxy_host", &flac_cfg.stream.proxy_host)) |
063e31ae8f92
[svn] Properly zero out proxy configuration strings if no value is retrieved, otherwise we crash and burn on shutdown.
chainsaw
parents:
104
diff
changeset
|
284 flac_cfg.stream.proxy_host = NULL; |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
285 bmp_cfg_db_get_string(db, NULL, "proxy_port", &tmp); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
286 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
287 if (tmp != NULL) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
288 flac_cfg.stream.proxy_port = atoi(tmp); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
289 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
290 bmp_cfg_db_get_bool(db, NULL, "proxy_use_auth", &flac_cfg.stream.proxy_use_auth); |
207
063e31ae8f92
[svn] Properly zero out proxy configuration strings if no value is retrieved, otherwise we crash and burn on shutdown.
chainsaw
parents:
104
diff
changeset
|
291 if(!bmp_cfg_db_get_string(db, NULL, "proxy_user", &flac_cfg.stream.proxy_user)) |
063e31ae8f92
[svn] Properly zero out proxy configuration strings if no value is retrieved, otherwise we crash and burn on shutdown.
chainsaw
parents:
104
diff
changeset
|
292 flac_cfg.stream.proxy_user = NULL; |
063e31ae8f92
[svn] Properly zero out proxy configuration strings if no value is retrieved, otherwise we crash and burn on shutdown.
chainsaw
parents:
104
diff
changeset
|
293 if(!bmp_cfg_db_get_string(db, NULL, "proxy_pass", &flac_cfg.stream.proxy_pass)) |
063e31ae8f92
[svn] Properly zero out proxy configuration strings if no value is retrieved, otherwise we crash and burn on shutdown.
chainsaw
parents:
104
diff
changeset
|
294 flac_cfg.stream.proxy_pass = NULL; |
104
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
295 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
296 bmp_cfg_db_close(db); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
297 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
298 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
299 int FLAC_XMMS__is_our_file(char *filename) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
300 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
301 FILE *f; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
302 FLAC__StreamMetadata streaminfo; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
303 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
304 if (source_to_decoder_type (filename) == DECODER_FILE) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
305 if(0 == (f = fopen(filename, "r"))) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
306 return 0; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
307 fclose(f); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
308 if(!FLAC__metadata_get_streaminfo(filename, &streaminfo)) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
309 return 0; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
310 return 1; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
311 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
312 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
313 if(!safe_decoder_init_(filename, &decoder2, &decoder_func_table2)) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
314 return 0; |
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 decoder_func_table2 -> safe_decoder_finish(decoder2); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
317 return 1; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
318 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
319 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
320 void FLAC_XMMS__play_file(char *filename) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
321 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
322 FILE *f; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
323 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
324 sample_buffer_first_ = sample_buffer_last_ = 0; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
325 audio_error_ = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
326 file_info_.abort_flag = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
327 file_info_.is_playing = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
328 file_info_.eof = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
329 file_info_.play_thread_open = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
330 file_info_.has_replaygain = false; |
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 if (source_to_decoder_type (filename) == DECODER_FILE) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
333 if(0 == (f = fopen(filename, "r"))) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
334 return; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
335 fclose(f); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
336 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
337 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
338 if(decoder_ == 0) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
339 return; |
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 if(!safe_decoder_init_(filename, &decoder_, &decoder_func_table_)) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
342 return; |
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 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
|
345 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
|
346 file_info_.sample_format = FMT_U8; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
347 file_info_.sample_format_bytes_per_sample = 1; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
348 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
349 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
|
350 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
|
351 file_info_.sample_format_bytes_per_sample = 2; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
352 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
353 else { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
354 /*@@@ 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
|
355 fprintf(stderr, "libxmms-flac: can't handle %d bit output\n", flac_cfg.output.resolution.replaygain.bps_out); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
356 decoder_func_table_ -> safe_decoder_finish(decoder_); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
357 return; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
358 } |
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 else { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
361 if(file_info_.bits_per_sample == 8) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
362 file_info_.sample_format = FMT_U8; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
363 file_info_.sample_format_bytes_per_sample = 1; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
364 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
365 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
|
366 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
|
367 file_info_.sample_format_bytes_per_sample = 2; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
368 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
369 else { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
370 /*@@@ 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
|
371 fprintf(stderr, "libxmms-flac: can't handle %d bit output\n", file_info_.bits_per_sample); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
372 decoder_func_table_ -> safe_decoder_finish(decoder_); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
373 return; |
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 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
376 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
|
377 file_info_.is_playing = true; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
378 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
379 if(flac_ip.output->open_audio(file_info_.sample_format, file_info_.sample_rate, file_info_.channels) == 0) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
380 audio_error_ = true; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
381 decoder_func_table_ -> safe_decoder_finish(decoder_); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
382 return; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
383 } |
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 file_info_.title = flac_format_song_title(filename); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
386 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
|
387 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
388 file_info_.seek_to_in_sec = -1; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
389 file_info_.play_thread_open = true; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
390 decode_thread_ = g_thread_create((GThreadFunc)play_loop_, NULL, TRUE, NULL); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
391 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
392 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
393 void FLAC_XMMS__stop() |
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 if(file_info_.is_playing) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
396 file_info_.is_playing = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
397 if(file_info_.play_thread_open) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
398 file_info_.play_thread_open = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
399 g_thread_join(decode_thread_); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
400 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
401 flac_ip.output->close_audio(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
402 decoder_func_table_ -> safe_decoder_finish (decoder_); |
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 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
406 void FLAC_XMMS__pause(short p) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
407 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
408 flac_ip.output->pause(p); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
409 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
410 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
411 void FLAC_XMMS__seek(int time) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
412 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
413 if (decoder_func_table_->seekable) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
414 file_info_.seek_to_in_sec = time; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
415 file_info_.eof = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
416 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
417 while(file_info_.seek_to_in_sec != -1) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
418 xmms_usleep(10000); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
419 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
420 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
421 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
422 int FLAC_XMMS__get_time() |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
423 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
424 if(audio_error_) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
425 return -2; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
426 if(!file_info_.is_playing || (file_info_.eof && !flac_ip.output->buffer_playing())) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
427 return -1; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
428 else |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
429 return flac_ip.output->output_time(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
430 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
431 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
432 void FLAC_XMMS__cleanup() |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
433 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
434 g_free(flac_ip.description); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
435 flac_ip.description = NULL; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
436 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
437 if (flac_cfg.title.tag_format) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
438 free(flac_cfg.title.tag_format); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
439 flac_cfg.title.tag_format = NULL; |
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 if (flac_cfg.title.user_char_set) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
443 free(flac_cfg.title.user_char_set); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
444 flac_cfg.title.user_char_set = NULL; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
445 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
446 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
447 if (flac_cfg.stream.proxy_host) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
448 free(flac_cfg.stream.proxy_host); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
449 flac_cfg.stream.proxy_host = NULL; |
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 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
452 if (flac_cfg.stream.proxy_user) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
453 free(flac_cfg.stream.proxy_user); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
454 flac_cfg.stream.proxy_user = NULL; |
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 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
457 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
458 if (flac_cfg.stream.proxy_pass) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
459 free(flac_cfg.stream.proxy_pass); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
460 flac_cfg.stream.proxy_pass = NULL; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
461 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
462 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
463 decoder_func_table_ -> safe_decoder_delete(decoder_); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
464 decoder_ = 0; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
465 } |
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 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
|
468 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
469 FLAC__StreamMetadata streaminfo; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
470 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
471 if(0 == filename) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
472 filename = ""; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
473 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
474 if(!FLAC__metadata_get_streaminfo(filename, &streaminfo)) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
475 /* @@@ how to report the error? */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
476 if(title) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
477 if (source_to_decoder_type (filename) == DECODER_FILE) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
478 static const char *errtitle = "Invalid FLAC File: "; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
479 *title = g_malloc(strlen(errtitle) + 1 + strlen(filename) + 1 + 1); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
480 sprintf(*title, "%s\"%s\"", errtitle, filename); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
481 } else { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
482 *title = NULL; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
483 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
484 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
485 if(length_in_msec) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
486 *length_in_msec = -1; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
487 return; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
488 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
489 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
490 if(title) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
491 *title = flac_format_song_title(filename); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
492 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
493 if(length_in_msec) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
494 *length_in_msec = (unsigned)((double)streaminfo.data.stream_info.total_samples / (double)streaminfo.data.stream_info.sample_rate * 1000.0 + 0.5); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
495 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
496 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
497 /*********************************************************************** |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
498 * local routines |
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 void *play_loop_(void *arg) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
502 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
503 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
|
504 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
|
505 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
506 (void)arg; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
507 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
508 while(file_info_.is_playing) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
509 if(!file_info_.eof) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
510 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
|
511 unsigned s; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
512 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
513 s = sample_buffer_last_ - sample_buffer_first_; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
514 if(decoder_func_table_ -> is_eof(decoder_)) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
515 file_info_.eof = true; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
516 break; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
517 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
518 else if (!decoder_func_table_ -> process_single(decoder_)) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
519 /*@@@ this should probably be a dialog */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
520 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
|
521 file_info_.eof = true; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
522 break; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
523 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
524 blocksize = sample_buffer_last_ - sample_buffer_first_ - s; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
525 decode_position_frame_last = decode_position_frame; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
526 if(!decoder_func_table_->seekable || !FLAC__file_decoder_get_decode_position(decoder_, &decode_position_frame)) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
527 decode_position_frame = 0; |
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 if(sample_buffer_last_ - sample_buffer_first_ > 0) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
530 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
|
531 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
|
532 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
|
533 unsigned written_time, bh_index_w; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
534 FLAC__uint64 decode_position; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
535 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
536 sample_buffer_first_ += n; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
537 while(flac_ip.output->buffer_free() < (int)bytes && file_info_.is_playing && file_info_.seek_to_in_sec == -1) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
538 xmms_usleep(10000); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
539 if(file_info_.is_playing && file_info_.seek_to_in_sec == -1) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
540 produce_audio(flac_ip.output->written_time(), file_info_.sample_format, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
541 file_info_.channels, bytes, sample_buffer_start, NULL); |
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 /* compute current bitrate */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
544 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
545 written_time = flac_ip.output->written_time(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
546 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
|
547 if(bh_index_w != bh_index_last_w) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
548 bh_index_last_w = bh_index_w; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
549 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
|
550 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
|
551 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
|
552 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
|
553 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
|
554 decode_position_last = decode_position; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
555 written_time_last = written_time; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
556 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
557 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
558 else { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
559 file_info_.eof = true; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
560 xmms_usleep(10000); |
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 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
563 else |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
564 xmms_usleep(10000); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
565 if(decoder_func_table_->seekable && file_info_.seek_to_in_sec != -1) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
566 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
|
567 unsigned target_sample = (unsigned)(distance * (double)file_info_.total_samples); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
568 if(FLAC__file_decoder_seek_absolute(decoder_, (FLAC__uint64)target_sample)) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
569 flac_ip.output->flush(file_info_.seek_to_in_sec * 1000); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
570 bh_index_last_w = bh_index_last_o = flac_ip.output->output_time() / BITRATE_HIST_SEGMENT_MSEC % BITRATE_HIST_SIZE; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
571 if(!FLAC__file_decoder_get_decode_position(decoder_, &decode_position_frame)) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
572 decode_position_frame = 0; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
573 file_info_.seek_to_in_sec = -1; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
574 file_info_.eof = false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
575 sample_buffer_first_ = sample_buffer_last_ = 0; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
576 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
577 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
578 else { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
579 /* display the right bitrate from history */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
580 unsigned bh_index_o = flac_ip.output->output_time() / BITRATE_HIST_SEGMENT_MSEC % BITRATE_HIST_SIZE; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
581 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
|
582 bh_index_last_o = bh_index_o; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
583 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
|
584 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
585 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
586 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
587 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
588 decoder_func_table_ -> safe_decoder_finish(decoder_); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
589 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
590 /* are these two calls necessary? */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
591 flac_ip.output->buffer_free(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
592 flac_ip.output->buffer_free(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
593 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
594 g_free(file_info_.title); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
595 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
596 g_thread_exit(NULL); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
597 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
|
598 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
599 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
600 /*********** File decoder functions */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
601 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
602 static FLAC__bool file_decoder_init (void *decoder) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
603 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
604 return FLAC__file_decoder_init( (FLAC__FileDecoder*) decoder) == FLAC__FILE_DECODER_OK; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
605 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
606 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
607 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
|
608 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
609 if(decoder && FLAC__file_decoder_get_state((FLAC__FileDecoder *) decoder) != FLAC__FILE_DECODER_UNINITIALIZED) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
610 FLAC__file_decoder_finish((FLAC__FileDecoder *) decoder); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
611 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
612 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
613 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
|
614 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
615 if(decoder) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
616 file_decoder_safe_decoder_finish_(decoder); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
617 FLAC__file_decoder_delete( (FLAC__FileDecoder *) decoder); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
618 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
619 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
620 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
621 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
|
622 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
623 return FLAC__file_decoder_get_state((FLAC__FileDecoder *) decoder) == FLAC__FILE_DECODER_END_OF_FILE; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
624 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
625 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
626 static const decoder_funcs_t FILE_DECODER_FUNCTIONS = { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
627 true, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
628 (void* (*) (void)) FLAC__file_decoder_new, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
629 (FLAC__bool (*) (void *, FLAC__bool)) FLAC__file_decoder_set_md5_checking, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
630 (FLAC__bool (*) (void *, const char*)) FLAC__file_decoder_set_filename, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
631 (FLAC__bool (*) (void *)) FLAC__file_decoder_set_metadata_ignore_all, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
632 (FLAC__bool (*) (void *, FLAC__MetadataType)) FLAC__file_decoder_set_metadata_respond, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
633 (FLAC__bool (*) (void *, WriteCallback)) FLAC__file_decoder_set_write_callback, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
634 (FLAC__bool (*) (void *, MetadataCallback)) FLAC__file_decoder_set_metadata_callback, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
635 (FLAC__bool (*) (void *, ErrorCallback)) FLAC__file_decoder_set_error_callback, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
636 (FLAC__bool (*) (void *, void *)) FLAC__file_decoder_set_client_data, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
637 (FLAC__bool (*) (void *)) file_decoder_init, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
638 (void (*) (void *)) file_decoder_safe_decoder_finish_, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
639 (void (*) (void *)) file_decoder_safe_decoder_delete_, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
640 (FLAC__bool (*) (void *)) FLAC__file_decoder_process_until_end_of_metadata, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
641 (FLAC__bool (*) (void *)) FLAC__file_decoder_process_single, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
642 file_decoder_is_eof |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
643 }; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
644 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
645 /*********** HTTP decoder functions */ |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
646 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
647 static gchar *url_; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
648 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
649 static FLAC__bool http_decoder_set_md5_checking (void *decoder, FLAC__bool value) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
650 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
651 (void) value; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
652 // operation unsupported |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
653 return FLAC__stream_decoder_get_state ((const FLAC__StreamDecoder *) decoder) == |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
654 FLAC__STREAM_DECODER_UNINITIALIZED; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
655 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
656 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
657 static FLAC__bool http_decoder_set_url (void *decoder, const char* url) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
658 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
659 (void) decoder; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
660 url_ = g_strdup (url); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
661 return true; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
662 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
663 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
664 static FLAC__StreamDecoderReadStatus http_decoder_read_callback (const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data) |
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 (void) decoder; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
667 (void) client_data; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
668 *bytes = flac_http_read (buffer, *bytes); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
669 return *bytes ? FLAC__STREAM_DECODER_READ_STATUS_CONTINUE : FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
670 } |
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 static FLAC__bool http_decoder_init (void *decoder) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
673 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
674 flac_http_open (url_, 0); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
675 g_free (url_); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
676 FLAC__stream_decoder_set_read_callback (decoder, http_decoder_read_callback); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
677 return FLAC__stream_decoder_init( (FLAC__StreamDecoder*) decoder) == FLAC__STREAM_DECODER_SEARCH_FOR_METADATA; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
678 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
679 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
680 static void http_decoder_safe_decoder_finish_(void *decoder) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
681 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
682 if(decoder && FLAC__stream_decoder_get_state((FLAC__StreamDecoder *) decoder) != FLAC__STREAM_DECODER_UNINITIALIZED) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
683 FLAC__stream_decoder_finish((FLAC__StreamDecoder *) decoder); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
684 flac_http_close(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
685 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
686 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
687 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
688 static void http_decoder_safe_decoder_delete_(void *decoder) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
689 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
690 if(decoder) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
691 http_decoder_safe_decoder_finish_(decoder); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
692 FLAC__stream_decoder_delete( (FLAC__StreamDecoder *) decoder); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
693 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
694 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
695 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
696 static FLAC__bool http_decoder_is_eof(void *decoder) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
697 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
698 return FLAC__stream_decoder_get_state((FLAC__StreamDecoder *) decoder) == FLAC__STREAM_DECODER_END_OF_STREAM; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
699 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
700 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
701 static const decoder_funcs_t HTTP_DECODER_FUNCTIONS = { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
702 false, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
703 (void* (*) (void)) FLAC__stream_decoder_new, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
704 http_decoder_set_md5_checking, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
705 (FLAC__bool (*) (void *, const char*)) http_decoder_set_url, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
706 (FLAC__bool (*) (void *)) FLAC__stream_decoder_set_metadata_ignore_all, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
707 (FLAC__bool (*) (void *, FLAC__MetadataType)) FLAC__stream_decoder_set_metadata_respond, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
708 (FLAC__bool (*) (void *, WriteCallback)) FLAC__stream_decoder_set_write_callback, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
709 (FLAC__bool (*) (void *, MetadataCallback)) FLAC__stream_decoder_set_metadata_callback, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
710 (FLAC__bool (*) (void *, ErrorCallback)) FLAC__stream_decoder_set_error_callback, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
711 (FLAC__bool (*) (void *, void *)) FLAC__stream_decoder_set_client_data, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
712 (FLAC__bool (*) (void *)) http_decoder_init, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
713 (void (*) (void *)) http_decoder_safe_decoder_finish_, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
714 (void (*) (void *)) http_decoder_safe_decoder_delete_, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
715 (FLAC__bool (*) (void *)) FLAC__stream_decoder_process_until_end_of_metadata, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
716 (FLAC__bool (*) (void *)) FLAC__stream_decoder_process_single, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
717 http_decoder_is_eof |
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 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
720 static decoder_funcs_t const *decoder_func_table_; |
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 static void init_decoder_func_tables() |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
723 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
724 DECODER_FUNCS [DECODER_FILE] = & FILE_DECODER_FUNCTIONS; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
725 DECODER_FUNCS [DECODER_HTTP] = & HTTP_DECODER_FUNCTIONS; |
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 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
728 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
|
729 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
730 return strncasecmp(source, "http://", 7) ? DECODER_FILE : DECODER_HTTP; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
731 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
732 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
733 static void change_decoder_if_needed (decoder_t new_decoder_type, void **decoderp, decoder_funcs_t const ** fntabp) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
734 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
735 const decoder_funcs_t *new_fn_table = DECODER_FUNCS [new_decoder_type]; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
736 if (*fntabp != new_fn_table) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
737 (*fntabp)->safe_decoder_delete(*decoderp); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
738 *fntabp = new_fn_table; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
739 *decoderp = new_fn_table -> new_decoder(); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
740 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
741 } |
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 FLAC__bool safe_decoder_init_(const char *filename, void **decoderp, decoder_funcs_t const ** fntabp) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
744 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
745 if(decoderp == 0 || *decoderp == 0) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
746 return false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
747 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
748 (*fntabp)->safe_decoder_finish(*decoderp); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
749 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
750 change_decoder_if_needed(source_to_decoder_type(filename), decoderp, fntabp); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
751 |
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 decoder_funcs_t const *fntab = *fntabp; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
754 void *decoder = *decoderp; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
755 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
756 decoder = *decoderp; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
757 fntab = *fntabp; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
758 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
759 fntab -> set_md5_checking(decoder, false); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
760 fntab -> set_source(decoder, filename); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
761 fntab -> set_metadata_ignore_all(decoder); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
762 fntab -> set_metadata_respond(decoder, FLAC__METADATA_TYPE_STREAMINFO); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
763 fntab -> set_metadata_respond(decoder, FLAC__METADATA_TYPE_VORBIS_COMMENT); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
764 fntab -> set_write_callback(decoder, write_callback_); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
765 fntab -> set_metadata_callback(decoder, metadata_callback_); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
766 fntab -> set_error_callback(decoder, error_callback_); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
767 fntab -> set_client_data(decoder, &file_info_); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
768 if(!fntab -> decoder_init(decoder)) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
769 return false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
770 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
771 if(!fntab -> process_until_end_of_metadata(decoder)) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
772 return false; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
773 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
774 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
775 return true; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
776 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
777 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
778 FLAC__StreamDecoderWriteStatus write_callback_(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
|
779 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
780 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
|
781 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
|
782 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
|
783 FLAC__byte *sample_buffer_start; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
784 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
785 (void)decoder; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
786 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
787 if(file_info->abort_flag) |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
788 return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; |
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 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
|
791 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
|
792 sample_buffer_last_ -= sample_buffer_first_; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
793 sample_buffer_first_ = 0; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
794 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
795 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
|
796 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
|
797 FLAC__replaygain_synthesis__apply_gain( |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
798 sample_buffer_start, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
799 !is_big_endian_host_, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
800 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
|
801 buffer, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
802 wide_samples, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
803 channels, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
804 bits_per_sample, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
805 file_info->sample_format_bytes_per_sample * 8, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
806 file_info->replay_scale, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
807 flac_cfg.output.replaygain.hard_limit, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
808 flac_cfg.output.resolution.replaygain.dither, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
809 &file_info->dither_context |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
810 ); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
811 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
812 else if(is_big_endian_host_) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
813 FLAC__plugin_common__pack_pcm_signed_big_endian( |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
814 sample_buffer_start, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
815 buffer, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
816 wide_samples, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
817 channels, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
818 bits_per_sample, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
819 file_info->sample_format_bytes_per_sample * 8 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
820 ); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
821 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
822 else { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
823 FLAC__plugin_common__pack_pcm_signed_little_endian( |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
824 sample_buffer_start, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
825 buffer, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
826 wide_samples, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
827 channels, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
828 bits_per_sample, |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
829 file_info->sample_format_bytes_per_sample * 8 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
830 ); |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
831 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
832 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
833 sample_buffer_last_ += wide_samples; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
834 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
835 return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
836 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
837 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
838 void metadata_callback_(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
|
839 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
840 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
|
841 (void)decoder; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
842 if(metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
843 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
|
844 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
|
845 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
|
846 file_info->channels = metadata->data.stream_info.channels; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
847 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
|
848 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
|
849 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
850 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
|
851 double gain, peak; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
852 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
|
853 file_info->has_replaygain = true; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
854 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
|
855 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
856 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
857 } |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
858 |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
859 void error_callback_(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
|
860 { |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
861 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
|
862 (void)decoder; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
863 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
|
864 file_info->abort_flag = true; |
4b31176c198a
[svn] - 1.1.2 compatible plugin (I HATE YOU FLAC PEOPLE)
nenolod
parents:
diff
changeset
|
865 } |