--- uae/src/sd-mme/sound.c 2018/04/24 16:42:38 1.1.1.1 +++ uae/src/sd-mme/sound.c 2018/04/24 17:14:58 1.1.1.4 @@ -1,8 +1,8 @@ - /* + /* * UAE - The Un*x Amiga Emulator - * + * * Support for Digital Unix/MME - * + * * Copyright 1997 Marcus Sundberg */ @@ -12,6 +12,7 @@ #include "config.h" #include "options.h" #include "memory.h" +#include "events.h" #include "custom.h" #include "audio.h" #include "gensound.h" @@ -88,15 +89,15 @@ int init_sound (void) fprintf(stderr, "Sound buffer size %d out of range.\n", currprefs.sound_maxbsiz); currprefs.sound_maxbsiz = 8192; } - + sndbufsize = currprefs.sound_maxbsiz; dspbits = currprefs.sound_bits; rate = currprefs.sound_freq; - + channels = 1; - + if((waveformat = (LPPCMWAVEFORMAT) mmeAllocMem(sizeof(PCMWAVEFORMAT))) == NULL ) { fprintf(stderr, "Failed to allocate PCMWAVEFORMAT struct\n"); @@ -106,13 +107,13 @@ int init_sound (void) waveformat->wf.nChannels = channels; waveformat->wBitsPerSample = dspbits; waveformat->wf.wFormatTag = WAVE_FORMAT_PCM; - + bytes_per_sample = waveformat->wf.nChannels * (waveformat->wBitsPerSample/8); waveformat->wf.nBlockAlign = bytes_per_sample; waveformat->wf.nAvgBytesPerSec = bytes_per_sample * waveformat->wf.nSamplesPerSec; - + /* Open the audio device with desired rate/format */ status = waveOutOpen( &mme_handle, WAVE_MAPPER, @@ -121,12 +122,12 @@ int init_sound (void) (unsigned int)NULL, CALLBACK_FUNCTION | WAVE_OPEN_SHAREABLE ); mmeFreeMem(waveformat); - + if(status != MMSYSERR_NOERROR) { fprintf(stderr, "waveOutOpen failed - status = %d\n", status); return 0; } - + /* Allocate wave header for use in write */ if((WaveHeader = (LPWAVEHDR) mmeAllocMem(sizeof(WAVEHDR))) == NULL ) { @@ -141,7 +142,8 @@ int init_sound (void) return 0; } sndbuffer = mme_audiobuf; - sample_evtime = (long)maxhpos * maxvpos * 50 / rate; + scaled_sample_evtime = (unsigned long)MAXHPOS_PAL * MAXVPOS_PAL * VBLANK_HZ_PAL * CYCLE_UNIT / rate; + scaled_sample_evtime_ok = 1; if (dspbits == 16) { init_sound_table16 ();