annotate src/filewriter/flac.c @ 3106:a0628e5f3074

gio: fix FD leak
author William Pitcock <nenolod@atheme.org>
date Thu, 30 Apr 2009 12:35:54 -0500
parents dcd8d93ba781
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
1 /* FileWriter FLAC Plugin
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
2 * Copyright (c) 2007 William Pitcock <nenolod@sacredspiral.co.uk>
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
3 *
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
4 * Partially derived from Og(g)re - Ogg-Output-Plugin:
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
5 * Copyright (c) 2002 Lars Siebold <khandha5@gmx.net>
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
6 *
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
10 * (at your option) any later version.
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
11 *
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
16 *
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
2835
f1b6f1b2cdb3 fixed FSF address
Andrew O. Shadoura <bugzilla@tut.by>
parents: 2774
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
20 */
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
21
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
22 #include "plugins.h"
1002
ad29227009f6 [svn] ifdef filewriter/flac.c out completely if FILEWRITER_FLAC isn't defined
js
parents: 996
diff changeset
23
ad29227009f6 [svn] ifdef filewriter/flac.c out completely if FILEWRITER_FLAC isn't defined
js
parents: 996
diff changeset
24 #ifdef FILEWRITER_FLAC
ad29227009f6 [svn] ifdef filewriter/flac.c out completely if FILEWRITER_FLAC isn't defined
js
parents: 996
diff changeset
25
995
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
26 #include <FLAC/all.h>
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
27 #include <stdlib.h>
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
28
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
29 static gint flac_open(void);
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
30 static void flac_write(gpointer data, gint length);
2774
f1f7ee810de8 add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents: 1978
diff changeset
31 static void flac_flush(void);
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
32 static void flac_close(void);
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
33 static gint flac_free(void);
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
34 static gint flac_playing(void);
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
35 static gint flac_get_written_time(void);
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
36
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
37 FileWriter flac_plugin =
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
38 {
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
39 NULL,
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
40 NULL,
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
41 flac_open,
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
42 flac_write,
2774
f1f7ee810de8 add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents: 1978
diff changeset
43 flac_flush,
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
44 flac_close,
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
45 flac_free,
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
46 flac_playing,
2873
31d6c44ffef2 most of encoder backends require GINT16_NE;
Andrew O. Shadoura <bugzilla@tut.by>
parents: 2835
diff changeset
47 flac_get_written_time,
31d6c44ffef2 most of encoder backends require GINT16_NE;
Andrew O. Shadoura <bugzilla@tut.by>
parents: 2835
diff changeset
48 FMT_S16_NE
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
49 };
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
50
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
51 static FLAC__StreamEncoder *flac_encoder;
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
52 static guint64 olen = 0;
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
53
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
54 static FLAC__StreamEncoderWriteStatus flac_write_cb(const FLAC__StreamEncoder *encoder,
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
55 const FLAC__byte buffer[], size_t bytes, unsigned samples, unsigned current_frame, gpointer data)
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
56 {
2950
dcd8d93ba781 - mp3: adapted to lame-3.98. now filewriter writes valid TLEN.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2873
diff changeset
57 aud_vfs_fwrite(buffer, bytes, 1, (VFSFile *) data);
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
58
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
59 return FLAC__STREAM_ENCODER_WRITE_STATUS_OK;
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
60 }
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
61
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
62 static FLAC__StreamEncoderSeekStatus flac_seek_cb(const FLAC__StreamEncoder *encoder,
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
63 FLAC__uint64 absolute_byte_offset, gpointer data)
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
64 {
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
65 VFSFile *file = (VFSFile *) data;
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
66
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
67 if (aud_vfs_fseek(file, absolute_byte_offset, SEEK_SET) < 0)
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
68 return FLAC__STREAM_ENCODER_SEEK_STATUS_ERROR;
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
69
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
70 return FLAC__STREAM_ENCODER_SEEK_STATUS_OK;
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
71 }
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
72
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
73 static FLAC__StreamEncoderTellStatus flac_tell_cb(const FLAC__StreamEncoder *encoder,
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
74 FLAC__uint64 *absolute_byte_offset, gpointer data)
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
75 {
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
76 VFSFile *file = (VFSFile *) data;
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
77
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
78 *absolute_byte_offset = aud_vfs_ftell(file);
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
79
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
80 return FLAC__STREAM_ENCODER_TELL_STATUS_OK;
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
81 }
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
82
995
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
83 #define INSERT_VORBIS_COMMENT(t, keyword) \
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
84 if (t) \
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
85 { \
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
86 gchar *scratch = g_strdup_printf(keyword, t); \
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
87 comment_entry.length = strlen(scratch); \
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
88 comment_entry.entry = (guchar *) scratch; \
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
89 FLAC__metadata_object_vorbiscomment_insert_comment(meta, \
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
90 meta->data.vorbis_comment.num_comments, comment_entry, TRUE); \
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
91 g_free(scratch); \
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
92 }
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
93
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
94 static gint flac_open(void)
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
95 {
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
96 olen = 0;
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
97
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
98 flac_encoder = FLAC__stream_encoder_new();
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
99
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
100 FLAC__stream_encoder_set_channels(flac_encoder, input.channels);
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
101 FLAC__stream_encoder_set_sample_rate(flac_encoder, input.frequency);
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
102 FLAC__stream_encoder_init_stream(flac_encoder, flac_write_cb, flac_seek_cb, flac_tell_cb,
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
103 NULL, output_file);
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
104
995
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
105 if (tuple)
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
106 {
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
107 FLAC__StreamMetadata *meta;
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
108 FLAC__StreamMetadata_VorbisComment_Entry comment_entry;
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
109
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
110 meta = FLAC__metadata_object_new(FLAC__METADATA_TYPE_VORBIS_COMMENT);
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
111
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1687
diff changeset
112 INSERT_VORBIS_COMMENT(aud_tuple_get_string(tuple, FIELD_TITLE, NULL), "title=%s");
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1687
diff changeset
113 INSERT_VORBIS_COMMENT(aud_tuple_get_string(tuple, FIELD_ARTIST, NULL), "artist=%s");
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1687
diff changeset
114 INSERT_VORBIS_COMMENT(aud_tuple_get_string(tuple, FIELD_ALBUM, NULL), "album=%s");
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1687
diff changeset
115 INSERT_VORBIS_COMMENT(aud_tuple_get_string(tuple, FIELD_GENRE, NULL), "genre=%s");
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1687
diff changeset
116 INSERT_VORBIS_COMMENT(aud_tuple_get_string(tuple, FIELD_COMMENT, NULL), "comment=%s");
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1687
diff changeset
117 INSERT_VORBIS_COMMENT(aud_tuple_get_string(tuple, FIELD_DATE, NULL), "date=%s");
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1687
diff changeset
118 INSERT_VORBIS_COMMENT(aud_tuple_get_int(tuple, FIELD_YEAR, NULL), "year=%d");
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1687
diff changeset
119 INSERT_VORBIS_COMMENT(aud_tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL), "tracknumber=%d");
995
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
120
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
121 FLAC__stream_encoder_set_metadata(flac_encoder, &meta, 1);
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
122 }
73f5e44d20d2 [svn] - add tuple handling, but i don't think i'm doing it right...
nenolod
parents: 994
diff changeset
123
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
124 return 1;
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
125 }
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
126
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
127 static void flac_write(gpointer data, gint length)
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
128 {
994
91f9925d88f1 [svn] - use my version for now as r2126 does not work
nenolod
parents: 993
diff changeset
129 #if 1
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
130 FLAC__int32 *encbuffer[2];
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
131 short int *tmpdata = data;
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
132 int i;
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
133
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
134 encbuffer[0] = g_new0(FLAC__int32, length / input.channels);
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
135 encbuffer[1] = g_new0(FLAC__int32, length / input.channels);
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
136
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
137 if (input.channels == 1)
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
138 {
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
139 for (i = 0; i < (length / 2); i++)
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
140 {
992
a277aaab4525 [svn] - remove the padding, flac starts working.
nenolod
parents: 991
diff changeset
141 encbuffer[0][i] = tmpdata[i];
a277aaab4525 [svn] - remove the padding, flac starts working.
nenolod
parents: 991
diff changeset
142 encbuffer[1][i] = tmpdata[i];
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
143 }
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
144 }
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
145 else
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
146 {
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
147 for (i = 0; i < (length / 4); i++)
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
148 {
992
a277aaab4525 [svn] - remove the padding, flac starts working.
nenolod
parents: 991
diff changeset
149 encbuffer[0][i] = tmpdata[2 * i];
a277aaab4525 [svn] - remove the padding, flac starts working.
nenolod
parents: 991
diff changeset
150 encbuffer[1][i] = tmpdata[2 * i + 1];
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
151 }
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
152 }
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
153
1044
b1128efde471 [svn] - get rid of all warnings gcc 4.2.0 emits with my build configuration.
yaz
parents: 1002
diff changeset
154 FLAC__stream_encoder_process(flac_encoder, (const FLAC__int32 **)encbuffer, length / (input.channels * 2));
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
155 olen += length;
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
156
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
157 g_free(encbuffer[0]);
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
158 g_free(encbuffer[1]);
994
91f9925d88f1 [svn] - use my version for now as r2126 does not work
nenolod
parents: 993
diff changeset
159 #else
993
ertzing
parents: 992
diff changeset
160 FLAC__int32 *encbuffer;
994
91f9925d88f1 [svn] - use my version for now as r2126 does not work
nenolod
parents: 993
diff changeset
161 gint16 *tmpdata = data;
993
ertzing
parents: 992
diff changeset
162 int i;
ertzing
parents: 992
diff changeset
163
ertzing
parents: 992
diff changeset
164 encbuffer = g_new0(FLAC__int32, length);
ertzing
parents: 992
diff changeset
165
996
ertzing
parents: 995
diff changeset
166 for (i=0; i < length; i++) {
993
ertzing
parents: 992
diff changeset
167 encbuffer[i] = tmpdata[i];
ertzing
parents: 992
diff changeset
168 }
ertzing
parents: 992
diff changeset
169
996
ertzing
parents: 995
diff changeset
170 FLAC__stream_encoder_process_interleaved(flac_encoder, encbuffer, length);
993
ertzing
parents: 992
diff changeset
171 olen += length;
ertzing
parents: 992
diff changeset
172
ertzing
parents: 992
diff changeset
173 g_free(encbuffer);
994
91f9925d88f1 [svn] - use my version for now as r2126 does not work
nenolod
parents: 993
diff changeset
174 #endif
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
175 }
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
176
2774
f1f7ee810de8 add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents: 1978
diff changeset
177 static void flac_flush(void)
f1f7ee810de8 add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents: 1978
diff changeset
178 {
f1f7ee810de8 add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents: 1978
diff changeset
179 //should we do something here? --AOS
f1f7ee810de8 add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents: 1978
diff changeset
180 }
f1f7ee810de8 add metadata to stream + flush() should do a real flush at least with mp3
Andrew O. Shadoura <bugzilla@tut.by>
parents: 1978
diff changeset
181
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
182 static void flac_close(void)
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
183 {
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
184 FLAC__stream_encoder_finish(flac_encoder);
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
185 FLAC__stream_encoder_delete(flac_encoder);
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
186 }
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
187
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
188 static gint flac_free(void)
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
189 {
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
190 return 1000000;
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
191 }
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
192
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
193 static gint flac_playing(void)
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
194 {
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
195 return 0;
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
196 }
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
197
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
198 static gint flac_get_written_time(void)
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
199 {
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
200 if (input.frequency && input.channels)
1269
0e160bafce1c - adapt filewriter for file:// scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents: 1044
diff changeset
201 return (gint) ((olen * 1000) / (input.frequency * 2 * input.channels) + offset);
991
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
202
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
203 return 0;
67cf9a1e3dc5 [svn] - commit what i have, presently broken
nenolod
parents:
diff changeset
204 }
1002
ad29227009f6 [svn] ifdef filewriter/flac.c out completely if FILEWRITER_FLAC isn't defined
js
parents: 996
diff changeset
205
ad29227009f6 [svn] ifdef filewriter/flac.c out completely if FILEWRITER_FLAC isn't defined
js
parents: 996
diff changeset
206 #endif