Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/winepulse.drv/mmdevdrv.c | 92 +------------------------------ dlls/winepulse.drv/pulse.c | 101 ++++++++++++++++++++++++++++++++++ dlls/winepulse.drv/unixlib.h | 1 + 3 files changed, 103 insertions(+), 91 deletions(-)
Signed-off-by: Andrew Eikum aeikum@codeweavers.com
On Thu, May 13, 2021 at 04:03:19PM +0200, Jacek Caban wrote:
Signed-off-by: Jacek Caban jacek@codeweavers.com
dlls/winepulse.drv/mmdevdrv.c | 92 +------------------------------ dlls/winepulse.drv/pulse.c | 101 ++++++++++++++++++++++++++++++++++ dlls/winepulse.drv/unixlib.h | 1 + 3 files changed, 103 insertions(+), 91 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c index d0d497c4bbb..0e1da1364fa 100644 --- a/dlls/winepulse.drv/mmdevdrv.c +++ b/dlls/winepulse.drv/mmdevdrv.c @@ -434,96 +434,6 @@ static void pulse_write(ACImpl *This) This->pulse_stream->pa_held_bytes -= to_write; }
-static void pulse_read(ACImpl *This) -{
- size_t bytes = pa_stream_readable_size(This->pulse_stream->stream);
- TRACE("Readable total: %zu, fragsize: %u\n", bytes, pa_stream_get_buffer_attr(This->pulse_stream->stream)->fragsize);
- bytes += This->pulse_stream->peek_len - This->pulse_stream->peek_ofs;
- while (bytes >= This->pulse_stream->period_bytes) {
BYTE *dst = NULL, *src;
size_t src_len, copy, rem = This->pulse_stream->period_bytes;
if (This->pulse_stream->started) {
LARGE_INTEGER stamp, freq;
ACPacket *p, *next;
if (!(p = (ACPacket*)list_head(&This->pulse_stream->packet_free_head))) {
p = (ACPacket*)list_head(&This->pulse_stream->packet_filled_head);
if (!p) return;
if (!p->discont) {
next = (ACPacket*)p->entry.next;
next->discont = 1;
} else
p = (ACPacket*)list_tail(&This->pulse_stream->packet_filled_head);
} else {
This->pulse_stream->held_bytes += This->pulse_stream->period_bytes;
}
QueryPerformanceCounter(&stamp);
QueryPerformanceFrequency(&freq);
p->qpcpos = (stamp.QuadPart * (INT64)10000000) / freq.QuadPart;
p->discont = 0;
list_remove(&p->entry);
list_add_tail(&This->pulse_stream->packet_filled_head, &p->entry);
dst = p->data;
}
while (rem) {
if (This->pulse_stream->peek_len) {
copy = min(rem, This->pulse_stream->peek_len - This->pulse_stream->peek_ofs);
if (dst) {
memcpy(dst, This->pulse_stream->peek_buffer + This->pulse_stream->peek_ofs, copy);
dst += copy;
}
rem -= copy;
This->pulse_stream->peek_ofs += copy;
if(This->pulse_stream->peek_len == This->pulse_stream->peek_ofs)
This->pulse_stream->peek_len = This->pulse_stream->peek_ofs = 0;
} else if (pa_stream_peek(This->pulse_stream->stream, (const void**)&src, &src_len) == 0 && src_len) {
copy = min(rem, src_len);
if (dst) {
if(src)
memcpy(dst, src, copy);
else
silence_buffer(This->pulse_stream->ss.format, dst, copy);
dst += copy;
}
rem -= copy;
if (copy < src_len) {
if (src_len > This->pulse_stream->peek_buffer_len) {
HeapFree(GetProcessHeap(), 0, This->pulse_stream->peek_buffer);
This->pulse_stream->peek_buffer = HeapAlloc(GetProcessHeap(), 0, src_len);
This->pulse_stream->peek_buffer_len = src_len;
}
if(src)
memcpy(This->pulse_stream->peek_buffer, src + copy, src_len - copy);
else
silence_buffer(This->pulse_stream->ss.format, This->pulse_stream->peek_buffer, src_len - copy);
This->pulse_stream->peek_len = src_len - copy;
This->pulse_stream->peek_ofs = 0;
}
pa_stream_drop(This->pulse_stream->stream);
}
}
bytes -= This->pulse_stream->period_bytes;
- }
-}
static DWORD WINAPI pulse_timer_cb(void *user) { LARGE_INTEGER delay; @@ -595,7 +505,7 @@ static DWORD WINAPI pulse_timer_cb(void *user) This->pulse_stream->lcl_offs_bytes %= This->pulse_stream->real_bufsize_bytes; This->pulse_stream->held_bytes -= adv_bytes; }else if(This->dataflow == eCapture){
pulse_read(This);
pulse->read(This->pulse_stream); } }else{ This->pulse_stream->last_time = now;
diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c index 260723815f6..d434f47d6dc 100644 --- a/dlls/winepulse.drv/pulse.c +++ b/dlls/winepulse.drv/pulse.c @@ -851,6 +851,106 @@ static void WINAPI pulse_release_stream(struct pulse_stream *stream, HANDLE time RtlFreeHeap(GetProcessHeap(), 0, stream); }
+static void WINAPI pulse_read(struct pulse_stream *stream) +{
- size_t bytes = pa_stream_readable_size(stream->stream);
- TRACE("Readable total: %zu, fragsize: %u\n", bytes, pa_stream_get_buffer_attr(stream->stream)->fragsize);
- bytes += stream->peek_len - stream->peek_ofs;
- while (bytes >= stream->period_bytes)
- {
BYTE *dst = NULL, *src;
size_t src_len, copy, rem = stream->period_bytes;
if (stream->started)
{
LARGE_INTEGER stamp, freq;
ACPacket *p, *next;
if (!(p = (ACPacket*)list_head(&stream->packet_free_head)))
{
p = (ACPacket*)list_head(&stream->packet_filled_head);
if (!p) return;
if (!p->discont) {
next = (ACPacket*)p->entry.next;
next->discont = 1;
} else
p = (ACPacket*)list_tail(&stream->packet_filled_head);
}
else
{
stream->held_bytes += stream->period_bytes;
}
NtQueryPerformanceCounter(&stamp, &freq);
p->qpcpos = (stamp.QuadPart * (INT64)10000000) / freq.QuadPart;
p->discont = 0;
list_remove(&p->entry);
list_add_tail(&stream->packet_filled_head, &p->entry);
dst = p->data;
}
while (rem)
{
if (stream->peek_len)
{
copy = min(rem, stream->peek_len - stream->peek_ofs);
if (dst)
{
memcpy(dst, stream->peek_buffer + stream->peek_ofs, copy);
dst += copy;
}
rem -= copy;
stream->peek_ofs += copy;
if(stream->peek_len == stream->peek_ofs)
stream->peek_len = stream->peek_ofs = 0;
}
else if (pa_stream_peek(stream->stream, (const void**)&src, &src_len) == 0 && src_len)
{
copy = min(rem, src_len);
if (dst) {
if(src)
memcpy(dst, src, copy);
else
silence_buffer(stream->ss.format, dst, copy);
dst += copy;
}
rem -= copy;
if (copy < src_len)
{
if (src_len > stream->peek_buffer_len)
{
RtlFreeHeap(GetProcessHeap(), 0, stream->peek_buffer);
stream->peek_buffer = RtlAllocateHeap(GetProcessHeap(), 0, src_len);
stream->peek_buffer_len = src_len;
}
if(src)
memcpy(stream->peek_buffer, src + copy, src_len - copy);
else
silence_buffer(stream->ss.format, stream->peek_buffer, src_len - copy);
stream->peek_len = src_len - copy;
stream->peek_ofs = 0;
}
pa_stream_drop(stream->stream);
}
}
bytes -= stream->period_bytes;
- }
+}
static const struct unix_funcs unix_funcs = { pulse_lock, @@ -860,6 +960,7 @@ static const struct unix_funcs unix_funcs = pulse_main_loop, pulse_create_stream, pulse_release_stream,
- pulse_read, pulse_test_connect,
};
diff --git a/dlls/winepulse.drv/unixlib.h b/dlls/winepulse.drv/unixlib.h index 51c850ac1ae..c725082e96d 100644 --- a/dlls/winepulse.drv/unixlib.h +++ b/dlls/winepulse.drv/unixlib.h @@ -77,5 +77,6 @@ struct unix_funcs const WAVEFORMATEX *fmt, UINT32 *channel_count, struct pulse_stream **ret); void (WINAPI *release_stream)(struct pulse_stream *stream, HANDLE timer);
- void (WINAPI *read)(struct pulse_stream *stream); HRESULT (WINAPI *test_connect)(const char *name, struct pulse_config *config);
};