mirror of
https://github.com/mpv-player/mpv
synced 2024-12-27 17:42:17 +00:00
non-blocking open - patch by Fredrik Kuivinen <freku045@student.liu.se>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@5205 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
dbfd7500d4
commit
3027484518
@ -7,6 +7,8 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
//#include <sys/soundcard.h>
|
||||
|
||||
#include "../config.h"
|
||||
@ -101,9 +103,15 @@ static int init(int rate,int channels,int format,int flags){
|
||||
if (verbose)
|
||||
printf("audio_setup: using '%s' dsp device\n", dsp);
|
||||
|
||||
audio_fd=open(dsp, O_WRONLY);
|
||||
audio_fd=open(dsp, O_WRONLY | O_NONBLOCK);
|
||||
if(audio_fd<0){
|
||||
printf("Can't open audio device %s -> nosound\n",dsp);
|
||||
printf("Can't open audio device %s: %s -> no sound\n", dsp, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Remove the non-blocking flag */
|
||||
if(fcntl(audio_fd, F_SETFL, 0) < 0) {
|
||||
printf("Can't make filedescriptor non-blocking: %s -> no sound\n", strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -203,9 +211,9 @@ static void uninit(){
|
||||
// stop playing and empty buffers (for seeking/pause)
|
||||
static void reset(){
|
||||
uninit();
|
||||
audio_fd=open(dsp, O_WRONLY);
|
||||
if(audio_fd<0){
|
||||
printf("\nFatal error: *** CANNOT RE-OPEN / RESET AUDIO DEVICE ***\n");
|
||||
audio_fd=open(dsp, O_WRONLY | O_NONBLOCK);
|
||||
if(audio_fd < 0 || fcntl(audio_fd, F_SETFL, 0) < 0){
|
||||
printf("\nFatal error: *** CANNOT RE-OPEN / RESET AUDIO DEVICE *** %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user