CHROMIUM: ALSA: hda/ca0132 - Fix divide error when frame_bits not set
authorHsin-Yu Chao <hychao@chromium.org>
Fri, 19 Oct 2012 06:04:00 +0000 (14:04 +0800)
committerGerrit <chrome-bot@google.com>
Fri, 19 Oct 2012 19:08:52 +0000 (12:08 -0700)
When frame_bits hasn't been set in snd_pcm_runtime, skip the calcuation
for latency value.

BUG=chrome-os-partner:12926
TEST=Manual. Boot system on battery, open youtube can play without
crash. Run looptest tool with debug log can see latency value changes
correctly according to effects setting.

Change-Id: Iab2d289d9f33e5d4ed178764217b1a08c30c73c5
Signed-off-by: Hsin-Yu Chao <hychao@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/36047
Reviewed-by: Chih-Chung Chang <chihchung@chromium.org>
Commit-Ready: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
sound/pci/hda/patch_ca0132.c

index 3c11ea8..37b67ed 100644 (file)
@@ -3363,7 +3363,8 @@ static void ca0132_update_latency(struct hda_codec *codec,
        substr = codec->pcm_info->pcm->streams[direction].substream;
        while (substr) {
                runtime = substr->runtime;
-               if (runtime)
+               /* update latency only when runtime is setup */
+               if (runtime && runtime->status->state != SNDRV_PCM_STATE_OPEN)
                        runtime->delay = bytes_to_frames(runtime,
                                        (latency * runtime->rate *
                                        runtime->byte_align) / 1000);