diff options
author | Eric Wong <normalperson@yhbt.net> | 2006-07-16 16:53:04 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2006-07-16 16:53:04 +0000 |
commit | b8a0f1ae6d32847270748e92e744606107114737 (patch) | |
tree | 649b933f2c3e24761ee7ec0bb228a78fe5bf8486 /src/audioOutputs/audioOutput_oss.c | |
parent | ea6dc826a1c40047058ab7d86c848b32be3de25e (diff) | |
download | mpd-b8a0f1ae6d32847270748e92e744606107114737.tar.gz mpd-b8a0f1ae6d32847270748e92e744606107114737.tar.xz mpd-b8a0f1ae6d32847270748e92e744606107114737.zip |
OSS: handle device disconnects and reconnects (w/o needing a mpd restart)
Like the ALSA patches, this allows OSS devices to be disconnected
during playback and MPD will be able to reopen and reuse them without
restarting.
git-svn-id: https://svn.musicpd.org/mpd/trunk@4366 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/audioOutputs/audioOutput_oss.c')
-rw-r--r-- | src/audioOutputs/audioOutput_oss.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/audioOutputs/audioOutput_oss.c b/src/audioOutputs/audioOutput_oss.c index 02403124e..3b52b9807 100644 --- a/src/audioOutputs/audioOutput_oss.c +++ b/src/audioOutputs/audioOutput_oss.c @@ -421,6 +421,12 @@ static int setParam(OssData * od, int param, int * value) { return 0; } +static void oss_close(OssData * od) +{ + if(od->fd >= 0) while (close(od->fd) && errno == EINTR); + od->fd = -1; +} + static int oss_open(AudioOutput * audioOutput) { int tmp; OssData * od = audioOutput->data; @@ -468,7 +474,7 @@ static int oss_open(AudioOutput * audioOutput) { return 0; fail: - if(od->fd >= 0) close(od->fd); + oss_close(od); audioOutput->open = 0; return -1; } @@ -483,7 +489,8 @@ static int oss_openDevice(AudioOutput * audioOutput) od->sampleRate = audioFormat->sampleRate; od->bits = audioFormat->bits; - ret = oss_open(audioOutput); + if ((ret = oss_open(audioOutput)) < 0) + return ret; audioFormat->channels = od->channels; audioFormat->sampleRate = od->sampleRate; @@ -496,11 +503,6 @@ static int oss_openDevice(AudioOutput * audioOutput) return ret; } -static void oss_close(OssData * od) { - if(od->fd >= 0) close(od->fd); - od->fd = -1; -} - static void oss_closeDevice(AudioOutput * audioOutput) { OssData * od = audioOutput->data; @@ -516,8 +518,6 @@ static void oss_dropBufferedAudio(AudioOutput * audioOutput) { ioctl(od->fd, SNDCTL_DSP_RESET, 0); oss_close(od); } - - /*oss_open(audioOutput);*/ } static int oss_playAudio(AudioOutput * audioOutput, char * playChunk, @@ -527,7 +527,8 @@ static int oss_playAudio(AudioOutput * audioOutput, char * playChunk, int ret; /* reopen the device since it was closed by dropBufferedAudio */ - if(od->fd < 0) oss_open(audioOutput); + if(od->fd < 0 && oss_open(audioOutput) < 0) + return -1; while (size > 0) { ret = write(od->fd, playChunk, size); |