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