OSDN Git Service

alsabat: add channels parameter for adjust_waveform()
authorLu, Han <han.lu@intel.com>
Wed, 8 Jun 2016 19:42:47 +0000 (03:42 +0800)
committerTakashi Iwai <tiwai@suse.de>
Wed, 8 Jun 2016 13:13:53 +0000 (15:13 +0200)
The function adjust_waveform() is a component of generate_sine_wave(),
and depended on bat->channels parameter. Add parameter "channels" to
remove the dependency, and then adjust_waveform() can be applied on
other use cases, e.g. a single channel sine wave generator.

Signed-off-by: Lu, Han <han.lu@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
bat/signal.c

index 15bea0a..2047f53 100644 (file)
@@ -109,7 +109,8 @@ static int reorder(struct bat *bat, float *val, int frames)
        return 0;
 }
 
-static int adjust_waveform(struct bat *bat, float *val, int frames)
+static int adjust_waveform(struct bat *bat, float *val, int frames,
+               int channels)
 {
        int i, nsamples, max;
        float factor, offset = 0.0;
@@ -134,7 +135,7 @@ static int adjust_waveform(struct bat *bat, float *val, int frames)
        }
 
        factor = max * RANGE_FACTOR;
-       nsamples = bat->channels * frames;
+       nsamples = channels * frames;
 
        for (i = 0; i < nsamples; i++)
                val[i] = val[i] * factor + offset;
@@ -171,7 +172,7 @@ int generate_sine_wave(struct bat *bat, int frames, void *buf)
                goto exit;
 
        /* adjust amplitude and offset of waveform */
-       err = adjust_waveform(bat, sinus_f, frames);
+       err = adjust_waveform(bat, sinus_f, frames, bat->channels);
        if (err != 0)
                goto exit;