Patchwork [2/2] ossaudio: check for oss support in oss_audio_init

login
register
mail settings
Submitter Gerd Hoffmann
Date Nov. 7, 2013, 11:32 a.m.
Message ID <1383823947-5132-3-git-send-email-kraxel@redhat.com>
Download mbox | patch
Permalink /patch/289300/
State New
Headers show

Comments

Gerd Hoffmann - Nov. 7, 2013, 11:32 a.m.
Check whenever the device path (/dev/dsp by default) exists and qemu is
allowed to access it.  Return NULL if it isn't, so ossaudio will not
be used on systems wihtout oss support (increasinly common on modern
linux systems).

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 audio/ossaudio.c | 4 ++++
 1 file changed, 4 insertions(+)

Patch

diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index 007c641..5a73716 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -849,6 +849,10 @@  static int oss_ctl_in (HWVoiceIn *hw, int cmd, ...)
 
 static void *oss_audio_init (void)
 {
+    if (access(conf.devpath_in, R_OK | W_OK) < 0 ||
+        access(conf.devpath_out, R_OK | W_OK) < 0) {
+        return NULL;
+    }
     return &conf;
 }