Fix sending of the data

This commit is contained in:
simon.kagstrom 2009-11-07 08:32:51 +00:00
parent 1a9c4b8c1d
commit f4357b88bd
3 changed files with 5 additions and 9 deletions

View File

@ -536,6 +536,7 @@ void C64::network_vblank()
* if this is the master or not) */
if (this->network_connection_type == MASTER)
{
remote->FlushSound();
/* Skip this frame if the data rate is too high */
if (remote->ThrottleTraffic())
has_throttled = true;

View File

@ -415,7 +415,7 @@ void Network::EnqueueSound(uint32 linecnt_diff, uint8 adr, uint8 val)
this->sound_head = 0;
/* Head has reached tail */
if (this->sound_head >= this->sound_tail)
if (this->sound_head == this->sound_tail)
this->sound_tail = (this->sound_head + 1) % NETWORK_SOUND_BUF_SIZE;
}
@ -453,11 +453,9 @@ void Network::FlushSound(void)
}
this->sound_tail = (this->sound_tail + snd->n_items) % NETWORK_SOUND_BUF_SIZE;
/* Reset the buffer again */
printf("Flushing sound (%d bytes in %d ms)\n", bytes, SDL_GetTicks() - this->sound_last_send);
this->sound_last_send = SDL_GetTicks();
InitNetworkUpdate(dst, SOUND_UPDATE,
InitNetworkUpdate(dst, SOUND_UPDATE, sizeof(NetworkUpdate) +
sizeof(NetworkUpdateSound) + sizeof(NetworkUpdateSoundInfo) * snd->n_items);
this->AddNetworkUpdate(dst);
@ -811,7 +809,7 @@ bool Network::DeMarshalData(NetworkUpdate *p)
cur->delay_cycles = ntohs(cur->delay_cycles);
}
}
} break;
default:
/* Unknown data... */
printf("Got unknown data: %d\n", p->type);

View File

@ -146,10 +146,7 @@ void DigitalRenderer::EmulateLine(void)
if (!ready)
return;
/* Flush network sound every ~100ms */
if (TheC64->network_connection_type == MASTER &&
this->linecnt % 2048 == 0)
TheC64->peer->FlushSound();
else if (TheC64->network_connection_type == CLIENT)
if (TheC64->network_connection_type == CLIENT)
{
static NetworkUpdateSoundInfo *cur = NULL;