From ecec8b6134dce69866bf8c79381ee9892e495696 Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Sat, 7 Nov 2009 14:13:21 +0000 Subject: [PATCH] Move network-related sound stuff to common code (so that it will work on all platforms) --- Src/SID.cpp | 29 +++++++++++++++++++++++++++++ Src/SID.h | 11 ----------- Src/SID_linux.h | 25 ++----------------------- 3 files changed, 31 insertions(+), 34 deletions(-) diff --git a/Src/SID.cpp b/Src/SID.cpp index e1b936f..edf19b7 100644 --- a/Src/SID.cpp +++ b/Src/SID.cpp @@ -912,6 +912,35 @@ void DigitalRenderer::Reset(void) #include "C64.h" extern C64 *TheC64; +/* + * Fill buffer (for Unix sound routines), sample volume (for sampled voice) + */ + +void MOS6581::EmulateLine(void) +{ + if (the_renderer != NULL) + the_renderer->EmulateLine(); + /* Flush network sound every ~100ms */ + if (TheC64->network_connection_type == CLIENT) + { + static NetworkUpdateSoundInfo *cur = NULL; + + if (!cur) { + cur = TheC64->peer->DequeueSound(); + } + + while (cur) { + if (cur->delay_cycles > 0) + cur->delay_cycles--; + if (cur->delay_cycles != 0) + break; + /* Delayed long enough - write to the SID! */ + this->WriteRegister(cur->adr, cur->val); + cur = TheC64->peer->DequeueSound(); + } + } + TheC64->linecnt++; +} void DigitalRenderer::WriteRegister(uint16 adr, uint8 byte) { diff --git a/Src/SID.h b/Src/SID.h index 3523096..4d44d04 100644 --- a/Src/SID.h +++ b/Src/SID.h @@ -113,17 +113,6 @@ struct MOS6581State { }; -/* - * Fill buffer (for Unix sound routines), sample volume (for sampled voice) - */ - -inline void MOS6581::EmulateLine(void) -{ - if (the_renderer != NULL) - the_renderer->EmulateLine(); -} - - inline void MOS6581::PushVolume(uint8 vol) { if (the_renderer != NULL) diff --git a/Src/SID_linux.h b/Src/SID_linux.h index aa81189..c2695c4 100644 --- a/Src/SID_linux.h +++ b/Src/SID_linux.h @@ -142,30 +142,9 @@ void DigitalRenderer::PushVolume(uint8 vol) void DigitalRenderer::EmulateLine(void) { -// if (!ready) - //return; - /* Flush network sound every ~100ms */ - if (TheC64->network_connection_type == CLIENT) - { - static NetworkUpdateSoundInfo *cur = NULL; - - if (!cur) { - cur = TheC64->peer->DequeueSound(); - } - - while (cur) { - 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 (!ready) + return; this->PushVolume(volume); - TheC64->linecnt++; }