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