More sound fixes

This commit is contained in:
simon.kagstrom 2009-11-07 09:54:51 +00:00
parent 4946f709c3
commit f1bd3a86f4
2 changed files with 13 additions and 5 deletions

View File

@ -405,6 +405,8 @@ void Network::EnqueueSound(uint32 linecnt_diff, uint8 adr, uint8 val)
{ {
NetworkUpdateSoundInfo *cur = &this->sound_active[this->sound_head]; NetworkUpdateSoundInfo *cur = &this->sound_active[this->sound_head];
if (linecnt_diff > 255)
linecnt_diff = 255;
cur->adr = adr; cur->adr = adr;
cur->val = val; cur->val = val;
cur->delay_cycles = linecnt_diff; 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); this->EnqueueSound(linecnt - this->sound_last_cycles, adr, val);
printf("Enqueuing write: %d\n", linecnt - this->sound_last_cycles);
/* Update the cycle counter */ /* Update the cycle counter */
sound_last_cycles = linecnt; sound_last_cycles = linecnt;
bytes += sizeof(NetworkUpdateSound); bytes += sizeof(NetworkUpdateSound);

View File

@ -143,25 +143,30 @@ void DigitalRenderer::PushVolume(uint8 vol)
void DigitalRenderer::EmulateLine(void) void DigitalRenderer::EmulateLine(void)
{ {
if (!ready) // if (!ready)
return; //return;
/* Flush network sound every ~100ms */ /* Flush network sound every ~100ms */
if (TheC64->network_connection_type == CLIENT) if (TheC64->network_connection_type == CLIENT)
{ {
static NetworkUpdateSoundInfo *cur = NULL; static NetworkUpdateSoundInfo *cur = NULL;
if (!cur) if (!cur) {
cur = TheC64->peer->DequeueSound(); cur = TheC64->peer->DequeueSound();
if (cur)
printf("delaying: %d\n", cur->delay_cycles);
}
while (cur) { while (cur) {
printf("Delaying for %d cycles\n", cur->delay_cycles);
cur->delay_cycles--;
if (cur->delay_cycles > 0) if (cur->delay_cycles > 0)
cur->delay_cycles--;
if (cur->delay_cycles != 0)
break; break;
/* Delayed long enough - write to the SID! */ /* Delayed long enough - write to the SID! */
printf("Writing %02x:%02x\n", cur->adr, cur->val); printf("Writing %02x:%02x\n", cur->adr, cur->val);
this->WriteRegister(cur->adr, cur->val); this->WriteRegister(cur->adr, cur->val);
cur = TheC64->peer->DequeueSound(); cur = TheC64->peer->DequeueSound();
if (cur)
printf("delay 2: %d\n", cur->delay_cycles);
} }
} }
this->PushVolume(volume); this->PushVolume(volume);