Good catch. I don't like the copying, though. What about making:
struct alsa_channel_map { int alsa_channels; int map[32]; };
and passing that into map_channels()? need_remapping can be indicated by a S_FALSE vs S_OK return from map_channels(), or maybe set outside the call in _Initialize().
What do you think?
Andrew
On Thu, Dec 04, 2014 at 02:26:05PM +0000, Mark Harmstone wrote:
At present, AudioClient_IsFormatSupported nukes the remapping information if called after AudioClient_Initialize.
dlls/winealsa.drv/mmdevdrv.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
diff --git a/dlls/winealsa.drv/mmdevdrv.c b/dlls/winealsa.drv/mmdevdrv.c index 007f351..3d14a53 100644 --- a/dlls/winealsa.drv/mmdevdrv.c +++ b/dlls/winealsa.drv/mmdevdrv.c @@ -1598,6 +1598,8 @@ static HRESULT WINAPI AudioClient_IsFormatSupported(IAudioClient *iface, WAVEFORMATEX *closest = NULL; unsigned int max = 0, min = 0; int err;
int alsa_channels_orig, alsa_channel_map_orig[32];
BOOL need_remapping_orig;
TRACE("(%p)->(%x, %p, %p)\n", This, mode, fmt, out);
@@ -1692,9 +1694,18 @@ static HRESULT WINAPI AudioClient_IsFormatSupported(IAudioClient *iface, closest->nChannels = min; }
- need_remapping_orig = This->need_remapping;
- alsa_channels_orig = This->alsa_channels;
- memcpy(alsa_channel_map_orig, This->alsa_channel_map, sizeof(This->alsa_channel_map));
- if(FAILED(map_channels(This, fmt))){ hr = AUDCLNT_E_DEVICE_INVALIDATED; WARN("map_channels failed\n");
This->need_remapping = need_remapping_orig;
This->alsa_channels = alsa_channels_orig;
memcpy(This->alsa_channel_map, alsa_channel_map_orig, sizeof(This->alsa_channel_map));
} if(This->alsa_channels > max){goto exit;
@@ -1702,6 +1713,10 @@ static HRESULT WINAPI AudioClient_IsFormatSupported(IAudioClient *iface, closest->nChannels = max; }
- This->need_remapping = need_remapping_orig;
- This->alsa_channels = alsa_channels_orig;
- memcpy(This->alsa_channel_map, alsa_channel_map_orig, sizeof(This->alsa_channel_map));
- if(closest->wFormatTag == WAVE_FORMAT_EXTENSIBLE) ((WAVEFORMATEXTENSIBLE*)closest)->dwChannelMask = get_channel_mask(closest->nChannels);