@@ -137,7 +137,8 @@ FreeSurround::FreeSurround(uint srate, bool moviemode, SurroundMode smode) :
137137 out_count(0 ),
138138 processed(true ),
139139 processed_size(0 ),
140- surround_mode(smode)
140+ surround_mode(smode),
141+ latency_frames(0 )
141142{
142143 VERBOSE (VB_AUDIO+VB_EXTRA,
143144 QString (" FreeSurround::FreeSurround rate %1 moviemode %2" )
@@ -161,6 +162,7 @@ FreeSurround::FreeSurround(uint srate, bool moviemode, SurroundMode smode) :
161162 break ;
162163 case SurroundModeActiveLinear:
163164 params.steering = 1 ;
165+ latency_frames = block_size/2 ;
164166 break ;
165167 default :
166168 break ;
@@ -243,10 +245,28 @@ uint FreeSurround::putFrames(void* buffer, uint numFrames, uint numChannels)
243245 bufs->ls [ic] = bufs->rs [ic] = (lt-rt) * center_level;
244246 }
245247 break ;
248+ case 5 :
249+ for (i = 0 ; i < numFrames && ic < bs; i++,ic++)
250+ {
251+ float lt = *samples++;
252+ float rt = *samples++;
253+ float c = *samples++;
254+ float lfe = (lt+rt) * center_level;
255+ float ls = *samples++;
256+ float rs = *samples++;
257+ bufs->l [ic] = lt;
258+ bufs->lfe [ic] = lfe;
259+ bufs->c [ic] = c;
260+ bufs->r [ic] = rt;
261+ bufs->ls [ic] = ls;
262+ bufs->rs [ic] = rs;
263+ }
264+ break ;
246265 }
247266 in_count = 0 ;
248267 out_count = processed_size = ic;
249268 processed = false ;
269+ latency_frames = 0 ;
250270 break ;
251271
252272 default :
@@ -268,23 +288,52 @@ uint FreeSurround::putFrames(void* buffer, uint numFrames, uint numChannels)
268288 *rt++ = *samples++;
269289 }
270290 break ;
291+ case 5 :
292+ // 5 ch is always passive mode,
293+ for (i = 0 ; i < numFrames && ic < bs; i++,ic++)
294+ {
295+ float l = *samples++;
296+ float r = *samples++;
297+ float c = *samples++;
298+ float lfe = (l+r) * center_level;
299+ float ls = *samples++;
300+ float rs = *samples++;
301+ bufs->l [ic] = l;
302+ bufs->lfe [ic] = lfe;
303+ bufs->c [ic] = c;
304+ bufs->r [ic] = r;
305+ bufs->ls [ic] = ls;
306+ bufs->rs [ic] = rs;
307+ }
308+ process = false ;
309+ break ;
271310 }
272- ic += numFrames;
273- processed = process;
274- if (ic != bs)
275- {
276- // dont modify unless no processing is to be done
277- // for audiotime consistency
278- in_count = ic;
279- break ;
280- }
281- // process_block takes some time so dont update in and out count
282- // before its finished so that Audiotime is correctly calculated
283311 if (process)
312+ {
313+ ic += numFrames;
314+ if (ic != bs)
315+ {
316+ // dont modify unless no processing is to be done
317+ // for audiotime consistency
318+ in_count = ic;
319+ break ;
320+ }
321+ processed = process;
322+ // process_block takes some time so dont update in and out count
323+ // before its finished so that Audiotime is correctly calculated
284324 process_block ();
285- in_count = 0 ;
286- out_count = bs;
287- processed_size = bs;
325+ in_count = 0 ;
326+ out_count = bs;
327+ processed_size = bs;
328+ latency_frames = block_size/2 ;
329+ }
330+ else
331+ {
332+ in_count = 0 ;
333+ out_count = processed_size = ic;
334+ processed = false ;
335+ latency_frames = 0 ;
336+ }
288337 break ;
289338 }
290339
@@ -386,9 +435,9 @@ void FreeSurround::process_block()
386435long long FreeSurround::getLatency ()
387436{
388437 // returns in usec
389- if (surround_mode == SurroundModePassive )
438+ if (latency_frames = 0 )
390439 return 0 ;
391- return decoder ? ((block_size/ 2 + in_count)*1000000 )/(2 *srate) : 0 ;
440+ return decoder ? ((latency_frames + in_count)*1000000 )/(2 *srate) : 0 ;
392441}
393442
394443void FreeSurround::flush ()
0 commit comments