annotate src/alac/plugin.c @ 1998:8f3188746b64

chase last changeset in aud
author William Pitcock <nenolod@atheme.org>
date Mon, 08 Oct 2007 02:02:02 -0500
parents 489e32a8e106
children 2f2ffbc2d04d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
1 /*
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
2 * Copyright (c) 2005 David Hammerton
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
3 * All rights reserved.
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
4 *
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
5 * Adapted from example program by William Pitcock <nenolod@atheme.org>
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
6 *
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
7 * Permission is hereby granted, free of charge, to any person
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
8 * obtaining a copy of this software and associated documentation
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
9 * files (the "Software"), to deal in the Software without
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
10 * restriction, including without limitation the rights to use,
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
11 * copy, modify, merge, publish, distribute, sublicense, and/or
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
12 * sell copies of the Software, and to permit persons to whom the
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
13 * Software is furnished to do so, subject to the following conditions:
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
14 *
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
15 * The above copyright notice and this permission notice shall be
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
16 * included in all copies or substantial portions of the Software.
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
17 *
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
20 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
21 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
22 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
25 * OTHER DEALINGS IN THE SOFTWARE.
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
26 */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
27
330
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 261
diff changeset
28 #include "config.h"
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 261
diff changeset
29
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
30 #include <ctype.h>
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
31 #include <stdio.h>
330
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 261
diff changeset
32
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 261
diff changeset
33 #if HAVE_STDINT_H
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 261
diff changeset
34 # include <stdint.h>
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 261
diff changeset
35 #else
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 261
diff changeset
36 # if HAVE_INTTYPES_H
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 261
diff changeset
37 # include <inttypes.h>
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 261
diff changeset
38 # endif
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 261
diff changeset
39 #endif
74df3bd6f472 [svn] - portability fixes:
nenolod
parents: 261
diff changeset
40
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
41 #include <stdlib.h>
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
42 #include <errno.h>
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
43 #include <string.h>
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
44
69
08c9353a9bb3 [svn] - about box
nenolod
parents: 68
diff changeset
45 #include <glib.h>
527
d124034ebea3 [svn] - glib/gi18n.h -> audacious/i18n.h for automatic dgettext support
nenolod
parents: 372
diff changeset
46 #include <audacious/i18n.h>
69
08c9353a9bb3 [svn] - about box
nenolod
parents: 68
diff changeset
47
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
48 #include <audacious/plugin.h>
1423
c5bbf2c90ba3 alac: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
49 #include <audacious/main.h>
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
50 #include <audacious/output.h>
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
51 #include <audacious/vfs.h>
69
08c9353a9bb3 [svn] - about box
nenolod
parents: 68
diff changeset
52 #include <audacious/util.h>
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
53
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
54 #include "demux.h"
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
55 #include "decomp.h"
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
56 #include "stream.h"
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
57
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
58 static int input_opened = 0;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
59
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
60 gpointer decode_thread(void *args);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
61 static GThread *playback_thread;
66
f04b33512c3d [svn] - get_time() implementation
nenolod
parents: 59
diff changeset
62 static int going = 0;
91
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
63 static int seek_to = -1;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
64
57
96901271d2e2 [svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents: 56
diff changeset
65 extern void set_endian();
96901271d2e2 [svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents: 56
diff changeset
66
1973
f86cb7fc1d4f Add -pipe -Wall if gcc and fix a few warnings.
Jonathan Schleifer <js@h3c.de>
parents: 1697
diff changeset
67 /*
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
68 static gchar *
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
69 extname(const char *filename)
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
70 {
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
71 gchar *ext = strrchr(filename, '.');
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
72
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
73 if (ext != NULL)
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
74 ++ext;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
75
1284
190a447e5229 "About" window is now translatable.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
76 return ext;
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
77 }
1973
f86cb7fc1d4f Add -pipe -Wall if gcc and fix a few warnings.
Jonathan Schleifer <js@h3c.de>
parents: 1697
diff changeset
78 */
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
79
69
08c9353a9bb3 [svn] - about box
nenolod
parents: 68
diff changeset
80 static void alac_about(void)
08c9353a9bb3 [svn] - about box
nenolod
parents: 68
diff changeset
81 {
08c9353a9bb3 [svn] - about box
nenolod
parents: 68
diff changeset
82 static GtkWidget *aboutbox;
1284
190a447e5229 "About" window is now translatable.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
83
69
08c9353a9bb3 [svn] - about box
nenolod
parents: 68
diff changeset
84 if(aboutbox != NULL)
08c9353a9bb3 [svn] - about box
nenolod
parents: 68
diff changeset
85 return;
08c9353a9bb3 [svn] - about box
nenolod
parents: 68
diff changeset
86
1677
f6f5603a0954 xmms_show_message() changed to audacious_info_dialog()
Matti Hamalainen <ccr@tnsp.org>
parents: 1510
diff changeset
87 aboutbox = audacious_info_dialog(_("About Apple Lossless Audio Plugin"),
1284
190a447e5229 "About" window is now translatable.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
88 _("Copyright (c) 2006 Audacious team\n"
190a447e5229 "About" window is now translatable.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
89 "Portions (c) 2005-2006 David Hammerton <crazney -at- crazney.net>"),
69
08c9353a9bb3 [svn] - about box
nenolod
parents: 68
diff changeset
90 _("Ok"), FALSE, NULL, NULL);
08c9353a9bb3 [svn] - about box
nenolod
parents: 68
diff changeset
91
08c9353a9bb3 [svn] - about box
nenolod
parents: 68
diff changeset
92 g_signal_connect(G_OBJECT(aboutbox), "destroy",
08c9353a9bb3 [svn] - about box
nenolod
parents: 68
diff changeset
93 G_CALLBACK(gtk_widget_destroyed),
08c9353a9bb3 [svn] - about box
nenolod
parents: 68
diff changeset
94 &aboutbox);
08c9353a9bb3 [svn] - about box
nenolod
parents: 68
diff changeset
95 }
08c9353a9bb3 [svn] - about box
nenolod
parents: 68
diff changeset
96
256
acb93b546742 [svn] Port to NewVFS probe function.
chainsaw
parents: 91
diff changeset
97 gboolean is_our_fd(char *filename, VFSFile* input_file)
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
98 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
99 demux_res_t demux_res;
77
c2981235af26 [svn] - thread safety
nenolod
parents: 71
diff changeset
100 stream_t *input_stream;
c2981235af26 [svn] - thread safety
nenolod
parents: 71
diff changeset
101
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
102 input_stream = stream_create_file(input_file, 1);
57
96901271d2e2 [svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents: 56
diff changeset
103
96901271d2e2 [svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents: 56
diff changeset
104 set_endian();
96901271d2e2 [svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents: 56
diff changeset
105
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
106 if (!input_stream)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
107 return FALSE;
1284
190a447e5229 "About" window is now translatable.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
108
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
109 /* if qtmovie_read returns successfully, the stream is up to
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
110 * the movie data, which can be used directly by the decoder */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
111 if (!qtmovie_read(input_stream, &demux_res))
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
112 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
113 stream_destroy(input_stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
114 return FALSE;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
115 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
116
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
117 stream_destroy(input_stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
118
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
119 return TRUE;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
120 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
121
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
122 Tuple *build_aud_tuple_from_demux(demux_res_t *demux_res, char *path)
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
123 {
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
124 Tuple *ti = aud_tuple_new_from_filename(path);
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
125
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
126 if (demux_res->tuple.art != NULL)
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
127 aud_tuple_associate_string(ti, FIELD_ARTIST, NULL, demux_res->tuple.art);
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
128 if (demux_res->tuple.nam != NULL)
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
129 aud_tuple_associate_string(ti, FIELD_TITLE, NULL, demux_res->tuple.nam);
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
130 if (demux_res->tuple.alb != NULL)
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
131 aud_tuple_associate_string(ti, FIELD_ALBUM, NULL, demux_res->tuple.alb);
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
132 if (demux_res->tuple.gen != NULL)
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
133 aud_tuple_associate_string(ti, FIELD_GENRE, NULL, demux_res->tuple.gen);
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
134 if (demux_res->tuple.cmt != NULL)
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
135 aud_tuple_associate_string(ti, FIELD_COMMENT, NULL, demux_res->tuple.cmt);
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
136 if (demux_res->tuple.day != NULL)
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
137 aud_tuple_associate_int(ti, FIELD_YEAR, NULL, atoi(demux_res->tuple.day));
1423
c5bbf2c90ba3 alac: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
138
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
139 aud_tuple_associate_string(ti, FIELD_CODEC, NULL, "Apple Lossless (ALAC)");
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
140 aud_tuple_associate_string(ti, FIELD_QUALITY, NULL, "lossless");
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
141
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
142 return ti;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
143 }
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
144
1423
c5bbf2c90ba3 alac: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
145 Tuple *build_tuple(char *filename)
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
146 {
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
147 demux_res_t demux_res;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
148 VFSFile *input_file;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
149 stream_t *input_stream;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
150
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
151 input_file = aud_vfs_fopen(filename, "rb");
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
152 input_stream = stream_create_file(input_file, 1);
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
153
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
154 set_endian();
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
155
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
156 if (!input_stream)
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
157 {
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
158 aud_vfs_fclose(input_file);
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
159 return NULL;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
160 }
1284
190a447e5229 "About" window is now translatable.
Stany HENRY <StrassBoy@gmail.com>
parents: 1190
diff changeset
161
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
162 /* if qtmovie_read returns successfully, the stream is up to
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
163 * the movie data, which can be used directly by the decoder */
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
164 if (!qtmovie_read(input_stream, &demux_res))
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
165 {
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
166 stream_destroy(input_stream);
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
167 aud_vfs_fclose(input_file);
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
168 return NULL;
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
169 }
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
170
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
171 stream_destroy(input_stream);
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
172 aud_vfs_fclose(input_file);
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
173
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
174 return build_aud_tuple_from_demux(&demux_res, filename);
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
175 }
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
176
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
177 static InputPlayback *playback;
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
178
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 527
diff changeset
179 static void play_file(InputPlayback *data)
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
180 {
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 527
diff changeset
181 char *filename = data->filename;
68
d435a3abc035 [svn] - set alac::going before we fork the decoder thread off, this stops the core from getting confused
nenolod
parents: 67
diff changeset
182 going = 1;
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
183 playback = data;
1347
76eee61ed25a alac: new threading model
William Pitcock <nenolod@atheme-project.org>
parents: 1284
diff changeset
184 playback_thread = g_thread_self();
1447
195b5657303e updated input plugins to use set_pb_ready to signal to the core that they're ready for playback
Giacomo Lozito <james@develia.org>
parents: 1431
diff changeset
185 playback->set_pb_ready(playback);
1347
76eee61ed25a alac: new threading model
William Pitcock <nenolod@atheme-project.org>
parents: 1284
diff changeset
186 decode_thread(filename);
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
187 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
188
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 527
diff changeset
189 static void stop(InputPlayback * data)
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
190 {
68
d435a3abc035 [svn] - set alac::going before we fork the decoder thread off, this stops the core from getting confused
nenolod
parents: 67
diff changeset
191 going = 0;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
192 g_thread_join(playback_thread);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
193 output_close_audio();
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
194 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
195
559
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 527
diff changeset
196 static void do_pause(InputPlayback *data, short paused)
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 527
diff changeset
197 {
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 527
diff changeset
198 output_pause(paused);
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 527
diff changeset
199 }
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 527
diff changeset
200
d5782f3bd760 [svn] Update plugins to the new input plugin API
iabervon
parents: 527
diff changeset
201 static void seek(InputPlayback * data, gint time)
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
202 {
91
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
203 seek_to = time;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
204 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
205
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
206 static int get_sample_info(demux_res_t *demux_res, uint32_t samplenum,
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
207 uint32_t *sample_duration,
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
208 uint32_t *sample_byte_size)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
209 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
210 unsigned int duration_index_accum = 0;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
211 unsigned int duration_cur_index = 0;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
212
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
213 if (samplenum >= demux_res->num_sample_byte_sizes)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
214 return 0;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
215
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
216 if (!demux_res->num_time_to_samples)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
217 return 0;
67
41e2dc106f4e [svn] - remove spurious debugging notices
nenolod
parents: 66
diff changeset
218
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
219 while ((demux_res->time_to_sample[duration_cur_index].sample_count + duration_index_accum)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
220 <= samplenum)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
221 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
222 duration_index_accum += demux_res->time_to_sample[duration_cur_index].sample_count;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
223 duration_cur_index++;
67
41e2dc106f4e [svn] - remove spurious debugging notices
nenolod
parents: 66
diff changeset
224
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
225 if (duration_cur_index >= demux_res->num_time_to_samples)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
226 return 0;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
227 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
228
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
229 *sample_duration = demux_res->time_to_sample[duration_cur_index].sample_duration;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
230 *sample_byte_size = demux_res->sample_byte_size[samplenum];
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
231
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
232 return 1;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
233 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
234
57
96901271d2e2 [svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents: 56
diff changeset
235 void GetBuffer(demux_res_t *demux_res)
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
236 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
237 unsigned long destBufferSize = 1024*16; /* 16kb buffer = 4096 frames = 1 alac sample */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
238 void *pDestBuffer = malloc(destBufferSize);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
239 int bytes_read = 0;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
240
57
96901271d2e2 [svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents: 56
diff changeset
241 unsigned int buffer_size = 1024*128;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
242 void *buffer;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
243
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
244 unsigned int i;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
245
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
246 buffer = malloc(buffer_size);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
247
68
d435a3abc035 [svn] - set alac::going before we fork the decoder thread off, this stops the core from getting confused
nenolod
parents: 67
diff changeset
248 for (i = 0; i < demux_res->num_sample_byte_sizes && going == 1; i++)
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
249 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
250 uint32_t sample_duration;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
251 uint32_t sample_byte_size;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
252
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
253 int outputBytes;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
254
91
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
255 #if 0
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
256 /* XXX: Horribly inaccurate seek. -nenolod */
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
257 if (seek_to != -1)
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
258 {
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
259 gulong duration =
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
260 (demux_res->num_sample_byte_sizes * (float)((1024 * demux_res->sample_size) - 1.0) /
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
261 (float)(demux_res->sample_rate / 251));
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
262
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
263 i = (duration - seek_to) / demux_res->num_sample_byte_sizes;
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
264
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
265 g_print("seek to ALAC frame: %d\n", i);
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
266
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
267 seek_to = -1;
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
268 }
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
269 #endif
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
270
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
271 /* just get one sample for now */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
272 if (!get_sample_info(demux_res, i,
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
273 &sample_duration, &sample_byte_size))
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
274 return;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
275
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
276 if (buffer_size < sample_byte_size)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
277 return;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
278
77
c2981235af26 [svn] - thread safety
nenolod
parents: 71
diff changeset
279 stream_read(demux_res->stream, sample_byte_size, buffer);
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
280
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
281 /* now fetch */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
282 outputBytes = destBufferSize;
77
c2981235af26 [svn] - thread safety
nenolod
parents: 71
diff changeset
283 decode_frame(demux_res->alac, buffer, pDestBuffer, &outputBytes);
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
284
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
285 /* write */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
286 bytes_read += outputBytes;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
287
1998
8f3188746b64 chase last changeset in aud
William Pitcock <nenolod@atheme.org>
parents: 1984
diff changeset
288 playback->pass_audio(playback, FMT_S16_LE, demux_res->num_channels, outputBytes, pDestBuffer, &going);
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
289 }
70
31799ddaf2e9 [svn] - fix memory leaks
nenolod
parents: 69
diff changeset
290
31799ddaf2e9 [svn] - fix memory leaks
nenolod
parents: 69
diff changeset
291 free(buffer);
31799ddaf2e9 [svn] - fix memory leaks
nenolod
parents: 69
diff changeset
292 free(pDestBuffer);
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
293 }
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
294
1074
0847931f52b7 [svn] Port to plugin API v2.
chainsaw
parents: 561
diff changeset
295 static gchar *fmts[] = { "m4a", "alac", NULL };
0847931f52b7 [svn] Port to plugin API v2.
chainsaw
parents: 561
diff changeset
296
0847931f52b7 [svn] Port to plugin API v2.
chainsaw
parents: 561
diff changeset
297 InputPlugin alac_ip = {
0847931f52b7 [svn] Port to plugin API v2.
chainsaw
parents: 561
diff changeset
298 .description = "Apple Lossless Plugin",
0847931f52b7 [svn] Port to plugin API v2.
chainsaw
parents: 561
diff changeset
299 .about = alac_about,
0847931f52b7 [svn] Port to plugin API v2.
chainsaw
parents: 561
diff changeset
300 .play_file = play_file,
0847931f52b7 [svn] Port to plugin API v2.
chainsaw
parents: 561
diff changeset
301 .stop = stop,
0847931f52b7 [svn] Port to plugin API v2.
chainsaw
parents: 561
diff changeset
302 .pause = do_pause,
0847931f52b7 [svn] Port to plugin API v2.
chainsaw
parents: 561
diff changeset
303 .seek = seek,
0847931f52b7 [svn] Port to plugin API v2.
chainsaw
parents: 561
diff changeset
304 .get_song_tuple = build_tuple,
0847931f52b7 [svn] Port to plugin API v2.
chainsaw
parents: 561
diff changeset
305 .is_our_file_from_vfs = is_our_fd,
1979
839804c3b3a4 aud_vfs_extensions -> vfs_extensions, some vtable fixes
William Pitcock <nenolod@atheme.org>
parents: 1978
diff changeset
306 .vfs_extensions = fmts,
1074
0847931f52b7 [svn] Port to plugin API v2.
chainsaw
parents: 561
diff changeset
307 };
0847931f52b7 [svn] Port to plugin API v2.
chainsaw
parents: 561
diff changeset
308
0847931f52b7 [svn] Port to plugin API v2.
chainsaw
parents: 561
diff changeset
309 InputPlugin *alac_iplist[] = { &alac_ip, NULL };
0847931f52b7 [svn] Port to plugin API v2.
chainsaw
parents: 561
diff changeset
310
1395
761e17b23e0c added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents: 1347
diff changeset
311 DECLARE_PLUGIN(alac, NULL, NULL, alac_iplist, NULL, NULL, NULL, NULL, NULL);
1074
0847931f52b7 [svn] Port to plugin API v2.
chainsaw
parents: 561
diff changeset
312
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
313 gpointer decode_thread(void *args)
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
314 {
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
315 demux_res_t demux_res;
71
5b0619b09745 [svn] Detect duration:
nenolod
parents: 70
diff changeset
316 gulong duration = 0; /* samples added up */
77
c2981235af26 [svn] - thread safety
nenolod
parents: 71
diff changeset
317 VFSFile *input_file;
c2981235af26 [svn] - thread safety
nenolod
parents: 71
diff changeset
318 stream_t *input_stream;
1423
c5bbf2c90ba3 alac: new tuple API
William Pitcock <nenolod@atheme-project.org>
parents: 1395
diff changeset
319 Tuple *ti;
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
320 gchar *title;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
321
85
86ce11c6b8c3 [svn] - Imported a few changes from alac decoder 0.1.3
js
parents: 79
diff changeset
322 memset(&demux_res, 0, sizeof(demux_res));
78
096db10ce25f [svn] - a few concurrency fixes
nenolod
parents: 77
diff changeset
323
57
96901271d2e2 [svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents: 56
diff changeset
324 set_endian();
96901271d2e2 [svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents: 56
diff changeset
325
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
326 input_file = aud_vfs_fopen((char *) args, "rb");
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
327 input_stream = stream_create_file(input_file, 1);
57
96901271d2e2 [svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents: 56
diff changeset
328
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
329 if (!input_stream)
91
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
330 return NULL;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
331
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
332 /* if qtmovie_read returns successfully, the stream is up to
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
333 * the movie data, which can be used directly by the decoder */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
334 if (!qtmovie_read(input_stream, &demux_res))
91
6e1002ea4ded [svn] - some seek code (can't be implemented right now though)
nenolod
parents: 85
diff changeset
335 return NULL;
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
336
78
096db10ce25f [svn] - a few concurrency fixes
nenolod
parents: 77
diff changeset
337 demux_res.stream = input_stream;
096db10ce25f [svn] - a few concurrency fixes
nenolod
parents: 77
diff changeset
338
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
339 /* Get the titlestring ready. */
1976
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
340 ti = build_aud_tuple_from_demux(&demux_res, (char *) args);
5fa26178eaef s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents: 1973
diff changeset
341 title = aud_tuple_formatter_make_title_string(ti, get_gentitle_format());
79
722fd456ae1a [svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents: 78
diff changeset
342
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
343 /* initialise the sound converter */
77
c2981235af26 [svn] - thread safety
nenolod
parents: 71
diff changeset
344 demux_res.alac = create_alac(demux_res.sample_size, demux_res.num_channels);
c2981235af26 [svn] - thread safety
nenolod
parents: 71
diff changeset
345 alac_set_info(demux_res.alac, demux_res.codecdata);
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
346
71
5b0619b09745 [svn] Detect duration:
nenolod
parents: 70
diff changeset
347 /* Sample rates are multiples of 251?! Apple is *fucking* *insane*! -nenolod */
5b0619b09745 [svn] Detect duration:
nenolod
parents: 70
diff changeset
348 duration = (demux_res.num_sample_byte_sizes * (float)((1024 * demux_res.sample_size) - 1.0) /
5b0619b09745 [svn] Detect duration:
nenolod
parents: 70
diff changeset
349 (float)(demux_res.sample_rate / 251));
5b0619b09745 [svn] Detect duration:
nenolod
parents: 70
diff changeset
350
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
351 playback->output->open_audio(FMT_S16_LE, demux_res.sample_rate, demux_res.num_channels);
1984
489e32a8e106 change some places to use set_params() instead of set_info() directly
William Pitcock <nenolod@atheme.org>
parents: 1979
diff changeset
352 playback->set_params(playback, title, duration, -1, demux_res.sample_rate, demux_res.num_channels);
57
96901271d2e2 [svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents: 56
diff changeset
353
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
354 /* will convert the entire buffer */
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
355 GetBuffer(&demux_res);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
356
66
f04b33512c3d [svn] - get_time() implementation
nenolod
parents: 59
diff changeset
357 going = 0;
f04b33512c3d [svn] - get_time() implementation
nenolod
parents: 59
diff changeset
358
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
359 stream_destroy(input_stream);
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
360
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
361 if (input_opened)
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1976
diff changeset
362 aud_vfs_fclose(input_file);
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
363
561
914c96de3244 [svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents: 559
diff changeset
364 playback->output->close_audio();
57
96901271d2e2 [svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents: 56
diff changeset
365
56
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
366 return NULL;
56c88eee9802 [svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff changeset
367 }