Skip to content

Commit

Permalink
Audio init adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed Jun 19, 2024
1 parent d22488a commit 06ac514
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 30 deletions.
8 changes: 5 additions & 3 deletions src/hal/hisi/v3_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ void *v3_audio_thread(void)
v3_aud_efrm echoFrame;

while (keepRunning) {
ret = v3_aud.fnGetFrame(_v3_aud_dev, _v3_aud_chn,
&frame, &echoFrame, 100);
if (ret && ret != 0xA015800E) {
memset(&frame, 0, sizeof(frame));
memset(&echoFrame, 0, sizeof(echoFrame));

if (ret = v3_aud.fnGetFrame(_v3_aud_dev, _v3_aud_chn,
&frame, &echoFrame, 100)) {
fprintf(stderr, "[v3_aud] Getting the frame failed "
"with %#x!\n", ret);
break;
Expand Down
8 changes: 5 additions & 3 deletions src/hal/hisi/v4_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ void *v4_audio_thread(void)
v4_aud_efrm echoFrame;

while (keepRunning) {
ret = v4_aud.fnGetFrame(_v4_aud_dev, _v4_aud_chn,
&frame, &echoFrame, 100);
if (ret && ret != 0xA015800E) {
memset(&frame, 0, sizeof(frame));
memset(&echoFrame, 0, sizeof(echoFrame));

if (ret = v4_aud.fnGetFrame(_v4_aud_dev, _v4_aud_chn,
&frame, &echoFrame, 100)) {
fprintf(stderr, "[v4_aud] Getting the frame failed "
"with %#x!\n", ret);
break;
Expand Down
12 changes: 7 additions & 5 deletions src/hal/star/i6_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,15 @@ void *i6_audio_thread(void)
i6_aud_efrm echoFrame;

while (keepRunning) {
ret = i6_aud.fnGetFrame(_i6_aud_dev, _i6_aud_chn,
&frame, &echoFrame, 100);
if (ret && ret != 0xA004200E) {
memset(&frame, 0, sizeof(frame));
memset(&echoFrame, 0, sizeof(echoFrame));

if (ret = i6_aud.fnGetFrame(_i6_aud_dev, _i6_aud_chn,
&frame, &echoFrame, 100)) {
fprintf(stderr, "[i6_aud] Getting the frame failed "
"with %#x!\n", ret);
break;
} else continue;
continue;
}

if (i6_aud_cb) {
hal_audframe outFrame;
Expand Down
10 changes: 5 additions & 5 deletions src/hal/star/i6c_aud.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ typedef enum {
} i6c_aud_input;

typedef enum {
I6C_AUD_SND_MONO,
I6C_AUD_SND_STEREO,
I6C_AUD_SND_4CH,
I6C_AUD_SND_6CH,
I6C_AEND_SND_8CH,
I6C_AUD_SND_MONO = 1,
I6C_AUD_SND_STEREO = 2,
I6C_AUD_SND_4CH = 4,
I6C_AUD_SND_6CH = 6,
I6C_AUD_SND_8CH = 8,
I6C_AUD_SND_END
} i6c_aud_snd;

Expand Down
20 changes: 11 additions & 9 deletions src/hal/star/i6c_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int i6c_audio_init(void)
return ret;
}
{
i6c_aud_input input = I6C_AUD_INPUT_I2S_A_01;
i6c_aud_input input[] = { I6C_AUD_INPUT_I2S_A_01 };
i6c_aud_i2s config;
config.intf = I6C_AUD_INTF_I2S_SLAVE;
config.bit = I6C_AUD_BIT_16;
Expand All @@ -99,15 +99,15 @@ int i6c_audio_init(void)
config.clock = I6C_AUD_CLK_OFF;
config.syncRxClkOn = 1;
config.tdmSlotNum = 1;
if (ret = i6c_aud.fnSetI2SConfig(input, &config))
if (ret = i6c_aud.fnSetI2SConfig(input[0], &config))
return ret;
if (ret = i6c_aud.fnAttachToDevice(_i6c_aud_dev, &input, 1))
if (ret = i6c_aud.fnAttachToDevice(_i6c_aud_dev, input, 1))
return ret;
}

{
char gain[1] = { 0xF6 };
if (ret = i6c_aud.fnSetGain(_i6c_aud_dev, _i6c_aud_chn, (char*)&gain, 1))
if (ret = i6c_aud.fnSetGain(_i6c_aud_dev, _i6c_aud_chn, gain, 1))
return ret;
}
if (ret = i6c_aud.fnEnableGroup(_i6c_aud_dev, _i6c_aud_chn))
Expand All @@ -123,13 +123,15 @@ void *i6c_audio_thread(void)
i6c_aud_frm frame, echoFrame;

while (keepRunning) {
ret = i6c_aud.fnGetFrame(_i6c_aud_dev, _i6c_aud_chn,
&frame, &echoFrame, 100);
if (ret && ret != 0xA004200E) {
memset(&frame, 0, sizeof(frame));
memset(&echoFrame, 0, sizeof(echoFrame));

if (ret = i6c_aud.fnGetFrame(_i6c_aud_dev, _i6c_aud_chn,
&frame, &echoFrame, 100)) {
fprintf(stderr, "[i6c_aud] Getting the frame failed "
"with %#x!\n", ret);
break;
} else continue;
continue;
}

if (i6c_aud_cb) {
hal_audframe outFrame;
Expand Down
12 changes: 7 additions & 5 deletions src/hal/star/i6f_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,15 @@ void *i6f_audio_thread(void)
i6f_aud_efrm echoFrame;

while (keepRunning) {
ret = i6f_aud.fnGetFrame(_i6f_aud_dev, _i6f_aud_chn,
&frame, &echoFrame, 100);
if (ret && ret == 0xA004200E) {
memset(&frame, 0, sizeof(frame));
memset(&echoFrame, 0, sizeof(echoFrame));

if (ret = i6f_aud.fnGetFrame(_i6f_aud_dev, _i6f_aud_chn,
&frame, &echoFrame, 100)) {
fprintf(stderr, "[i6f_aud] Getting the frame failed "
"with %#x!\n", ret);
break;
} else continue;
continue;
}

if (i6f_aud_cb) {
hal_audframe outFrame;
Expand Down

0 comments on commit 06ac514

Please sign in to comment.