From 3a72e6a87c9cfa9a25b41aceab49b8096f48b9c7 Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Wed, 4 Nov 2009 17:12:20 +0000 Subject: [PATCH] Remove current sound implementation (doesn't work anyway) --- Src/C64_SDL.h | 1 - Src/Network.cpp | 148 +----------------------------------------------- Src/Network.h | 34 +---------- Src/SID.cpp | 1 - 4 files changed, 4 insertions(+), 180 deletions(-) diff --git a/Src/C64_SDL.h b/Src/C64_SDL.h index 04e2606..eade45c 100644 --- a/Src/C64_SDL.h +++ b/Src/C64_SDL.h @@ -548,7 +548,6 @@ void C64::network_vblank() remote->EncodeTextMessage(msg); remote->EncodeJoystickUpdate(*js); - remote->EncodeSound(); if (remote->SendUpdate() == false) { diff --git a/Src/Network.cpp b/Src/Network.cpp index 43dd3a5..ebb94af 100644 --- a/Src/Network.cpp +++ b/Src/Network.cpp @@ -114,53 +114,6 @@ void Network::Tick(int ms) this->last_traffic = this->traffic; } -size_t Network::EncodeSoundRLE(struct NetworkUpdate *dst, - Uint8 *buffer, size_t buf_len) -{ - size_t out = 0; - size_t len = 0; - Uint8 volume = buffer[0]; - - dst->type = SOUND_UPDATE_RLE; - - for (unsigned int i = 0; i < buf_len; i++) - { - if (volume != buffer[i] || - len >= 255) - { - dst->data[out] = len; - dst->data[out + 1] = volume; - out += 2; - - len = 0; - volume = buffer[i]; - } - len++; - /* Abort if the encoding becomes larger than the raw encoding */ - if (len >= buf_len) - return buf_len + 2; - } - if (len != 0) - { - dst->data[out] = len; - dst->data[out + 1] = volume; - - out += 2; - } - InitNetworkUpdate(dst, SOUND_UPDATE_RLE, - sizeof(struct NetworkUpdate) + out); - - return out; -} - -size_t Network::EncodeSoundRaw(struct NetworkUpdate *dst, - Uint8 *buffer, size_t len) -{ - InitNetworkUpdate(dst, SOUND_UPDATE_RAW, - sizeof(struct NetworkUpdate) + len); - return len; -} - bool Network::DecodeDisplayDiff(struct NetworkUpdate *src, int x_start, int y_start) { @@ -428,24 +381,6 @@ bool Network::DecodeDisplayUpdate(struct NetworkUpdate *src) return false; } -size_t Network::EncodeSoundBuffer(struct NetworkUpdate *dst, Uint8 *buf, size_t len) -{ - size_t out; - - /* Try encoding as RLE, but if it's too large, go for RAW */ - out = this->EncodeSoundRLE(dst, buf, len); - if (out > len) - out = this->EncodeSoundRaw(dst, buf, len); - return out; -} - -size_t Network::GetSoundBufferSize() -{ - if (Network::sample_tail > Network::sample_head) - return NETWORK_SOUND_BUF_SIZE - Network::sample_tail + Network::sample_head; - return Network::sample_head- Network::sample_tail; -} - void Network::EncodeTextMessage(char *str) { NetworkUpdate *dst = (NetworkUpdate *)this->cur_ud; @@ -461,40 +396,6 @@ void Network::EncodeTextMessage(char *str) this->AddNetworkUpdate(dst); } -void Network::EncodeSound() -{ - NetworkUpdate *dst = (NetworkUpdate *)this->cur_ud; - static Uint8 tmp_buf[NETWORK_SOUND_BUF_SIZE]; - int offset = 0; - - /* This is not enabled yet... */ - return; - /* Nothing to encode? */ - if (this->network_connection_state != MASTER || - this->GetSoundBufferSize() < NETWORK_SOUND_BUF_SIZE / 2) - return; - - if (Network::sample_tail > Network::sample_head) - { - memcpy(tmp_buf + offset, Network::sample_buf + Network::sample_tail, - NETWORK_SOUND_BUF_SIZE - Network::sample_tail); - offset += NETWORK_SOUND_BUF_SIZE - Network::sample_tail; - Network::sample_tail = 0; - } - memcpy(tmp_buf + offset, Network::sample_buf + Network::sample_tail, - Network::sample_head - Network::sample_tail); - offset += Network::sample_head - Network::sample_tail; - Network::sample_tail = Network::sample_head; - - this->EncodeSoundBuffer(dst, tmp_buf, offset); - this->AddNetworkUpdate(dst); -} - -void Network::PushSound(uint8 vol) -{ - Network::sample_buf[Network::sample_head] = vol; - Network::sample_head = (Network::sample_head + 1) % NETWORK_SOUND_BUF_SIZE; -} void Network::EncodeJoystickUpdate(Uint8 v) { @@ -511,41 +412,6 @@ void Network::EncodeJoystickUpdate(Uint8 v) this->cur_joystick_data = v; } -size_t Network::DecodeSoundRLE(struct NetworkUpdate *src, MOS6581 *dst) -{ - int p = 0; - int sz = src->size - sizeof(NetworkUpdate); - - while (p < sz) - { - Uint8 len = src->data[p + 0]; - Uint8 volume = src->data[p + 1]; - - while (len > 0) - { - dst->PushVolume(volume); - len--; - } - p += 2; - } -} - -size_t Network::DecodeSoundUpdate(struct NetworkUpdate *src, MOS6581 *dst) -{ - size_t out; - - if (src->type == SOUND_UPDATE_RAW) - { - out = src->size - sizeof(struct NetworkUpdate); - for (int i = 0; i < out; i++) - dst->PushVolume(src->data[i]); - } - else if (src->type == SOUND_UPDATE_RLE) - out = this->DecodeSoundRLE(src, dst); - - return out; -} - void Network::ResetNetworkUpdate(void) { memset(this->ud, 0, NETWORK_UPDATE_SIZE); @@ -712,8 +578,7 @@ bool Network::MarshalData(NetworkUpdate *p) case DISPLAY_UPDATE_RAW: case DISPLAY_UPDATE_RLE: case DISPLAY_UPDATE_DIFF: - case SOUND_UPDATE_RAW: - case SOUND_UPDATE_RLE: + case SOUND_UPDATE: case JOYSTICK_UPDATE: case DISCONNECT: case CONNECT_TO_PEER: @@ -804,8 +669,7 @@ bool Network::DeMarshalData(NetworkUpdate *p) case DISPLAY_UPDATE_RAW: case DISPLAY_UPDATE_RLE: case DISPLAY_UPDATE_DIFF: - case SOUND_UPDATE_RAW: - case SOUND_UPDATE_RLE: + case SOUND_UPDATE: case JOYSTICK_UPDATE: case DISCONNECT: case CONNECT_TO_PEER: @@ -883,13 +747,10 @@ bool Network::DecodeUpdate(C64Display *display, uint8 *js, MOS6581 *dst) { switch(p->type) { - case SOUND_UPDATE_RAW: - case SOUND_UPDATE_RLE: + case SOUND_UPDATE: /* No sound updates _to_ the master */ if (this->network_connection_state == MASTER) break; - if (this->DecodeSoundUpdate(p, dst) == false) - out = false; break; case DISPLAY_UPDATE_RAW: case DISPLAY_UPDATE_RLE: @@ -1225,9 +1086,6 @@ void Network::Disconnect() this->SendUpdate(); } -uint8 Network::sample_buf[NETWORK_SOUND_BUF_SIZE]; -int Network::sample_head; -int Network::sample_tail; bool Network::networking_started = false; #if defined(GEKKO) diff --git a/Src/Network.h b/Src/Network.h index 275ce56..39a318a 100644 --- a/Src/Network.h +++ b/Src/Network.h @@ -44,6 +44,7 @@ typedef enum JOYSTICK_UPDATE = 7, ENTER_MENU = 8, TEXT_MESSAGE = 9, + SOUND_UPDATE = 10, } network_message_type_t; typedef enum @@ -170,8 +171,6 @@ public: ~Network(); - void EncodeSound(); - void EncodeScreenshot(Uint8 *dst, Uint8 *master); void EncodeDisplay(Uint8 *master, Uint8 *remote); @@ -226,25 +225,12 @@ public: */ void Disconnect(); - static void PushSound(uint8 vol); - bool is_master; /* Some peers are more equal than others */ protected: void InitNetwork(); void ShutdownNetwork(); - size_t DecodeSoundRLE(struct NetworkUpdate *src, MOS6581 *dst); - - size_t DecodeSoundUpdate(struct NetworkUpdate *src, MOS6581 *dst); - - size_t EncodeSoundRLE(struct NetworkUpdate *dst, - Uint8 *buffer, size_t len); - size_t EncodeSoundRaw(struct NetworkUpdate *dst, - Uint8 *buffer, size_t len); - - size_t GetSoundBufferSize(); - /** Encode part of a screen into @a dst in a single sweep * * @param dst the destination update structure @@ -258,18 +244,6 @@ protected: Uint8 *screen, Uint8 *remote, int square, bool use_diff = true); - /** - * Encode the @a buf sound buffer into @a dst - * - * @param dst the destination update structure - * @param buf the buffer to encode - * @param len the length of the in-buffer - * - * @return the size of the encoded message - */ - size_t EncodeSoundBuffer(struct NetworkUpdate *dst, - Uint8 *buf, size_t len); - /** * Decode a display update message onto @a screen * @@ -358,7 +332,6 @@ protected: Uint8 *raw_buf; Uint8 *rle_buf; Uint8 *diff_buf; - Uint8 *sound_buf; Uint8 screenshot[SCREENSHOT_X * SCREENSHOT_Y / 2]; Uint32 *square_updated; @@ -383,11 +356,6 @@ protected: network_connection_state_t network_connection_state; - /* Sound */ - static uint8 sample_buf[NETWORK_SOUND_BUF_SIZE]; - static int sample_head; - static int sample_tail; - public: static bool networking_started; }; diff --git a/Src/SID.cpp b/Src/SID.cpp index cdb8412..64aaa31 100644 --- a/Src/SID.cpp +++ b/Src/SID.cpp @@ -1210,7 +1210,6 @@ void DigitalRenderer::calc_buffer(int16 *buf, long count) int32 sum_output = SampleTab[master_volume] << 8; int32 sum_output_filter = 0; - Network::PushSound(master_volume); // Loop for all three voices for (int j=0; j<3; j++) { DRVoice *v = &voice[j];