summaryrefslogtreecommitdiff
path: root/sys/wasapi/gstwasapisrc.c
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2018-02-06 23:56:41 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2018-02-08 14:29:58 +0530
commit624de04fdb730fd87eead407651172a7acb1d16b (patch)
tree58676a287b3f0742ef3dfc42a596db3b9f92493c /sys/wasapi/gstwasapisrc.c
parent62b6224e37e180498990ba7d79a09bf87889e520 (diff)
downloadgstreamer-plugins-bad-624de04fdb730fd87eead407651172a7acb1d16b.tar.gz
wasapi: Cover more HRESULT error messages
This requires using allocated strings, but it's the best option. For instance, a call could fail because CoInitialize() wasn't called, or because some other thing in the stack failed. https://bugzilla.gnome.org/show_bug.cgi?id=793289
Diffstat (limited to 'sys/wasapi/gstwasapisrc.c')
-rw-r--r--sys/wasapi/gstwasapisrc.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/sys/wasapi/gstwasapisrc.c b/sys/wasapi/gstwasapisrc.c
index 49f1d31b5..dcb196c86 100644
--- a/sys/wasapi/gstwasapisrc.c
+++ b/sys/wasapi/gstwasapisrc.c
@@ -405,9 +405,10 @@ gst_wasapi_src_prepare (GstAudioSrc * asrc, GstAudioRingBufferSpec * spec)
self->mix_format, NULL);
}
if (hr != S_OK) {
+ gchar *msg = gst_wasapi_util_hresult_to_string (hr);
GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ, (NULL),
- ("IAudioClient::Initialize () failed: %s",
- gst_wasapi_util_hresult_to_string (hr)));
+ ("IAudioClient::Initialize () failed: %s", msg));
+ g_free (msg);
goto beach;
}
@@ -553,12 +554,14 @@ gst_wasapi_src_read (GstAudioSrc * asrc, gpointer data, guint length,
hr = IAudioCaptureClient_GetBuffer (self->capture_client,
(BYTE **) & from, &have_frames, &flags, NULL, NULL);
if (hr != S_OK) {
+ gchar *msg = gst_wasapi_util_hresult_to_string (hr);
if (hr == AUDCLNT_S_BUFFER_EMPTY)
GST_WARNING_OBJECT (self, "IAudioCaptureClient::GetBuffer failed: %s"
- ", retrying", gst_wasapi_util_hresult_to_string (hr));
+ ", retrying", msg);
else
GST_ERROR_OBJECT (self, "IAudioCaptureClient::GetBuffer failed: %s",
- gst_wasapi_util_hresult_to_string (hr));
+ msg);
+ g_free (msg);
length = 0;
goto beach;
}
@@ -598,9 +601,10 @@ gst_wasapi_src_read (GstAudioSrc * asrc, gpointer data, guint length,
/* Always release all captured buffers if we've captured any at all */
hr = IAudioCaptureClient_ReleaseBuffer (self->capture_client, have_frames);
if (hr != S_OK) {
+ gchar *msg = gst_wasapi_util_hresult_to_string (hr);
GST_ERROR_OBJECT (self,
- "IAudioCaptureClient::ReleaseBuffer () failed: %s",
- gst_wasapi_util_hresult_to_string (hr));
+ "IAudioCaptureClient::ReleaseBuffer () failed: %s", msg);
+ g_free (msg);
goto beach;
}
}
@@ -620,9 +624,10 @@ gst_wasapi_src_delay (GstAudioSrc * asrc)
hr = IAudioClient_GetCurrentPadding (self->client, &delay);
if (hr != S_OK) {
+ gchar *msg = gst_wasapi_util_hresult_to_string (hr);
GST_ELEMENT_ERROR (self, RESOURCE, READ, (NULL),
- ("IAudioClient::GetCurrentPadding failed %s",
- gst_wasapi_util_hresult_to_string (hr)));
+ ("IAudioClient::GetCurrentPadding failed %s", msg));
+ g_free (msg);
}
return delay;
@@ -637,15 +642,17 @@ gst_wasapi_src_reset (GstAudioSrc * asrc)
if (self->client) {
hr = IAudioClient_Stop (self->client);
if (hr != S_OK) {
- GST_ERROR_OBJECT (self, "IAudioClient::Stop () failed: %s",
- gst_wasapi_util_hresult_to_string (hr));
+ gchar *msg = gst_wasapi_util_hresult_to_string (hr);
+ GST_ERROR_OBJECT (self, "IAudioClient::Stop () failed: %s", msg);
+ g_free (msg);
return;
}
hr = IAudioClient_Reset (self->client);
if (hr != S_OK) {
- GST_ERROR_OBJECT (self, "IAudioClient::Reset () failed: %s",
- gst_wasapi_util_hresult_to_string (hr));
+ gchar *msg = gst_wasapi_util_hresult_to_string (hr);
+ GST_ERROR_OBJECT (self, "IAudioClient::Reset () failed: %s", msg);
+ g_free (msg);
return;
}
}