winepulse: Move pulse_get_next_packet_size to unix lib.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-05-19 22:27:30 +02:00 committed by Alexandre Julliard
parent 80b996c53c
commit a6131544e8
3 changed files with 26 additions and 28 deletions

View File

@ -638,18 +638,6 @@ static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient3 *iface,
return pulse->get_latency(This->pulse_stream, latency); return pulse->get_latency(This->pulse_stream, latency);
} }
static void ACImpl_GetCapturePad(ACImpl *This, UINT32 *out)
{
ACPacket *packet = This->pulse_stream->locked_ptr;
if (!packet && !list_empty(&This->pulse_stream->packet_filled_head)) {
packet = (ACPacket*)list_head(&This->pulse_stream->packet_filled_head);
This->pulse_stream->locked_ptr = packet;
list_remove(&packet->entry);
}
if (out)
*out = This->pulse_stream->held_bytes / pa_frame_size(&This->pulse_stream->ss);
}
static HRESULT WINAPI AudioClient_GetCurrentPadding(IAudioClient3 *iface, static HRESULT WINAPI AudioClient_GetCurrentPadding(IAudioClient3 *iface,
UINT32 *out) UINT32 *out)
{ {
@ -1234,17 +1222,13 @@ static HRESULT WINAPI AudioCaptureClient_GetNextPacketSize(
ACImpl *This = impl_from_IAudioCaptureClient(iface); ACImpl *This = impl_from_IAudioCaptureClient(iface);
TRACE("(%p)->(%p)\n", This, frames); TRACE("(%p)->(%p)\n", This, frames);
if (!frames) if (!frames)
return E_POINTER; return E_POINTER;
if (!This->pulse_stream)
return AUDCLNT_E_NOT_INITIALIZED;
pulse->lock(); return pulse->get_next_packet_size(This->pulse_stream, frames);
ACImpl_GetCapturePad(This, NULL);
if (This->pulse_stream->locked_ptr)
*frames = This->pulse_stream->period_bytes / pa_frame_size(&This->pulse_stream->ss);
else
*frames = 0;
pulse->unlock();
return S_OK;
} }
static const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl = static const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl =

View File

@ -43,6 +43,14 @@
WINE_DEFAULT_DEBUG_CHANNEL(pulse); WINE_DEFAULT_DEBUG_CHANNEL(pulse);
typedef struct _ACPacket
{
struct list entry;
UINT64 qpcpos;
BYTE *data;
UINT32 discont;
} ACPacket;
static pa_context *pulse_ctx; static pa_context *pulse_ctx;
static pa_mainloop *pulse_ml; static pa_mainloop *pulse_ml;
@ -1674,6 +1682,18 @@ static HRESULT WINAPI pulse_get_current_padding(struct pulse_stream *stream, UIN
return S_OK; return S_OK;
} }
static HRESULT WINAPI pulse_get_next_packet_size(struct pulse_stream *stream, UINT32 *frames)
{
pulse_lock();
pulse_capture_padding(stream);
if (stream->locked_ptr)
*frames = stream->period_bytes / pa_frame_size(&stream->ss);
else
*frames = 0;
pulse_unlock();
return S_OK;
}
static void WINAPI pulse_set_volumes(struct pulse_stream *stream, float master_volume, static void WINAPI pulse_set_volumes(struct pulse_stream *stream, float master_volume,
const float *volumes, const float *session_volumes) const float *volumes, const float *session_volumes)
{ {
@ -1720,6 +1740,7 @@ static const struct unix_funcs unix_funcs =
pulse_get_buffer_size, pulse_get_buffer_size,
pulse_get_latency, pulse_get_latency,
pulse_get_current_padding, pulse_get_current_padding,
pulse_get_next_packet_size,
pulse_set_volumes, pulse_set_volumes,
pulse_set_event_handle, pulse_set_event_handle,
pulse_test_connect, pulse_test_connect,

View File

@ -29,14 +29,6 @@ struct pulse_config
unsigned int speakers_mask; unsigned int speakers_mask;
}; };
typedef struct _ACPacket
{
struct list entry;
UINT64 qpcpos;
BYTE *data;
UINT32 discont;
} ACPacket;
struct pulse_stream struct pulse_stream
{ {
EDataFlow dataflow; EDataFlow dataflow;
@ -90,6 +82,7 @@ struct unix_funcs
HRESULT (WINAPI *get_buffer_size)(struct pulse_stream *stream, UINT32 *out); HRESULT (WINAPI *get_buffer_size)(struct pulse_stream *stream, UINT32 *out);
HRESULT (WINAPI *get_latency)(struct pulse_stream *stream, REFERENCE_TIME *latency); HRESULT (WINAPI *get_latency)(struct pulse_stream *stream, REFERENCE_TIME *latency);
HRESULT (WINAPI *get_current_padding)(struct pulse_stream *stream, UINT32 *out); HRESULT (WINAPI *get_current_padding)(struct pulse_stream *stream, UINT32 *out);
HRESULT (WINAPI *get_next_packet_size)(struct pulse_stream *stream, UINT32 *frames);
void (WINAPI *set_volumes)(struct pulse_stream *stream, float master_volume, void (WINAPI *set_volumes)(struct pulse_stream *stream, float master_volume,
const float *volumes, const float *session_volumes); const float *volumes, const float *session_volumes);
HRESULT (WINAPI *set_event_handle)(struct pulse_stream *stream, HANDLE event); HRESULT (WINAPI *set_event_handle)(struct pulse_stream *stream, HANDLE event);