mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 17:29:57 -04:00
Open the recording device only when the game starts microphone capture.
The game opens two input streams while it starts and leaves both stopped through ordinary play, and each open took the system's default recording device and held it, paused, until the game ended: Windows shows the microphone as in use for the whole session, and a Bluetooth headset can drop to its call profile. An open now checks that a default input exists and prepares the stream and its bounded buffer; the device is opened at StartInputStream and released at stop or close, after which the game can still read or purge what was buffered. A start that is refused returns an input error and can be tried again. tests/audio_input_check.py did not compile on this line (it had no stand-in for the microphone setting); with the change it builds and passes: idle streams hold no device, a refused start can be retried, a stop releases the device and keeps the unread frames, two streams are independent. Not checked with a real microphone in the game. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -86,7 +86,7 @@ static void open_input(Cpu *c) {
|
||||
}
|
||||
MicCapture *m = mic_open(f[0], f[1], f[2], frames);
|
||||
if (!m) {
|
||||
rt_log("mic: cannot open the default recording device: %s", mic_error());
|
||||
rt_log("mic: cannot prepare the input stream: %s", mic_error());
|
||||
ret_x(c, BAD_INPUT);
|
||||
return;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ static void open_input(Cpu *c) {
|
||||
s->next_log = (uint64_t)f[2] * 5;
|
||||
uint64_t impl = key + 8;
|
||||
memcpy(ipc_guest(key, 8), &impl, 8);
|
||||
rt_log("mic: default recording device opened; bounded buffer %d frames", mic_capacity(m));
|
||||
rt_log("mic: input stream ready; bounded buffer %d frames; device opens when capture starts", mic_capacity(m));
|
||||
ret_x(c, 0);
|
||||
}
|
||||
static void start_input(Cpu *c) {
|
||||
@@ -115,6 +115,8 @@ static void stop_input(Cpu *c) {
|
||||
Input *s = find(c->x[0]);
|
||||
if (s) {
|
||||
mic_stop(s->mic);
|
||||
if (s->running)
|
||||
rt_log("mic: capture stopped; recording device released");
|
||||
s->running = 0;
|
||||
}
|
||||
ret_x(c, 0);
|
||||
|
||||
Reference in New Issue
Block a user