@geastack/targets 0.1.83 → 0.1.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/README.md +24 -0
  2. package/build-config.json +481 -0
  3. package/package.json +8 -7
  4. package/targets/cmake/gea_build_config.cmake +12 -0
  5. package/targets/esp32/chip_bindings/audio/es8311.cpp +30 -8
  6. package/targets/esp32/display.cpp +57 -28
  7. package/targets/esp32/gea_framework.cmake +25 -3
  8. package/targets/esp32/memory_config.h +7 -0
  9. package/targets/esp32/services/app_runner.cpp +13 -4
  10. package/targets/esp32/services/device_control.cpp +82 -27
  11. package/targets/esp32/services/frame_scheduler.cpp +117 -2
  12. package/targets/esp32-p4-m5stack-tab5/main/CMakeLists.txt +2 -1
  13. package/targets/esp32-p4-waveshare-touch-lcd-3.5/main/CMakeLists.txt +2 -1
  14. package/targets/esp32-p4-waveshare-touch-lcd-7/main/CMakeLists.txt +2 -1
  15. package/targets/esp32-s3-elecrow-rotary-2.1/main/CMakeLists.txt +2 -0
  16. package/targets/esp32-s3-epaper-1.54/main/CMakeLists.txt +3 -1
  17. package/targets/esp32-s3-lilygo-t-display-s3-long/CMakeLists.txt +1 -1
  18. package/targets/esp32-s3-lilygo-t-display-s3-long/main/CMakeLists.txt +1 -24
  19. package/targets/esp32-s3-touch-amoled-1.75/main/CMakeLists.txt +2 -1
  20. package/targets/esp32-s3-touch-amoled-1.8/main/CMakeLists.txt +10 -61
  21. package/targets/esp32-s3-touch-amoled-1.8/main/panel_reset.cpp +54 -0
  22. package/targets/esp32-s3-touch-amoled-2.06/dependencies.lock +1 -42
  23. package/targets/esp32-s3-touch-amoled-2.06/main/CMakeLists.txt +11 -128
  24. package/targets/rp2350-tufty-2350/CMakeLists.txt +6 -7
  25. package/targets/rp2350-waveshare-touch-amoled-2.41/CMakeLists.txt +4 -0
package/README.md CHANGED
@@ -68,6 +68,30 @@ See the `tutorials` repository's
68
68
  `embedded-tutorials/02-custom-board-composition` course for a complete target
69
69
  definition and firmware build.
70
70
 
71
+ ## ES8311 audio duplex mode
72
+
73
+ The ESP32 ES8311 binding defaults to half duplex. Applications can opt into
74
+ simultaneous capture and playback with `"GEA_AUDIO_FULL_DUPLEX=1"` in their
75
+ `gea.defines` array. Removing the define restores the default; it is not a
76
+ board-wide setting. On the AMOLED 2.06, capture uses its separate ES7210 ADC.
77
+
78
+ In full duplex, opening either direction preserves the other. RX uses 20 ms
79
+ blocks and does not hold the TX write lock while waiting for samples. Both
80
+ directions must use the same sample rate because they share I2S clocks; a
81
+ conflicting open fails without closing the existing stream. Capture is 16 kHz,
82
+ so simultaneous playback must also be 16 kHz. Closing playback leaves capture
83
+ running, and audio resources are released once neither direction uses them.
84
+
85
+ The driver exposes raw microphone audio; this option does not add acoustic
86
+ echo cancellation. Applications using a loudspeaker must provide their own
87
+ echo processing if required. Default half-duplex capture keeps its existing
88
+ 2048-sample blocks and playback arbitration.
89
+
90
+ `node targets/esp32/test/audio-full-duplex.test.mjs` compiles the production
91
+ open/capture methods in both modes, checks clock conflicts, and verifies that
92
+ a blocked RX read permits TX progress only in the opted-in mode. Its executable
93
+ uses the board's existing ignored `build/` directory.
94
+
71
95
  ## License
72
96
 
73
97
  This repo is the GeaStack **embedded board support** (ESP32, RP2350) and is
