Commit f7cae999 authored by Jeremy Shaw's avatar Jeremy Shaw Committed by Alexandre Julliard

Move the data around when the ring buffer is resized so that the empty

messages are between the tosave and toget indexes.
parent 17b9837a
......@@ -717,9 +717,22 @@ static int ALSA_AddRingMessage(ALSA_MSG_RING* omr, enum win_wm_message msg, DWOR
EnterCriticalSection(&omr->msg_crst);
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;
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));
/* 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)
{
......
......@@ -454,9 +454,22 @@ static int NAS_AddRingMessage(MSG_RING* mr, enum win_wm_message msg, DWORD param
EnterCriticalSection(&mr->msg_crst);
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;
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));
/* 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)
{
......
......@@ -909,9 +909,22 @@ static int OSS_AddRingMessage(OSS_MSG_RING* omr, enum win_wm_message msg, DWORD
EnterCriticalSection(&omr->msg_crst);
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;
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));
/* 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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment