Mercurial > mplayer.hg
annotate libmpdemux/demux_audio.c @ 5915:f716aa9e2df2
Convert printf to mp_msg in the network layer
author | albeu |
---|---|
date | Tue, 30 Apr 2002 16:58:54 +0000 |
parents | f9d23c2aa6b7 |
children | e29f95ed5d36 |
rev | line source |
---|---|
4694 | 1 |
2 #include "config.h" | |
4712 | 3 #include "../mp_msg.h" |
4694 | 4 |
5 #include <stdlib.h> | |
6 #include <stdio.h> | |
7 #include "stream.h" | |
8 #include "demuxer.h" | |
9 #include "stheader.h" | |
10 #include "genres.h" | |
11 | |
12 #include <string.h> | |
13 #ifdef MP_DEBUG | |
14 #include <assert.h> | |
15 #endif | |
16 | |
17 #define MP3 1 | |
18 #define WAV 2 | |
19 | |
20 | |
21 #define HDR_SIZE 4 | |
22 | |
23 typedef struct da_priv { | |
24 int frmt; | |
4764
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
25 float last_pts; |
4694 | 26 } da_priv_t; |
27 | |
28 extern int mp_decode_mp3_header(unsigned char* hbuf); | |
29 extern void free_sh_audio(sh_audio_t* sh); | |
4700
30131db5dfbb
Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents:
4694
diff
changeset
|
30 extern void resync_audio_stream(sh_audio_t *sh_audio); |
4694 | 31 |
4764
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
32 static int hr_mp3_seek = 0; |
4694 | 33 |
34 int demux_audio_open(demuxer_t* demuxer) { | |
35 stream_t *s; | |
36 sh_audio_t* sh_audio; | |
37 uint8_t hdr[HDR_SIZE]; | |
38 int st_pos = 0,frmt = 0, n = 0, pos = 0, step; | |
39 da_priv_t* priv; | |
40 #ifdef MP_DEBUG | |
41 assert(demuxer != NULL); | |
42 assert(demuxer->stream != NULL); | |
43 #endif | |
44 | |
45 s = demuxer->stream; | |
46 | |
47 while(n < 5 && ! s->eof) { | |
48 st_pos = stream_tell(s); | |
49 step = 1; | |
50 if(pos < HDR_SIZE) { | |
51 stream_read(s,&hdr[pos],HDR_SIZE-pos); | |
52 pos = HDR_SIZE; | |
53 } | |
54 | |
55 if( hdr[0] == 'R' && hdr[1] == 'I' && hdr[2] == 'F' && hdr[3] == 'F' ) { | |
56 stream_skip(s,4); | |
57 if(s->eof) | |
58 break; | |
59 stream_read(s,hdr,4); | |
60 if(s->eof) | |
61 break; | |
62 if(hdr[0] != 'W' || hdr[1] != 'A' || hdr[2] != 'V' || hdr[3] != 'E' ) | |
63 stream_skip(s,-8); | |
64 else | |
65 // We found wav header. Now we can have 'fmt ' or a mp3 header | |
66 // empty the buffer | |
67 step = 4; | |
68 } else if( hdr[0] == 'f' && hdr[1] == 'm' && hdr[2] == 't' && hdr[3] == ' ' ) { | |
69 frmt = WAV; | |
70 break; | |
4717
b7054dadd2c0
We should skip exactly the first frame on mp3 files.
albeu
parents:
4712
diff
changeset
|
71 } else if((n = mp_decode_mp3_header(hdr)) > 0) { |
4694 | 72 frmt = MP3; |
73 break; | |
74 } | |
75 // Add here some other audio format detection | |
76 if(step < HDR_SIZE) | |
77 memmove(hdr,&hdr[step],HDR_SIZE-step); | |
78 pos -= step; | |
79 } | |
80 | |
81 if(!frmt) | |
82 return 0; | |
83 | |
84 sh_audio = new_sh_audio(demuxer,0); | |
85 | |
86 switch(frmt) { | |
87 case MP3: | |
88 sh_audio->format = 0x55; | |
4717
b7054dadd2c0
We should skip exactly the first frame on mp3 files.
albeu
parents:
4712
diff
changeset
|
89 demuxer->movi_start = st_pos-HDR_SIZE+n; |
4700
30131db5dfbb
Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents:
4694
diff
changeset
|
90 for(n = 0; n < 5 ; n++) { |
30131db5dfbb
Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents:
4694
diff
changeset
|
91 pos = mp_decode_mp3_header(hdr); |
30131db5dfbb
Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents:
4694
diff
changeset
|
92 if(pos < 0) |
30131db5dfbb
Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents:
4694
diff
changeset
|
93 return 0; |
30131db5dfbb
Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents:
4694
diff
changeset
|
94 stream_skip(s,pos-4); |
30131db5dfbb
Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents:
4694
diff
changeset
|
95 if(s->eof) |
30131db5dfbb
Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents:
4694
diff
changeset
|
96 return 0; |
30131db5dfbb
Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents:
4694
diff
changeset
|
97 stream_read(s,hdr,4); |
30131db5dfbb
Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents:
4694
diff
changeset
|
98 if(s->eof) |
30131db5dfbb
Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents:
4694
diff
changeset
|
99 return 0; |
30131db5dfbb
Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents:
4694
diff
changeset
|
100 } |
4694 | 101 if(s->end_pos) { |
102 char tag[4]; | |
103 stream_seek(s,s->end_pos-128); | |
104 stream_read(s,tag,3); | |
105 tag[3] = '\0'; | |
106 if(strcmp(tag,"TAG")) | |
107 demuxer->movi_end = s->end_pos; | |
108 else { | |
109 char buf[31]; | |
110 uint8_t g; | |
111 demuxer->movi_end = stream_tell(s)-3; | |
112 stream_read(s,buf,30); | |
113 buf[30] = '\0'; | |
114 demux_info_add(demuxer,"Title",buf); | |
115 stream_read(s,buf,30); | |
116 buf[30] = '\0'; | |
117 demux_info_add(demuxer,"Artist",buf); | |
118 stream_read(s,buf,30); | |
119 buf[30] = '\0'; | |
120 demux_info_add(demuxer,"Album",buf); | |
121 stream_read(s,buf,4); | |
4764
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
122 buf[4] = '\0'; |
4694 | 123 demux_info_add(demuxer,"Year",buf); |
124 stream_read(s,buf,30); | |
125 buf[30] = '\0'; | |
126 demux_info_add(demuxer,"Comment",buf); | |
127 if(buf[28] == 0 && buf[29] != 0) { | |
128 uint8_t trk = (uint8_t)buf[29]; | |
129 sprintf(buf,"%d",trk); | |
130 demux_info_add(demuxer,"Track",buf); | |
131 } | |
132 g = stream_read_char(s); | |
133 demux_info_add(demuxer,"Genre",genres[g]); | |
134 } | |
135 } | |
136 break; | |
137 case WAV: { | |
4720
10ad330c1733
fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents:
4717
diff
changeset
|
138 unsigned int chunk_type; |
10ad330c1733
fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents:
4717
diff
changeset
|
139 unsigned int chunk_size; |
4694 | 140 WAVEFORMATEX* w; |
141 int l; | |
142 sh_audio->wf = w = (WAVEFORMATEX*)malloc(sizeof(WAVEFORMATEX)); | |
143 l = stream_read_dword_le(s); | |
144 if(l < 16) { | |
145 printf("Bad wav header length : too short !!!\n"); | |
146 free_sh_audio(sh_audio); | |
147 return 0; | |
148 } | |
149 w->wFormatTag = sh_audio->format = stream_read_word_le(s); | |
150 w->nChannels = sh_audio->channels = stream_read_word_le(s); | |
151 w->nSamplesPerSec = sh_audio->samplerate = stream_read_dword_le(s); | |
152 w->nAvgBytesPerSec = stream_read_dword_le(s); | |
153 w->nBlockAlign = stream_read_word_le(s); | |
154 w->wBitsPerSample = sh_audio->samplesize = stream_read_word_le(s); | |
155 w->cbSize = 0; | |
156 l -= 16; | |
157 if(l) | |
158 stream_skip(s,l); | |
4720
10ad330c1733
fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents:
4717
diff
changeset
|
159 do |
10ad330c1733
fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents:
4717
diff
changeset
|
160 { |
10ad330c1733
fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents:
4717
diff
changeset
|
161 chunk_type = stream_read_fourcc(demuxer->stream); |
10ad330c1733
fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents:
4717
diff
changeset
|
162 chunk_size = stream_read_dword_le(demuxer->stream); |
10ad330c1733
fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents:
4717
diff
changeset
|
163 if (chunk_type != mmioFOURCC('d', 'a', 't', 'a')) |
10ad330c1733
fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents:
4717
diff
changeset
|
164 stream_skip(demuxer->stream, chunk_size); |
10ad330c1733
fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents:
4717
diff
changeset
|
165 } while (chunk_type != mmioFOURCC('d', 'a', 't', 'a')); |
4694 | 166 demuxer->movi_start = stream_tell(s); |
167 demuxer->movi_end = s->end_pos; | |
168 } break; | |
169 } | |
170 | |
171 priv = (da_priv_t*)malloc(sizeof(da_priv_t)); | |
172 priv->frmt = frmt; | |
4764
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
173 priv->last_pts = -1; |
4694 | 174 demuxer->priv = priv; |
175 demuxer->audio->id = 0; | |
176 demuxer->audio->sh = sh_audio; | |
177 sh_audio->ds = demuxer->audio; | |
178 | |
179 if(stream_tell(s) != demuxer->movi_start) | |
180 stream_seek(s,demuxer->movi_start); | |
181 | |
4712 | 182 mp_msg(MSGT_DEMUX,MSGL_V,"demux_audio: audio data 0x%X - 0x%X \n",demuxer->movi_start,demuxer->movi_end); |
183 | |
4694 | 184 return 1; |
185 } | |
186 | |
187 | |
188 int demux_audio_fill_buffer(demux_stream_t *ds) { | |
189 sh_audio_t* sh_audio; | |
190 demuxer_t* demux; | |
191 da_priv_t* priv; | |
192 stream_t* s; | |
193 #ifdef MP_DEBUG | |
194 assert(ds != NULL); | |
195 assert(ds->sh != NULL); | |
196 assert(ds->demuxer != NULL); | |
197 #endif | |
198 sh_audio = ds->sh; | |
199 demux = ds->demuxer; | |
200 priv = demux->priv; | |
201 s = demux->stream; | |
202 | |
203 if(s->eof || (demux->movi_end && stream_tell(s) >= demux->movi_end) ) | |
204 return 0; | |
205 | |
206 switch(priv->frmt) { | |
207 case MP3 : | |
208 while(! s->eof || (demux->movi_end && stream_tell(s) >= demux->movi_end) ) { | |
209 uint8_t hdr[4]; | |
210 int len; | |
211 stream_read(s,hdr,4); | |
212 len = mp_decode_mp3_header(hdr); | |
213 if(len < 0) { | |
214 stream_skip(s,-3); | |
215 } else { | |
216 demux_packet_t* dp; | |
217 if(s->eof || (demux->movi_end && stream_tell(s) >= demux->movi_end) ) | |
218 return 0; | |
219 dp = new_demux_packet(len); | |
220 memcpy(dp->buffer,hdr,4); | |
221 stream_read(s,dp->buffer + 4,len-4); | |
4764
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
222 priv->last_pts = priv->last_pts < 0 ? 0 : priv->last_pts + 1152/(float)sh_audio->samplerate; |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
223 ds->pts = priv->last_pts - (ds_tell_pts(demux->audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps; |
4694 | 224 ds_add_packet(ds,dp); |
225 return 1; | |
226 } | |
4700
30131db5dfbb
Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents:
4694
diff
changeset
|
227 } break; |
4694 | 228 case WAV : { |
229 int l = sh_audio->wf->nAvgBytesPerSec; | |
230 demux_packet_t* dp = new_demux_packet(l); | |
231 stream_read(s,dp->buffer,l); | |
4764
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
232 priv->last_pts = priv->last_pts < 0 ? 0 : priv->last_pts + l/(float)sh_audio->i_bps; |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
233 ds->pts = priv->last_pts - (ds_tell_pts(demux->audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps; |
4694 | 234 ds_add_packet(ds,dp); |
235 return 1; | |
236 } | |
237 default: | |
4720
10ad330c1733
fixed WAV demuxer so that it skips to the actual start of the audio data
melanson
parents:
4717
diff
changeset
|
238 printf("Audio demuxer : unknown format %d\n",priv->frmt); |
4694 | 239 } |
240 | |
241 | |
242 return 0; | |
243 } | |
244 | |
4764
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
245 static void high_res_mp3_seek(demuxer_t *demuxer,float time) { |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
246 uint8_t hdr[4]; |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
247 int len,nf; |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
248 da_priv_t* priv = demuxer->priv; |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
249 sh_audio_t* sh = (sh_audio_t*)demuxer->audio->sh; |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
250 |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
251 nf = time*sh->samplerate/1152; |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
252 while(nf > 0) { |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
253 stream_read(demuxer->stream,hdr,4); |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
254 len = mp_decode_mp3_header(hdr); |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
255 if(len < 0) { |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
256 stream_skip(demuxer->stream,-3); |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
257 continue; |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
258 } |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
259 stream_skip(demuxer->stream,len-4); |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
260 priv->last_pts += 1152/(float)sh->samplerate; |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
261 nf--; |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
262 } |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
263 } |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
264 |
4694 | 265 void demux_audio_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){ |
266 sh_audio_t* sh_audio; | |
267 stream_t* s; | |
268 int base,pos; | |
269 float len; | |
270 da_priv_t* priv; | |
271 | |
4764
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
272 if(!(sh_audio = demuxer->audio->sh)) |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
273 return; |
4694 | 274 s = demuxer->stream; |
275 priv = demuxer->priv; | |
276 | |
4764
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
277 if(priv->frmt == MP3 && hr_mp3_seek && !(flags & 2)) { |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
278 len = (flags & 1) ? rel_seek_secs - priv->last_pts : rel_seek_secs; |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
279 if(len < 0) { |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
280 stream_seek(s,demuxer->movi_start); |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
281 len = priv->last_pts + len; |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
282 priv->last_pts = 0; |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
283 } |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
284 if(len > 0) |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
285 high_res_mp3_seek(demuxer,len); |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
286 sh_audio->timer = priv->last_pts - (ds_tell_pts(demuxer->audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps; |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
287 resync_audio_stream(sh_audio); |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
288 return; |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
289 } |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
290 |
5796 | 291 base = flags&1 ? demuxer->movi_start : stream_tell(s); |
292 if(flags&2) | |
293 pos = base + ((demuxer->movi_end - demuxer->movi_start)*rel_seek_secs); | |
294 else | |
295 pos = base + (rel_seek_secs*sh_audio->i_bps); | |
4694 | 296 |
297 if(demuxer->movi_end && pos >= demuxer->movi_end) { | |
4764
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
298 sh_audio->timer = (stream_tell(s) - demuxer->movi_start)/(float)sh_audio->i_bps; |
4694 | 299 return; |
300 } else if(pos < demuxer->movi_start) | |
301 pos = demuxer->movi_start; | |
4764
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
302 |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
303 priv->last_pts = (pos-demuxer->movi_start)/(float)sh_audio->i_bps; |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
304 sh_audio->timer = priv->last_pts - (ds_tell_pts(demuxer->audio)-sh_audio->a_in_buffer_len)/(float)sh_audio->i_bps; |
4694 | 305 |
306 switch(priv->frmt) { | |
307 case WAV: | |
4764
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
308 pos -= (pos % (sh_audio->channels * sh_audio->samplesize) ); |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
309 // We need to decrease the pts by one step to make it the "last one" |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
310 priv->last_pts -= sh_audio->wf->nAvgBytesPerSec/(float)sh_audio->i_bps; |
4694 | 311 break; |
312 } | |
313 | |
314 stream_seek(s,pos); | |
315 | |
4700
30131db5dfbb
Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents:
4694
diff
changeset
|
316 resync_audio_stream(sh_audio); |
30131db5dfbb
Improved mp3 detection (don't detect mpeg1/2 as mp3 anymore)
albeu
parents:
4694
diff
changeset
|
317 |
4694 | 318 } |
4764
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
319 |
5812 | 320 void demux_close_audio(demuxer_t* demuxer) { |
321 da_priv_t* priv = demuxer->priv; | |
322 | |
323 if(!priv) | |
324 return; | |
325 free(priv); | |
326 } | |
327 | |
4764
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
328 /****************** Options stuff ******************/ |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
329 |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
330 #include "../cfgparser.h" |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
331 |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
332 static config_t demux_audio_opts[] = { |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
333 { "hr-mp3-seek", &hr_mp3_seek, CONF_TYPE_FLAG, 0, 0, 1, NULL }, |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
334 { "nohr-mp3-seek", &hr_mp3_seek, CONF_TYPE_FLAG, 0, 1, 0, NULL}, |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
335 {NULL, NULL, 0, 0, 0, 0, NULL} |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
336 }; |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
337 |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
338 void demux_audio_register_options(m_config_t* cfg) { |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
339 m_config_register_options(cfg,demux_audio_opts); |
9579496a91db
Added pts for mp3 and wav. And perfect seeking for mp3, unless flags & 2
albeu
parents:
4720
diff
changeset
|
340 } |