@@ -0,0 +1,481 @@
1
+ {
2
+ "version": 1,
3
+ "platforms": {
4
+ "esp32": {
5
+ "supported": [
6
+ "ui.styleStorage",
7
+ "compiler.staticCssRules",
8
+ "compiler.staticCssTape",
9
+ "compiler.staticCssTapeMinChunk",
10
+ "compiler.translationUnits",
11
+ "compiler.storeRelowering",
12
+ "compiler.moduleGraph",
13
+ "compiler.allowAny",
14
+ "compiler.numberPrecision",
15
+ "renderer.subtreeRevealChecks",
16
+ "renderer.recordInlinePositions",
17
+ "diagnostics.performanceCounters",
18
+ "diagnostics.frameTiming"
19
+ ],
20
+ "defaults": {
21
+ "ui": {
22
+ "styleStorage": "inline"
23
+ },
24
+ "compiler": {
25
+ "staticCssRules": true,
26
+ "staticCssTape": true,
27
+ "staticCssTapeMinChunk": 5,
28
+ "translationUnits": "default",
29
+ "storeRelowering": true,
30
+ "moduleGraph": "auto",
31
+ "allowAny": false
32
+ }
33
+ }
34
+ },
35
+ "rp2350": {
36
+ "supported": [
37
+ "ui.styleStorage",
38
+ "compiler.staticCssRules",
39
+ "compiler.staticCssTape",
40
+ "compiler.staticCssTapeMinChunk",
41
+ "compiler.translationUnits",
42
+ "compiler.storeRelowering",
43
+ "compiler.moduleGraph",
44
+ "compiler.allowAny"
45
+ ],
46
+ "defaults": {
47
+ "ui": {
48
+ "styleStorage": "inline"
49
+ },
50
+ "compiler": {
51
+ "staticCssRules": true,
52
+ "staticCssTape": true,
53
+ "staticCssTapeMinChunk": 5,
54
+ "translationUnits": "default",
55
+ "storeRelowering": true,
56
+ "moduleGraph": "auto",
57
+ "allowAny": false
58
+ }
59
+ }
60
+ },
61
+ "macos": {
62
+ "supported": [
63
+ "compiler.staticCssRules",
64
+ "compiler.staticCssTape",
65
+ "compiler.staticCssTapeMinChunk",
66
+ "compiler.translationUnits",
67
+ "compiler.storeRelowering",
68
+ "compiler.moduleGraph",
69
+ "compiler.allowAny"
70
+ ],
71
+ "defaults": {
72
+ "compiler": {
73
+ "staticCssRules": true,
74
+ "staticCssTape": true,
75
+ "staticCssTapeMinChunk": 5,
76
+ "translationUnits": "default",
77
+ "storeRelowering": true,
78
+ "moduleGraph": "auto",
79
+ "allowAny": false
80
+ }
81
+ }
82
+ },
83
+ "ios": {
84
+ "supported": [
85
+ "compiler.staticCssRules",
86
+ "compiler.staticCssTape",
87
+ "compiler.staticCssTapeMinChunk",
88
+ "compiler.translationUnits",
89
+ "compiler.storeRelowering",
90
+ "compiler.moduleGraph",
91
+ "compiler.allowAny"
92
+ ],
93
+ "defaults": {
94
+ "compiler": {
95
+ "staticCssRules": true,
96
+ "staticCssTape": true,
97
+ "staticCssTapeMinChunk": 5,
98
+ "translationUnits": "default",
99
+ "storeRelowering": true,
100
+ "moduleGraph": "auto",
101
+ "allowAny": false
102
+ }
103
+ }
104
+ },
105
+ "windows": {
106
+ "supported": [
107
+ "compiler.staticCssRules",
108
+ "compiler.staticCssTape",
109
+ "compiler.staticCssTapeMinChunk",
110
+ "compiler.translationUnits",
111
+ "compiler.storeRelowering",
112
+ "compiler.moduleGraph",
113
+ "compiler.allowAny"
114
+ ],
115
+ "defaults": {
116
+ "compiler": {
117
+ "staticCssRules": true,
118
+ "staticCssTape": true,
119
+ "staticCssTapeMinChunk": 5,
120
+ "translationUnits": "balanced",
121
+ "storeRelowering": true,
122
+ "moduleGraph": "auto",
123
+ "allowAny": false
124
+ }
125
+ }
126
+ },
127
+ "pebble": {
128
+ "supported": [
129
+ "compiler.staticCssRules",
130
+ "compiler.staticCssTape",
131
+ "compiler.staticCssTapeMinChunk",
132
+ "compiler.translationUnits",
133
+ "compiler.storeRelowering",
134
+ "compiler.moduleGraph",
135
+ "compiler.allowAny"
136
+ ],
137
+ "defaults": {
138
+ "compiler": {
139
+ "staticCssRules": true,
140
+ "staticCssTape": true,
141
+ "staticCssTapeMinChunk": 5,
142
+ "translationUnits": "default",
143
+ "storeRelowering": true,
144
+ "moduleGraph": "auto",
145
+ "allowAny": false
146
+ }
147
+ }
148
+ },
149
+ "geaos": {
150
+ "supported": [
151
+ "compiler.staticCssRules",
152
+ "compiler.staticCssTape",
153
+ "compiler.staticCssTapeMinChunk",
154
+ "compiler.translationUnits",
155
+ "compiler.storeRelowering",
156
+ "compiler.moduleGraph",
157
+ "compiler.allowAny"
158
+ ],
159
+ "defaults": {
160
+ "compiler": {
161
+ "staticCssRules": true,
162
+ "staticCssTape": true,
163
+ "staticCssTapeMinChunk": 5,
164
+ "translationUnits": "default",
165
+ "storeRelowering": true,
166
+ "moduleGraph": "auto",
167
+ "allowAny": false
168
+ }
169
+ }
170
+ },
171
+ "xbox": {
172
+ "supported": [
173
+ "compiler.staticCssRules",
174
+ "compiler.staticCssTape",
175
+ "compiler.staticCssTapeMinChunk",
176
+ "compiler.translationUnits",
177
+ "compiler.storeRelowering",
178
+ "compiler.moduleGraph",
179
+ "compiler.allowAny"
180
+ ],
181
+ "defaults": {
182
+ "compiler": {
183
+ "staticCssRules": true,
184
+ "staticCssTape": true,
185
+ "staticCssTapeMinChunk": 5,
186
+ "translationUnits": "default",
187
+ "storeRelowering": true,
188
+ "moduleGraph": "auto",
189
+ "allowAny": false
190
+ }
191
+ }
192
+ },
193
+ "web": {
194
+ "supported": [
195
+ "compiler.staticCssRules",
196
+ "compiler.staticCssTape",
197
+ "compiler.staticCssTapeMinChunk",
198
+ "compiler.translationUnits",
199
+ "compiler.storeRelowering",
200
+ "compiler.moduleGraph",
201
+ "compiler.allowAny",
202
+ "ui.styleStorage"
203
+ ],
204
+ "defaults": {
205
+ "compiler": {
206
+ "staticCssRules": true,
207
+ "staticCssTape": true,
208
+ "staticCssTapeMinChunk": 5,
209
+ "translationUnits": "default",
210
+ "storeRelowering": true,
211
+ "moduleGraph": "auto",
212
+ "allowAny": false
213
+ },
214
+ "ui": {
215
+ "styleStorage": "inline"
216
+ }
217
+ },
218
+ "cssDevicePixelRatio": 1.5,
219
+ "inference": {
220
+ "canvasOnly": true
221
+ }
222
+ }
223
+ },
224
+ "boards": {
225
+ "esp32-s3-touch-amoled-1.8": {
226
+ "supported": [
227
+ "compiler.generatedCodeOptimization",
228
+ "renderer.fuseReplayFlush",
229
+ "renderer.adaptiveCoalescing",
230
+ "renderer.broadDirtyBounds",
231
+ "display.framebufferStream",
232
+ "display.presentStream"
233
+ ],
234
+ "defaults": {
235
+ "compiler": {
236
+ "generatedCodeOptimization": "Os",
237
+ "numberPrecision": "float64"
238
+ },
239
+ "renderer": {
240
+ "fuseReplayFlush": false,
241
+ "subtreeRevealChecks": true,
242
+ "recordInlinePositions": true,
243
+ "adaptiveCoalescing": false,
244
+ "broadDirtyBounds": false
245
+ },
246
+ "display": {
247
+ "framebufferStream": "independent",
248
+ "presentStream": "independent"
249
+ },
250
+ "diagnostics": {
251
+ "performanceCounters": true,
252
+ "frameTiming": true
253
+ }
254
+ },
255
+ "cssDevicePixelRatio": 1.5,
256
+ "constraints": {}
257
+ },
258
+ "esp32-s3-touch-amoled-2.06": {
259
+ "supported": [
260
+ "compiler.generatedCodeOptimization",
261
+ "renderer.fuseReplayFlush",
262
+ "renderer.adaptiveCoalescing",
263
+ "renderer.broadDirtyBounds",
264
+ "display.framebufferStream",
265
+ "display.presentStream",
266
+ "display.flushPoolBytes",
267
+ "services.wifi"
268
+ ],
269
+ "defaults": {
270
+ "compiler": {
271
+ "generatedCodeOptimization": "O2",
272
+ "numberPrecision": "float32"
273
+ },
274
+ "renderer": {
275
+ "fuseReplayFlush": false,
276
+ "subtreeRevealChecks": true,
277
+ "recordInlinePositions": true,
278
+ "adaptiveCoalescing": true,
279
+ "broadDirtyBounds": true
280
+ },
281
+ "display": {
282
+ "framebufferStream": "continuous",
283
+ "presentStream": "continuous",
284
+ "flushPoolBytes": 0
285
+ },
286
+ "diagnostics": {
287
+ "performanceCounters": false,
288
+ "frameTiming": false
289
+ },
290
+ "services": {
291
+ "wifi": "auto"
292
+ }
293
+ },
294
+ "cssDevicePixelRatio": 1.5,
295
+ "constraints": {},
296
+ "inference": {
297
+ "canvasOnly": true
298
+ }
299
+ },
300
+ "esp32-s3-touch-amoled-2.41": {
301
+ "supported": [
302
+ "compiler.generatedCodeOptimization",
303
+ "renderer.fuseReplayFlush",
304
+ "renderer.adaptiveCoalescing",
305
+ "renderer.broadDirtyBounds",
306
+ "display.framebufferStream",
307
+ "display.presentStream"
308
+ ],
309
+ "defaults": {
310
+ "compiler": {
311
+ "generatedCodeOptimization": "O2",
312
+ "numberPrecision": "float64"
313
+ },
314
+ "renderer": {
315
+ "fuseReplayFlush": false,
316
+ "subtreeRevealChecks": true,
317
+ "recordInlinePositions": true,
318
+ "adaptiveCoalescing": false,
319
+ "broadDirtyBounds": false
320
+ },
321
+ "display": {
322
+ "framebufferStream": "independent",
323
+ "presentStream": "independent"
324
+ },
325
+ "diagnostics": {
326
+ "performanceCounters": true,
327
+ "frameTiming": true
328
+ }
329
+ },
330
+ "cssDevicePixelRatio": 1.5,
331
+ "constraints": {
332
+ "display.framebufferStream": [
333
+ "independent"
334
+ ],
335
+ "display.presentStream": [
336
+ "independent"
337
+ ]
338
+ }
339
+ },
340
+ "esp32-s3-lilygo-t-display-s3-long": {
341
+ "supported": [
342
+ "compiler.generatedCodeOptimization",
343
+ "renderer.fuseReplayFlush",
344
+ "renderer.adaptiveCoalescing",
345
+ "renderer.broadDirtyBounds",
346
+ "display.framebufferStream",
347
+ "display.presentStream"
348
+ ],
349
+ "defaults": {
350
+ "compiler": {
351
+ "generatedCodeOptimization": "Os",
352
+ "numberPrecision": "float64"
353
+ },
354
+ "renderer": {
355
+ "fuseReplayFlush": false,
356
+ "subtreeRevealChecks": true,
357
+ "recordInlinePositions": true,
358
+ "adaptiveCoalescing": false,
359
+ "broadDirtyBounds": false
360
+ },
361
+ "display": {
362
+ "framebufferStream": "independent",
363
+ "presentStream": "independent"
364
+ },
365
+ "diagnostics": {
366
+ "performanceCounters": true,
367
+ "frameTiming": true
368
+ }
369
+ },
370
+ "cssDevicePixelRatio": 1,
371
+ "constraints": {
372
+ "display.framebufferStream": [
373
+ "independent"
374
+ ],
375
+ "renderer.fuseReplayFlush": [
376
+ false
377
+ ]
378
+ }
379
+ },
380
+ "rp2350-tufty-2350": {
381
+ "cssDevicePixelRatio": 1,
382
+ "supported": []
383
+ },
384
+ "rp2350-waveshare-touch-amoled-2.41": {
385
+ "cssDevicePixelRatio": 1.5,
386
+ "supported": []
387
+ },
388
+ "esp32-s3-waveshare-touch-lcd-4b": {
389
+ "supported": [
390
+ "compiler.generatedCodeOptimization",
391
+ "services.wifi"
392
+ ],
393
+ "defaults": {
394
+ "compiler": {
395
+ "generatedCodeOptimization": "O2"
396
+ },
397
+ "services": {
398
+ "wifi": "auto"
399
+ }
400
+ },
401
+ "cssDevicePixelRatio": 1,
402
+ "constraints": {}
403
+ },
404
+ "esp32-s3": {
405
+ "supported": [
406
+ "compiler.generatedCodeOptimization",
407
+ "services.wifi"
408
+ ],
409
+ "defaults": {
410
+ "compiler": {
411
+ "generatedCodeOptimization": "O2",
412
+ "numberPrecision": "float32"
413
+ },
414
+ "services": {
415
+ "wifi": "auto"
416
+ }
417
+ },
418
+ "cssDevicePixelRatio": 1.5
419
+ },
420
+ "esp32-s3-touch-amoled-1.75": {
421
+ "cssDevicePixelRatio": 1.5,
422
+ "defaults": {
423
+ "diagnostics": {
424
+ "frameTiming": true
425
+ }
426
+ },
427
+ "supported": []
428
+ },
429
+ "esp32-s3-epaper-1.54": {
430
+ "cssDevicePixelRatio": 1,
431
+ "supported": []
432
+ },
433
+ "esp32-s3-lilygo-t5-epaper-4.7": {
434
+ "cssDevicePixelRatio": 1,
435
+ "supported": []
436
+ },
437
+ "esp32-m5stack-m5paper": {
438
+ "cssDevicePixelRatio": 1,
439
+ "supported": []
440
+ },
441
+ "esp32-s3-m5stack-papers3": {
442
+ "cssDevicePixelRatio": 1,
443
+ "supported": []
444
+ },
445
+ "esp32-s3-m5stack-sticks3": {
446
+ "cssDevicePixelRatio": 1.5,
447
+ "supported": []
448
+ },
449
+ "esp32-s3-elecrow-rotary-2.1": {
450
+ "cssDevicePixelRatio": 1.5,
451
+ "supported": []
452
+ },
453
+ "esp32-p4-waveshare-touch-lcd-7": {
454
+ "cssDevicePixelRatio": 1,
455
+ "defaults": {
456
+ "diagnostics": {
457
+ "frameTiming": true
458
+ }
459
+ },
460
+ "supported": []
461
+ },
462
+ "esp32-p4-waveshare-touch-lcd-3.5": {
463
+ "cssDevicePixelRatio": 1,
464
+ "defaults": {
465
+ "diagnostics": {
466
+ "frameTiming": true
467
+ }
468
+ },
469
+ "supported": []
470
+ },
471
+ "esp32-p4-m5stack-tab5": {
472
+ "cssDevicePixelRatio": 2,
473
+ "defaults": {
474
+ "diagnostics": {
475
+ "frameTiming": true
476
+ }
477
+ },
478
+ "supported": []
479
+ }
480
+ }
481
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geastack/targets",
3
- "version": "0.1.83",
3
+ "version": "0.1.85",
4
4
  "description": "Native embedded build targets (ESP32-IDF, RP2350) for geastack apps: board sources, target catalog, and CMake glue driven by the gea CLI.",
5
5
  "license": "GPL-3.0-only",
6
6
  "repository": {
@@ -15,6 +15,7 @@
15
15
  },
16
16
  "files": [
17
17
  "targets.json",
18
+ "build-config.json",
18
19
  "targets",
19
20
  "!targets/**/build/**",
20
21
  "!targets/**/build-*/**",
@@ -36,13 +37,13 @@
36
37
  },
37
38
  "dependencies": {
38
39
  "@geastack/chips": "^0.1.4",
39
- "@geastack/compiler": "^1.0.15",
40
- "@geastack/core": "^0.1.24",
41
- "@geastack/elements": "^0.1.2",
42
- "@geastack/engine": "^0.1.5",
40
+ "@geastack/compiler": "^1.0.20",
41
+ "@geastack/core": "^0.1.31",
42
+ "@geastack/elements": "^0.1.3",
43
+ "@geastack/engine": "^0.1.8",
43
44
  "@geastack/geaos": "^0.1.3",
44
- "@geastack/geatsc-plugin-gea": "^0.1.6",
45
- "@geastack/host": "^0.1.8"
45
+ "@geastack/geatsc-plugin-gea": "^0.1.13",
46
+ "@geastack/host": "^0.1.10"
46
47
  },
47
48
  "scripts": {
48
49
  "test": "for f in $(git ls-files | grep -E '(^|/)(test[-_][^/]*|[^/]*\\.test)\\.mjs$'); do echo \"==> $f\"; node \"$f\" || exit 1; done"
@@ -0,0 +1,12 @@
1
+ # Resolved application choices come from the CLI, never from an app name.
2
+ # IDF's early requirements pass only receives the path through its child env.
3
+ foreach(_gea_input GEA_BUILD_CONFIG_FILE GEA_BUILD_CONFIG_JSON)
4
+ if(NOT ${_gea_input} AND DEFINED ENV{${_gea_input}})
5
+ set(${_gea_input} "$ENV{${_gea_input}}")
6
+ endif()
7
+ endforeach()
8
+ if(GEA_BUILD_CONFIG_FILE)
9
+ include("${GEA_BUILD_CONFIG_FILE}")
10
+ elseif(NOT CMAKE_SCRIPT_MODE_FILE)
11
+ message(FATAL_ERROR "Resolved package.json build settings are missing. Build with a current gea CLI.")
12
+ endif()
@@ -23,10 +23,15 @@
23
23
 
24
24
  #include "host/media.h"
25
25
 
26
- // AFE (acoustic echo cancellation) integration deferred — esp-sr 2.4.4's API
27
- // requires afe_config_init("MR", models, AFE_TYPE_VC, AFE_MODE_LOW_COST) and
28
- // esp_afe_handle_from_config(). Phase 5.0 ships raw mic mix; AEC is a Phase 5.1
29
- // follow-up once the basic call flow is on-device verified.
26
+ // Full duplex is an app opt-in. Both directions share a clock, so a live
27
+ // capture stream cannot coexist with playback at a different sample rate.
28
+ #ifndef GEA_AUDIO_FULL_DUPLEX
29
+ #define GEA_AUDIO_FULL_DUPLEX 0
30
+ #endif
31
+ static_assert(GEA_AUDIO_FULL_DUPLEX == 0 || GEA_AUDIO_FULL_DUPLEX == 1);
32
+
33
+ // Capture is raw microphone PCM. Full duplex does not imply acoustic echo
34
+ // cancellation; the application must supply any required echo processing.
30
35
 
31
36
  namespace gea::platform::esp32::chip_bindings::es8311 {
32
37
 
@@ -66,6 +71,7 @@ public:
66
71
 
67
72
  bool open(int sampleRate, int channels, int bitsPerSample) {
68
73
  std::lock_guard<std::mutex> lock(writeMutex_);
74
+ std::lock_guard<std::mutex> captureLock(readMutex_);
69
75
  const gea::chips::es8311::OutputFormat format(sampleRate, channels, bitsPerSample);
70
76
  if (!format.isPcm16()) return false;
71
77
 
@@ -77,7 +83,11 @@ public:
77
83
  return true;
78
84
  }
79
85
 
80
- if (recordOpen_) closeRecorderLocked();
86
+ if constexpr (GEA_AUDIO_FULL_DUPLEX) {
87
+ if (recordOpen_ && i2sSampleRate_ != sampleRate) return false;
88
+ } else {
89
+ if (recordOpen_) closeRecorderLocked();
90
+ }
81
91
  if (speakerOpen_) closeSpeakerLocked();
82
92
 
83
93
  const esp_err_t initErr = initSpeaker(sampleRate);
@@ -142,6 +152,7 @@ public:
142
152
 
143
153
  void close() {
144
154
  std::lock_guard<std::mutex> lock(writeMutex_);
155
+ std::lock_guard<std::mutex> captureLock(readMutex_);
145
156
  closeSpeakerLocked();
146
157
  // An idle capture task leaves the audio path up while the speaker plays; free it once neither uses it.
147
158
  if (!micInUse()) releaseAudioLocked();
@@ -377,8 +388,13 @@ private:
377
388
 
378
389
  esp_err_t initRecorder(int sampleRate) {
379
390
  if (recordOpen_ && i2sSampleRate_ == sampleRate) return ESP_OK;
391
+ if constexpr (GEA_AUDIO_FULL_DUPLEX) {
392
+ if (speakerOpen_ && speakerSampleRate_ != sampleRate) return ESP_ERR_NOT_SUPPORTED;
393
+ }
380
394
  if (recordOpen_) closeRecorderLocked();
381
- if (speakerOpen_) closeSpeakerLocked();
395
+ if constexpr (!GEA_AUDIO_FULL_DUPLEX) {
396
+ if (speakerOpen_) closeSpeakerLocked();
397
+ }
382
398
 
383
399
  esp_err_t err = initCodecDevice(sampleRate, ESP_CODEC_DEV_TYPE_IN, recordCodec_);
384
400
  if (err != ESP_OK) return err;
@@ -513,13 +529,16 @@ private:
513
529
  int speakerChannels_ = 0;
514
530
  int speakerBitsPerSample_ = 0;
515
531
  int speakerVolume_ = 100;
532
+ // Configuration/destruction takes write then read. A duplex read releases
533
+ // write before blocking on RX, allowing TX to run at the same time.
516
534
  std::mutex writeMutex_;
535
+ std::mutex readMutex_;
517
536
 
518
537
  TaskHandle_t captureTask_ = nullptr;
519
538
  std::vector<gea::host::NativeMediaTrackHandle> attachedTracks_;
520
539
  std::vector<gea::host::NativeMediaTrackHandle> captureSnapshot_;
521
540
  std::mutex attachedMutex_;
522
- static constexpr std::size_t kCaptureFrameSamples = 2048;
541
+ static constexpr std::size_t kCaptureFrameSamples = GEA_AUDIO_FULL_DUPLEX ? 320 : 2048;
523
542
  std::array<std::int16_t, kCaptureFrameSamples * 2> stereoFrame_{};
524
543
  std::array<std::int16_t, kCaptureFrameSamples> monoFrame_{};
525
544
 
@@ -551,6 +570,7 @@ private:
551
570
  if (idle) {
552
571
  {
553
572
  std::lock_guard<std::mutex> lock(writeMutex_);
573
+ std::lock_guard<std::mutex> captureLock(readMutex_);
554
574
  // A track attached since the check started a new capture task, which now owns the audio path.
555
575
  if (!micInUse()) {
556
576
  closeRecorderLocked();
@@ -563,9 +583,11 @@ private:
563
583
 
564
584
  int err = ESP_OK;
565
585
  {
566
- std::lock_guard<std::mutex> lock(writeMutex_);
586
+ std::unique_lock<std::mutex> lock(writeMutex_);
587
+ std::lock_guard<std::mutex> captureLock(readMutex_);
567
588
  err = initRecorder(16000);
568
589
  if (err == ESP_OK && recordCodec_) {
590
+ if constexpr (GEA_AUDIO_FULL_DUPLEX) lock.unlock();
569
591
  err = esp_codec_dev_read(recordCodec_, stereoFrame_.data(), stereoFrame_.size() * sizeof(std::int16_t));
570
592
  }
571
593
  }