Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
atari: Fill audio buffer with silence when too many interrupts trigge…
…red on same buffer
  • Loading branch information
pmandin committed Jan 13, 2019
1 parent b85ccc0 commit 7964e0a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
8 changes: 7 additions & 1 deletion src/audio/mint/SDL_mintaudio.c
Expand Up @@ -103,6 +103,12 @@ int SDL_MintAudio_InitBuffers(SDL_AudioSpec *spec)
SDL_MintAudio_numbuf = SDL_MintAudio_num_its = SDL_MintAudio_num_upd = 0;
SDL_MintAudio_max_buf = MAX_DMA_BUF;

/* For filling silence when too many interrupts per update */
SDL_MintAudio_itbuffer = MINTAUDIO_audiobuf[0];
SDL_MintAudio_itbuflen = (dmabuflen >> 2)-1;
SDL_MintAudio_itsilence = (spec->silence << 24)|(spec->silence << 16)|
(spec->silence << 8)|spec->silence;

return (1);
}

Expand All @@ -118,7 +124,7 @@ void SDL_MintAudio_FreeBuffers(void)
}
if (MINTAUDIO_audiobuf[0]) {
Mfree(MINTAUDIO_audiobuf[0]);
MINTAUDIO_audiobuf[0] = MINTAUDIO_audiobuf[1] = NULL;
SDL_MintAudio_itbuffer = MINTAUDIO_audiobuf[0] = MINTAUDIO_audiobuf[1] = NULL;
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/audio/mint/SDL_mintaudio.h
Expand Up @@ -121,6 +121,10 @@ void SDL_MintAudio_WaitThread(void);
extern volatile unsigned long SDL_MintAudio_clocktics;
extern volatile unsigned long SDL_MintAudio_num_its;

extern volatile void *SDL_MintAudio_itbuffer;
extern volatile unsigned long SDL_MintAudio_itbuflen;
extern volatile unsigned long SDL_MintAudio_itsilence;

/* Functions */
void SDL_MintAudio_XbiosInterruptMeasureClock(void);
void SDL_MintAudio_XbiosInterrupt(void);
Expand Down
41 changes: 35 additions & 6 deletions src/audio/mint/SDL_mintaudio_it.S
Expand Up @@ -71,26 +71,55 @@ SDL_MintAudio_EndIntMeasure:

_SDL_MintAudio_XbiosInterrupt:
_SDL_MintAudio_Dma8Interrupt:
#if defined(__mcoldfire__)
lea sp@(-12),sp
moveml d0-d1/a0,sp@
#else
moveml d0-d1/a0,sp@-
#endif

/* Clear service bit, so other MFP interrupts can work */
#if defined(__mcoldfire__)
movel d0,sp@-

moveql #5,d0
bclr d0,0xfffffa0f:w

movel sp@+,d0
#else
bclr #5,0xfffffa0f:w
#endif

_SDL_MintAudio_StfaInterrupt:
addql #1,_SDL_MintAudio_num_its

move.l _SDL_MintAudio_num_its,d0
addql #1,d0
move.l d0,_SDL_MintAudio_num_its

cmp.l #5,d0
bmi.s _SDL_MintAudio_nosilence

move.l _SDL_MintAudio_itbuffer,d1
beq.s _SDL_MintAudio_nosilence
move.l d1,a0

move.l _SDL_MintAudio_itbuflen,d0
move.l _SDL_MintAudio_itsilence,d1
_SDL_MintAudio_fillsilence:
move.l d1,a0@+
subq.l #1,d0
bpl.s _SDL_MintAudio_fillsilence

_SDL_MintAudio_nosilence:
#if defined(__mcoldfire__)
moveml sp@,d0-d1/a0
lea sp@(12),sp
#else
moveml sp@+,d0-d1/a0
#endif
rte

.bss

.even
.comm _SDL_MintAudio_clocktics,4
.comm _SDL_MintAudio_num_its,4

.comm _SDL_MintAudio_itbuffer,4 /* Audio DMA buffer */
.comm _SDL_MintAudio_itbuflen,4 /* Length in longword */
.comm _SDL_MintAudio_itsilence,4 /* Silence value */

0 comments on commit 7964e0a

Please sign in to comment.