From f1bd3a86f49f7aac16c88204ef0e803c75659290 Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Sat, 7 Nov 2009 09:54:51 +0000 Subject: [PATCH] More sound fixes --- Src/Network.cpp | 3 +++ Src/SID_linux.h | 15 ++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Src/Network.cpp b/Src/Network.cpp index 8c7dfe8..1cc71db 100644 --- a/Src/Network.cpp +++ b/Src/Network.cpp @@ -405,6 +405,8 @@ void Network::EnqueueSound(uint32 linecnt_diff, uint8 adr, uint8 val) { NetworkUpdateSoundInfo *cur = &this->sound_active[this->sound_head]; + if (linecnt_diff > 255) + linecnt_diff = 255; cur->adr = adr; cur->val = val; cur->delay_cycles = linecnt_diff; @@ -424,6 +426,7 @@ void Network::RegisterSidWrite(uint32 linecnt, uint8 adr, uint8 val) { this->EnqueueSound(linecnt - this->sound_last_cycles, adr, val); + printf("Enqueuing write: %d\n", linecnt - this->sound_last_cycles); /* Update the cycle counter */ sound_last_cycles = linecnt; bytes += sizeof(NetworkUpdateSound); diff --git a/Src/SID_linux.h b/Src/SID_linux.h index 99765c3..a72de5e 100644 --- a/Src/SID_linux.h +++ b/Src/SID_linux.h @@ -143,25 +143,30 @@ void DigitalRenderer::PushVolume(uint8 vol) void DigitalRenderer::EmulateLine(void) { - if (!ready) - return; +// if (!ready) + //return; /* Flush network sound every ~100ms */ if (TheC64->network_connection_type == CLIENT) { static NetworkUpdateSoundInfo *cur = NULL; - if (!cur) + if (!cur) { cur = TheC64->peer->DequeueSound(); + if (cur) + printf("delaying: %d\n", cur->delay_cycles); + } while (cur) { - printf("Delaying for %d cycles\n", cur->delay_cycles); - cur->delay_cycles--; if (cur->delay_cycles > 0) + cur->delay_cycles--; + if (cur->delay_cycles != 0) break; /* Delayed long enough - write to the SID! */ printf("Writing %02x:%02x\n", cur->adr, cur->val); this->WriteRegister(cur->adr, cur->val); cur = TheC64->peer->DequeueSound(); + if (cur) + printf("delay 2: %d\n", cur->delay_cycles); } } this->PushVolume(volume);