summaryrefslogtreecommitdiff
path: root/backends/oss/oss-stream-control.c
diff options
context:
space:
mode:
authorMichal Ratajsky <[email protected]>2016-01-04 20:31:14 +0100
committerMichal Ratajsky <[email protected]>2016-01-04 20:31:14 +0100
commit9772797c31ebed2417b42a9389caae1b16847e86 (patch)
tree0257271d6f8387ce89984bf8341b11186381c8d5 /backends/oss/oss-stream-control.c
parentd32ca3f420d036cd750fc1aad7f95da40559cc5d (diff)
downloadlibmatemixer-9772797c31ebed2417b42a9389caae1b16847e86.tar.bz2
libmatemixer-9772797c31ebed2417b42a9389caae1b16847e86.tar.xz
Improve error checking in many places
Diffstat (limited to 'backends/oss/oss-stream-control.c')
-rw-r--r--backends/oss/oss-stream-control.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/backends/oss/oss-stream-control.c b/backends/oss/oss-stream-control.c
index 0307fc7..9bdd3a5 100644
--- a/backends/oss/oss-stream-control.c
+++ b/backends/oss/oss-stream-control.c
@@ -24,6 +24,7 @@
#include <libmatemixer/matemixer-private.h>
#include "oss-common.h"
+#include "oss-stream.h"
#include "oss-stream-control.h"
#define OSS_VOLUME_JOIN(left,right) (((left) & 0xFF) | (((right) & 0xFF) << 8))
@@ -136,10 +137,19 @@ oss_stream_control_new (const gchar *name,
gboolean stereo)
{
OssStreamControl *control;
+ gint newfd;
MateMixerStreamControlFlags flags;
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (label != NULL, NULL);
+ g_return_val_if_fail (OSS_IS_STREAM (stream), NULL);
+
+ newfd = dup (fd);
+ if (newfd == -1) {
+ g_warning ("Failed to duplicate file descriptor: %s",
+ g_strerror (errno));
+ return NULL;
+ }
flags = MATE_MIXER_STREAM_CONTROL_VOLUME_READABLE |
MATE_MIXER_STREAM_CONTROL_VOLUME_WRITABLE;
@@ -154,7 +164,7 @@ oss_stream_control_new (const gchar *name,
"stream", stream,
NULL);
- control->priv->fd = fd;
+ control->priv->fd = newfd;
control->priv->devnum = devnum;
control->priv->stereo = stereo;
return control;
@@ -367,18 +377,24 @@ oss_stream_control_get_min_volume (MateMixerStreamControl *mmsc)
static guint
oss_stream_control_get_max_volume (MateMixerStreamControl *mmsc)
{
+ g_return_val_if_fail (OSS_IS_STREAM_CONTROL (mmsc), 0);
+
return 100;
}
static guint
oss_stream_control_get_normal_volume (MateMixerStreamControl *mmsc)
{
+ g_return_val_if_fail (OSS_IS_STREAM_CONTROL (mmsc), 0);
+
return 100;
}
static guint
oss_stream_control_get_base_volume (MateMixerStreamControl *mmsc)
{
+ g_return_val_if_fail (OSS_IS_STREAM_CONTROL (mmsc), 0);
+
return 100;
}