atari: Fill audio buffer with silence when too many interrupts triggered on same buffer SDL-1.2
authorPatrice Mandin <patmandin@gmail.com>
Sun, 13 Jan 2019 15:27:50 +0100
branchSDL-1.2
changeset 125378586f153eede
parent 12536 6472da23f3ef
atari: Fill audio buffer with silence when too many interrupts triggered on same buffer
src/audio/mint/SDL_mintaudio.c
src/audio/mint/SDL_mintaudio.h
src/audio/mint/SDL_mintaudio_it.S
     1.1 --- a/src/audio/mint/SDL_mintaudio.c	Sun Jan 13 15:13:13 2019 +0100
     1.2 +++ b/src/audio/mint/SDL_mintaudio.c	Sun Jan 13 15:27:50 2019 +0100
     1.3 @@ -103,6 +103,12 @@
     1.4  	SDL_MintAudio_numbuf = SDL_MintAudio_num_its = SDL_MintAudio_num_upd = 0;
     1.5  	SDL_MintAudio_max_buf = MAX_DMA_BUF;
     1.6  
     1.7 +	/* For filling silence when too many interrupts per update */
     1.8 +	SDL_MintAudio_itbuffer = MINTAUDIO_audiobuf[0];
     1.9 +	SDL_MintAudio_itbuflen = (dmabuflen >> 2)-1;
    1.10 +	SDL_MintAudio_itsilence = (spec->silence << 24)|(spec->silence << 16)|
    1.11 +		(spec->silence << 8)|spec->silence;
    1.12 +
    1.13  	return (1);
    1.14  }
    1.15  
    1.16 @@ -118,7 +124,7 @@
    1.17  	}
    1.18  	if (MINTAUDIO_audiobuf[0]) {
    1.19  		Mfree(MINTAUDIO_audiobuf[0]);
    1.20 -		MINTAUDIO_audiobuf[0] = MINTAUDIO_audiobuf[1] = NULL;
    1.21 +		SDL_MintAudio_itbuffer = MINTAUDIO_audiobuf[0] = MINTAUDIO_audiobuf[1] = NULL;
    1.22  	}
    1.23  }
    1.24  
     2.1 --- a/src/audio/mint/SDL_mintaudio.h	Sun Jan 13 15:13:13 2019 +0100
     2.2 +++ b/src/audio/mint/SDL_mintaudio.h	Sun Jan 13 15:27:50 2019 +0100
     2.3 @@ -121,6 +121,10 @@
     2.4  extern volatile unsigned long SDL_MintAudio_clocktics;
     2.5  extern volatile unsigned long SDL_MintAudio_num_its;
     2.6  
     2.7 +extern volatile void *SDL_MintAudio_itbuffer;
     2.8 +extern volatile unsigned long SDL_MintAudio_itbuflen;
     2.9 +extern volatile unsigned long SDL_MintAudio_itsilence;
    2.10 +
    2.11  /* Functions */
    2.12  void SDL_MintAudio_XbiosInterruptMeasureClock(void);
    2.13  void SDL_MintAudio_XbiosInterrupt(void);
     3.1 --- a/src/audio/mint/SDL_mintaudio_it.S	Sun Jan 13 15:13:13 2019 +0100
     3.2 +++ b/src/audio/mint/SDL_mintaudio_it.S	Sun Jan 13 15:27:50 2019 +0100
     3.3 @@ -71,22 +71,47 @@
     3.4  
     3.5  _SDL_MintAudio_XbiosInterrupt:
     3.6  _SDL_MintAudio_Dma8Interrupt:
     3.7 +#if defined(__mcoldfire__)
     3.8 +	lea	sp@(-12),sp
     3.9 +	moveml	d0-d1/a0,sp@
    3.10 +#else
    3.11 +	moveml	d0-d1/a0,sp@-
    3.12 +#endif
    3.13  
    3.14  	/* Clear service bit, so other MFP interrupts can work */
    3.15  #if defined(__mcoldfire__)
    3.16 -	movel	d0,sp@-
    3.17 -
    3.18  	moveql	#5,d0
    3.19  	bclr	d0,0xfffffa0f:w
    3.20 -
    3.21 -	movel	sp@+,d0
    3.22  #else
    3.23  	bclr	#5,0xfffffa0f:w
    3.24  #endif
    3.25  
    3.26  _SDL_MintAudio_StfaInterrupt:
    3.27 -	addql	#1,_SDL_MintAudio_num_its
    3.28 +	move.l	_SDL_MintAudio_num_its,d0
    3.29 +	addql	#1,d0
    3.30 +	move.l	d0,_SDL_MintAudio_num_its
    3.31 + 
    3.32 +	cmp.l	#5,d0
    3.33 +	bmi.s	_SDL_MintAudio_nosilence
    3.34  
    3.35 +	move.l	_SDL_MintAudio_itbuffer,d1
    3.36 +	beq.s	_SDL_MintAudio_nosilence
    3.37 +	move.l	d1,a0
    3.38 +
    3.39 +	move.l	_SDL_MintAudio_itbuflen,d0
    3.40 +	move.l	_SDL_MintAudio_itsilence,d1
    3.41 +_SDL_MintAudio_fillsilence:
    3.42 +	move.l	d1,a0@+
    3.43 +	subq.l	#1,d0
    3.44 +	bpl.s	_SDL_MintAudio_fillsilence
    3.45 +
    3.46 +_SDL_MintAudio_nosilence:
    3.47 +#if defined(__mcoldfire__)
    3.48 +	moveml	sp@,d0-d1/a0
    3.49 +	lea	sp@(12),sp
    3.50 +#else
    3.51 +	moveml	sp@+,d0-d1/a0
    3.52 +#endif
    3.53  	rte
    3.54  
    3.55  	.bss
    3.56 @@ -94,3 +119,7 @@
    3.57  	.even
    3.58  	.comm	_SDL_MintAudio_clocktics,4
    3.59  	.comm	_SDL_MintAudio_num_its,4
    3.60 +
    3.61 +	.comm	_SDL_MintAudio_itbuffer,4	/* Audio DMA buffer */
    3.62 +	.comm	_SDL_MintAudio_itbuflen,4	/* Length in longword */
    3.63 +	.comm	_SDL_MintAudio_itsilence,4	/* Silence value */