mmdevapi: Store device_name as a pointer in struct audio_client.

This commit is contained in:
Paul Gofman 2024-06-17 18:12:34 -06:00 committed by Alexandre Julliard
parent 65880e0c8c
commit 103cd4fa7a
2 changed files with 5 additions and 8 deletions

View file

@ -623,6 +623,7 @@ static ULONG WINAPI client_Release(IAudioClient3 *iface)
if (This->stream)
stream_release(This->stream, This->timer_thread);
free(This->device_name);
free(This);
}
@ -1492,7 +1493,6 @@ HRESULT AudioClient_Create(GUID *guid, IMMDevice *device, IAudioClient **out)
struct audio_client *This;
char *name;
EDataFlow dataflow;
size_t size;
HRESULT hr;
TRACE("%s %p %p\n", debugstr_guid(guid), device, out);
@ -1507,15 +1507,13 @@ HRESULT AudioClient_Create(GUID *guid, IMMDevice *device, IAudioClient **out)
return E_UNEXPECTED;
}
size = strlen(name) + 1;
This = calloc(1, FIELD_OFFSET(struct audio_client, device_name[size]));
This = calloc(1, sizeof(*This));
if (!This) {
free(name);
return E_OUTOFMEMORY;
}
memcpy(This->device_name, name, size);
free(name);
This->device_name = name;
This->IAudioCaptureClient_iface.lpVtbl = &AudioCaptureClient_Vtbl;
This->IAudioClient3_iface.lpVtbl = &AudioClient3_Vtbl;
@ -1529,6 +1527,7 @@ HRESULT AudioClient_Create(GUID *guid, IMMDevice *device, IAudioClient **out)
hr = CoCreateFreeThreadedMarshaler((IUnknown *)&This->IAudioClient3_iface, &This->marshal);
if (FAILED(hr)) {
free(This->device_name);
free(This);
return hr;
}

View file

@ -80,7 +80,5 @@ struct audio_client {
struct audio_session_wrapper *session_wrapper;
struct list entry;
/* Keep at end */
char device_name[0];
char *device_name;
};