Usually these loops only run once, so there's no problem here. But sometimes
they run twice, and by adding the number of bytes to a 16 bit pointer type we
would advance twice as much as we should.
Also use snd_pcm_frames_to_bytes() in alsasrc to calculate
the number of bytes to skip, same as we do in alsasink.
Thanks to Lucio A. Hernandez <lucio.a.hernandez@gmail.com> for reporting.
GstAlsaSink *alsa;
gint err;
gint cptr;
- gint16 *ptr = data;
+ guint8 *ptr = data;
alsa = GST_ALSA_SINK (asink);
if (alsa->iec958 && alsa->need_swap) {
guint i;
+ guint16 *ptr_tmp = (guint16 *) ptr;
GST_DEBUG_OBJECT (asink, "swapping bytes");
for (i = 0; i < length / 2; i++) {
- ptr[i] = GUINT16_SWAP_LE_BE (ptr[i]);
+ ptr_tmp[i] = GUINT16_SWAP_LE_BE (ptr_tmp[i]);
}
}
GstAlsaSrc *alsa;
gint err;
gint cptr;
- gint16 *ptr;
+ guint8 *ptr = data;
alsa = GST_ALSA_SRC (asrc);
cptr = length / alsa->bpf;
- ptr = data;
GST_ALSA_SRC_LOCK (asrc);
while (cptr > 0) {
continue;
}
- ptr += err * alsa->channels;
+ ptr += snd_pcm_frames_to_bytes (alsa->handle, err);
cptr -= err;
}
GST_ALSA_SRC_UNLOCK (asrc);