[PATCH 5/5] wineoss: Move set_volumes to the unixlib.

Andrew Eikum aeikum at codeweavers.com
Mon Apr 18 08:55:25 CDT 2022


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

On Fri, Apr 15, 2022 at 09:40:43PM +0100, Huw Davies wrote:
> Signed-off-by: Huw Davies <huw at codeweavers.com>
> ---
>  dlls/wineoss.drv/mmdevdrv.c | 35 ++++++-----------------------------
>  dlls/wineoss.drv/oss.c      | 35 +++++++++++++++++++++++++++++++++++
>  dlls/wineoss.drv/unixlib.h  | 31 ++++++++++---------------------
>  3 files changed, 51 insertions(+), 50 deletions(-)
> 
> diff --git a/dlls/wineoss.drv/mmdevdrv.c b/dlls/wineoss.drv/mmdevdrv.c
> index cdd9b09bff7..9e3380ca8d9 100644
> --- a/dlls/wineoss.drv/mmdevdrv.c
> +++ b/dlls/wineoss.drv/mmdevdrv.c
> @@ -18,22 +18,7 @@
>   */
>  
>  #define COBJMACROS
> -#include "config.h"
> -
>  #include <stdarg.h>
> -#include <errno.h>
> -#include <limits.h>
> -#include <stdio.h>
> -#include <stdlib.h>
> -#include <string.h>
> -#include <sys/types.h>
> -#include <sys/stat.h>
> -#include <sys/ioctl.h>
> -#include <fcntl.h>
> -#include <unistd.h>
> -#include <math.h>
> -#include <sys/soundcard.h>
> -#include <pthread.h>
>  
>  #include "windef.h"
>  #include "winbase.h"
> @@ -277,16 +262,6 @@ static DWORD WINAPI timer_thread(void *user)
>      return 0;
>  }
>  
> -static void oss_lock(struct oss_stream *stream)
> -{
> -    pthread_mutex_lock(&stream->lock);
> -}
> -
> -static void oss_unlock(struct oss_stream *stream)
> -{
> -    pthread_mutex_unlock(&stream->lock);
> -}
> -
>  static void set_device_guid(EDataFlow flow, HKEY drv_key, const WCHAR *key_name,
>          GUID *guid)
>  {
> @@ -361,11 +336,13 @@ static void get_device_guid(EDataFlow flow, const char *device, GUID *guid)
>  
>  static void set_stream_volumes(ACImpl *This)
>  {
> -    struct oss_stream *stream = This->stream;
> +    struct set_volumes_params params;
>  
> -    oss_lock(stream);
> -    stream->mute = This->session->mute;
> -    oss_unlock(stream);
> +    params.stream = This->stream;
> +    params.master_volume = (This->session->mute ? 0.0f : This->session->master_vol);
> +    params.volumes = This->vols;
> +    params.session_volumes = This->session->channel_vols;
> +    OSS_CALL(set_volumes, &params);
>  }
>  
>  static const OSSDevice *get_ossdevice_from_guid(const GUID *guid)
> diff --git a/dlls/wineoss.drv/oss.c b/dlls/wineoss.drv/oss.c
> index 79f2e994d89..b4e2cbda704 100644
> --- a/dlls/wineoss.drv/oss.c
> +++ b/dlls/wineoss.drv/oss.c
> @@ -44,6 +44,28 @@
>  
>  #include "unixlib.h"
>  
> +struct oss_stream
> +{
> +    WAVEFORMATEX *fmt;
> +    EDataFlow flow;
> +    UINT flags;
> +    AUDCLNT_SHAREMODE share;
> +    HANDLE event;
> +
> +    int fd;
> +
> +    BOOL playing, mute, please_quit;
> +    UINT64 written_frames, last_pos_frames;
> +    UINT32 period_frames, bufsize_frames, held_frames, tmp_buffer_frames, in_oss_frames;
> +    UINT32 oss_bufsize_bytes, lcl_offs_frames; /* offs into local_buffer where valid data starts */
> +    REFERENCE_TIME period;
> +
> +    BYTE *local_buffer, *tmp_buffer;
> +    INT32 getbuf_last; /* <0 when using tmp_buffer */
> +
> +    pthread_mutex_t lock;
> +};
> +
>  WINE_DEFAULT_DEBUG_CHANNEL(oss);
>  
>  /* copied from kernelbase */
> @@ -1316,6 +1338,18 @@ static NTSTATUS get_position(void *args)
>      return oss_unlock_result(stream, &params->result, S_OK);
>  }
>  
> +static NTSTATUS set_volumes(void *args)
> +{
> +    struct set_volumes_params *params = args;
> +    struct oss_stream *stream = params->stream;
> +
> +    oss_lock(stream);
> +    stream->mute = !params->master_volume;
> +    oss_unlock(stream);
> +
> +    return STATUS_SUCCESS;
> +}
> +
>  static NTSTATUS set_event_handle(void *args)
>  {
>      struct set_event_handle_params *params = args;
> @@ -1368,6 +1402,7 @@ unixlib_entry_t __wine_unix_call_funcs[] =
>      get_next_packet_size,
>      get_frequency,
>      get_position,
> +    set_volumes,
>      set_event_handle,
>      is_started,
>  };
> diff --git a/dlls/wineoss.drv/unixlib.h b/dlls/wineoss.drv/unixlib.h
> index ed93f0836b1..1ed152fe794 100644
> --- a/dlls/wineoss.drv/unixlib.h
> +++ b/dlls/wineoss.drv/unixlib.h
> @@ -18,27 +18,7 @@
>  
>  #include "mmdeviceapi.h"
>  
> -struct oss_stream
> -{
> -    WAVEFORMATEX *fmt;
> -    EDataFlow flow;
> -    UINT flags;
> -    AUDCLNT_SHAREMODE share;
> -    HANDLE event;
> -
> -    int fd;
> -
> -    BOOL playing, mute, please_quit;
> -    UINT64 written_frames, last_pos_frames;
> -    UINT32 period_frames, bufsize_frames, held_frames, tmp_buffer_frames, in_oss_frames;
> -    UINT32 oss_bufsize_bytes, lcl_offs_frames; /* offs into local_buffer where valid data starts */
> -    REFERENCE_TIME period;
> -
> -    BYTE *local_buffer, *tmp_buffer;
> -    INT32 getbuf_last; /* <0 when using tmp_buffer */
> -
> -    pthread_mutex_t lock;
> -};
> +struct stream_oss;
>  
>  /* From <dlls/mmdevapi/mmdevapi.h> */
>  enum DriverPriority
> @@ -208,6 +188,14 @@ struct get_position_params
>      UINT64 *qpctime;
>  };
>  
> +struct set_volumes_params
> +{
> +    struct oss_stream *stream;
> +    float master_volume;
> +    const float *volumes;
> +    const float *session_volumes;
> +};
> +
>  struct set_event_handle_params
>  {
>      struct oss_stream *stream;
> @@ -243,6 +231,7 @@ enum oss_funcs
>      oss_get_next_packet_size,
>      oss_get_frequency,
>      oss_get_position,
> +    oss_set_volumes,
>      oss_set_event_handle,
>      oss_is_started,
>  };
> -- 
> 2.25.1
> 
> 



More information about the wine-devel mailing list