Mercurial > audlegacy-plugins
annotate src/aac/src/libmp4.c @ 739:9480fdc511f1 trunk
[svn] - do not pass a buffered FD to the decoding thread, just use it for
determining whether or not the stream is ADTS.
author | nenolod |
---|---|
date | Tue, 27 Feb 2007 04:19:56 -0800 |
parents | eecd54a11610 |
children | 6ae04ca57bc1 |
rev | line source |
---|---|
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
1 #include <glib.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
2 #include <gtk/gtk.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
3 #include <string.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
4 #include <stdlib.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
5 #include "faad.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
6 #include "mp4ff.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
7 #include "tagging.h" |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
8 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
9 #include <audacious/plugin.h> |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
10 #include <audacious/output.h> |
4
0ad4849f6219
[svn] - the first pass missed some libaudacious references, this fixes them
nenolod
parents:
0
diff
changeset
|
11 #include <audacious/util.h> |
0ad4849f6219
[svn] - the first pass missed some libaudacious references, this fixes them
nenolod
parents:
0
diff
changeset
|
12 #include <audacious/titlestring.h> |
0ad4849f6219
[svn] - the first pass missed some libaudacious references, this fixes them
nenolod
parents:
0
diff
changeset
|
13 #include <audacious/vfs.h> |
527
d124034ebea3
[svn] - glib/gi18n.h -> audacious/i18n.h for automatic dgettext support
nenolod
parents:
393
diff
changeset
|
14 #include <audacious/i18n.h> |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
15 |
583 | 16 #define MP4_VERSION VERSION |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
17 |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
18 #define SBR_DEC |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
19 |
737
eecd54a11610
[svn] - use vfs_buffered_file_new_from_uri for probing.
nenolod
parents:
700
diff
changeset
|
20 extern VFSFile *vfs_buffered_file_new_from_uri(gchar *uri); |
eecd54a11610
[svn] - use vfs_buffered_file_new_from_uri for probing.
nenolod
parents:
700
diff
changeset
|
21 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
22 /* |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
23 * BUFFER_SIZE is the highest amount of memory that can be pulled. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
24 * We use this for sanity checks, among other things, as mp4ff needs |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
25 * a labotomy sometimes. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
26 */ |
583 | 27 #define BUFFER_SIZE FAAD_MIN_STREAMSIZE*64 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
28 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
29 /* |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
30 * AAC_MAGIC is the pattern that marks the beginning of an MP4 container. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
31 */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
32 #define AAC_MAGIC (unsigned char [4]) { 0xFF, 0xF9, 0x5C, 0x80 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
33 |
583 | 34 static void mp4_init(void); |
35 static void mp4_about(void); | |
36 static int mp4_is_our_file(char *); | |
37 static void mp4_play(InputPlayback *); | |
38 static void mp4_stop(InputPlayback *); | |
39 static void mp4_pause(InputPlayback *, short); | |
40 static void mp4_seek(InputPlayback *, int); | |
41 static int mp4_get_time(InputPlayback *); | |
42 static void mp4_cleanup(void); | |
43 static void mp4_get_song_title_len(char *filename, char **, int *); | |
44 static TitleInput* mp4_get_song_tuple(char *); | |
45 static int mp4_is_our_fd(char *, VFSFile *); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
46 |
374 | 47 gchar *mp4_fmts[] = { "m4a", "mp4", "aac", NULL }; |
48 | |
583 | 49 static void * mp4_decode(void *); |
50 static gchar * mp4_get_song_title(char *filename); | |
51 static void audmp4_file_info_box(gchar *); | |
52 gboolean buffer_playing; | |
53 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
54 InputPlugin mp4_ip = |
583 | 55 { |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
56 NULL, // handle |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
57 NULL, // filename |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
58 "MP4 Audio Plugin", |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
59 mp4_init, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
60 mp4_about, |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
61 NULL, // configuration |
583 | 62 mp4_is_our_file, |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
63 NULL, //scandir |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
64 mp4_play, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
65 mp4_stop, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
66 mp4_pause, |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
67 mp4_seek, |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
68 NULL, // set equalizer |
583 | 69 mp4_get_time, |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
70 NULL, // get volume |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
71 NULL, |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
72 mp4_cleanup, |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
73 NULL, // obsolete |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
74 NULL, // send visualisation data |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
75 NULL, // set player window info |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
76 NULL, // set song title text |
583 | 77 mp4_get_song_title_len, // get song title text |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
78 NULL, // info box |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
79 NULL, // to output plugin |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
80 mp4_get_song_tuple, |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
81 NULL, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
82 NULL, |
583 | 83 mp4_is_our_fd, |
374 | 84 mp4_fmts, |
583 | 85 }; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
86 |
583 | 87 typedef struct _mp4cfg |
88 { | |
89 #define FILE_UNKNOWN 0 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
90 #define FILE_MP4 1 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
91 #define FILE_AAC 2 |
583 | 92 gshort file_type; |
93 } Mp4Config; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
94 |
583 | 95 static Mp4Config mp4cfg; |
96 static GThread *decodeThread; | |
97 GStaticMutex mutex = G_STATIC_MUTEX_INIT; | |
98 static int seekPosition = -1; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
99 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
100 void getMP4info(char*); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
101 int getAACTrack(mp4ff_t *); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
102 |
583 | 103 static guint32 mp4_read_callback(void *data, void *buffer, guint32 len) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
104 { |
583 | 105 if (data == NULL || buffer == NULL) |
106 return -1; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
107 |
583 | 108 return vfs_fread(buffer, 1, len, (VFSFile *) data); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
109 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
110 |
583 | 111 static guint32 mp4_seek_callback(void *data, guint64 pos) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
112 { |
583 | 113 if (data == NULL) |
114 return -1; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
115 |
583 | 116 return vfs_fseek((VFSFile *) data, pos, SEEK_SET); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
117 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
118 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
119 static gchar * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
120 extname(const char *filename) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
121 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
122 gchar *ext = strrchr(filename, '.'); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
123 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
124 if (ext != NULL) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
125 ++ext; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
126 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
127 return ext; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
128 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
129 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
130 InputPlugin *get_iplugin_info(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
131 { |
583 | 132 return(&mp4_ip); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
133 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
134 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
135 static void mp4_init(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
136 { |
583 | 137 mp4cfg.file_type = FILE_UNKNOWN; |
138 seekPosition = -1; | |
139 return; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
140 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
141 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
142 static void mp4_play(InputPlayback *playback) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
143 { |
583 | 144 buffer_playing = TRUE; |
145 decodeThread = g_thread_create((GThreadFunc)mp4_decode, playback, TRUE, NULL); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
146 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
147 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
148 static void mp4_stop(InputPlayback *playback) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
149 { |
583 | 150 if (buffer_playing) |
151 { | |
152 buffer_playing = FALSE; | |
153 g_thread_join(decodeThread); | |
154 playback->output->close_audio(); | |
155 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
156 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
157 |
678
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
158 /* |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
159 * These routines are derived from MPlayer. |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
160 */ |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
161 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
162 /// \param srate (out) sample rate |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
163 /// \param num (out) number of audio frames in this ADTS frame |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
164 /// \return size of the ADTS frame in bytes |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
165 /// aac_parse_frames needs a buffer at least 8 bytes long |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
166 int aac_parse_frame(guchar *buf, int *srate, int *num) |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
167 { |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
168 int i = 0, sr, fl = 0, id; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
169 static int srates[] = {96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 0, 0, 0}; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
170 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
171 if((buf[i] != 0xFF) || ((buf[i+1] & 0xF6) != 0xF0)) |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
172 return 0; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
173 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
174 id = (buf[i+1] >> 3) & 0x01; //id=1 mpeg2, 0: mpeg4 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
175 sr = (buf[i+2] >> 2) & 0x0F; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
176 if(sr > 11) |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
177 return 0; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
178 *srate = srates[sr]; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
179 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
180 fl = ((buf[i+3] & 0x03) << 11) | (buf[i+4] << 3) | ((buf[i+5] >> 5) & 0x07); |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
181 *num = (buf[i+6] & 0x02) + 1; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
182 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
183 return fl; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
184 } |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
185 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
186 static gboolean parse_aac_stream(VFSFile *stream) |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
187 { |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
188 int cnt = 0, c, len, srate, num; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
189 off_t init, probed; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
190 static guchar buf[8]; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
191 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
192 init = probed = vfs_ftell(stream); |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
193 while(probed-init <= 32768 && cnt < 8) |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
194 { |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
195 c = 0; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
196 while(probed-init <= 32768 && c != 0xFF) |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
197 { |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
198 c = vfs_getc(stream); |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
199 if(c < 0) |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
200 return FALSE; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
201 probed = vfs_ftell(stream); |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
202 } |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
203 buf[0] = 0xFF; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
204 if(vfs_fread(&(buf[1]), 1, 7, stream) < 7) |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
205 return FALSE; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
206 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
207 len = aac_parse_frame(buf, &srate, &num); |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
208 if(len > 0) |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
209 { |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
210 cnt++; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
211 vfs_fseek(stream, len - 8, SEEK_CUR); |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
212 } |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
213 probed = vfs_ftell(stream); |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
214 } |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
215 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
216 if(cnt < 8) |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
217 return FALSE; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
218 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
219 return TRUE; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
220 } |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
221 |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
222 static int aac_probe(unsigned char *buffer, int len) |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
223 { |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
224 int i = 0, pos = 0; |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
225 #ifdef DEBUG |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
226 g_print("\nAAC_PROBE: %d bytes\n", len); |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
227 #endif |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
228 while(i <= len-4) { |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
229 if( |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
230 ((buffer[i] == 0xff) && ((buffer[i+1] & 0xf6) == 0xf0)) || |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
231 (buffer[i] == 'A' && buffer[i+1] == 'D' && buffer[i+2] == 'I' && buffer[i+3] == 'F') |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
232 ) { |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
233 pos = i; |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
234 break; |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
235 } |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
236 #ifdef DEBUG |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
237 g_print("AUDIO PAYLOAD: %x %x %x %x\n", |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
238 buffer[i], buffer[i+1], buffer[i+2], buffer[i+3]); |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
239 #endif |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
240 i++; |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
241 } |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
242 #ifdef DEBUG |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
243 g_print("\nAAC_PROBE: ret %d\n", pos); |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
244 #endif |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
245 return pos; |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
246 } |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
247 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
248 static int mp4_is_our_file(char *filename) |
262
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
249 { |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
250 VFSFile *file; |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
251 gchar* extension; |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
252 gchar magic[8]; |
393 | 253 |
254 memset(magic, '\0', 8); | |
255 | |
262
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
256 extension = strrchr(filename, '.'); |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
257 if ((file = vfs_fopen(filename, "rb"))) { |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
258 vfs_fread(magic, 1, 8, file); |
678
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
259 vfs_rewind(file); |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
260 if (parse_aac_stream(file) == TRUE) { |
262
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
261 vfs_fclose(file); |
678
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
262 return TRUE; |
262
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
263 } |
583 | 264 if (!memcmp(magic, "ID3", 3)) { // ID3 tag bolted to the front, obfuscated magic bytes |
262
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
265 vfs_fclose(file); |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
266 if (extension &&( |
583 | 267 !strcasecmp(extension, ".mp4") || // official extension |
268 !strcasecmp(extension, ".m4a") || // Apple mp4 extension | |
269 !strcasecmp(extension, ".aac") // old MPEG2/4-AAC extension | |
270 )) | |
271 return 1; | |
272 else | |
273 return 0; | |
262
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
274 } |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
275 if (!memcmp(&magic[4], "ftyp", 4)) { |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
276 vfs_fclose(file); |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
277 return 1; |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
278 } |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
279 vfs_fclose(file); |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
280 } |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
281 return 0; |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
282 } |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
283 |
583 | 284 static int mp4_is_our_fd(char *filename, VFSFile* file) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
285 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
286 gchar* extension; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
287 gchar magic[8]; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
288 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
289 extension = strrchr(filename, '.'); |
255 | 290 vfs_fread(magic, 1, 8, file); |
678
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
291 vfs_rewind(file); |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
292 if (parse_aac_stream(file) == TRUE) |
255 | 293 return 1; |
294 if (!memcmp(&magic[4], "ftyp", 4)) | |
295 return 1; | |
583 | 296 if (!memcmp(magic, "ID3", 3)) { // ID3 tag bolted to the front, obfuscated magic bytes |
255 | 297 if (extension &&( |
583 | 298 !strcasecmp(extension, ".mp4") || // official extension |
299 !strcasecmp(extension, ".m4a") || // Apple mp4 extension | |
300 !strcasecmp(extension, ".aac") // old MPEG2/4-AAC extension | |
255 | 301 )) |
302 return 1; | |
303 else | |
304 return 0; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
305 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
306 return 0; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
307 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
308 |
583 | 309 static void mp4_about(void) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
310 { |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
311 static GtkWidget *aboutbox = NULL; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
312 aboutbox = xmms_show_message("About MP4 AAC player plugin", |
583 | 313 "Using libfaad2-" FAAD2_VERSION " for decoding.\n" |
680
3a06665a810e
[svn] - satisfy Nero AG attribution requirement for FAAD 2.5 code import
nenolod
parents:
679
diff
changeset
|
314 "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com\n" |
583 | 315 "Copyright (c) 2005-2006 Audacious team", |
316 "Ok", FALSE, NULL, NULL); | |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
317 g_signal_connect(G_OBJECT(aboutbox), "destroy", |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
318 G_CALLBACK(gtk_widget_destroyed), |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
319 &aboutbox); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
320 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
321 |
583 | 322 static void mp4_pause(InputPlayback *playback, short flag) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
323 { |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
324 playback->output->pause(flag); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
325 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
326 |
583 | 327 static void mp4_seek(InputPlayback *data, int time) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
328 { |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
329 seekPosition = time; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
330 while(buffer_playing && seekPosition != -1) |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
331 xmms_usleep(10000); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
332 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
333 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
334 static int mp4_get_time(InputPlayback *playback) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
335 { |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
336 if(!buffer_playing) |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
337 return (-1); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
338 else |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
339 return (playback->output->output_time()); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
340 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
341 |
583 | 342 static void mp4_cleanup(void) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
343 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
344 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
345 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
346 static TitleInput *mp4_get_song_tuple(char *fn) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
347 { |
583 | 348 mp4ff_callback_t *mp4cb = g_malloc0(sizeof(mp4ff_callback_t)); |
349 VFSFile *mp4fh; | |
350 mp4ff_t *mp4file; | |
351 TitleInput *input = NULL; | |
352 gchar *filename = g_strdup(fn); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
353 |
583 | 354 mp4fh = vfs_fopen(filename, "rb"); |
355 mp4cb->read = mp4_read_callback; | |
356 mp4cb->seek = mp4_seek_callback; | |
357 mp4cb->user_data = mp4fh; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
358 |
583 | 359 if (!(mp4file = mp4ff_open_read(mp4cb))) { |
360 g_free(mp4cb); | |
361 vfs_fclose(mp4fh); | |
362 } else { | |
363 gint mp4track= getAACTrack(mp4file); | |
364 gint numSamples = mp4ff_num_samples(mp4file, mp4track); | |
365 guint framesize = 1024; | |
366 gulong samplerate; | |
367 guchar channels; | |
368 gint msDuration; | |
369 mp4AudioSpecificConfig mp4ASC; | |
370 gchar *tmpval; | |
371 guchar *buffer = NULL; | |
372 guint bufferSize = 0; | |
373 faacDecHandle decoder; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
374 |
583 | 375 if (mp4track == -1) |
376 return NULL; | |
377 | |
378 decoder = faacDecOpen(); | |
379 mp4ff_get_decoder_config(mp4file, mp4track, &buffer, &bufferSize); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
380 |
583 | 381 if ( !buffer ) { |
382 faacDecClose(decoder); | |
383 return FALSE; | |
384 } | |
385 if ( faacDecInit2(decoder, buffer, bufferSize, | |
386 &samplerate, &channels) < 0 ) { | |
387 faacDecClose(decoder); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
388 |
583 | 389 return FALSE; |
390 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
391 |
583 | 392 /* Add some hacks for SBR profile */ |
393 if (AudioSpecificConfig(buffer, bufferSize, &mp4ASC) >= 0) { | |
394 if (mp4ASC.frameLengthFlag == 1) framesize = 960; | |
395 if (mp4ASC.sbr_present_flag == 1) framesize *= 2; | |
396 } | |
397 | |
398 g_free(buffer); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
399 |
583 | 400 faacDecClose(decoder); |
401 | |
402 msDuration = ((float)numSamples * (float)(framesize - 1.0)/(float)samplerate) * 1000; | |
403 | |
404 input = bmp_title_input_new(); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
405 |
583 | 406 mp4ff_meta_get_title(mp4file, &input->track_name); |
407 mp4ff_meta_get_album(mp4file, &input->album_name); | |
408 mp4ff_meta_get_artist(mp4file, &input->performer); | |
409 mp4ff_meta_get_date(mp4file, &tmpval); | |
410 mp4ff_meta_get_genre(mp4file, &input->genre); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
411 |
583 | 412 if (tmpval) |
413 { | |
414 input->year = atoi(tmpval); | |
415 free(tmpval); | |
416 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
417 |
583 | 418 input->file_name = g_path_get_basename(filename); |
419 input->file_path = g_path_get_dirname(filename); | |
420 input->file_ext = extname(filename); | |
421 input->length = msDuration; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
422 |
583 | 423 free (mp4cb); |
424 vfs_fclose(mp4fh); | |
425 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
426 |
583 | 427 return input; |
428 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
429 |
583 | 430 static void mp4_get_song_title_len(char *filename, char **title, int *len) |
431 { | |
432 (*title) = mp4_get_song_title(filename); | |
433 (*len) = -1; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
434 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
435 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
436 static gchar *mp4_get_song_title(char *filename) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
437 { |
583 | 438 mp4ff_callback_t *mp4cb = g_malloc0(sizeof(mp4ff_callback_t)); |
439 VFSFile *mp4fh; | |
440 mp4ff_t *mp4file; | |
441 gchar *title = NULL; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
442 |
583 | 443 mp4fh = vfs_fopen(filename, "rb"); |
444 mp4cb->read = mp4_read_callback; | |
445 mp4cb->seek = mp4_seek_callback; | |
446 mp4cb->user_data = mp4fh; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
447 |
583 | 448 if (!(mp4file = mp4ff_open_read(mp4cb))) { |
449 g_free(mp4cb); | |
450 vfs_fclose(mp4fh); | |
451 } else { | |
452 TitleInput *input; | |
453 gchar *tmpval; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
454 |
583 | 455 input = bmp_title_input_new(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
456 |
583 | 457 mp4ff_meta_get_title(mp4file, &input->track_name); |
458 mp4ff_meta_get_album(mp4file, &input->album_name); | |
459 mp4ff_meta_get_artist(mp4file, &input->performer); | |
460 mp4ff_meta_get_date(mp4file, &tmpval); | |
461 mp4ff_meta_get_genre(mp4file, &input->genre); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
462 |
583 | 463 if (tmpval) |
464 { | |
465 input->year = atoi(tmpval); | |
466 free(tmpval); | |
467 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
468 |
583 | 469 input->file_name = g_path_get_basename(filename); |
470 input->file_path = g_path_get_dirname(filename); | |
471 input->file_ext = extname(filename); | |
472 | |
473 title = xmms_get_titlestring(xmms_get_gentitle_format(), input); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
474 |
583 | 475 free (input->track_name); |
476 free (input->album_name); | |
477 free (input->performer); | |
478 free (input->genre); | |
479 free (input->file_name); | |
480 free (input->file_path); | |
481 free (input); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
482 |
583 | 483 free (mp4cb); |
484 vfs_fclose(mp4fh); | |
485 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
486 |
583 | 487 if (!title) |
488 { | |
489 title = g_path_get_basename(filename); | |
490 if (extname(title)) | |
491 *(extname(title) - 1) = '\0'; | |
492 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
493 |
583 | 494 return title; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
495 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
496 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
497 static int my_decode_mp4( InputPlayback *playback, char *filename, mp4ff_t *mp4file ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
498 { |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
499 // We are reading an MP4 file |
583 | 500 gint mp4track= getAACTrack(mp4file); |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
501 faacDecHandle decoder; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
502 mp4AudioSpecificConfig mp4ASC; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
503 guchar *buffer = NULL; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
504 guint bufferSize = 0; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
505 gulong samplerate; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
506 guchar channels; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
507 gulong msDuration; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
508 gulong numSamples; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
509 gulong sampleID = 1; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
510 guint framesize = 1024; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
511 |
694
a429ce72d20e
[svn] - handle a situation where buffer could be NULL (e.g. bail)
nenolod
parents:
693
diff
changeset
|
512 if (mp4track < 0) |
a429ce72d20e
[svn] - handle a situation where buffer could be NULL (e.g. bail)
nenolod
parents:
693
diff
changeset
|
513 { |
a429ce72d20e
[svn] - handle a situation where buffer could be NULL (e.g. bail)
nenolod
parents:
693
diff
changeset
|
514 g_print("Unsupported Audio track type\n"); |
a429ce72d20e
[svn] - handle a situation where buffer could be NULL (e.g. bail)
nenolod
parents:
693
diff
changeset
|
515 return TRUE; |
a429ce72d20e
[svn] - handle a situation where buffer could be NULL (e.g. bail)
nenolod
parents:
693
diff
changeset
|
516 } |
a429ce72d20e
[svn] - handle a situation where buffer could be NULL (e.g. bail)
nenolod
parents:
693
diff
changeset
|
517 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
518 gchar *xmmstitle = NULL; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
519 xmmstitle = mp4_get_song_title(filename); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
520 if(xmmstitle == NULL) |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
521 xmmstitle = g_strdup(filename); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
522 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
523 decoder = faacDecOpen(); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
524 mp4ff_get_decoder_config(mp4file, mp4track, &buffer, &bufferSize); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
525 if ( !buffer ) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
526 faacDecClose(decoder); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
527 return FALSE; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
528 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
529 if ( faacDecInit2(decoder, buffer, bufferSize, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
530 &samplerate, &channels) < 0 ) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
531 faacDecClose(decoder); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
532 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
533 return FALSE; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
534 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
535 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
536 /* Add some hacks for SBR profile */ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
537 if (AudioSpecificConfig(buffer, bufferSize, &mp4ASC) >= 0) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
538 if (mp4ASC.frameLengthFlag == 1) framesize = 960; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
539 if (mp4ASC.sbr_present_flag == 1) framesize *= 2; |
583 | 540 } |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
541 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
542 g_free(buffer); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
543 if( !channels ) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
544 faacDecClose(decoder); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
545 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
546 return FALSE; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
547 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
548 numSamples = mp4ff_num_samples(mp4file, mp4track); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
549 msDuration = ((float)numSamples * (float)(framesize - 1.0)/(float)samplerate) * 1000; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
550 playback->output->open_audio(FMT_S16_NE, samplerate, channels); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
551 playback->output->flush(0); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
552 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
553 mp4_ip.set_info(xmmstitle, msDuration, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
554 mp4ff_get_avg_bitrate( mp4file, mp4track ), |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
555 samplerate,channels); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
556 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
557 while ( buffer_playing ) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
558 void* sampleBuffer; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
559 faacDecFrameInfo frameInfo; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
560 gint rc; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
561 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
562 /* Seek if seek position has changed */ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
563 if ( seekPosition!=-1 ) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
564 sampleID = (float)seekPosition*(float)samplerate/(float)(framesize - 1.0); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
565 playback->output->flush(seekPosition*1000); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
566 seekPosition = -1; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
567 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
568 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
569 /* Otherwise continue playing */ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
570 buffer=NULL; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
571 bufferSize=0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
572 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
573 /* If we've run to the end of the file, we're done. */ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
574 if(sampleID >= numSamples){ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
575 /* Finish playing before we close the |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
576 output. */ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
577 while ( playback->output->buffer_playing() ) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
578 xmms_usleep(10000); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
579 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
580 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
581 playback->output->flush(seekPosition*1000); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
582 playback->output->close_audio(); |
583 | 583 faacDecClose(decoder); |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
584 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
585 g_static_mutex_lock(&mutex); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
586 buffer_playing = FALSE; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
587 g_static_mutex_unlock(&mutex); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
588 g_thread_exit(NULL); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
589 |
583 | 590 return FALSE; |
591 } | |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
592 rc= mp4ff_read_sample(mp4file, mp4track, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
593 sampleID++, &buffer, &bufferSize); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
594 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
595 /*g_print(":: %d/%d\n", sampleID-1, numSamples);*/ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
596 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
597 /* If we can't read the file, we're done. */ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
598 if((rc == 0) || (buffer== NULL) || (bufferSize == 0) || (bufferSize > BUFFER_SIZE)){ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
599 g_print("MP4: read error\n"); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
600 sampleBuffer = NULL; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
601 sampleID=0; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
602 playback->output->buffer_free(); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
603 playback->output->close_audio(); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
604 |
583 | 605 faacDecClose(decoder); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
606 |
583 | 607 return FALSE; |
608 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
609 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
610 /* g_print(" :: %d/%d\n", bufferSize, BUFFER_SIZE); */ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
611 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
612 sampleBuffer= faacDecDecode(decoder, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
613 &frameInfo, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
614 buffer, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
615 bufferSize); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
616 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
617 /* If there was an error decoding, we're done. */ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
618 if(frameInfo.error > 0){ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
619 g_print("MP4: %s\n", |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
620 faacDecGetErrorMessage(frameInfo.error)); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
621 playback->output->close_audio(); |
583 | 622 faacDecClose(decoder); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
623 |
583 | 624 return FALSE; |
625 } | |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
626 if(buffer){ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
627 g_free(buffer); |
583 | 628 buffer=NULL; |
629 bufferSize=0; | |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
630 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
631 if (buffer_playing == FALSE) |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
632 { |
583 | 633 playback->output->close_audio(); |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
634 return FALSE; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
635 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
636 produce_audio(playback->output->written_time(), |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
637 FMT_S16_NE, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
638 channels, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
639 frameInfo.samples<<1, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
640 sampleBuffer, &buffer_playing); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
641 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
642 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
643 playback->output->close_audio(); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
644 faacDecClose(decoder); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
645 |
583 | 646 return TRUE; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
647 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
648 |
692
a77e766e332d
[svn] - fix another potential synchronization problem
nenolod
parents:
690
diff
changeset
|
649 static void my_decode_aac( InputPlayback *playback, char *filename, VFSFile *file ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
650 { |
583 | 651 faacDecHandle decoder = 0; |
695
e6b3dddb3c35
[svn] - no idea why we were using a dynamically allocated buffer for raw aac
nenolod
parents:
694
diff
changeset
|
652 guchar buffer[BUFFER_SIZE]; |
583 | 653 gulong bufferconsumed = 0; |
654 gulong samplerate = 0; | |
655 guchar channels; | |
656 gulong buffervalid = 0; | |
657 TitleInput* input; | |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
658 gchar *ttemp = NULL, *stemp = NULL; |
583 | 659 gchar *temp = g_strdup(filename); |
660 gchar *ext = strrchr(temp, '.'); | |
661 gchar *xmmstitle = NULL; | |
662 faacDecConfigurationPtr config; | |
697
74a762a3592e
[svn] - temporarily cheat and disable certain codepaths for local files
nenolod
parents:
695
diff
changeset
|
663 gboolean remote = str_has_prefix_nocase(filename, "http:") || |
74a762a3592e
[svn] - temporarily cheat and disable certain codepaths for local files
nenolod
parents:
695
diff
changeset
|
664 str_has_prefix_nocase(filename, "https:"); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
665 |
692
a77e766e332d
[svn] - fix another potential synchronization problem
nenolod
parents:
690
diff
changeset
|
666 vfs_rewind(file); |
583 | 667 if((decoder = faacDecOpen()) == NULL){ |
668 g_print("AAC: Open Decoder Error\n"); | |
669 vfs_fclose(file); | |
670 buffer_playing = FALSE; | |
671 g_static_mutex_unlock(&mutex); | |
672 g_thread_exit(NULL); | |
673 } | |
674 if((buffervalid = vfs_fread(buffer, 1, BUFFER_SIZE, file))==0){ | |
675 g_print("AAC: Error reading file\n"); | |
676 vfs_fclose(file); | |
677 buffer_playing = FALSE; | |
678 faacDecClose(decoder); | |
679 g_static_mutex_unlock(&mutex); | |
680 g_thread_exit(NULL); | |
681 } | |
682 if(!strncmp((char*)buffer, "ID3", 3)){ | |
683 gint size = 0; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
684 |
583 | 685 vfs_fseek(file, 0, SEEK_SET); |
686 size = (buffer[6]<<21) | (buffer[7]<<14) | (buffer[8]<<7) | buffer[9]; | |
687 size+=10; | |
688 vfs_fread(buffer, 1, size, file); | |
689 buffervalid = vfs_fread(buffer, 1, BUFFER_SIZE, file); | |
690 } | |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
691 |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
692 ttemp = vfs_get_metadata(file, "stream-name"); |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
693 |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
694 if (ttemp != NULL) |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
695 { |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
696 xmmstitle = g_strdup(ttemp); |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
697 g_free(ttemp); |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
698 } |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
699 else |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
700 xmmstitle = g_strdup(g_basename(temp)); |
679
c8dc00a58f0d
[svn] - remove a bunch of pointless code. we don't do ID3 for raw AAC files at this time.
nenolod
parents:
678
diff
changeset
|
701 |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
702 bufferconsumed = aac_probe(buffer, buffervalid); |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
703 if(bufferconsumed) { |
690
0305b3165a01
[svn] - ringbuffering underrun fixups -- found with purify
nenolod
parents:
689
diff
changeset
|
704 memmove(buffer, &buffer[bufferconsumed], buffervalid); |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
705 buffervalid -= bufferconsumed; |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
706 buffervalid += vfs_fread(&buffer[buffervalid], 1, |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
707 BUFFER_SIZE-buffervalid, file); |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
708 bufferconsumed = 0; |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
709 } |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
710 |
583 | 711 bufferconsumed = faacDecInit(decoder, |
712 buffer, | |
713 buffervalid, | |
714 &samplerate, | |
715 &channels); | |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
716 #ifdef DEBUG |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
717 g_print("samplerate: %d, channels: %d\n", samplerate, channels); |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
718 #endif |
583 | 719 if(playback->output->open_audio(FMT_S16_NE,samplerate,channels) == FALSE){ |
720 g_print("AAC: Output Error\n"); | |
721 faacDecClose(decoder); | |
722 vfs_fclose(file); | |
723 playback->output->close_audio(); | |
724 g_free(xmmstitle); | |
725 buffer_playing = FALSE; | |
726 g_static_mutex_unlock(&mutex); | |
727 g_thread_exit(NULL); | |
728 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
729 |
583 | 730 mp4_ip.set_info(xmmstitle, -1, -1, samplerate, channels); |
731 playback->output->flush(0); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
732 |
700
27a557e80e15
[svn] - fix a ringbuffering error. found by purify.
nenolod
parents:
697
diff
changeset
|
733 while(buffer_playing && buffervalid > 0 && buffer != NULL) |
27a557e80e15
[svn] - fix a ringbuffering error. found by purify.
nenolod
parents:
697
diff
changeset
|
734 { |
583 | 735 faacDecFrameInfo finfo; |
736 unsigned long samplesdecoded; | |
737 char* sample_buffer = NULL; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
738 |
700
27a557e80e15
[svn] - fix a ringbuffering error. found by purify.
nenolod
parents:
697
diff
changeset
|
739 if(bufferconsumed > 0) |
27a557e80e15
[svn] - fix a ringbuffering error. found by purify.
nenolod
parents:
697
diff
changeset
|
740 { |
690
0305b3165a01
[svn] - ringbuffering underrun fixups -- found with purify
nenolod
parents:
689
diff
changeset
|
741 memmove(buffer, &buffer[bufferconsumed], buffervalid); |
583 | 742 buffervalid -= bufferconsumed; |
743 buffervalid += vfs_fread(&buffer[buffervalid], 1, | |
744 BUFFER_SIZE-buffervalid, file); | |
745 bufferconsumed = 0; | |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
746 |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
747 ttemp = vfs_get_metadata(file, "stream-name"); |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
748 |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
749 if (ttemp != NULL) |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
750 stemp = vfs_get_metadata(file, "track-name"); |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
751 |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
752 if (stemp != NULL) |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
753 { |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
754 static gchar *ostmp = NULL; |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
755 |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
756 if (ostmp == NULL || g_ascii_strcasecmp(stemp, ostmp)) |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
757 { |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
758 if (xmmstitle != NULL) |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
759 g_free(xmmstitle); |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
760 |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
761 xmmstitle = g_strdup_printf("%s (%s)", stemp, ttemp); |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
762 |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
763 if (ostmp != NULL) |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
764 g_free(ostmp); |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
765 |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
766 ostmp = stemp; |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
767 |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
768 mp4_ip.set_info(xmmstitle, -1, -1, samplerate, channels); |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
769 } |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
770 } |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
771 |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
772 g_free(ttemp); |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
773 ttemp = NULL; |
583 | 774 } |
688
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
775 |
583 | 776 sample_buffer = faacDecDecode(decoder, &finfo, buffer, buffervalid); |
688
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
777 |
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
778 bufferconsumed += finfo.bytesconsumed; |
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
779 samplesdecoded = finfo.samples; |
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
780 |
700
27a557e80e15
[svn] - fix a ringbuffering error. found by purify.
nenolod
parents:
697
diff
changeset
|
781 if(finfo.error > 0 && remote != FALSE) |
27a557e80e15
[svn] - fix a ringbuffering error. found by purify.
nenolod
parents:
697
diff
changeset
|
782 { |
686 | 783 memmove(buffer, &buffer[1], buffervalid); |
688
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
784 if(buffervalid < BUFFER_SIZE) { |
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
785 buffervalid += |
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
786 vfs_fread(&buffer[buffervalid], 1, BUFFER_SIZE-buffervalid, file); |
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
787 } |
686 | 788 bufferconsumed = aac_probe(buffer, buffervalid); |
789 if(bufferconsumed) { | |
700
27a557e80e15
[svn] - fix a ringbuffering error. found by purify.
nenolod
parents:
697
diff
changeset
|
790 buffervalid -= bufferconsumed; |
689 | 791 memmove(buffer, &buffer[bufferconsumed], buffervalid); |
686 | 792 bufferconsumed = 0; |
583 | 793 } |
686 | 794 continue; |
583 | 795 } |
688
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
796 |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
797 if((samplesdecoded <= 0) && !sample_buffer){ |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
798 #ifdef DEBUG |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
799 g_print("AAC: decoded %d samples!\n", samplesdecoded); |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
800 #endif |
583 | 801 continue; |
802 } | |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
803 |
583 | 804 produce_audio(playback->output->written_time(), |
805 FMT_S16_LE, channels, | |
806 samplesdecoded<<1, sample_buffer, &buffer_playing); | |
807 } | |
808 playback->output->buffer_free(); | |
809 playback->output->close_audio(); | |
810 buffer_playing = FALSE; | |
811 faacDecClose(decoder); | |
812 g_free(xmmstitle); | |
813 vfs_fclose(file); | |
814 seekPosition = -1; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
815 |
583 | 816 buffer_playing = FALSE; |
817 g_static_mutex_unlock(&mutex); | |
818 g_thread_exit(NULL); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
819 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
820 |
583 | 821 static void *mp4_decode( void *args ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
822 { |
583 | 823 mp4ff_callback_t *mp4cb = g_malloc0(sizeof(mp4ff_callback_t)); |
824 VFSFile *mp4fh; | |
825 mp4ff_t *mp4file; | |
678
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
826 gboolean ret; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
827 |
583 | 828 InputPlayback *playback = args; |
829 char *filename = playback->filename; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
830 |
737
eecd54a11610
[svn] - use vfs_buffered_file_new_from_uri for probing.
nenolod
parents:
700
diff
changeset
|
831 mp4fh = vfs_buffered_file_new_from_uri(filename); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
832 |
583 | 833 g_static_mutex_lock(&mutex); |
834 seekPosition= -1; | |
835 buffer_playing= TRUE; | |
836 g_static_mutex_unlock(&mutex); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
837 |
692
a77e766e332d
[svn] - fix another potential synchronization problem
nenolod
parents:
690
diff
changeset
|
838 if (mp4fh == NULL) |
a77e766e332d
[svn] - fix another potential synchronization problem
nenolod
parents:
690
diff
changeset
|
839 g_thread_exit(NULL); |
a77e766e332d
[svn] - fix another potential synchronization problem
nenolod
parents:
690
diff
changeset
|
840 |
678
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
841 ret = parse_aac_stream(mp4fh); |
739
9480fdc511f1
[svn] - do not pass a buffered FD to the decoding thread, just use it for
nenolod
parents:
737
diff
changeset
|
842 vfs_fclose(mp4fh); |
9480fdc511f1
[svn] - do not pass a buffered FD to the decoding thread, just use it for
nenolod
parents:
737
diff
changeset
|
843 |
9480fdc511f1
[svn] - do not pass a buffered FD to the decoding thread, just use it for
nenolod
parents:
737
diff
changeset
|
844 mp4fh = vfs_fopen(filename, "rb"); |
9480fdc511f1
[svn] - do not pass a buffered FD to the decoding thread, just use it for
nenolod
parents:
737
diff
changeset
|
845 mp4cb->read = mp4_read_callback; |
9480fdc511f1
[svn] - do not pass a buffered FD to the decoding thread, just use it for
nenolod
parents:
737
diff
changeset
|
846 mp4cb->seek = mp4_seek_callback; |
9480fdc511f1
[svn] - do not pass a buffered FD to the decoding thread, just use it for
nenolod
parents:
737
diff
changeset
|
847 mp4cb->user_data = mp4fh; |
9480fdc511f1
[svn] - do not pass a buffered FD to the decoding thread, just use it for
nenolod
parents:
737
diff
changeset
|
848 |
583 | 849 mp4file= mp4ff_open_read(mp4cb); |
678
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
850 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
851 if( ret == TRUE ) { |
583 | 852 g_free(mp4cb); |
692
a77e766e332d
[svn] - fix another potential synchronization problem
nenolod
parents:
690
diff
changeset
|
853 my_decode_aac( playback, filename, mp4fh ); |
583 | 854 } |
678
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
855 else |
583 | 856 my_decode_mp4( playback, filename, mp4file ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
857 |
583 | 858 return NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
859 } |