Commit 668f9516 authored by Davide Beatrici's avatar Davide Beatrici Committed by Alexandre Julliard

winealsa: Move SimpleAudioVolume into mmdevapi.

parent 96c8be00
......@@ -39,6 +39,24 @@ static inline struct audio_session_wrapper *impl_from_IAudioSessionControl2(IAud
return CONTAINING_RECORD(iface, struct audio_session_wrapper, IAudioSessionControl2_iface);
}
static inline struct audio_session_wrapper *impl_from_ISimpleAudioVolume(ISimpleAudioVolume *iface)
{
return CONTAINING_RECORD(iface, struct audio_session_wrapper, ISimpleAudioVolume_iface);
}
static void set_stream_volumes(struct audio_client *This)
{
struct set_volumes_params params;
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;
params.channel = 0;
WINE_UNIX_CALL(set_volumes, &params);
}
static HRESULT WINAPI control_QueryInterface(IAudioSessionControl2 *iface, REFIID riid, void **ppv)
{
TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
......@@ -247,3 +265,128 @@ const IAudioSessionControl2Vtbl AudioSessionControl2_Vtbl =
control_IsSystemSoundsSession,
control_SetDuckingPreference
};
static HRESULT WINAPI simplevolume_QueryInterface(ISimpleAudioVolume *iface, REFIID riid,
void **ppv)
{
TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
if (!ppv)
return E_POINTER;
if (IsEqualIID(riid, &IID_IUnknown) ||
IsEqualIID(riid, &IID_ISimpleAudioVolume))
*ppv = iface;
else {
*ppv = NULL;
return E_NOINTERFACE;
}
IUnknown_AddRef((IUnknown *)*ppv);
return S_OK;
}
static ULONG WINAPI simplevolume_AddRef(ISimpleAudioVolume *iface)
{
struct audio_session_wrapper *This = impl_from_ISimpleAudioVolume(iface);
return IAudioSessionControl2_AddRef(&This->IAudioSessionControl2_iface);
}
static ULONG WINAPI simplevolume_Release(ISimpleAudioVolume *iface)
{
struct audio_session_wrapper *This = impl_from_ISimpleAudioVolume(iface);
return IAudioSessionControl2_Release(&This->IAudioSessionControl2_iface);
}
static HRESULT WINAPI simplevolume_SetMasterVolume(ISimpleAudioVolume *iface, float level,
const GUID *context)
{
struct audio_session_wrapper *This = impl_from_ISimpleAudioVolume(iface);
struct audio_session *session = This->session;
struct audio_client *client;
TRACE("(%p)->(%f, %s)\n", session, level, wine_dbgstr_guid(context));
if (level < 0.f || level > 1.f)
return E_INVALIDARG;
if (context)
FIXME("Notifications not supported yet\n");
sessions_lock();
session->master_vol = level;
LIST_FOR_EACH_ENTRY(client, &session->clients, struct audio_client, entry)
set_stream_volumes(client);
sessions_unlock();
return S_OK;
}
static HRESULT WINAPI simplevolume_GetMasterVolume(ISimpleAudioVolume *iface, float *level)
{
struct audio_session_wrapper *This = impl_from_ISimpleAudioVolume(iface);
struct audio_session *session = This->session;
TRACE("(%p)->(%p)\n", session, level);
if (!level)
return NULL_PTR_ERR;
*level = session->master_vol;
return S_OK;
}
static HRESULT WINAPI simplevolume_SetMute(ISimpleAudioVolume *iface, BOOL mute,
const GUID *context)
{
struct audio_session_wrapper *This = impl_from_ISimpleAudioVolume(iface);
struct audio_session *session = This->session;
struct audio_client *client;
TRACE("(%p)->(%u, %s)\n", session, mute, debugstr_guid(context));
if (context)
FIXME("Notifications not supported yet\n");
sessions_lock();
session->mute = mute;
LIST_FOR_EACH_ENTRY(client, &session->clients, struct audio_client, entry)
set_stream_volumes(client);
sessions_unlock();
return S_OK;
}
static HRESULT WINAPI simplevolume_GetMute(ISimpleAudioVolume *iface, BOOL *mute)
{
struct audio_session_wrapper *This = impl_from_ISimpleAudioVolume(iface);
struct audio_session *session = This->session;
TRACE("(%p)->(%p)\n", session, mute);
if (!mute)
return NULL_PTR_ERR;
*mute = session->mute;
return S_OK;
}
const ISimpleAudioVolumeVtbl SimpleAudioVolume_Vtbl =
{
simplevolume_QueryInterface,
simplevolume_AddRef,
simplevolume_Release,
simplevolume_SetMasterVolume,
simplevolume_GetMasterVolume,
simplevolume_SetMute,
simplevolume_GetMute
};
......@@ -73,7 +73,7 @@ static const IAudioClient3Vtbl AudioClient3_Vtbl;
static const IAudioRenderClientVtbl AudioRenderClient_Vtbl;
static const IAudioCaptureClientVtbl AudioCaptureClient_Vtbl;
extern const IAudioSessionControl2Vtbl AudioSessionControl2_Vtbl;
static const ISimpleAudioVolumeVtbl SimpleAudioVolume_Vtbl;
extern const ISimpleAudioVolumeVtbl SimpleAudioVolume_Vtbl;
static const IAudioClockVtbl AudioClock_Vtbl;
static const IAudioClock2Vtbl AudioClock2_Vtbl;
static const IAudioStreamVolumeVtbl AudioStreamVolume_Vtbl;
......@@ -106,11 +106,6 @@ static inline ACImpl *impl_from_IAudioCaptureClient(IAudioCaptureClient *iface)
return CONTAINING_RECORD(iface, ACImpl, IAudioCaptureClient_iface);
}
static inline AudioSessionWrapper *impl_from_ISimpleAudioVolume(ISimpleAudioVolume *iface)
{
return CONTAINING_RECORD(iface, AudioSessionWrapper, ISimpleAudioVolume_iface);
}
static inline AudioSessionWrapper *impl_from_IChannelAudioVolume(IChannelAudioVolume *iface)
{
return CONTAINING_RECORD(iface, AudioSessionWrapper, IChannelAudioVolume_iface);
......@@ -1511,134 +1506,6 @@ static AudioSessionWrapper *AudioSessionWrapper_Create(ACImpl *client)
return ret;
}
static HRESULT WINAPI SimpleAudioVolume_QueryInterface(
ISimpleAudioVolume *iface, REFIID riid, void **ppv)
{
TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
if(!ppv)
return E_POINTER;
*ppv = NULL;
if(IsEqualIID(riid, &IID_IUnknown) ||
IsEqualIID(riid, &IID_ISimpleAudioVolume))
*ppv = iface;
if(*ppv){
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
WARN("Unknown interface %s\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
static ULONG WINAPI SimpleAudioVolume_AddRef(ISimpleAudioVolume *iface)
{
AudioSessionWrapper *This = impl_from_ISimpleAudioVolume(iface);
return IAudioSessionControl2_AddRef(&This->IAudioSessionControl2_iface);
}
static ULONG WINAPI SimpleAudioVolume_Release(ISimpleAudioVolume *iface)
{
AudioSessionWrapper *This = impl_from_ISimpleAudioVolume(iface);
return IAudioSessionControl2_Release(&This->IAudioSessionControl2_iface);
}
static HRESULT WINAPI SimpleAudioVolume_SetMasterVolume(
ISimpleAudioVolume *iface, float level, const GUID *context)
{
AudioSessionWrapper *This = impl_from_ISimpleAudioVolume(iface);
AudioSession *session = This->session;
ACImpl *client;
TRACE("(%p)->(%f, %s)\n", session, level, wine_dbgstr_guid(context));
if(level < 0.f || level > 1.f)
return E_INVALIDARG;
if(context)
FIXME("Notifications not supported yet\n");
TRACE("ALSA does not support volume control\n");
sessions_lock();
session->master_vol = level;
LIST_FOR_EACH_ENTRY(client, &session->clients, ACImpl, entry)
set_stream_volumes(client);
sessions_unlock();
return S_OK;
}
static HRESULT WINAPI SimpleAudioVolume_GetMasterVolume(
ISimpleAudioVolume *iface, float *level)
{
AudioSessionWrapper *This = impl_from_ISimpleAudioVolume(iface);
AudioSession *session = This->session;
TRACE("(%p)->(%p)\n", session, level);
if(!level)
return NULL_PTR_ERR;
*level = session->master_vol;
return S_OK;
}
static HRESULT WINAPI SimpleAudioVolume_SetMute(ISimpleAudioVolume *iface,
BOOL mute, const GUID *context)
{
AudioSessionWrapper *This = impl_from_ISimpleAudioVolume(iface);
AudioSession *session = This->session;
ACImpl *client;
TRACE("(%p)->(%u, %s)\n", session, mute, debugstr_guid(context));
if(context)
FIXME("Notifications not supported yet\n");
sessions_lock();
session->mute = mute;
LIST_FOR_EACH_ENTRY(client, &session->clients, ACImpl, entry)
set_stream_volumes(client);
sessions_unlock();
return S_OK;
}
static HRESULT WINAPI SimpleAudioVolume_GetMute(ISimpleAudioVolume *iface,
BOOL *mute)
{
AudioSessionWrapper *This = impl_from_ISimpleAudioVolume(iface);
AudioSession *session = This->session;
TRACE("(%p)->(%p)\n", session, mute);
if(!mute)
return NULL_PTR_ERR;
*mute = session->mute;
return S_OK;
}
static const ISimpleAudioVolumeVtbl SimpleAudioVolume_Vtbl =
{
SimpleAudioVolume_QueryInterface,
SimpleAudioVolume_AddRef,
SimpleAudioVolume_Release,
SimpleAudioVolume_SetMasterVolume,
SimpleAudioVolume_GetMasterVolume,
SimpleAudioVolume_SetMute,
SimpleAudioVolume_GetMute
};
static HRESULT WINAPI AudioStreamVolume_QueryInterface(
IAudioStreamVolume *iface, REFIID riid, void **ppv)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment