New issue
Advanced search Search tips

Issue 860408 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Jul 12
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 1
Type: Bug

Blocking:
issue 862047



Sign in to add a comment

CRAS: stuck in while look in capture_with_fmt_conv()

Project Member Reported by hychao@chromium.org, Jul 5

Issue description

This issue is found while testing recording on Jabra speakerphone.

(gdb) bt
#0  cras_fmt_conv_convert_frames (conv=0x7809f8002590, in_buf=0x7809fd115556 "D", out_buf=0x7809f8004a00 "\244\377\247\377", in_frames=0x7809fdbedb00, out_frames=2)
    at server/cras_fmt_conv.c:876
#1  0x00005b76b4ec8ad6 in capture_with_fmt_conv (dev_stream=0x7809f8001b00, source_samples=0x7809fd115556 "D", num_frames=341) at server/dev_stream.c:273
#2  dev_stream_capture (dev_stream=0x7809f8001b00, area=<optimized out>, area_offset=<optimized out>, software_gain_scaler=1) at server/dev_stream.c:381
#3  0x00005b76b4ec7490 in capture_to_streams (adev=<optimized out>) at server/dev_io.c:378
#4  dev_io_capture (list=0x5b76b65c4348) at server/dev_io.c:655
#5  0x00005b76b4ec7d52 in dev_io_run (odevs=0x5b76b65c4340, idevs=0x5b76b65c4348, output_converter=0x0) at server/dev_io.c:727
#6  0x00005b76b4eb294c in audio_io_thread (arg=0x5b76b65c4320) at server/audio_thread.c:889
#7  0x00007809fef952b8 in start_thread (arg=0x7809fdbee700) at pthread_create.c:333
#8  0x00007809fe50efad in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
(gdb) p *in_frames
$91 = 1
(gdb) p conv->in_fmt
$92 = {format = SND_PCM_FORMAT_S16_LE, frame_rate = 16000, num_channels = 1, channel_layout = "\377\377\377\377\000\377\377\377\377\377\377"}
(gdb) p conv->out_fmt
$93 = {format = SND_PCM_FORMAT_S16_LE, frame_rate = 48000, num_channels = 1, channel_layout = "\377\377\377\377\000\377\377\377\377\377\377"}


this is a bug that format converter(with SRC 16k -> 48k) trying to convert 1 frame of data but actually consumes 0 frame.
 
In an old commit https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/276980/4
we've changed the limit value to floor(fr*in_rate/out_rate) to make a little more space for linear resampler to work.
We should stick to that and make sure this "small frame" case(2 < 48000/16000) has at least 1 frame of room to do resample job.
Project Member

Comment 2 by bugdroid1@chromium.org, Jul 5

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/adhd/+/86aab9b6259a6a8f3df78e1429dd9e4adca49ef7

commit 86aab9b6259a6a8f3df78e1429dd9e4adca49ef7
Author: Hsin-Yu Chao <hychao@chromium.org>
Date: Thu Jul 05 14:19:15 2018

CRAS: fmt_conv - Bug fix in cras_fmt_conv

When re-calculating the room in output buffer at SRC and linear
resampling, the intermediate limit was determined using
cras_frames_at_rate() function, and changed in commit 4aca14a79
to take the floor instead of ceiling of calculated number.

There is a bug found when limit count is smaller than the ratio
of in/out sample rate (e.g 16K and 48K), the intermediate limit is
rounded to zero and that confuses both the linear resampler and
rate converter. Fix this issue by making sure the limit value is
at least 1.

BUG= chromium:860408 
TEST=unittest

Change-Id: I64a401a684ca9c694c5fa40a7fa6e79883e15ba2
Reviewed-on: https://chromium-review.googlesource.com/1126800
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>

[modify] https://crrev.com/86aab9b6259a6a8f3df78e1429dd9e4adca49ef7/cras/src/tests/fmt_conv_unittest.cc
[modify] https://crrev.com/86aab9b6259a6a8f3df78e1429dd9e4adca49ef7/cras/src/server/cras_fmt_conv.c

Blocking: 862047
Status: Fixed (was: Started)
Project Member

Comment 4 by bugdroid1@chromium.org, Jul 22

Labels: merge-merged-release-R68-10718.B
The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/third_party/adhd/+/d0e23fa94d2a59f830f76a566b75b6838ac504d7

commit d0e23fa94d2a59f830f76a566b75b6838ac504d7
Author: Hsin-Yu Chao <hychao@chromium.org>
Date: Sun Jul 22 15:39:58 2018

CRAS: fmt_conv - Bug fix in cras_fmt_conv

When re-calculating the room in output buffer at SRC and linear
resampling, the intermediate limit was determined using
cras_frames_at_rate() function, and changed in commit 4aca14a79
to take the floor instead of ceiling of calculated number.

There is a bug found when limit count is smaller than the ratio
of in/out sample rate (e.g 16K and 48K), the intermediate limit is
rounded to zero and that confuses both the linear resampler and
rate converter. Fix this issue by making sure the limit value is
at least 1.

BUG= chromium:860408 
TEST=unittest

Change-Id: I64a401a684ca9c694c5fa40a7fa6e79883e15ba2
Reviewed-on: https://chromium-review.googlesource.com/1126800
Commit-Ready: Hsinyu Chao <hychao@chromium.org>
Tested-by: Hsinyu Chao <hychao@chromium.org>
Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
(cherry picked from commit 86aab9b6259a6a8f3df78e1429dd9e4adca49ef7)
Reviewed-on: https://chromium-review.googlesource.com/1146341
Reviewed-by: Hsinyu Chao <hychao@chromium.org>
Commit-Queue: Hsinyu Chao <hychao@chromium.org>

[modify] https://crrev.com/d0e23fa94d2a59f830f76a566b75b6838ac504d7/cras/src/tests/fmt_conv_unittest.cc
[modify] https://crrev.com/d0e23fa94d2a59f830f76a566b75b6838ac504d7/cras/src/server/cras_fmt_conv.c

Sign in to add a comment