Mercurial > audlegacy-plugins
annotate src/alac/plugin.c @ 66:f04b33512c3d trunk
[svn] - get_time() implementation
author | nenolod |
---|---|
date | Sat, 30 Sep 2006 22:44:36 -0700 |
parents | 72ad216a01ac |
children | 41e2dc106f4e |
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 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
28 #include <ctype.h> |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
29 #include <stdio.h> |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
30 #include <stdint.h> |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
31 #include <stdlib.h> |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
32 #include <errno.h> |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
33 #include <string.h> |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
34 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
35 #include <audacious/plugin.h> |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
36 #include <audacious/output.h> |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
37 #include <audacious/vfs.h> |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
38 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
39 #include "demux.h" |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
40 #include "decomp.h" |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
41 #include "stream.h" |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
42 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
43 alac_file *alac = NULL; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
44 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
45 static VFSFile *input_file = NULL; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
46 static int input_opened = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
47 static stream_t *input_stream; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
48 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
49 gpointer decode_thread(void *args); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
50 static GThread *playback_thread; |
66 | 51 static int going = 0; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
52 |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
53 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
|
54 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
55 static void alac_init(void) |
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 /* empty */ |
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 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
60 gboolean is_our_file(char *filename) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
61 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
62 demux_res_t demux_res; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
63 input_file = vfs_fopen(filename, "rb"); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
64 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
|
65 |
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
66 set_endian(); |
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
67 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
68 if (!input_stream) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
69 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
70 fprintf(stderr, "failed to create input stream from file\n"); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
71 vfs_fclose(input_file); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
72 return FALSE; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
73 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
74 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
75 /* 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
|
76 * 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
|
77 if (!qtmovie_read(input_stream, &demux_res)) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
78 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
79 fprintf(stderr, "failed to load the QuickTime movie headers\n"); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
80 stream_destroy(input_stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
81 vfs_fclose(input_file); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
82 return FALSE; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
83 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
84 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
85 stream_destroy(input_stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
86 vfs_fclose(input_file); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
87 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
88 return TRUE; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
89 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
90 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
91 static void play_file(char *filename) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
92 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
93 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
|
94 } |
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 static void stop(void) |
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 g_thread_join(playback_thread); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
99 output_close_audio(); |
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 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
102 static void seek(gint time) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
103 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
104 /* unimplemented */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
105 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
106 |
66 | 107 static gint get_time(void) |
108 { | |
109 if (going) | |
110 return get_output_time(); | |
111 else | |
112 return -1; | |
113 } | |
114 | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
115 InputPlugin alac_ip = { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
116 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
117 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
118 "Apple Lossless Plugin", /* Description */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
119 alac_init, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
120 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
121 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
122 is_our_file, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
123 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
124 play_file, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
125 stop, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
126 output_pause, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
127 seek, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
128 NULL, |
66 | 129 get_time, |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
130 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
131 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
132 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
133 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
134 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
135 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
136 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
137 NULL, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
138 NULL, /* file_info_box */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
139 NULL |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
140 }; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
141 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
142 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
|
143 uint32_t *sample_duration, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
144 uint32_t *sample_byte_size) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
145 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
146 unsigned int duration_index_accum = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
147 unsigned int duration_cur_index = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
148 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
149 if (samplenum >= demux_res->num_sample_byte_sizes) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
150 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
151 fprintf(stderr, "sample %i does not exist\n", samplenum); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
152 return 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
153 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
154 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
155 if (!demux_res->num_time_to_samples) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
156 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
157 fprintf(stderr, "no time to samples\n"); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
158 return 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
159 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
160 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
|
161 <= samplenum) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
162 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
163 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
|
164 duration_cur_index++; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
165 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
|
166 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
167 fprintf(stderr, "sample %i does not have a duration\n", samplenum); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
168 return 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
169 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
170 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
171 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
172 *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
|
173 *sample_byte_size = demux_res->sample_byte_size[samplenum]; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
174 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
175 return 1; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
176 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
177 |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
178 void GetBuffer(demux_res_t *demux_res) |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
179 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
180 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
|
181 void *pDestBuffer = malloc(destBufferSize); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
182 int bytes_read = 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
183 |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
184 unsigned int buffer_size = 1024*128; |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
185 void *buffer; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
186 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
187 unsigned int i; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
188 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
189 buffer = malloc(buffer_size); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
190 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
191 for (i = 0; i < demux_res->num_sample_byte_sizes; i++) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
192 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
193 uint32_t sample_duration; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
194 uint32_t sample_byte_size; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
195 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
196 int outputBytes; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
197 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
198 /* just get one sample for now */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
199 if (!get_sample_info(demux_res, i, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
200 &sample_duration, &sample_byte_size)) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
201 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
202 fprintf(stderr, "sample failed\n"); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
203 return; |
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 if (buffer_size < sample_byte_size) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
207 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
208 fprintf(stderr, "sorry buffer too small! (is %i want %i)\n", |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
209 buffer_size, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
210 sample_byte_size); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
211 return; |
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 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
214 stream_read(input_stream, sample_byte_size, |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
215 buffer); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
216 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
217 /* now fetch */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
218 outputBytes = destBufferSize; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
219 decode_frame(alac, buffer, pDestBuffer, &outputBytes); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
220 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
221 /* write */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
222 bytes_read += outputBytes; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
223 |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
224 produce_audio(alac_ip.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
|
225 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
226 } |
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 static void init_sound_converter(demux_res_t *demux_res) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
229 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
230 alac = create_alac(demux_res->sample_size, demux_res->num_channels); |
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 alac_set_info(alac, demux_res->codecdata); |
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 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
235 gpointer decode_thread(void *args) |
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 demux_res_t demux_res; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
238 unsigned int output_size, i; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
239 |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
240 set_endian(); |
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
241 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
242 input_file = vfs_fopen((char *) args, "rb"); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
243 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
|
244 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
245 if (!input_stream) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
246 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
247 fprintf(stderr, "failed to create input stream from file\n"); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
248 return 0; |
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 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
251 /* 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
|
252 * 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
|
253 if (!qtmovie_read(input_stream, &demux_res)) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
254 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
255 fprintf(stderr, "failed to load the QuickTime movie headers\n"); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
256 return 0; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
257 } |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
258 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
259 /* initialise the sound converter */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
260 init_sound_converter(&demux_res); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
261 |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
262 alac_ip.output->open_audio(FMT_S16_LE, demux_res.sample_rate, demux_res.num_channels); |
59
72ad216a01ac
[svn] - tell audacious that playback is starting when we open an alac file
nenolod
parents:
58
diff
changeset
|
263 alac_ip.set_info((char *) args, -1, -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
|
264 |
66 | 265 going = 1; |
266 | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
267 /* will convert the entire buffer */ |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
268 GetBuffer(&demux_res); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
269 |
66 | 270 going = 0; |
271 | |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
272 stream_destroy(input_stream); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
273 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
274 if (input_opened) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
275 vfs_fclose(input_file); |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
276 |
57
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
277 alac_ip.output->close_audio(); |
96901271d2e2
[svn] - fix crashing. works on my x64 box, static on bigendian (tested: x64-be, mips, ppc64)
nenolod
parents:
56
diff
changeset
|
278 |
56
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
279 return NULL; |
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 |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
282 InputPlugin *get_iplugin_info(void) |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
283 { |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
284 return &alac_ip; |
56c88eee9802
[svn] - experimental ALAC plugin -- don't use this, it crashes
nenolod
parents:
diff
changeset
|
285 } |