[PATCH 6/7] winepulse: Move pulse_get_next_packet_size to unix lib.

Andrew Eikum aeikum at codeweavers.com
Thu May 20 10:46:36 CDT 2021


Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>

On Wed, May 19, 2021 at 10:27:30PM +0200, Jacek Caban wrote:
> Signed-off-by: Jacek Caban <jacek at codeweavers.com>
> ---
>  dlls/winepulse.drv/mmdevdrv.c | 24 ++++--------------------
>  dlls/winepulse.drv/pulse.c    | 21 +++++++++++++++++++++
>  dlls/winepulse.drv/unixlib.h  |  9 +--------
>  3 files changed, 26 insertions(+), 28 deletions(-)
> 
> 

> diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
> index b85d9b5e80b..bf9a6672b05 100644
> --- a/dlls/winepulse.drv/mmdevdrv.c
> +++ b/dlls/winepulse.drv/mmdevdrv.c
> @@ -638,18 +638,6 @@ static HRESULT WINAPI AudioClient_GetStreamLatency(IAudioClient3 *iface,
>      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,
>          UINT32 *out)
>  {
> @@ -1234,17 +1222,13 @@ static HRESULT WINAPI AudioCaptureClient_GetNextPacketSize(
>      ACImpl *This = impl_from_IAudioCaptureClient(iface);
>  
>      TRACE("(%p)->(%p)\n", This, frames);
> +
>      if (!frames)
>          return E_POINTER;
> +    if (!This->pulse_stream)
> +        return AUDCLNT_E_NOT_INITIALIZED;
>  
> -    pulse->lock();
> -    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;
> +    return pulse->get_next_packet_size(This->pulse_stream, frames);
>  }
>  
>  static const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl =
> diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c
> index 4ff3753c189..43212822f4e 100644
> --- a/dlls/winepulse.drv/pulse.c
> +++ b/dlls/winepulse.drv/pulse.c
> @@ -43,6 +43,14 @@
>  
>  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_mainloop *pulse_ml;
>  
> @@ -1674,6 +1682,18 @@ static HRESULT WINAPI pulse_get_current_padding(struct pulse_stream *stream, UIN
>      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,
>                                       const float *volumes, const float *session_volumes)
>  {
> @@ -1720,6 +1740,7 @@ static const struct unix_funcs unix_funcs =
>      pulse_get_buffer_size,
>      pulse_get_latency,
>      pulse_get_current_padding,
> +    pulse_get_next_packet_size,
>      pulse_set_volumes,
>      pulse_set_event_handle,
>      pulse_test_connect,
> diff --git a/dlls/winepulse.drv/unixlib.h b/dlls/winepulse.drv/unixlib.h
> index e3471607d26..956dc36e267 100644
> --- a/dlls/winepulse.drv/unixlib.h
> +++ b/dlls/winepulse.drv/unixlib.h
> @@ -29,14 +29,6 @@ struct pulse_config
>      unsigned int speakers_mask;
>  };
>  
> -typedef struct _ACPacket
> -{
> -    struct list entry;
> -    UINT64 qpcpos;
> -    BYTE *data;
> -    UINT32 discont;
> -} ACPacket;
> -
>  struct pulse_stream
>  {
>      EDataFlow dataflow;
> @@ -90,6 +82,7 @@ struct unix_funcs
>      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_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,
>                                 const float *volumes, const float *session_volumes);
>      HRESULT (WINAPI *set_event_handle)(struct pulse_stream *stream, HANDLE event);
> 




More information about the wine-devel mailing list