paula_sndbufpt = paula_sndbufpt_start;
}
#endif
+#if SOUND_MODE_NG
+ if ((uae_u8*)paula_sndbufpt - (uae_u8*)paula_sndbuffer >= paula_sndbufsize * 2) {
+ paula_sndbufpt = paula_sndbuffer;
+ }
+#else
if ((uae_u8*)paula_sndbufpt - (uae_u8*)paula_sndbuffer >= paula_sndbufsize) {
finish_sound_buffer();
}
+#endif
#if SOUNDSTUFF > 1
while (doublesample-- > 0) {
memcpy(paula_sndbufpt, paula_sndbufpt_start, len * 2);
uae_u8 *pullbuffer;
int pullbufferlen;
int pullbuffermaxlen;
+ bool gotpullevent;
#if USE_XAUDIO
// xaudio2
#define SND_MAX_BUFFER2 524288
#define SND_MAX_BUFFER 65536
+#if SOUND_MODE_NG
+uae_u16 paula_sndbuffer[SND_MAX_BUFFER * 2 + 8];
+#else
uae_u16 paula_sndbuffer[SND_MAX_BUFFER];
+#endif
uae_u16 *paula_sndbufpt;
int paula_sndbufsize;
int active_sound_stereo;
HRESULT hr;
BYTE *pData;
+ s->gotpullevent = false;
+
if (s->pullbufferlen <= 0)
return false;
return finish_sound_buffer_wasapi_pull_do(sd);
} else if (type == SOUND_DEVICE_PA) {
struct sound_dp *s = sd->data;
+ s->gotpullevent = false;
ResetEvent(s->pullevent);
SetEvent(s->pullevent2);
}
return 0;
}
+static frame_time_t prevtime;
+
+void audio_got_pull_event(void)
+{
+ struct sound_dp *s = sdp->data;
+ if (s && !s->gotpullevent) {
+ frame_time_t cyc = read_processor_time();
+ //write_log("%lld\n", cyc - prevtime);
+ prevtime = cyc;
+ s->gotpullevent = true;
+ }
+}
+
bool audio_is_event_frame_possible(int ms)
{
int type = sdp->devicetype;
- if (sdp->paused || sdp->deactive || sdp->reset)
+ if (sdp->paused || sdp->deactive || sdp->reset) {
return false;
+ }
if (type == SOUND_DEVICE_WASAPI || type == SOUND_DEVICE_WASAPI_EXCLUSIVE || type == SOUND_DEVICE_PA) {
+#if 0
+ return true;
+#else
struct sound_dp *s = sdp->data;
int bufsize = (int)((uae_u8*)paula_sndbufpt - (uae_u8*)paula_sndbuffer);
bufsize /= sdp->samplesize;
int todo = s->bufferFrameCount - bufsize;
int samplesperframe = (int)(sdp->obtainedfreq / vblank_hz);
return samplesperframe >= todo - samplesperframe;
+#endif
}
return false;
}
if (type == SOUND_DEVICE_WASAPI || type == SOUND_DEVICE_WASAPI_EXCLUSIVE || type == SOUND_DEVICE_PA) {
struct sound_dp *s = sdp->data;
if (s->pullmode) {
- return WaitForSingleObject(s->pullevent, 0) == WAIT_OBJECT_0;
+ if (!s->gotpullevent) {
+ if (WaitForSingleObject(s->pullevent, 0) == WAIT_OBJECT_0) {
+ audio_got_pull_event();
+ return true;
+ }
+ return false;
+ }
+ return true;
}
}
return false;
HANDLE sound_event = get_sound_event();
bool wasneg = ms < 0;
bool pullcheck = false;
+
int ret = 0;
if (ms < 0)
ms = -ms;
if (main) {
if (sound_event) {
- bool pullcheck = audio_is_event_frame_possible(ms);
+ pullcheck = audio_is_event_frame_possible(ms);
if (pullcheck) {
if (WaitForSingleObject(sound_event, 0) == WAIT_OBJECT_0) {
if (wasneg) {
write_log(_T("efw %d imm abort\n"), ms);
}
+ audio_got_pull_event();
return -1;
}
}
evt[c++] = sound_event;
}
DWORD status = WaitForMultipleObjects(c, evt, FALSE, ms);
- if (sound_event_cnt >= 0 && status == WAIT_OBJECT_0 + sound_event_cnt)
+ if (sound_event_cnt >= 0 && status == WAIT_OBJECT_0 + sound_event_cnt) {
ret = -1;
- if (vblank_event_cnt >= 0 && status == WAIT_OBJECT_0 + vblank_event_cnt)
+ audio_got_pull_event();
+ }
+ if (vblank_event_cnt >= 0 && status == WAIT_OBJECT_0 + vblank_event_cnt) {
ret = -1;
+ }
if (wasneg) {
if (sound_event_cnt >= 0 && status == WAIT_OBJECT_0 + sound_event_cnt) {
write_log(_T("efw %d delayed abort\n"), ms);