BYTE* encoded_data;
AudinPulseDevice* pulse = (AudinPulseDevice*) userdata;
+ /* There is a race condition here where we may receive this callback
+ * before the buffer has been set up in the main code. It's probably
+ * possible to fix with additional locking, but it's easier just to
+ * ignore input until the buffer is ready.
+ */
+ if (pulse->buffer == NULL)
+ {
+ /* fprintf(stderr, "%s: ignoring input, pulse buffer not ready.\n", __func__); */
+ return;
+ }
+
pa_stream_peek(stream, &data, &length);
frames = length / pulse->bytes_per_frame;
DEBUG_DVC("");
+ pulse->buffer = NULL;
pulse->receive = receive;
pulse->user_data = user_data;