Remove current sound implementation (doesn't work anyway)

This commit is contained in:
simon.kagstrom 2009-11-04 17:12:20 +00:00
parent 3ba94e90c5
commit 3a72e6a87c
4 changed files with 4 additions and 180 deletions

View File

@ -548,7 +548,6 @@ void C64::network_vblank()
remote->EncodeTextMessage(msg);
remote->EncodeJoystickUpdate(*js);
remote->EncodeSound();
if (remote->SendUpdate() == false)
{

View File

@ -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)

View File

@ -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;
};

View File

@ -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];