Skip to content

Commit

Permalink
Fix potential issue with audio recording cleanup. Pending I/O request…
Browse files Browse the repository at this point in the history
… wasn't aborted
  • Loading branch information
capehill committed Dec 16, 2024
1 parent 34f6793 commit 3a768ce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/audio/amigaos4/SDL_os4audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ OS4_CaptureFromDevice(_THIS, void * buffer, int buflen)
request = os4data->ahiRequest[0];

if (os4data->lastCaptureTicks == 0 || (now - os4data->lastCaptureTicks) > RESTART_CAPTURE_THRESHOLD) {
if (os4data->requestSent) {
IExec->WaitIO((struct IORequest *)request);
if (os4data->link) {
IExec->WaitIO((struct IORequest *)os4data->link);
}

/* Assume that we have to (re)start recording */
Expand All @@ -464,13 +464,13 @@ OS4_CaptureFromDevice(_THIS, void * buffer, int buflen)
dprintf("Start recording\n");

IExec->DoIO((struct IORequest *)request);
os4data->requestSent = SDL_FALSE;
os4data->link = NULL;

current = OS4_SwapBuffer(current);
} else {
/* Wait for the previous request completion */
if (os4data->requestSent) {
IExec->WaitIO((struct IORequest *)request);
if (os4data->link) {
IExec->WaitIO((struct IORequest *)os4data->link);
}
}

Expand All @@ -482,7 +482,7 @@ OS4_CaptureFromDevice(_THIS, void * buffer, int buflen)
os4data->ahiType);

IExec->SendIO((struct IORequest *)request);
os4data->requestSent = SDL_TRUE;
os4data->link = request;

current = OS4_SwapBuffer(current);

Expand Down
5 changes: 2 additions & 3 deletions src/audio/amigaos4/SDL_os4audio.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <[email protected]>
Copyright (C) 1997-2024 Sam Lantinga <[email protected]>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
Expand Down Expand Up @@ -38,14 +38,13 @@ struct SDL_PrivateAudioData
struct AHIRequest *ahiRequest[2];
uint32 ahiType;
int currentBuffer; // buffer number to fill
struct AHIRequest *link; // point to previous I/O request sent
struct AHIRequest *link; // point to previous I/O request sent (both recording and playing)

SDL_bool deviceOpen;
Uint32 audioBufferSize;
Uint8 *audioBuffer[2];

Uint32 lastCaptureTicks;
SDL_bool requestSent; // Keeps book of IO done with SendIO(), to avoid issues with WaitIO()
};

typedef struct SDL_PrivateAudioData OS4AudioData;
Expand Down

0 comments on commit 3a768ce

Please sign in to comment.