Mercurial > audlegacy-plugins
annotate src/alac/plugin.c @ 805:1ba5f86aeac9 trunk
[svn] - should check data != NULL before clear data->playing.
author | yaz |
---|---|
date | Mon, 12 Mar 2007 09:12:26 -0700 |
parents | 914c96de3244 |
children | 0847931f52b7 |
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 | 28 #include "config.h" |
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 | 32 |
33 #if HAVE_STDINT_H | |
34 # include <stdint.h> | |
35 #else | |
36 # if HAVE_INTTYPES_H | |
37 # include <inttypes.h> | |
38 # endif | |
39 #endif | |
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 | 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 | 47 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
48 #include <audacious/plugin.h> |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
49 #include <audacious/output.h> |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
50 #include <audacious/vfs.h> |
69 | 51 #include <audacious/util.h> |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
52 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
53 #include "demux.h" |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
54 #include "decomp.h" |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
55 #include "stream.h" |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
56 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
57 static int input_opened = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
58 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
59 gpointer decode_thread(void *args); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
60 static GThread *playback_thread; |
66 | 61 static int going = 0; |
91
6e1002ea4ded
[svn] - some seek code (can't be implemented right now though)
nenolod
parents:
85
diff
changeset
|
62 static int seek_to = -1; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
63 |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
64 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
|
65 |
79
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
66 static gchar * |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
67 extname(const char *filename) |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
68 { |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
69 gchar *ext = strrchr(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 if (ext != NULL) |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
72 ++ext; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
73 |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
74 return ext; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
75 } |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
76 |
69 | 77 static void alac_about(void) |
78 { | |
79 static GtkWidget *aboutbox; | |
80 | |
81 if(aboutbox != NULL) | |
82 return; | |
83 | |
84 aboutbox = xmms_show_message("About Apple Lossless Audio Plugin", | |
85 "Copyright (c) 2006 Audacious team\n" | |
86 "Portions (c) 2005-2006 David Hammerton <crazney -at- crazney.net>", | |
87 _("Ok"), FALSE, NULL, NULL); | |
88 | |
89 g_signal_connect(G_OBJECT(aboutbox), "destroy", | |
90 G_CALLBACK(gtk_widget_destroyed), | |
91 &aboutbox); | |
92 } | |
93 | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
94 static void alac_init(void) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
95 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
96 /* empty */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
97 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
98 |
256 | 99 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
|
100 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
101 demux_res_t demux_res; |
77 | 102 stream_t *input_stream; |
103 | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
104 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
|
105 |
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
106 set_endian(); |
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
107 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
108 if (!input_stream) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
109 return FALSE; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
110 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
111 /* 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
|
112 * 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
|
113 if (!qtmovie_read(input_stream, &demux_res)) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
114 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
115 stream_destroy(input_stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
116 return FALSE; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
117 } |
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 stream_destroy(input_stream); |
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 return TRUE; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
122 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
123 |
79
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
124 TitleInput *build_tuple_from_demux(demux_res_t *demux_res, char *path) |
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 TitleInput *ti = bmp_title_input_new(); |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
127 |
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.art != NULL) |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
129 ti->performer = g_strdup(demux_res->tuple.art); |
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.nam != NULL) |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
131 ti->track_name = g_strdup(demux_res->tuple.nam); |
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.alb != NULL) |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
133 ti->album_name = g_strdup(demux_res->tuple.alb); |
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.gen != NULL) |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
135 ti->genre = g_strdup(demux_res->tuple.gen); |
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.cmt != NULL) |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
137 ti->comment = g_strdup(demux_res->tuple.cmt); |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
138 if (demux_res->tuple.day != NULL) |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
139 ti->year = atoi(demux_res->tuple.day); |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
140 |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
141 ti->file_name = g_path_get_basename(path); |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
142 ti->file_path = g_path_get_dirname(path); |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
143 ti->file_ext = extname(path); |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
144 |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
145 return ti; |
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 |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
148 TitleInput *build_tuple(char *filename) |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
149 { |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
150 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
|
151 VFSFile *input_file; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
152 stream_t *input_stream; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
153 TitleInput *ti; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
154 |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
155 input_file = vfs_fopen(filename, "rb"); |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
156 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
|
157 |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
158 set_endian(); |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
159 |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
160 if (!input_stream) |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
161 { |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
162 vfs_fclose(input_file); |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
163 return NULL; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
164 } |
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 /* 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
|
167 * 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
|
168 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
|
169 { |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
170 stream_destroy(input_stream); |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
171 vfs_fclose(input_file); |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
172 return NULL; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
173 } |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
174 |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
175 stream_destroy(input_stream); |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
176 vfs_fclose(input_file); |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
177 |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
178 return build_tuple_from_demux(&demux_res, filename); |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
179 } |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
180 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
181 static InputPlayback *playback; |
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
182 |
559 | 183 static void play_file(InputPlayback *data) |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
184 { |
559 | 185 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
|
186 going = 1; |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
187 playback = data; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
188 playback_thread = g_thread_create(decode_thread, filename, TRUE, NULL); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
189 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
190 |
559 | 191 static void stop(InputPlayback * data) |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
192 { |
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
|
193 going = 0; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
194 g_thread_join(playback_thread); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
195 output_close_audio(); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
196 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
197 |
559 | 198 static void do_pause(InputPlayback *data, short paused) |
199 { | |
200 output_pause(paused); | |
201 } | |
202 | |
203 static void seek(InputPlayback * data, gint time) | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
204 { |
91
6e1002ea4ded
[svn] - some seek code (can't be implemented right now though)
nenolod
parents:
85
diff
changeset
|
205 seek_to = time; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
206 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
207 |
559 | 208 static gint get_time(InputPlayback *data) |
66 | 209 { |
210 if (going) | |
211 return get_output_time(); | |
212 else | |
213 return -1; | |
214 } | |
215 | |
372
a157306caf03
[svn] - finalize the plugin-side of the extension-assist ABI
nenolod
parents:
332
diff
changeset
|
216 gchar *alac_fmts[] = { "m4a", "alac", NULL }; |
a157306caf03
[svn] - finalize the plugin-side of the extension-assist ABI
nenolod
parents:
332
diff
changeset
|
217 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
218 InputPlugin alac_ip = { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
219 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
220 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
221 "Apple Lossless Plugin", /* Description */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
222 alac_init, |
69 | 223 alac_about, |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
224 NULL, |
332
626f9f4d79a8
[svn] Remove old-style is_our_file() where a new-style is_our_fd() exists
kiyoshi
parents:
330
diff
changeset
|
225 NULL, |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
226 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
227 play_file, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
228 stop, |
559 | 229 do_pause, |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
230 seek, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
231 NULL, |
66 | 232 get_time, |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
233 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
234 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
235 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
236 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
237 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
238 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
239 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
240 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
241 NULL, /* file_info_box */ |
79
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
242 NULL, |
256 | 243 build_tuple, |
244 NULL, | |
245 NULL, | |
246 is_our_fd, | |
372
a157306caf03
[svn] - finalize the plugin-side of the extension-assist ABI
nenolod
parents:
332
diff
changeset
|
247 alac_fmts |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
248 }; |
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 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
|
251 uint32_t *sample_duration, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
252 uint32_t *sample_byte_size) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
253 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
254 unsigned int duration_index_accum = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
255 unsigned int duration_cur_index = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
256 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
257 if (samplenum >= demux_res->num_sample_byte_sizes) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
258 return 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
259 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
260 if (!demux_res->num_time_to_samples) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
261 return 0; |
67 | 262 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
263 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
|
264 <= samplenum) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
265 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
266 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
|
267 duration_cur_index++; |
67 | 268 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
269 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
|
270 return 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
271 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
272 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
273 *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
|
274 *sample_byte_size = demux_res->sample_byte_size[samplenum]; |
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 return 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
277 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
278 |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
279 void GetBuffer(demux_res_t *demux_res) |
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 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
|
282 void *pDestBuffer = malloc(destBufferSize); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
283 int bytes_read = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
284 |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
285 unsigned int buffer_size = 1024*128; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
286 void *buffer; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
287 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
288 unsigned int i; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
289 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
290 buffer = malloc(buffer_size); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
291 |
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
|
292 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
|
293 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
294 uint32_t sample_duration; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
295 uint32_t sample_byte_size; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
296 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
297 int outputBytes; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
298 |
91
6e1002ea4ded
[svn] - some seek code (can't be implemented right now though)
nenolod
parents:
85
diff
changeset
|
299 #if 0 |
6e1002ea4ded
[svn] - some seek code (can't be implemented right now though)
nenolod
parents:
85
diff
changeset
|
300 /* XXX: Horribly inaccurate seek. -nenolod */ |
6e1002ea4ded
[svn] - some seek code (can't be implemented right now though)
nenolod
parents:
85
diff
changeset
|
301 if (seek_to != -1) |
6e1002ea4ded
[svn] - some seek code (can't be implemented right now though)
nenolod
parents:
85
diff
changeset
|
302 { |
6e1002ea4ded
[svn] - some seek code (can't be implemented right now though)
nenolod
parents:
85
diff
changeset
|
303 gulong duration = |
6e1002ea4ded
[svn] - some seek code (can't be implemented right now though)
nenolod
parents:
85
diff
changeset
|
304 (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
|
305 (float)(demux_res->sample_rate / 251)); |
6e1002ea4ded
[svn] - some seek code (can't be implemented right now though)
nenolod
parents:
85
diff
changeset
|
306 |
6e1002ea4ded
[svn] - some seek code (can't be implemented right now though)
nenolod
parents:
85
diff
changeset
|
307 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
|
308 |
6e1002ea4ded
[svn] - some seek code (can't be implemented right now though)
nenolod
parents:
85
diff
changeset
|
309 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
|
310 |
6e1002ea4ded
[svn] - some seek code (can't be implemented right now though)
nenolod
parents:
85
diff
changeset
|
311 seek_to = -1; |
6e1002ea4ded
[svn] - some seek code (can't be implemented right now though)
nenolod
parents:
85
diff
changeset
|
312 } |
6e1002ea4ded
[svn] - some seek code (can't be implemented right now though)
nenolod
parents:
85
diff
changeset
|
313 #endif |
6e1002ea4ded
[svn] - some seek code (can't be implemented right now though)
nenolod
parents:
85
diff
changeset
|
314 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
315 /* just get one sample for now */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
316 if (!get_sample_info(demux_res, i, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
317 &sample_duration, &sample_byte_size)) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
318 return; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
319 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
320 if (buffer_size < sample_byte_size) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
321 return; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
322 |
77 | 323 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
|
324 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
325 /* now fetch */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
326 outputBytes = destBufferSize; |
77 | 327 decode_frame(demux_res->alac, buffer, pDestBuffer, &outputBytes); |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
328 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
329 /* write */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
330 bytes_read += outputBytes; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
331 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
332 produce_audio(playback->output->written_time(), 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
|
333 } |
70 | 334 |
335 free(buffer); | |
336 free(pDestBuffer); | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
337 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
338 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
339 gpointer decode_thread(void *args) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
340 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
341 demux_res_t demux_res; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
342 unsigned int output_size, i; |
71 | 343 gulong duration = 0; /* samples added up */ |
344 gint framesize; | |
77 | 345 VFSFile *input_file; |
346 stream_t *input_stream; | |
79
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
347 TitleInput *ti; |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
348 gchar *title; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
349 |
85 | 350 memset(&demux_res, 0, sizeof(demux_res)); |
78 | 351 |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
352 set_endian(); |
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 input_file = vfs_fopen((char *) args, "rb"); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
355 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
|
356 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
357 if (!input_stream) |
91
6e1002ea4ded
[svn] - some seek code (can't be implemented right now though)
nenolod
parents:
85
diff
changeset
|
358 return NULL; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
359 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
360 /* 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
|
361 * 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
|
362 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
|
363 return NULL; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
364 |
78 | 365 demux_res.stream = input_stream; |
366 | |
79
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
367 /* Get the titlestring ready. */ |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
368 ti = build_tuple_from_demux(&demux_res, (char *) args); |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
369 title = xmms_get_titlestring(xmms_get_gentitle_format(), ti); |
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
370 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
371 /* initialise the sound converter */ |
77 | 372 demux_res.alac = create_alac(demux_res.sample_size, demux_res.num_channels); |
373 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
|
374 |
71 | 375 /* Sample rates are multiples of 251?! Apple is *fucking* *insane*! -nenolod */ |
376 duration = (demux_res.num_sample_byte_sizes * (float)((1024 * demux_res.sample_size) - 1.0) / | |
377 (float)(demux_res.sample_rate / 251)); | |
378 | |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
379 playback->output->open_audio(FMT_S16_LE, demux_res.sample_rate, demux_res.num_channels); |
79
722fd456ae1a
[svn] - parse metadata on ALAC files... seems to work, but the method is inefficient
nenolod
parents:
78
diff
changeset
|
380 alac_ip.set_info(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
|
381 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
382 /* will convert the entire buffer */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
383 GetBuffer(&demux_res); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
384 |
66 | 385 going = 0; |
386 | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
387 stream_destroy(input_stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
388 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
389 if (input_opened) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
390 vfs_fclose(input_file); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
391 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
392 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
|
393 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
394 return NULL; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
395 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
396 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
397 InputPlugin *get_iplugin_info(void) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
398 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
399 return &alac_ip; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
400 } |