Move the data around when the ring buffer is resized so that the empty
messages are between the tosave and toget indexes.
This commit is contained in:
parent
17b9837af4
commit
f7cae99969
|
@ -717,9 +717,22 @@ static int ALSA_AddRingMessage(ALSA_MSG_RING* omr, enum win_wm_message msg, DWOR
|
||||||
EnterCriticalSection(&omr->msg_crst);
|
EnterCriticalSection(&omr->msg_crst);
|
||||||
if ((omr->msg_toget == ((omr->msg_tosave + 1) % omr->ring_buffer_size)))
|
if ((omr->msg_toget == ((omr->msg_tosave + 1) % omr->ring_buffer_size)))
|
||||||
{
|
{
|
||||||
|
int old_ring_buffer_size = omr->ring_buffer_size;
|
||||||
omr->ring_buffer_size += ALSA_RING_BUFFER_INCREMENT;
|
omr->ring_buffer_size += ALSA_RING_BUFFER_INCREMENT;
|
||||||
TRACE("omr->ring_buffer_size=%d\n",omr->ring_buffer_size);
|
TRACE("omr->ring_buffer_size=%d\n",omr->ring_buffer_size);
|
||||||
omr->messages = HeapReAlloc(GetProcessHeap(),0,omr->messages, omr->ring_buffer_size * sizeof(ALSA_MSG));
|
omr->messages = HeapReAlloc(GetProcessHeap(),0,omr->messages, omr->ring_buffer_size * sizeof(ALSA_MSG));
|
||||||
|
/* Now we need to rearrange the ring buffer so that the new
|
||||||
|
buffers just allocated are in between omr->msg_tosave and
|
||||||
|
omr->msg_toget.
|
||||||
|
*/
|
||||||
|
if (omr->msg_tosave < omr->msg_toget)
|
||||||
|
{
|
||||||
|
memmove(&(omr->messages[omr->msg_toget + ALSA_RING_BUFFER_INCREMENT]),
|
||||||
|
&(omr->messages[omr->msg_toget]),
|
||||||
|
sizeof(ALSA_MSG)*(old_ring_buffer_size - omr->msg_toget)
|
||||||
|
);
|
||||||
|
omr->msg_toget += ALSA_RING_BUFFER_INCREMENT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (wait)
|
if (wait)
|
||||||
{
|
{
|
||||||
|
|
|
@ -454,9 +454,22 @@ static int NAS_AddRingMessage(MSG_RING* mr, enum win_wm_message msg, DWORD param
|
||||||
EnterCriticalSection(&mr->msg_crst);
|
EnterCriticalSection(&mr->msg_crst);
|
||||||
if ((mr->msg_toget == ((mr->msg_tosave + 1) % mr->ring_buffer_size)))
|
if ((mr->msg_toget == ((mr->msg_tosave + 1) % mr->ring_buffer_size)))
|
||||||
{
|
{
|
||||||
|
int old_ring_buffer_size = mr->ring_buffer_size;
|
||||||
mr->ring_buffer_size += NAS_RING_BUFFER_INCREMENT;
|
mr->ring_buffer_size += NAS_RING_BUFFER_INCREMENT;
|
||||||
TRACE("omr->ring_buffer_size=%d\n",mr->ring_buffer_size);
|
TRACE("omr->ring_buffer_size=%d\n",mr->ring_buffer_size);
|
||||||
mr->messages = HeapReAlloc(GetProcessHeap(),0,mr->messages, mr->ring_buffer_size * sizeof(RING_MSG));
|
mr->messages = HeapReAlloc(GetProcessHeap(),0,mr->messages, mr->ring_buffer_size * sizeof(RING_MSG));
|
||||||
|
/* Now we need to rearrange the ring buffer so that the new
|
||||||
|
buffers just allocated are in between mr->msg_tosave and
|
||||||
|
mr->msg_toget.
|
||||||
|
*/
|
||||||
|
if (mr->msg_tosave < mr->msg_toget)
|
||||||
|
{
|
||||||
|
memmove(&(mr->messages[mr->msg_toget + NAS_RING_BUFFER_INCREMENT]),
|
||||||
|
&(mr->messages[mr->msg_toget]),
|
||||||
|
sizeof(RING_MSG)*(old_ring_buffer_size - mr->msg_toget)
|
||||||
|
);
|
||||||
|
mr->msg_toget += NAS_RING_BUFFER_INCREMENT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (wait)
|
if (wait)
|
||||||
{
|
{
|
||||||
|
|
|
@ -909,9 +909,22 @@ static int OSS_AddRingMessage(OSS_MSG_RING* omr, enum win_wm_message msg, DWORD
|
||||||
EnterCriticalSection(&omr->msg_crst);
|
EnterCriticalSection(&omr->msg_crst);
|
||||||
if ((omr->msg_toget == ((omr->msg_tosave + 1) % omr->ring_buffer_size)))
|
if ((omr->msg_toget == ((omr->msg_tosave + 1) % omr->ring_buffer_size)))
|
||||||
{
|
{
|
||||||
|
int old_ring_buffer_size = omr->ring_buffer_size;
|
||||||
omr->ring_buffer_size += OSS_RING_BUFFER_INCREMENT;
|
omr->ring_buffer_size += OSS_RING_BUFFER_INCREMENT;
|
||||||
TRACE("omr->ring_buffer_size=%d\n",omr->ring_buffer_size);
|
TRACE("omr->ring_buffer_size=%d\n",omr->ring_buffer_size);
|
||||||
omr->messages = HeapReAlloc(GetProcessHeap(),0,omr->messages, omr->ring_buffer_size * sizeof(OSS_MSG));
|
omr->messages = HeapReAlloc(GetProcessHeap(),0,omr->messages, omr->ring_buffer_size * sizeof(OSS_MSG));
|
||||||
|
/* Now we need to rearrange the ring buffer so that the new
|
||||||
|
buffers just allocated are in between omr->msg_tosave and
|
||||||
|
omr->msg_toget.
|
||||||
|
*/
|
||||||
|
if (omr->msg_tosave < omr->msg_toget)
|
||||||
|
{
|
||||||
|
memmove(&(omr->messages[omr->msg_toget + OSS_RING_BUFFER_INCREMENT]),
|
||||||
|
&(omr->messages[omr->msg_toget]),
|
||||||
|
sizeof(OSS_MSG)*(old_ring_buffer_size - omr->msg_toget)
|
||||||
|
);
|
||||||
|
omr->msg_toget += OSS_RING_BUFFER_INCREMENT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (wait)
|
if (wait)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue