1 | *** audiooutputalsa.cpp---org Sun May 15 22:57:52 2011 |
---|
2 | --- audiooutputalsa.cpp Thu Jul 21 10:22:40 2011 |
---|
3 | *************** void AudioOutputALSA::WriteAudio(uchar * |
---|
4 | *** 508,513 **** |
---|
5 | --- 508,521 ---- |
---|
6 | return; |
---|
7 | } |
---|
8 | |
---|
9 | + // check if size is a multiple of alsa-frames |
---|
10 | + if ((size % (output_bytes_per_frame * channels)) != 0) { |
---|
11 | + int size_needed = (size / (output_bytes_per_frame * channels)) * channels * output_bytes_per_frame; |
---|
12 | + VBERROR(QString(LOC + "WriteAudio: data not aligned to alsa-frame size")); |
---|
13 | + VBERROR(QString(LOC + " size: %1, size needed: %2") |
---|
14 | + .arg(size).arg(size_needed)); |
---|
15 | + } |
---|
16 | + |
---|
17 | if ((!passthru && channels == 6) || channels == 8) |
---|
18 | ReorderSmpteToAlsa(aubuf, frames, output_format, channels - 6); |
---|
19 | |
---|
20 | *************** int AudioOutputALSA::SetParameters(snd_p |
---|
21 | *** 724,731 **** |
---|
22 | .arg(buffer_size).arg(period_size)); |
---|
23 | |
---|
24 | /* set member variables */ |
---|
25 | soundcard_buffer_size = buffer_size * output_bytes_per_frame; |
---|
26 | ! fragment_size = (period_size * output_bytes_per_frame) >> 1; |
---|
27 | |
---|
28 | /* get the current swparams */ |
---|
29 | err = snd_pcm_sw_params_current(handle, swparams); |
---|
30 | --- 732,749 ---- |
---|
31 | .arg(buffer_size).arg(period_size)); |
---|
32 | |
---|
33 | /* set member variables */ |
---|
34 | + // buffer_size and period_size are alsa-frames: |
---|
35 | + // one alsa-frame = (output_bytes_per_frame * channels) bytes |
---|
36 | + // at least fragment_size has to be a multiple of alsa-frames |
---|
37 | + // because its value is given to WriteAudio() as size |
---|
38 | soundcard_buffer_size = buffer_size * output_bytes_per_frame; |
---|
39 | ! snd_pcm_uframes_t org_period_size = period_size; |
---|
40 | ! period_size = period_size - (period_size % (channels * output_bytes_per_frame)); |
---|
41 | ! fragment_size = (period_size * output_bytes_per_frame); |
---|
42 | ! if (org_period_size != period_size) { |
---|
43 | ! VBAUDIO(QString("Period size changed from %1 to %2") |
---|
44 | ! .arg(org_period_size).arg(period_size)); |
---|
45 | ! } |
---|
46 | |
---|
47 | /* get the current swparams */ |
---|
48 | err = snd_pcm_sw_params_current(handle, swparams); |
---|