Mercurial > audlegacy-plugins
annotate src/aac/src/libmp4.c @ 1325:a33da9237bed
Several "i18n" improvements.
author | Stany HENRY <StrassBoy@gmail.com> |
---|---|
date | Sat, 21 Jul 2007 17:55:46 +0200 |
parents | f34112ab9101 |
children | 76f826e6052d |
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> |
1188
22a470857579
- fix the bug that aac plugin had failed to get proper playtime length on AMD64.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1167
diff
changeset
|
15 #include <audacious/strings.h> |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
16 |
583 | 17 #define MP4_VERSION VERSION |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
18 |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
19 #define SBR_DEC |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
20 |
737
eecd54a11610
[svn] - use vfs_buffered_file_new_from_uri for probing.
nenolod
parents:
700
diff
changeset
|
21 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
|
22 |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
23 /* |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
24 * 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
|
25 * 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
|
26 * a labotomy sometimes. |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
27 */ |
583 | 28 #define BUFFER_SIZE FAAD_MIN_STREAMSIZE*64 |
0
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 /* |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
31 * 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
|
32 */ |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
33 #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
|
34 |
583 | 35 static void mp4_init(void); |
36 static void mp4_about(void); | |
37 static int mp4_is_our_file(char *); | |
38 static void mp4_play(InputPlayback *); | |
39 static void mp4_stop(InputPlayback *); | |
40 static void mp4_pause(InputPlayback *, short); | |
41 static void mp4_seek(InputPlayback *, int); | |
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 |
1073 | 47 static gchar *fmts[] = { "m4a", "mp4", "aac", NULL }; |
374 | 48 |
583 | 49 static void * mp4_decode(void *); |
50 static gchar * mp4_get_song_title(char *filename); | |
51 gboolean buffer_playing; | |
52 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
53 InputPlugin mp4_ip = |
583 | 54 { |
1073 | 55 .description = "MP4 Audio Plugin", |
56 .init = mp4_init, | |
57 .about = mp4_about, | |
58 .is_our_file = mp4_is_our_file, | |
59 .play_file = mp4_play, | |
60 .stop = mp4_stop, | |
61 .pause = mp4_pause, | |
62 .seek = mp4_seek, | |
63 .cleanup = mp4_cleanup, | |
64 .get_song_info = mp4_get_song_title_len, | |
65 .get_song_tuple = mp4_get_song_tuple, | |
66 .is_our_file_from_vfs = mp4_is_our_fd, | |
67 .vfs_extensions = fmts, | |
583 | 68 }; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
69 |
1073 | 70 InputPlugin *mp4_iplist[] = { &mp4_ip, NULL }; |
71 | |
72 DECLARE_PLUGIN(mp4, NULL, NULL, mp4_iplist, NULL, NULL, NULL, NULL); | |
73 | |
583 | 74 typedef struct _mp4cfg |
75 { | |
76 #define FILE_UNKNOWN 0 | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
77 #define FILE_MP4 1 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
78 #define FILE_AAC 2 |
583 | 79 gshort file_type; |
80 } Mp4Config; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
81 |
583 | 82 static Mp4Config mp4cfg; |
83 static GThread *decodeThread; | |
84 GStaticMutex mutex = G_STATIC_MUTEX_INIT; | |
85 static int seekPosition = -1; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
86 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
87 void getMP4info(char*); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
88 int getAACTrack(mp4ff_t *); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
89 |
583 | 90 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
|
91 { |
583 | 92 if (data == NULL || buffer == NULL) |
93 return -1; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
94 |
583 | 95 return vfs_fread(buffer, 1, len, (VFSFile *) data); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
96 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
97 |
583 | 98 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
|
99 { |
583 | 100 if (data == NULL) |
101 return -1; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
102 |
583 | 103 return vfs_fseek((VFSFile *) data, pos, SEEK_SET); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
104 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
105 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
106 static gchar * |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
107 extname(const char *filename) |
1304
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
108 { |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
109 gchar *ext = strrchr(filename, '.'); |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
110 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
111 if (ext != NULL) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
112 ++ext; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
113 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
114 return ext; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
115 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
116 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
117 static void mp4_init(void) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
118 { |
583 | 119 mp4cfg.file_type = FILE_UNKNOWN; |
120 seekPosition = -1; | |
121 return; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
122 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
123 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
124 static void mp4_play(InputPlayback *playback) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
125 { |
583 | 126 buffer_playing = TRUE; |
1163 | 127 playback->playing = 1; //XXX should acquire lock? |
583 | 128 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
|
129 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
130 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
131 static void mp4_stop(InputPlayback *playback) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
132 { |
583 | 133 if (buffer_playing) |
134 { | |
135 buffer_playing = FALSE; | |
1163 | 136 playback->playing = 0; //XXX should acquire lock? |
583 | 137 g_thread_join(decodeThread); |
138 playback->output->close_audio(); | |
139 } | |
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 |
678
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
142 /* |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
143 * 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
|
144 */ |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
145 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
146 /// \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
|
147 /// \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
|
148 /// \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
|
149 /// 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
|
150 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
|
151 { |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
152 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
|
153 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
|
154 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
155 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
|
156 return 0; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
157 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
158 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
|
159 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
|
160 if(sr > 11) |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
161 return 0; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
162 *srate = srates[sr]; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
163 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
164 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
|
165 *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
|
166 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
167 return fl; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
168 } |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
169 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
170 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
|
171 { |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
172 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
|
173 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
|
174 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
|
175 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
176 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
|
177 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
|
178 { |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
179 c = 0; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
180 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
|
181 { |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
182 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
|
183 if(c < 0) |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
184 return FALSE; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
185 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
|
186 } |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
187 buf[0] = 0xFF; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
188 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
|
189 return FALSE; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
190 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
191 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
|
192 if(len > 0) |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
193 { |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
194 cnt++; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
195 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
|
196 } |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
197 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
|
198 } |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
199 |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
200 if(cnt < 8) |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
201 return FALSE; |
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 return TRUE; |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
204 } |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
205 |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
206 static int aac_probe(unsigned char *buffer, int len) |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
207 { |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
208 int i = 0, pos = 0; |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
209 #ifdef DEBUG |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
210 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
|
211 #endif |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
212 while(i <= len-4) { |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
213 if( |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
214 ((buffer[i] == 0xff) && ((buffer[i+1] & 0xf6) == 0xf0)) || |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
215 (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
|
216 ) { |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
217 pos = i; |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
218 break; |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
219 } |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
220 #ifdef DEBUG |
1304
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
221 g_print("AUDIO PAYLOAD: %x %x %x %x\n", |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
222 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
|
223 #endif |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
224 i++; |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
225 } |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
226 #ifdef DEBUG |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
227 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
|
228 #endif |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
229 return pos; |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
230 } |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
231 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
232 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
|
233 { |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
234 VFSFile *file; |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
235 gchar* extension; |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
236 gchar magic[8]; |
393 | 237 |
238 memset(magic, '\0', 8); | |
239 | |
262
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
240 extension = strrchr(filename, '.'); |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
241 if ((file = vfs_fopen(filename, "rb"))) { |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
242 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
|
243 vfs_rewind(file); |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
244 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
|
245 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
|
246 return TRUE; |
262
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
247 } |
583 | 248 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
|
249 vfs_fclose(file); |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
250 if (extension &&( |
583 | 251 !strcasecmp(extension, ".mp4") || // official extension |
252 !strcasecmp(extension, ".m4a") || // Apple mp4 extension | |
253 !strcasecmp(extension, ".aac") // old MPEG2/4-AAC extension | |
254 )) | |
255 return 1; | |
256 else | |
257 return 0; | |
262
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
258 } |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
259 if (!memcmp(&magic[4], "ftyp", 4)) { |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
260 vfs_fclose(file); |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
261 return 1; |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
262 } |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
263 vfs_fclose(file); |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
264 } |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
265 return 0; |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
266 } |
f653f1219db2
[svn] So input.c wants to have the old-style function available...
chainsaw
parents:
255
diff
changeset
|
267 |
583 | 268 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
|
269 { |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
270 gchar* extension; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
271 gchar magic[8]; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
272 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
273 extension = strrchr(filename, '.'); |
255 | 274 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
|
275 vfs_rewind(file); |
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
276 if (parse_aac_stream(file) == TRUE) |
255 | 277 return 1; |
278 if (!memcmp(&magic[4], "ftyp", 4)) | |
279 return 1; | |
583 | 280 if (!memcmp(magic, "ID3", 3)) { // ID3 tag bolted to the front, obfuscated magic bytes |
255 | 281 if (extension &&( |
583 | 282 !strcasecmp(extension, ".mp4") || // official extension |
283 !strcasecmp(extension, ".m4a") || // Apple mp4 extension | |
284 !strcasecmp(extension, ".aac") // old MPEG2/4-AAC extension | |
255 | 285 )) |
286 return 1; | |
287 else | |
288 return 0; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
289 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
290 return 0; |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
291 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
292 |
583 | 293 static void mp4_about(void) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
294 { |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
295 static GtkWidget *aboutbox = NULL; |
1304
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
296 gchar *about_text; |
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
297 |
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
298 about_text = g_strjoin ("", _("Using libfaad2-"), FAAD2_VERSION, |
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
299 _(" for decoding.\n" |
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
300 "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com\n" |
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
301 "Copyright (c) 2005-2006 Audacious team"), NULL); |
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
302 |
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
303 aboutbox = xmms_show_message(_("About MP4 AAC player plugin"), |
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
304 about_text, |
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
305 _("Ok"), FALSE, NULL, NULL); |
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
306 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
307 g_signal_connect(G_OBJECT(aboutbox), "destroy", |
1304
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
308 G_CALLBACK(gtk_widget_destroyed), &aboutbox); |
1325
a33da9237bed
Several "i18n" improvements.
Stany HENRY <StrassBoy@gmail.com>
parents:
1304
diff
changeset
|
309 g_free(about_text); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
310 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
311 |
583 | 312 static void mp4_pause(InputPlayback *playback, short flag) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
313 { |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
314 playback->output->pause(flag); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
315 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
316 |
583 | 317 static void mp4_seek(InputPlayback *data, int time) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
318 { |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
319 seekPosition = time; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
320 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
|
321 xmms_usleep(10000); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
322 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
323 |
583 | 324 static void mp4_cleanup(void) |
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 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
327 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
328 static TitleInput *mp4_get_song_tuple(char *fn) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
329 { |
583 | 330 mp4ff_callback_t *mp4cb = g_malloc0(sizeof(mp4ff_callback_t)); |
331 VFSFile *mp4fh; | |
332 mp4ff_t *mp4file; | |
333 TitleInput *input = NULL; | |
334 gchar *filename = g_strdup(fn); | |
785
e23b8e1472e3
[svn] - don't use a vfs buffered source for local files
nenolod
parents:
760
diff
changeset
|
335 gboolean remote = str_has_prefix_nocase(filename, "http:") || |
e23b8e1472e3
[svn] - don't use a vfs buffered source for local files
nenolod
parents:
760
diff
changeset
|
336 str_has_prefix_nocase(filename, "https:"); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
337 |
785
e23b8e1472e3
[svn] - don't use a vfs buffered source for local files
nenolod
parents:
760
diff
changeset
|
338 mp4fh = remote ? vfs_buffered_file_new_from_uri(filename) : vfs_fopen(filename, "rb"); |
760
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
339 |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
340 /* check if this file is an ADTS stream, if so return a blank tuple */ |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
341 if (parse_aac_stream(mp4fh)) |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
342 { |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
343 g_free(mp4cb); |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
344 |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
345 input = bmp_title_input_new(); |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
346 |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
347 input->track_name = vfs_get_metadata(mp4fh, "track-name"); |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
348 input->album_name = vfs_get_metadata(mp4fh, "stream-name"); |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
349 |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
350 input->file_name = g_path_get_basename(filename); |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
351 input->file_path = g_path_get_dirname(filename); |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
352 input->file_ext = extname(filename); |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
353 |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
354 input->mtime = 0; |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
355 input->length = -1; |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
356 |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
357 return input; |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
358 } |
6ed8d477ba89
[svn] - add tuple building for ADTS/Shoutcast streams
nenolod
parents:
759
diff
changeset
|
359 |
785
e23b8e1472e3
[svn] - don't use a vfs buffered source for local files
nenolod
parents:
760
diff
changeset
|
360 vfs_rewind(mp4fh); |
e23b8e1472e3
[svn] - don't use a vfs buffered source for local files
nenolod
parents:
760
diff
changeset
|
361 |
583 | 362 mp4cb->read = mp4_read_callback; |
363 mp4cb->seek = mp4_seek_callback; | |
1304
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
364 mp4cb->user_data = mp4fh; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
365 |
583 | 366 if (!(mp4file = mp4ff_open_read(mp4cb))) { |
367 g_free(mp4cb); | |
368 vfs_fclose(mp4fh); | |
369 } else { | |
370 gint mp4track= getAACTrack(mp4file); | |
371 gint numSamples = mp4ff_num_samples(mp4file, mp4track); | |
372 guint framesize = 1024; | |
1188
22a470857579
- fix the bug that aac plugin had failed to get proper playtime length on AMD64.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1167
diff
changeset
|
373 guint samplerate = 0; |
22a470857579
- fix the bug that aac plugin had failed to get proper playtime length on AMD64.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1167
diff
changeset
|
374 guchar channels = 0; |
583 | 375 gint msDuration; |
376 mp4AudioSpecificConfig mp4ASC; | |
377 gchar *tmpval; | |
378 guchar *buffer = NULL; | |
379 guint bufferSize = 0; | |
380 faacDecHandle decoder; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
381 |
583 | 382 if (mp4track == -1) |
383 return NULL; | |
384 | |
385 decoder = faacDecOpen(); | |
386 mp4ff_get_decoder_config(mp4file, mp4track, &buffer, &bufferSize); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
387 |
583 | 388 if ( !buffer ) { |
389 faacDecClose(decoder); | |
390 return FALSE; | |
391 } | |
1304
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
392 if ( faacDecInit2(decoder, buffer, bufferSize, |
583 | 393 &samplerate, &channels) < 0 ) { |
394 faacDecClose(decoder); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
395 |
583 | 396 return FALSE; |
397 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
398 |
583 | 399 /* Add some hacks for SBR profile */ |
400 if (AudioSpecificConfig(buffer, bufferSize, &mp4ASC) >= 0) { | |
401 if (mp4ASC.frameLengthFlag == 1) framesize = 960; | |
402 if (mp4ASC.sbr_present_flag == 1) framesize *= 2; | |
403 } | |
1304
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
404 |
583 | 405 g_free(buffer); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
406 |
583 | 407 faacDecClose(decoder); |
408 | |
409 msDuration = ((float)numSamples * (float)(framesize - 1.0)/(float)samplerate) * 1000; | |
410 | |
411 input = bmp_title_input_new(); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
412 |
583 | 413 mp4ff_meta_get_title(mp4file, &input->track_name); |
414 mp4ff_meta_get_album(mp4file, &input->album_name); | |
415 mp4ff_meta_get_artist(mp4file, &input->performer); | |
416 mp4ff_meta_get_date(mp4file, &tmpval); | |
417 mp4ff_meta_get_genre(mp4file, &input->genre); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
418 |
583 | 419 if (tmpval) |
420 { | |
421 input->year = atoi(tmpval); | |
422 free(tmpval); | |
423 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
424 |
583 | 425 input->file_name = g_path_get_basename(filename); |
426 input->file_path = g_path_get_dirname(filename); | |
427 input->file_ext = extname(filename); | |
428 input->length = msDuration; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
429 |
583 | 430 free (mp4cb); |
431 vfs_fclose(mp4fh); | |
432 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
433 |
583 | 434 return input; |
435 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
436 |
583 | 437 static void mp4_get_song_title_len(char *filename, char **title, int *len) |
438 { | |
439 (*title) = mp4_get_song_title(filename); | |
440 (*len) = -1; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
441 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
442 |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
443 static gchar *mp4_get_song_title(char *filename) |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
444 { |
583 | 445 mp4ff_callback_t *mp4cb = g_malloc0(sizeof(mp4ff_callback_t)); |
446 VFSFile *mp4fh; | |
447 mp4ff_t *mp4file; | |
448 gchar *title = NULL; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
449 |
583 | 450 mp4fh = vfs_fopen(filename, "rb"); |
451 mp4cb->read = mp4_read_callback; | |
452 mp4cb->seek = mp4_seek_callback; | |
1304
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
453 mp4cb->user_data = mp4fh; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
454 |
583 | 455 if (!(mp4file = mp4ff_open_read(mp4cb))) { |
456 g_free(mp4cb); | |
457 vfs_fclose(mp4fh); | |
458 } else { | |
459 TitleInput *input; | |
460 gchar *tmpval; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
461 |
583 | 462 input = bmp_title_input_new(); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
463 |
583 | 464 mp4ff_meta_get_title(mp4file, &input->track_name); |
465 mp4ff_meta_get_album(mp4file, &input->album_name); | |
466 mp4ff_meta_get_artist(mp4file, &input->performer); | |
467 mp4ff_meta_get_date(mp4file, &tmpval); | |
468 mp4ff_meta_get_genre(mp4file, &input->genre); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
469 |
583 | 470 if (tmpval) |
471 { | |
472 input->year = atoi(tmpval); | |
473 free(tmpval); | |
474 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
475 |
583 | 476 input->file_name = g_path_get_basename(filename); |
477 input->file_path = g_path_get_dirname(filename); | |
478 input->file_ext = extname(filename); | |
479 | |
480 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
|
481 |
583 | 482 free (input->track_name); |
483 free (input->album_name); | |
484 free (input->performer); | |
485 free (input->genre); | |
486 free (input->file_name); | |
487 free (input->file_path); | |
488 free (input); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
489 |
583 | 490 free (mp4cb); |
491 vfs_fclose(mp4fh); | |
492 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
493 |
583 | 494 if (!title) |
495 { | |
496 title = g_path_get_basename(filename); | |
497 if (extname(title)) | |
498 *(extname(title) - 1) = '\0'; | |
499 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
500 |
583 | 501 return title; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
502 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
503 |
561
914c96de3244
[svn] Convert plugins to use InputPlayback.output instead of InputPlugin.output
iabervon
parents:
559
diff
changeset
|
504 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
|
505 { |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
506 // We are reading an MP4 file |
583 | 507 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
|
508 faacDecHandle decoder; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
509 mp4AudioSpecificConfig mp4ASC; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
510 guchar *buffer = NULL; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
511 guint bufferSize = 0; |
1188
22a470857579
- fix the bug that aac plugin had failed to get proper playtime length on AMD64.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1167
diff
changeset
|
512 guint samplerate = 0; |
22a470857579
- fix the bug that aac plugin had failed to get proper playtime length on AMD64.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1167
diff
changeset
|
513 guchar channels = 0; |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
514 gulong msDuration; |
1188
22a470857579
- fix the bug that aac plugin had failed to get proper playtime length on AMD64.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1167
diff
changeset
|
515 guint numSamples; |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
516 gulong sampleID = 1; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
517 guint framesize = 1024; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
518 |
694
a429ce72d20e
[svn] - handle a situation where buffer could be NULL (e.g. bail)
nenolod
parents:
693
diff
changeset
|
519 if (mp4track < 0) |
a429ce72d20e
[svn] - handle a situation where buffer could be NULL (e.g. bail)
nenolod
parents:
693
diff
changeset
|
520 { |
a429ce72d20e
[svn] - handle a situation where buffer could be NULL (e.g. bail)
nenolod
parents:
693
diff
changeset
|
521 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
|
522 return TRUE; |
a429ce72d20e
[svn] - handle a situation where buffer could be NULL (e.g. bail)
nenolod
parents:
693
diff
changeset
|
523 } |
a429ce72d20e
[svn] - handle a situation where buffer could be NULL (e.g. bail)
nenolod
parents:
693
diff
changeset
|
524 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
525 gchar *xmmstitle = NULL; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
526 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
|
527 if(xmmstitle == NULL) |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
528 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
|
529 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
530 decoder = faacDecOpen(); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
531 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
|
532 if ( !buffer ) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
533 faacDecClose(decoder); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
534 return FALSE; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
535 } |
1304
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
536 if ( faacDecInit2(decoder, buffer, bufferSize, |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
537 &samplerate, &channels) < 0 ) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
538 faacDecClose(decoder); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
539 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
540 return FALSE; |
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 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
543 /* 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
|
544 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
|
545 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
|
546 if (mp4ASC.sbr_present_flag == 1) framesize *= 2; |
583 | 547 } |
1304
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
548 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
549 g_free(buffer); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
550 if( !channels ) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
551 faacDecClose(decoder); |
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 return FALSE; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
554 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
555 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
|
556 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
|
557 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
|
558 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
|
559 |
1304
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
560 mp4_ip.set_info(xmmstitle, msDuration, |
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
561 mp4ff_get_avg_bitrate( mp4file, mp4track ), |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
562 samplerate,channels); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
563 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
564 while ( buffer_playing ) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
565 void* sampleBuffer; |
1304
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
566 faacDecFrameInfo frameInfo; |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
567 gint rc; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
568 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
569 /* 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
|
570 if ( seekPosition!=-1 ) { |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
571 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
|
572 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
|
573 seekPosition = -1; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
574 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
575 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
576 /* Otherwise continue playing */ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
577 buffer=NULL; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
578 bufferSize=0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
579 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
580 /* 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
|
581 if(sampleID >= numSamples){ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
582 /* 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
|
583 output. */ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
584 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
|
585 xmms_usleep(10000); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
586 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
587 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
588 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
|
589 playback->output->close_audio(); |
583 | 590 faacDecClose(decoder); |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
591 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
592 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
|
593 buffer_playing = FALSE; |
1167
f22b4eb572fb
[svn] - add playback->playing = 0 where buffer_playing = FALSE is done. without this, playback_get_time() would be confused and playback wouldn't advance in playlist.
yaz
parents:
1163
diff
changeset
|
594 playback->playing = 0; |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
595 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
|
596 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
|
597 |
583 | 598 return FALSE; |
599 } | |
1304
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
600 rc= mp4ff_read_sample(mp4file, mp4track, |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
601 sampleID++, &buffer, &bufferSize); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
602 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
603 /*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
|
604 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
605 /* 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
|
606 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
|
607 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
|
608 sampleBuffer = NULL; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
609 sampleID=0; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
610 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
|
611 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
|
612 |
583 | 613 faacDecClose(decoder); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
614 |
583 | 615 return FALSE; |
616 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
617 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
618 /* 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
|
619 |
1304
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
620 sampleBuffer= faacDecDecode(decoder, |
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
621 &frameInfo, |
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
622 buffer, |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
623 bufferSize); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
624 |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
625 /* 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
|
626 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
|
627 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
|
628 faacDecGetErrorMessage(frameInfo.error)); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
629 playback->output->close_audio(); |
583 | 630 faacDecClose(decoder); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
631 |
583 | 632 return FALSE; |
633 } | |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
634 if(buffer){ |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
635 g_free(buffer); |
583 | 636 buffer=NULL; |
637 bufferSize=0; | |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
638 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
639 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
|
640 { |
1167
f22b4eb572fb
[svn] - add playback->playing = 0 where buffer_playing = FALSE is done. without this, playback_get_time() would be confused and playback wouldn't advance in playlist.
yaz
parents:
1163
diff
changeset
|
641 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
|
642 return FALSE; |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
643 } |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
644 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
|
645 FMT_S16_NE, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
646 channels, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
647 frameInfo.samples<<1, |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
648 sampleBuffer, &buffer_playing); |
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
649 } |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
650 |
584
5e2b137a24fe
[svn] - Cleaned up AAC plugin a bit more, but still couldn't fix the bug
mf0102
parents:
583
diff
changeset
|
651 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
|
652 faacDecClose(decoder); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
653 |
583 | 654 return TRUE; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
655 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
656 |
740
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
657 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
|
658 { |
583 | 659 faacDecHandle decoder = 0; |
740
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
660 guchar streambuffer[BUFFER_SIZE]; |
583 | 661 gulong bufferconsumed = 0; |
662 gulong samplerate = 0; | |
1188
22a470857579
- fix the bug that aac plugin had failed to get proper playtime length on AMD64.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1167
diff
changeset
|
663 guchar channels = 0; |
583 | 664 gulong buffervalid = 0; |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
665 gchar *ttemp = NULL, *stemp = NULL; |
583 | 666 gchar *temp = g_strdup(filename); |
667 gchar *xmmstitle = NULL; | |
697
74a762a3592e
[svn] - temporarily cheat and disable certain codepaths for local files
nenolod
parents:
695
diff
changeset
|
668 gboolean remote = str_has_prefix_nocase(filename, "http:") || |
74a762a3592e
[svn] - temporarily cheat and disable certain codepaths for local files
nenolod
parents:
695
diff
changeset
|
669 str_has_prefix_nocase(filename, "https:"); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
670 |
692
a77e766e332d
[svn] - fix another potential synchronization problem
nenolod
parents:
690
diff
changeset
|
671 vfs_rewind(file); |
583 | 672 if((decoder = faacDecOpen()) == NULL){ |
673 g_print("AAC: Open Decoder Error\n"); | |
674 vfs_fclose(file); | |
675 buffer_playing = FALSE; | |
1167
f22b4eb572fb
[svn] - add playback->playing = 0 where buffer_playing = FALSE is done. without this, playback_get_time() would be confused and playback wouldn't advance in playlist.
yaz
parents:
1163
diff
changeset
|
676 playback->playing = 0; |
583 | 677 g_static_mutex_unlock(&mutex); |
678 g_thread_exit(NULL); | |
679 } | |
740
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
680 if((buffervalid = vfs_fread(streambuffer, 1, BUFFER_SIZE, file))==0){ |
583 | 681 g_print("AAC: Error reading file\n"); |
682 vfs_fclose(file); | |
683 buffer_playing = FALSE; | |
1167
f22b4eb572fb
[svn] - add playback->playing = 0 where buffer_playing = FALSE is done. without this, playback_get_time() would be confused and playback wouldn't advance in playlist.
yaz
parents:
1163
diff
changeset
|
684 playback->playing = 0; |
583 | 685 faacDecClose(decoder); |
686 g_static_mutex_unlock(&mutex); | |
687 g_thread_exit(NULL); | |
688 } | |
740
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
689 if(!strncmp((char*)streambuffer, "ID3", 3)){ |
583 | 690 gint size = 0; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
691 |
583 | 692 vfs_fseek(file, 0, SEEK_SET); |
1304
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
693 size = (streambuffer[6]<<21) | (streambuffer[7]<<14) | |
740
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
694 (streambuffer[8]<<7) | streambuffer[9]; |
583 | 695 size+=10; |
740
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
696 vfs_fread(streambuffer, 1, size, file); |
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
697 buffervalid = vfs_fread(streambuffer, 1, BUFFER_SIZE, file); |
583 | 698 } |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
699 |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
700 ttemp = vfs_get_metadata(file, "stream-name"); |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
701 |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
702 if (ttemp != NULL) |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
703 { |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
704 xmmstitle = g_strdup(ttemp); |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
705 g_free(ttemp); |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
706 } |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
707 else |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
708 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
|
709 |
740
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
710 bufferconsumed = aac_probe(streambuffer, buffervalid); |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
711 if(bufferconsumed) { |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
712 buffervalid -= bufferconsumed; |
740
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
713 memmove(streambuffer, &streambuffer[bufferconsumed], buffervalid); |
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
714 buffervalid += vfs_fread(&streambuffer[buffervalid], 1, |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
715 BUFFER_SIZE-buffervalid, file); |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
716 bufferconsumed = 0; |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
717 } |
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
718 |
583 | 719 bufferconsumed = faacDecInit(decoder, |
740
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
720 streambuffer, |
583 | 721 buffervalid, |
722 &samplerate, | |
723 &channels); | |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
724 #ifdef DEBUG |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
725 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
|
726 #endif |
583 | 727 if(playback->output->open_audio(FMT_S16_NE,samplerate,channels) == FALSE){ |
728 g_print("AAC: Output Error\n"); | |
729 faacDecClose(decoder); | |
730 vfs_fclose(file); | |
731 playback->output->close_audio(); | |
732 g_free(xmmstitle); | |
733 buffer_playing = FALSE; | |
1167
f22b4eb572fb
[svn] - add playback->playing = 0 where buffer_playing = FALSE is done. without this, playback_get_time() would be confused and playback wouldn't advance in playlist.
yaz
parents:
1163
diff
changeset
|
734 playback->playing = 0; |
583 | 735 g_static_mutex_unlock(&mutex); |
736 g_thread_exit(NULL); | |
737 } | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
738 |
1075
37abd9b3de4b
[svn] - conversion to yaz's style was not needed, just API v2 ;p
nenolod
parents:
1073
diff
changeset
|
739 mp4_ip.set_info(xmmstitle, -1, -1, samplerate, channels); |
583 | 740 playback->output->flush(0); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
741 |
740
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
742 while(buffer_playing && buffervalid > 0 && streambuffer != NULL) |
700
27a557e80e15
[svn] - fix a ringbuffering error. found by purify.
nenolod
parents:
697
diff
changeset
|
743 { |
583 | 744 faacDecFrameInfo finfo; |
745 unsigned long samplesdecoded; | |
746 char* sample_buffer = NULL; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
747 |
700
27a557e80e15
[svn] - fix a ringbuffering error. found by purify.
nenolod
parents:
697
diff
changeset
|
748 if(bufferconsumed > 0) |
27a557e80e15
[svn] - fix a ringbuffering error. found by purify.
nenolod
parents:
697
diff
changeset
|
749 { |
583 | 750 buffervalid -= bufferconsumed; |
740
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
751 memmove(streambuffer, &streambuffer[bufferconsumed], buffervalid); |
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
752 buffervalid += vfs_fread(&streambuffer[buffervalid], 1, |
583 | 753 BUFFER_SIZE-buffervalid, file); |
754 bufferconsumed = 0; | |
693
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 ttemp = vfs_get_metadata(file, "stream-name"); |
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 (ttemp != NULL) |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
759 stemp = vfs_get_metadata(file, "track-name"); |
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 if (stemp != NULL) |
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 static gchar *ostmp = NULL; |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
764 |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
765 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
|
766 { |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
767 if (xmmstitle != NULL) |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
768 g_free(xmmstitle); |
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 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
|
771 |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
772 if (ostmp != NULL) |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
773 g_free(ostmp); |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
774 |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
775 ostmp = stemp; |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
776 |
1075
37abd9b3de4b
[svn] - conversion to yaz's style was not needed, just API v2 ;p
nenolod
parents:
1073
diff
changeset
|
777 mp4_ip.set_info(xmmstitle, -1, -1, samplerate, channels); |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
778 } |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
779 } |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
780 |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
781 g_free(ttemp); |
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
782 ttemp = NULL; |
583 | 783 } |
688
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
784 |
740
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
785 sample_buffer = faacDecDecode(decoder, &finfo, streambuffer, buffervalid); |
688
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
786 |
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
787 bufferconsumed += finfo.bytesconsumed; |
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
788 samplesdecoded = finfo.samples; |
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
789 |
700
27a557e80e15
[svn] - fix a ringbuffering error. found by purify.
nenolod
parents:
697
diff
changeset
|
790 if(finfo.error > 0 && remote != FALSE) |
27a557e80e15
[svn] - fix a ringbuffering error. found by purify.
nenolod
parents:
697
diff
changeset
|
791 { |
759
0c18e4b8e840
[svn] - when shifting the ringbuffer to left by one byte to regain alignment,
nenolod
parents:
740
diff
changeset
|
792 buffervalid--; |
740
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
793 memmove(streambuffer, &streambuffer[1], buffervalid); |
688
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
794 if(buffervalid < BUFFER_SIZE) { |
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
795 buffervalid += |
740
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
796 vfs_fread(&streambuffer[buffervalid], 1, BUFFER_SIZE-buffervalid, file); |
688
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
797 } |
740
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
798 bufferconsumed = aac_probe(streambuffer, buffervalid); |
686 | 799 if(bufferconsumed) { |
700
27a557e80e15
[svn] - fix a ringbuffering error. found by purify.
nenolod
parents:
697
diff
changeset
|
800 buffervalid -= bufferconsumed; |
740
6ae04ca57bc1
[svn] - some ringbuffering issues could cause crashing. a final review has
nenolod
parents:
739
diff
changeset
|
801 memmove(streambuffer, &streambuffer[bufferconsumed], buffervalid); |
686 | 802 bufferconsumed = 0; |
583 | 803 } |
686 | 804 continue; |
583 | 805 } |
688
43c77973e494
[svn] - some ringbuffering fixes -- aac+ shouldn't crash now, but more
nenolod
parents:
686
diff
changeset
|
806 |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
807 if((samplesdecoded <= 0) && !sample_buffer){ |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
808 #ifdef DEBUG |
684
c9eaa64b92b3
[svn] - aacplus shoutcast support. prepare for segfaults.
nenolod
parents:
682
diff
changeset
|
809 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
|
810 #endif |
583 | 811 continue; |
812 } | |
693
a7ba9d27c7b5
[svn] - shoutcast title streaming. sucks, could probably be improved upon, but
nenolod
parents:
692
diff
changeset
|
813 |
583 | 814 produce_audio(playback->output->written_time(), |
815 FMT_S16_LE, channels, | |
816 samplesdecoded<<1, sample_buffer, &buffer_playing); | |
817 } | |
818 playback->output->buffer_free(); | |
819 playback->output->close_audio(); | |
820 buffer_playing = FALSE; | |
1167
f22b4eb572fb
[svn] - add playback->playing = 0 where buffer_playing = FALSE is done. without this, playback_get_time() would be confused and playback wouldn't advance in playlist.
yaz
parents:
1163
diff
changeset
|
821 playback->playing = 0; |
583 | 822 faacDecClose(decoder); |
823 g_free(xmmstitle); | |
824 vfs_fclose(file); | |
825 seekPosition = -1; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
826 |
583 | 827 buffer_playing = FALSE; |
1167
f22b4eb572fb
[svn] - add playback->playing = 0 where buffer_playing = FALSE is done. without this, playback_get_time() would be confused and playback wouldn't advance in playlist.
yaz
parents:
1163
diff
changeset
|
828 playback->playing = 0; |
583 | 829 g_static_mutex_unlock(&mutex); |
830 g_thread_exit(NULL); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
831 } |
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
832 |
583 | 833 static void *mp4_decode( void *args ) |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
834 { |
583 | 835 mp4ff_callback_t *mp4cb = g_malloc0(sizeof(mp4ff_callback_t)); |
836 VFSFile *mp4fh; | |
837 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
|
838 gboolean ret; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
839 |
583 | 840 InputPlayback *playback = args; |
841 char *filename = playback->filename; | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
842 |
737
eecd54a11610
[svn] - use vfs_buffered_file_new_from_uri for probing.
nenolod
parents:
700
diff
changeset
|
843 mp4fh = vfs_buffered_file_new_from_uri(filename); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
844 |
583 | 845 g_static_mutex_lock(&mutex); |
846 seekPosition= -1; | |
847 buffer_playing= TRUE; | |
848 g_static_mutex_unlock(&mutex); | |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
849 |
692
a77e766e332d
[svn] - fix another potential synchronization problem
nenolod
parents:
690
diff
changeset
|
850 if (mp4fh == NULL) |
a77e766e332d
[svn] - fix another potential synchronization problem
nenolod
parents:
690
diff
changeset
|
851 g_thread_exit(NULL); |
a77e766e332d
[svn] - fix another potential synchronization problem
nenolod
parents:
690
diff
changeset
|
852 |
678
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
853 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
|
854 |
1230
f45a99c8bc0d
Updates to the AAC reduced open patch by Christian "Joker" Birchinger.
Tony Vroon <chainsaw@gentoo.org>
parents:
1229
diff
changeset
|
855 if( ret == TRUE ) |
f45a99c8bc0d
Updates to the AAC reduced open patch by Christian "Joker" Birchinger.
Tony Vroon <chainsaw@gentoo.org>
parents:
1229
diff
changeset
|
856 vfs_fseek(mp4fh, 0, SEEK_SET); |
f45a99c8bc0d
Updates to the AAC reduced open patch by Christian "Joker" Birchinger.
Tony Vroon <chainsaw@gentoo.org>
parents:
1229
diff
changeset
|
857 else { |
f45a99c8bc0d
Updates to the AAC reduced open patch by Christian "Joker" Birchinger.
Tony Vroon <chainsaw@gentoo.org>
parents:
1229
diff
changeset
|
858 vfs_fclose(mp4fh); |
f45a99c8bc0d
Updates to the AAC reduced open patch by Christian "Joker" Birchinger.
Tony Vroon <chainsaw@gentoo.org>
parents:
1229
diff
changeset
|
859 mp4fh = vfs_fopen(filename, "rb"); |
f45a99c8bc0d
Updates to the AAC reduced open patch by Christian "Joker" Birchinger.
Tony Vroon <chainsaw@gentoo.org>
parents:
1229
diff
changeset
|
860 } |
1229
c9ff58a0feab
An experimental attempt to reduce the number of stream opens for AAC, by Christian @Joker" Birchinger. Tell him if it breaks.
Tony Vroon <chainsaw@gentoo.org>
parents:
1188
diff
changeset
|
861 |
739
9480fdc511f1
[svn] - do not pass a buffered FD to the decoding thread, just use it for
nenolod
parents:
737
diff
changeset
|
862 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
|
863 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
|
864 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
|
865 |
583 | 866 mp4file= mp4ff_open_read(mp4cb); |
1304
f34112ab9101
As usual, "i18n" modifications.
Stany HENRY <StrassBoy@gmail.com>
parents:
1230
diff
changeset
|
867 |
678
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
868 if( ret == TRUE ) { |
583 | 869 g_free(mp4cb); |
692
a77e766e332d
[svn] - fix another potential synchronization problem
nenolod
parents:
690
diff
changeset
|
870 my_decode_aac( playback, filename, mp4fh ); |
583 | 871 } |
678
9e4145566248
[svn] - allow static AAC files to play. working on AACplus, but this brings us closer.
nenolod
parents:
595
diff
changeset
|
872 else |
583 | 873 my_decode_mp4( playback, filename, mp4file ); |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
874 |
583 | 875 return NULL; |
0
13389e613d67
[svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff
changeset
|
876 } |