Skip to content

Commit 3964a9d

Browse files
Andrula Songabonislawski
authored andcommitted
audio: volume: initialize variables before using
initialize variables before using and finalize the output align register to sink address for aligned store. Signed-off-by: Andrula Song <xiaoyuan.song@intel.com>
1 parent e7c5da4 commit 3964a9d

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

src/audio/volume/volume_hifi3.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ static void vol_s24_to_s24_s32(struct comp_dev *dev, struct audio_stream *sink,
7373
{
7474
struct vol_data *cd = comp_get_drvdata(dev);
7575
ae_f32x2 in_sample = AE_ZERO32();
76-
ae_f32x2 out_sample;
77-
ae_f32x2 volume;
76+
ae_f32x2 out_sample = AE_ZERO32();
77+
ae_f32x2 volume = AE_ZERO32();
7878
ae_f32x2 *buf;
7979
ae_f32x2 *buf_end;
80-
ae_valign inu;
81-
ae_valign outu;
80+
ae_valign inu = AE_ZALIGN64();
81+
ae_valign outu = AE_ZALIGN64();
8282
int i;
8383
ae_f32x2 *in = (ae_f32x2 *)source->r_ptr;
8484
ae_f32x2 *out = (ae_f32x2 *)sink->w_ptr;
@@ -100,7 +100,6 @@ static void vol_s24_to_s24_s32(struct comp_dev *dev, struct audio_stream *sink,
100100
* avoid risk of buf not aligned to 64 bits.
101101
*/
102102
AE_LA32X2POS_PC(inu, in);
103-
AE_SA64POS_FC(outu, out);
104103

105104
/* process two continuous sample data once */
106105
for (i = 0; i < samples; i += 2) {
@@ -135,6 +134,7 @@ static void vol_s24_to_s24_s32(struct comp_dev *dev, struct audio_stream *sink,
135134

136135
/* Store the output sample */
137136
AE_SA32X2_IC(out_sample, outu, out);
137+
AE_SA64POS_FC(outu, out);
138138

139139
/* calc peak vol
140140
* TODO: fix channel value
@@ -161,8 +161,8 @@ static void vol_s32_to_s24_s32(struct comp_dev *dev, struct audio_stream *sink,
161161
{
162162
struct vol_data *cd = comp_get_drvdata(dev);
163163
ae_f32x2 in_sample = AE_ZERO32();
164-
ae_f32x2 out_sample;
165-
ae_f32x2 volume;
164+
ae_f32x2 out_sample = AE_ZERO32();
165+
ae_f32x2 volume = AE_ZERO32();
166166
int i;
167167
ae_f64 mult0;
168168
ae_f64 mult1;
@@ -174,8 +174,8 @@ static void vol_s32_to_s24_s32(struct comp_dev *dev, struct audio_stream *sink,
174174
const int samples = channels_count * frames;
175175
ae_f32x2 *in = (ae_f32x2 *)source->r_ptr;
176176
ae_f32x2 *out = (ae_f32x2 *)sink->w_ptr;
177-
ae_valign inu;
178-
ae_valign outu;
177+
ae_valign inu = AE_ZALIGN64();
178+
ae_valign outu = AE_ZALIGN64();
179179

180180
/** to ensure the address is 8-byte aligned and avoid risk of
181181
* error loading of volume gain while the cd->vol would be set
@@ -190,7 +190,7 @@ static void vol_s32_to_s24_s32(struct comp_dev *dev, struct audio_stream *sink,
190190
* avoid risk of buf not aligned to 64 bits.
191191
*/
192192
AE_LA32X2POS_PC(inu, in);
193-
AE_SA64POS_FC(outu, out);
193+
194194

195195
/* process two continuous sample data once */
196196
for (i = 0; i < samples; i += 2) {
@@ -224,6 +224,7 @@ static void vol_s32_to_s24_s32(struct comp_dev *dev, struct audio_stream *sink,
224224
#endif
225225
vol_setup_circular(sink);
226226
AE_SA32X2_IC(out_sample, outu, out);
227+
AE_SA64POS_FC(outu, out);
227228

228229
/* calc peak vol
229230
* TODO: fix channel value
@@ -248,16 +249,17 @@ static void vol_s16_to_s16(struct comp_dev *dev, struct audio_stream *sink,
248249
const struct audio_stream *source, uint32_t frames)
249250
{
250251
struct vol_data *cd = comp_get_drvdata(dev);
251-
ae_f32x2 volume0, volume1;
252+
ae_f32x2 volume0 = AE_ZERO32();
253+
ae_f32x2 volume1 = AE_ZERO32();
252254
ae_f32x2 out_sample0, out_sample1;
253255
ae_f16x4 in_sample = AE_ZERO16();
254256
ae_f16x4 out_sample = AE_ZERO16();
255257
int i;
256258
ae_f32x2 *buf;
257259
ae_f32x2 *buf_end;
258260
ae_f32x2 *vol;
259-
ae_valign inu;
260-
ae_valign outu;
261+
ae_valign inu = AE_ZALIGN64();
262+
ae_valign outu = AE_ZALIGN64();
261263
ae_f16x4 *in = (ae_f16x4 *)source->r_ptr;
262264
ae_f16x4 *out = (ae_f16x4 *)sink->w_ptr;
263265
const int channels_count = sink->channels;
@@ -278,7 +280,6 @@ static void vol_s16_to_s16(struct comp_dev *dev, struct audio_stream *sink,
278280
* risk of buf not aligned to 8-byte
279281
*/
280282
AE_LA16X4POS_PC(inu, in);
281-
AE_SA64POS_FC(outu, out);
282283

283284
for (i = 0; i < samples; i += 4) {
284285
/* Set buf as circular buffer */
@@ -321,6 +322,7 @@ static void vol_s16_to_s16(struct comp_dev *dev, struct audio_stream *sink,
321322
/* store the output */
322323
out_sample = AE_ROUND16X4F32SSYM(out_sample0, out_sample1);
323324
AE_SA16X4_IC(out_sample, outu, out);
325+
AE_SA64POS_FC(outu, out);
324326

325327
/* calc peak vol
326328
* TODO: fix channel value

0 commit comments

Comments
 (0)