[PATCH 4/9] winepulse: Adjust pulse stream volumes for master volume.

Andrew Eikum aeikum at codeweavers.com
Mon May 17 14:59:21 CDT 2021


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

On Thu, May 13, 2021 at 04:03:58PM +0200, Jacek Caban wrote:
> Signed-off-by: Jacek Caban <jacek at codeweavers.com>
> ---
>  dlls/winepulse.drv/mmdevdrv.c | 7 +++++--
>  dlls/winepulse.drv/pulse.c    | 5 +++--
>  dlls/winepulse.drv/unixlib.h  | 3 ++-
>  3 files changed, 10 insertions(+), 5 deletions(-)
> 
> 

> diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
> index 2a9ebd86c3a..8933a95d834 100644
> --- a/dlls/winepulse.drv/mmdevdrv.c
> +++ b/dlls/winepulse.drv/mmdevdrv.c
> @@ -264,7 +264,7 @@ static int write_buffer(const ACImpl *This, BYTE *buffer, UINT32 bytes)
>      channels = This->pulse_stream->ss.channels;
>      for (i = 0; i < channels; i++)
>      {
> -        vol[i] = This->pulse_stream->vol[i] * This->session->master_vol * This->session->channel_vols[i];
> +        vol[i] = This->pulse_stream->vol[i] * This->session->channel_vols[i];
>          adjust |= vol[i] != 1.0f;
>      }
>      if (!adjust) goto write;
> @@ -528,7 +528,7 @@ static DWORD WINAPI pulse_timer_cb(void *user)
>  
>  static void set_stream_volumes(ACImpl *This)
>  {
> -    pulse->set_volumes(This->pulse_stream, This->vol);
> +    pulse->set_volumes(This->pulse_stream, This->session->master_vol, This->vol);
>  }
>  
>  HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, const WCHAR ***ids, GUID **keys,
> @@ -2593,6 +2593,7 @@ static HRESULT WINAPI SimpleAudioVolume_SetMasterVolume(
>  {
>      AudioSessionWrapper *This = impl_from_ISimpleAudioVolume(iface);
>      AudioSession *session = This->session;
> +    ACImpl *client;
>  
>      TRACE("(%p)->(%f, %s)\n", session, level, wine_dbgstr_guid(context));
>  
> @@ -2606,6 +2607,8 @@ static HRESULT WINAPI SimpleAudioVolume_SetMasterVolume(
>  
>      pulse->lock();
>      session->master_vol = level;
> +    LIST_FOR_EACH_ENTRY(client, &This->session->clients, ACImpl, entry)
> +        set_stream_volumes(client);
>      pulse->unlock();
>  
>      return S_OK;
> diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c
> index f0bfcd98b7d..02f4d11a7f1 100644
> --- a/dlls/winepulse.drv/pulse.c
> +++ b/dlls/winepulse.drv/pulse.c
> @@ -1004,12 +1004,13 @@ static HRESULT WINAPI pulse_stop(struct pulse_stream *stream)
>      return hr;
>  }
>  
> -static void WINAPI pulse_set_volumes(struct pulse_stream *stream, const float *volumes)
> +static void WINAPI pulse_set_volumes(struct pulse_stream *stream, float master_volume,
> +                                     const float *volumes)
>  {
>      unsigned int i;
>  
>      for (i = 0; i < stream->ss.channels; i++)
> -        stream->vol[i] = volumes[i];
> +        stream->vol[i] = volumes[i] * master_volume;
>  }
>  
>  static const struct unix_funcs unix_funcs =
> diff --git a/dlls/winepulse.drv/unixlib.h b/dlls/winepulse.drv/unixlib.h
> index 7b5c5400a1f..8636f11d6f5 100644
> --- a/dlls/winepulse.drv/unixlib.h
> +++ b/dlls/winepulse.drv/unixlib.h
> @@ -80,6 +80,7 @@ struct unix_funcs
>      void (WINAPI *release_stream)(struct pulse_stream *stream, HANDLE timer);
>      void (WINAPI *read)(struct pulse_stream *stream);
>      HRESULT (WINAPI *stop)(struct pulse_stream *stream);
> -    void (WINAPI *set_volumes)(struct pulse_stream *stream, const float *volumes);
> +    void (WINAPI *set_volumes)(struct pulse_stream *stream, float master_volume,
> +                               const float *volumes);
>      HRESULT (WINAPI *test_connect)(const char *name, struct pulse_config *config);
>  };
> 




More information about the wine-devel mailing list