mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-22 19:39:24 +01:00
Transfer only larger sound buffers
This commit is contained in:
parent
852c6d546a
commit
7c216605bc
@ -132,6 +132,9 @@ size_t Network::EncodeSoundRLE(struct NetworkUpdate *dst,
|
|||||||
volume = buffer[i];
|
volume = buffer[i];
|
||||||
}
|
}
|
||||||
len++;
|
len++;
|
||||||
|
/* Abort if the encoding becomes larger than the raw encoding */
|
||||||
|
if (len >= buf_len)
|
||||||
|
return buf_len + 2;
|
||||||
}
|
}
|
||||||
if (len != 0)
|
if (len != 0)
|
||||||
{
|
{
|
||||||
@ -406,10 +409,16 @@ size_t Network::EncodeSoundBuffer(struct NetworkUpdate *dst, Uint8 *buf, size_t
|
|||||||
out = this->EncodeSoundRLE(dst, buf, len);
|
out = this->EncodeSoundRLE(dst, buf, len);
|
||||||
if (out > len)
|
if (out > len)
|
||||||
out = this->EncodeSoundRaw(dst, buf, len);
|
out = this->EncodeSoundRaw(dst, buf, len);
|
||||||
|
|
||||||
return out;
|
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::EncodeSound()
|
void Network::EncodeSound()
|
||||||
{
|
{
|
||||||
NetworkUpdate *dst = (NetworkUpdate *)this->cur_ud;
|
NetworkUpdate *dst = (NetworkUpdate *)this->cur_ud;
|
||||||
@ -418,7 +427,7 @@ void Network::EncodeSound()
|
|||||||
|
|
||||||
/* Nothing to encode? */
|
/* Nothing to encode? */
|
||||||
if (!Network::is_master ||
|
if (!Network::is_master ||
|
||||||
Network::sample_head == Network::sample_tail)
|
this->GetSoundBufferSize() < NETWORK_SOUND_BUF_SIZE / 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Network::sample_tail > Network::sample_head)
|
if (Network::sample_tail > Network::sample_head)
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#define FRODO_NETWORK_MAGIC 0x1976
|
#define FRODO_NETWORK_MAGIC 0x1976
|
||||||
|
|
||||||
#define NETWORK_UPDATE_SIZE (256 * 1024)
|
#define NETWORK_UPDATE_SIZE (256 * 1024)
|
||||||
#define NETWORK_SOUND_BUF_SIZE 1024
|
#define NETWORK_SOUND_BUF_SIZE 4096
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
/* Connection-related messages */
|
/* Connection-related messages */
|
||||||
@ -216,6 +216,8 @@ protected:
|
|||||||
size_t EncodeSoundRaw(struct NetworkUpdate *dst,
|
size_t EncodeSoundRaw(struct NetworkUpdate *dst,
|
||||||
Uint8 *buffer, size_t len);
|
Uint8 *buffer, size_t len);
|
||||||
|
|
||||||
|
size_t GetSoundBufferSize();
|
||||||
|
|
||||||
/** Encode part of a screen into @a dst in a single sweep
|
/** Encode part of a screen into @a dst in a single sweep
|
||||||
*
|
*
|
||||||
* @param dst the destination update structure
|
* @param dst the destination update structure
|
||||||
|
Loading…
Reference in New Issue
Block a user