aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cubeb_winmm.c
diff options
context:
space:
mode:
authorMatthew Gregan <[email protected]>2016-06-07 14:14:52 +1200
committerMatthew Gregan <[email protected]>2016-06-07 14:14:52 +1200
commitf20762315925b5041f3ab189a6347ebc411a6ec3 (patch)
tree37f24324bad551c2d3561a6fc28974207df9f2cd /src/cubeb_winmm.c
parent71ab5a404ebb6f8513e23095d82ffab3a46d8a55 (diff)
downloadcubeb-f20762315925b5041f3ab189a6347ebc411a6ec3.tar.gz
cubeb-f20762315925b5041f3ab189a6347ebc411a6ec3.zip
wasapi,winmm: Fix various VS2015 analysis warnings.
Diffstat (limited to 'src/cubeb_winmm.c')
-rw-r--r--src/cubeb_winmm.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/cubeb_winmm.c b/src/cubeb_winmm.c
index 35866e2..746909b 100644
--- a/src/cubeb_winmm.c
+++ b/src/cubeb_winmm.c
@@ -207,7 +207,7 @@ winmm_refill_stream(cubeb_stream * stm)
short * b = (short *) hdr->lpData;
uint32_t i;
for (i = 0; i < got * stm->params.channels; i++) {
- b[i] *= stm->soft_volume;
+ b[i] = (short) (b[i] * stm->soft_volume);
}
}
}
@@ -701,7 +701,8 @@ winmm_stream_get_latency(cubeb_stream * stm, uint32_t * latency)
return CUBEB_ERROR;
}
- *latency = written - time.u.sample;
+ XASSERT(written - time.u.sample <= UINT32_MAX);
+ *latency = (uint32_t) (written - time.u.sample);
return CUBEB_OK;
}
@@ -787,7 +788,10 @@ static char *
guid_to_cstr(LPGUID guid)
{
char * ret = malloc(sizeof(char) * 40);
- _snprintf(ret, sizeof(char) * 40,
+ if (!ret) {
+ return NULL;
+ }
+ _snprintf_s(ret, sizeof(char) * 40, _TRUNCATE,
"{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
guid->Data1, guid->Data2, guid->Data3,
guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
@@ -818,7 +822,10 @@ static char *
device_id_idx(UINT devid)
{
char * ret = (char *)malloc(sizeof(char)*16);
- _snprintf(ret, 16, "%u", devid);
+ if (!ret) {
+ return NULL;
+ }
+ _snprintf_s(ret, 16, _TRUNCATE, "%u", devid);
return ret;
}
@@ -828,6 +835,9 @@ winmm_create_device_from_outcaps2(LPWAVEOUTCAPS2A caps, UINT devid)
cubeb_device_info * ret;
ret = calloc(1, sizeof(cubeb_device_info));
+ if (!ret) {
+ return NULL;
+ }
ret->devid = (cubeb_devid)(size_t)devid;
ret->device_id = device_id_idx(devid);
ret->friendly_name = _strdup(caps->szPname);
@@ -856,6 +866,9 @@ winmm_create_device_from_outcaps(LPWAVEOUTCAPSA caps, UINT devid)
cubeb_device_info * ret;
ret = calloc(1, sizeof(cubeb_device_info));
+ if (!ret) {
+ return NULL;
+ }
ret->devid = (cubeb_devid)(size_t)devid;
ret->device_id = device_id_idx(devid);
ret->friendly_name = _strdup(caps->szPname);
@@ -903,6 +916,9 @@ winmm_create_device_from_incaps2(LPWAVEINCAPS2A caps, UINT devid)
cubeb_device_info * ret;
ret = calloc(1, sizeof(cubeb_device_info));
+ if (!ret) {
+ return NULL;
+ }
ret->devid = (cubeb_devid)(size_t)devid;
ret->device_id = device_id_idx(devid);
ret->friendly_name = _strdup(caps->szPname);
@@ -931,6 +947,9 @@ winmm_create_device_from_incaps(LPWAVEINCAPSA caps, UINT devid)
cubeb_device_info * ret;
ret = calloc(1, sizeof(cubeb_device_info));
+ if (!ret) {
+ return NULL;
+ }
ret->devid = (cubeb_devid)(size_t)devid;
ret->device_id = device_id_idx(devid);
ret->friendly_name = _strdup(caps->szPname);