summaryrefslogtreecommitdiff
path: root/plugins/oss
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <waker@users.sourceforge.net>2014-05-11 19:51:28 +0200
committerGravatar Alexey Yakovenko <waker@users.sourceforge.net>2014-05-11 19:51:28 +0200
commit1428dcfd195e1547822512690a41df5f09ebc8bd (patch)
tree1a538d4eddc2881be74a433fd2b601495aaee4ab /plugins/oss
parent3e479de90998d9eecad0977467591c9d035722dc (diff)
oss: possible fix to deadlock caused by oss_stop
Diffstat (limited to 'plugins/oss')
-rw-r--r--plugins/oss/oss.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/plugins/oss/oss.c b/plugins/oss/oss.c
index 4a26d448..538b4807 100644
--- a/plugins/oss/oss.c
+++ b/plugins/oss/oss.c
@@ -133,11 +133,10 @@ oss_init (void) {
mutex = 0;
// prepare oss for playback
- const char *name = oss_device;
- fd = open (name, O_WRONLY);
+ fd = open (oss_device, O_WRONLY);
if (fd == -1) {
- fprintf (stderr, "oss: failed to open file %s\n", name);
- perror (name);
+ fprintf (stderr, "oss: failed to open file %s\n", oss_device);
+ perror (oss_device);
plugin.free ();
return -1;
}
@@ -188,7 +187,7 @@ static int
oss_stop (void) {
state = OUTPUT_STATE_STOPPED;
deadbeef->streamer_reset (1);
- return oss_free();
+ return 0;
}
static int
@@ -216,21 +215,23 @@ oss_setformat (ddb_waveformat_t *fmt) {
int _state = state;
int v4workaround = deadbeef->conf_get_int ("oss.v4workaround", 0);
+ deadbeef->mutex_lock (mutex);
+
if (v4workaround) {
- oss_stop ();
+ if (fd) {
+ close (fd);
+ fd = 0;
+ }
+ fd = open (oss_device, O_WRONLY);
memcpy (&plugin.fmt, fmt, sizeof (ddb_waveformat_t));
}
- else {
- deadbeef->mutex_lock (mutex);
-
- if (0 != oss_set_hwparams (fmt)) {
- deadbeef->mutex_unlock (mutex);
- return -1;
- }
-
+ if (0 != oss_set_hwparams (fmt)) {
deadbeef->mutex_unlock (mutex);
+ return -1;
}
+ deadbeef->mutex_unlock (mutex);
+
switch (_state) {
case OUTPUT_STATE_STOPPED:
return oss_stop ();