]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Partial audio future plans, mostly disabled for now.
authorToni Wilen <twilen@winuae.net>
Sat, 29 Nov 2025 11:19:51 +0000 (13:19 +0200)
committerToni Wilen <twilen@winuae.net>
Sat, 29 Nov 2025 11:19:51 +0000 (13:19 +0200)
audio.cpp
custom.cpp
include/audio.h
od-win32/sounddep/sound.cpp
od-win32/sounddep/sound.h
od-win32/win32.cpp

index 0cd0e911b20f88f70556e42dbc7b4c3939259092..3d4c6ac43e1e0e07281708b3a923634937f4d765 100644 (file)
--- a/audio.cpp
+++ b/audio.cpp
@@ -825,9 +825,15 @@ static void check_sound_buffers(void)
                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);
index 4314f548d60e53d1db159d28c028fc97675762ba..0b05f3753dd77b44b9e10a9432c327c93b4cd95c 100644 (file)
@@ -4903,6 +4903,9 @@ static bool framewait(void)
 
                        while (rpt_vsync(clockadjust) < 0) {
                                rtg_vsynccheck();
+#if 0
+                               audio_is_pull_event();
+#endif
 #if 0
                                if (audio_is_pull_event()) {
                                        maybe_process_pull_audio();
index c893652c5cb23312532d04a6fd6c9ce973e64d0e..a0f58d57a182101e73affb3363856f96cc4b357f 100644 (file)
@@ -47,6 +47,7 @@ int audio_pull_buffer(void);
 bool audio_finish_pull(void);
 bool audio_is_pull_event(void);
 bool audio_is_event_frame_possible(int);
+void audio_got_pull_event(void);
 
 extern int sampleripper_enabled;
 
index 4d08ec84b783ead0f5f86d553c2e3249cde755d5..8ad6cb7d5e60c4072dd7e04dd4bae55f2d9bea7b 100644 (file)
@@ -110,6 +110,7 @@ struct sound_dp
        uae_u8 *pullbuffer;
        int pullbufferlen;
        int pullbuffermaxlen;
+       bool gotpullevent;
 
 #if USE_XAUDIO
        // xaudio2
@@ -148,7 +149,11 @@ static int statuscnt;
 #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;
@@ -2366,6 +2371,8 @@ static bool finish_sound_buffer_wasapi_pull_do(struct sound_data *sd)
        HRESULT hr;
        BYTE *pData;
 
+       s->gotpullevent = false;
+
        if (s->pullbufferlen <= 0)
                return false;
 
@@ -2634,6 +2641,7 @@ static bool send_sound_do(struct sound_data *sd)
                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);
        }
@@ -2681,18 +2689,36 @@ HANDLE get_sound_event(void)
        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;
 }
@@ -2738,7 +2764,14 @@ bool audio_is_pull_event(void)
        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;
index b13c425faf25cc05b484d8605ecbcd663896e33d..5ed55ac1b2d045df3f6f7a7bc8ada2a8f0113fae 100644 (file)
@@ -7,6 +7,7 @@
 */
 
 #define SOUNDSTUFF 1
+#define SOUND_MODE_NG 0
 
 extern uae_u16 paula_sndbuffer[];
 extern uae_u16 *paula_sndbufpt;
index d13b5c3b71645f439b771dd7c0209fbcf819cb82..c040b2e7f70db1a65208ced51468033032568aac 100644 (file)
@@ -468,18 +468,20 @@ static int sleep_millis2 (int ms, bool main)
        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;
                                }
                        }
@@ -521,10 +523,13 @@ static int sleep_millis2 (int ms, bool main)
                        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);