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