diff --git a/src/hal/sstar/i6_hal.c b/src/hal/sstar/i6_hal.c index 2c351ae..a19b440 100644 --- a/src/hal/sstar/i6_hal.c +++ b/src/hal/sstar/i6_hal.c @@ -87,7 +87,7 @@ int i6_audio_init(void) config.chnNum = 1; config.i2s.clock = I6_AUD_CLK_OFF; config.i2s.leftJustOn = 0; - config.i2s.syncRxClkOn = 0; + config.i2s.syncRxClkOn = 1; if (ret = i6_aud.fnSetDeviceConfig(_i6_aud_dev, &config)) return ret; } @@ -102,6 +102,34 @@ int i6_audio_init(void) return EXIT_SUCCESS; } +void *i6_audio_thread(void) +{ + int ret; + + i6_aud_frm frame, echoFrame; + + while (keepRunning) { + if ((ret = i6_aud.fnGetFrame(_i6_aud_dev, _i6_aud_chn, + &frame, &echoFrame, 100)) & 0xFF == 0xD) { + fprintf(stderr, "[i6_aud] Getting the frame failed" + " with %#x!\n", ret); + break; + } else continue; + + if (i6_aud_cb) { + hal_audframe outFrame; + (i6_aud_cb)(&outFrame); + } + + if (ret = i6_aud.fnFreeFrame(_i6_aud_dev, _i6_aud_chn, + &frame, &echoFrame)) { + fprintf(stderr, "[i6_aud] Releasing the frame failed" + " with %#x!\n", ret); + } + } + fprintf(stderr, "[i6_aud] Shutting down encoding thread...\n"); +} + int i6_channel_bind(char index, char framerate, char jpeg) { int ret; diff --git a/src/hal/sstar/i6_hal.h b/src/hal/sstar/i6_hal.h index 855853d..e00aa65 100644 --- a/src/hal/sstar/i6_hal.h +++ b/src/hal/sstar/i6_hal.h @@ -17,6 +17,7 @@ extern int (*i6_venc_cb)(char, hal_vidstream*); void i6_hal_deinit(void); int i6_hal_init(void); +void *i6_audio_thread(void); void i6_audio_deinit(void); int i6_audio_init(void); diff --git a/src/hal/sstar/i6c_hal.c b/src/hal/sstar/i6c_hal.c index 04ca1bb..5913a5b 100644 --- a/src/hal/sstar/i6c_hal.c +++ b/src/hal/sstar/i6c_hal.c @@ -82,7 +82,7 @@ int i6c_audio_init(void) config.sound = I6C_AUD_SND_MONO; config.rate = 48000; config.periodSize = 0x600; - config.interleavedOn = 1; + config.interleavedOn = 0; if (ret = i6c_aud.fnEnableDevice(_i6c_aud_dev, &config)) return ret; } @@ -90,7 +90,7 @@ int i6c_audio_init(void) 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_32; + config.bit = I6C_AUD_BIT_16; config.leftJustOn = 0; config.rate = 48000; config.clock = I6C_AUD_CLK_OFF; @@ -113,6 +113,34 @@ int i6c_audio_init(void) return EXIT_SUCCESS; } +void *i6c_audio_thread(void) +{ + int ret; + + i6c_aud_frm frame, echoFrame; + + while (keepRunning) { + if ((ret = i6c_aud.fnGetFrame(_i6c_aud_dev, _i6c_aud_chn, + &frame, &echoFrame, 100)) & 0xFF == 0xD) { + fprintf(stderr, "[i6c_aud] Getting the frame failed" + " with %#x!\n", ret); + break; + } else continue; + + if (i6c_aud_cb) { + hal_audframe outFrame; + (i6c_aud_cb)(&outFrame); + } + + if (ret = i6c_aud.fnFreeFrame(_i6c_aud_dev, _i6c_aud_chn, + &frame, &echoFrame)) { + fprintf(stderr, "[i6c_aud] Releasing the frame failed" + " with %#x!\n", ret); + } + } + fprintf(stderr, "[i6c_aud] Shutting down encoding thread...\n"); +} + int i6c_channel_bind(char index, char framerate, char jpeg) { int ret; diff --git a/src/hal/sstar/i6c_hal.h b/src/hal/sstar/i6c_hal.h index 304d430..e3c457c 100644 --- a/src/hal/sstar/i6c_hal.h +++ b/src/hal/sstar/i6c_hal.h @@ -20,6 +20,7 @@ int i6c_hal_init(void); void i6c_audio_deinit(void); int i6c_audio_init(void); +void *i6c_audio_thread(void); int i6c_channel_bind(char index, char framerate, char jpeg); int i6c_channel_create(char index, short width, short height, char mirror, char flip, char jpeg); diff --git a/src/hal/sstar/i6f_hal.c b/src/hal/sstar/i6f_hal.c index b758bbc..d0426de 100644 --- a/src/hal/sstar/i6f_hal.c +++ b/src/hal/sstar/i6f_hal.c @@ -106,6 +106,34 @@ int i6f_audio_init(void) return EXIT_SUCCESS; } +void *i6f_audio_thread(void) +{ + int ret; + + i6f_aud_frm frame, echoFrame; + + while (keepRunning) { + if ((ret = i6f_aud.fnGetFrame(_i6f_aud_dev, _i6f_aud_chn, + &frame, &echoFrame, 100)) & 0xFF == 0xD) { + fprintf(stderr, "[i6f_aud] Getting the frame failed" + " with %#x!\n", ret); + break; + } else continue; + + if (i6f_aud_cb) { + hal_audframe outFrame; + (i6f_aud_cb)(&outFrame); + } + + if (ret = i6f_aud.fnFreeFrame(_i6f_aud_dev, _i6f_aud_chn, + &frame, &echoFrame)) { + fprintf(stderr, "[i6f_aud] Releasing the frame failed" + " with %#x!\n", ret); + } + } + fprintf(stderr, "[i6f_aud] Shutting down encoding thread...\n"); +} + int i6f_channel_bind(char index, char framerate, char jpeg) { int ret; diff --git a/src/hal/sstar/i6f_hal.h b/src/hal/sstar/i6f_hal.h index e6031fb..c751215 100644 --- a/src/hal/sstar/i6f_hal.h +++ b/src/hal/sstar/i6f_hal.h @@ -18,6 +18,7 @@ int i6f_hal_init(void); void i6f_audio_deinit(void); int i6f_audio_init(void); +void *i6f_audio_thread(void); int i6f_channel_bind(char index, char framerate, char jpeg); int i6f_channel_create(char index, short width, short height, char mirror, char flip, char jpeg);