فهرست منبع

update: 优化i2s适配,能跑通mp3播放了

Wendal Chen 2 سال پیش
والد
کامیت
3ca7bdbc69
3فایلهای تغییر یافته به همراه25 افزوده شده و 6 حذف شده
  1. 6 2
      app/port/luat_base_air101.c
  2. 9 1
      app/port/luat_conf_bsp.h
  3. 10 3
      app/port/luat_i2s_air101.c

+ 6 - 2
app/port/luat_base_air101.c

@@ -244,13 +244,17 @@ static const luaL_Reg loadedlibs[] = {
 #ifdef LUAT_USE_FASTLZ
   {"fastlz", luaopen_fastlz},
 #endif
-#ifdef LUAT_USE_MEDIA
+#ifdef LUAT_USE_I2S
   {"i2s", luaopen_i2s},
+#endif
+#ifdef LUAT_USE_MEDIA
   {"audio", luaopen_multimedia_audio},
-#ifndef LUAT_USE_TTS_ONLY
   {"codec", luaopen_multimedia_codec},
 #endif
+#ifdef LUAT_USE_USERNET
+  {"usernet", luaopen_usernet},
 #endif
+
   // {"opus", luaopen_opus},
   {NULL, NULL}
 };

+ 9 - 1
app/port/luat_conf_bsp.h

@@ -110,7 +110,9 @@
 // 硬件加速的版本只支持AES128,若使用AES256就报错了
 #define LUAT_USE_CRYPTO_AES_MBEDTLS  1
 
-#define LUAT_USE_MEDIA  1
+// 音频相关
+// #define LUAT_USE_I2S 1
+// #define LUAT_USE_MEDIA  1
 
 //---------------SDIO-FATFS特别配置
 // sdio库对接的是fatfs
@@ -303,4 +305,10 @@
 #undef LUAT_USE_REPL
 #endif
 
+#ifdef LUAT_USE_MEDIA
+#ifndef LUAT_USE_I2S
+#define LUAT_USE_I2S 1
+#endif
+#endif
+
 #endif

+ 10 - 3
app/port/luat_i2s_air101.c

@@ -47,7 +47,7 @@ static void I2s_dma_tx_irq(void *p){
 	if(ret_len >= 4 ){
 		I2s_tx_send();
 	}else{
-		run_status &= ~CODEC_RUNING;  
+		run_status &= ~CODEC_RUNING;
 	}
 }
 
@@ -123,8 +123,9 @@ int luat_i2s_send(uint8_t id, char* buff, size_t len) {
 		run_status |= CODEC_RUNING;
 	    ret = I2s_tx_send();
 		if(ret == -1){
-		    printf("fifo empty for send\n");
-			run_status &= ~CODEC_RUNING; 
+		    LLOGE("fifo empty for send\n");
+			run_status &= ~CODEC_RUNING;
+			return 0;
 		}
 	}
     return len;
@@ -156,3 +157,9 @@ int luat_i2s_close(uint8_t id) {
 	}
     return 0;
 }
+
+int luat_i2s_tx_stat(uint8_t id, size_t *buffsize, size_t* remain) {
+	*buffsize = AUDIO_BUF_SIZE;
+	*remain = dma_tx_buf.Pos;
+	return 0;
+}