Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
682fe8ce
Commit
682fe8ce
authored
Aug 01, 2006
by
Eric Wong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
audioOutput_oss: cleanups (stolen from -ke)
git-svn-id:
https://svn.musicpd.org/mpd/trunk@4518
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
83b619e9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
73 deletions
+58
-73
audioOutput_oss.c
src/audioOutputs/audioOutput_oss.c
+58
-73
No files found.
src/audioOutputs/audioOutput_oss.c
View file @
682fe8ce
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#ifdef HAVE_OSS
#ifdef HAVE_OSS
#include "../utils.h"
#include "../conf.h"
#include "../conf.h"
#include "../log.h"
#include "../log.h"
#include "../sig_handlers.h"
#include "../sig_handlers.h"
...
@@ -54,7 +55,7 @@
...
@@ -54,7 +55,7 @@
typedef
struct
_OssData
{
typedef
struct
_OssData
{
int
fd
;
int
fd
;
char
*
device
;
c
onst
c
har
*
device
;
int
channels
;
int
channels
;
int
sampleRate
;
int
sampleRate
;
int
bitFormat
;
int
bitFormat
;
...
@@ -282,9 +283,6 @@ static OssData *newOssData(void)
...
@@ -282,9 +283,6 @@ static OssData *newOssData(void)
static
void
freeOssData
(
OssData
*
od
)
static
void
freeOssData
(
OssData
*
od
)
{
{
if
(
od
->
device
)
free
(
od
->
device
);
if
(
od
->
supported
[
OSS_RATE
])
if
(
od
->
supported
[
OSS_RATE
])
free
(
od
->
supported
[
OSS_RATE
]);
free
(
od
->
supported
[
OSS_RATE
]);
if
(
od
->
supported
[
OSS_CHANNELS
])
if
(
od
->
supported
[
OSS_CHANNELS
])
...
@@ -307,7 +305,7 @@ static void freeOssData(OssData * od)
...
@@ -307,7 +305,7 @@ static void freeOssData(OssData * od)
#define OSS_STAT_DOESN_T_EXIST -3
#define OSS_STAT_DOESN_T_EXIST -3
#define OSS_STAT_OTHER -4
#define OSS_STAT_OTHER -4
static
int
oss_statDevice
(
char
*
device
,
int
*
stErrno
)
static
int
oss_statDevice
(
c
onst
c
har
*
device
,
int
*
stErrno
)
{
{
struct
stat
st
;
struct
stat
st
;
...
@@ -332,89 +330,76 @@ static int oss_statDevice(char *device, int *stErrno)
...
@@ -332,89 +330,76 @@ static int oss_statDevice(char *device, int *stErrno)
return
0
;
return
0
;
}
}
static
const
char
*
default_devices
[]
=
{
"/dev/sound/dsp"
,
"/dev/dsp"
};
static
int
oss_testDefault
(
void
)
static
int
oss_testDefault
(
void
)
{
{
int
fd
;
int
fd
,
i
;
fd
=
open
(
"/dev/sound/dsp"
,
O_WRONLY
);
if
(
fd
>=
0
)
{
for
(
i
=
ARRAY_SIZE
(
default_devices
);
--
i
>=
0
;
)
{
close
(
fd
);
if
((
fd
=
open
(
default_devices
[
i
],
O_WRONLY
))
>=
0
)
{
return
0
;
xclose
(
fd
);
return
0
;
}
WARNING
(
"Error opening OSS device
\"
%s
\"
: %s
\n
"
,
default_devices
[
i
],
strerror
(
errno
));
}
}
WARNING
(
"Error opening OSS device
\"
/dev/sound/dsp
\"
: %s
\n
"
,
return
-
1
;
strerror
(
errno
));
}
fd
=
open
(
"/dev/dsp"
,
O_WRONLY
);
static
int
oss_open_default
(
AudioOutput
*
ao
,
ConfigParam
*
param
,
OssData
*
od
)
{
int
i
;
int
err
[
ARRAY_SIZE
(
default_devices
)];
int
ret
[
ARRAY_SIZE
(
default_devices
)];
if
(
fd
>=
0
)
{
for
(
i
=
ARRAY_SIZE
(
default_devices
);
--
i
>=
0
;
)
{
close
(
fd
);
ret
[
i
]
=
oss_statDevice
(
default_devices
[
i
],
&
err
[
i
]);
return
0
;
if
(
ret
[
i
]
==
0
)
{
od
->
device
=
default_devices
[
i
];
return
0
;
}
}
}
WARNING
(
"Error opening OSS device
\"
/dev/dsp
\"
: %s
\n
"
,
strerror
(
errno
));
if
(
param
)
ERROR
(
"Error trying to open specified OSS device"
return
-
1
;
" at line %i
\n
"
,
param
->
line
);
else
ERROR
(
"error trying to open default OSS device
\n
"
);
for
(
i
=
ARRAY_SIZE
(
default_devices
)
-
1
;
i
>=
0
;
--
i
)
{
const
char
*
dev
=
default_devices
[
i
];
switch
(
ret
[
i
])
{
case
OSS_STAT_DOESN_T_EXIST
:
ERROR
(
"%s not found
\n
"
,
dev
);
break
;
case
OSS_STAT_NOT_CHAR_DEV
:
ERROR
(
"%s is not a character device
\n
"
,
dev
);
break
;
case
OSS_STAT_NO_PERMS
:
ERROR
(
"%s: permission denied
\n
"
,
dev
);
break
;
default:
ERROR
(
"Error accessing %s: %s"
,
dev
,
strerror
(
err
[
i
]));
}
}
exit
(
EXIT_FAILURE
);
return
0
;
/* some compilers can be dumb... */
}
}
static
int
oss_initDriver
(
AudioOutput
*
audioOutput
,
ConfigParam
*
param
)
static
int
oss_initDriver
(
AudioOutput
*
audioOutput
,
ConfigParam
*
param
)
{
{
BlockParam
*
bp
=
NULL
;
OssData
*
od
=
newOssData
();
OssData
*
od
;
if
(
param
)
bp
=
getBlockParam
(
param
,
"device"
);
od
=
newOssData
();
audioOutput
->
data
=
od
;
audioOutput
->
data
=
od
;
if
(
param
)
{
if
(
!
bp
)
{
BlockParam
*
bp
=
getBlockParam
(
param
,
"device"
);
int
err
[
2
];
if
(
bp
)
{
int
ret
[
2
];
od
->
device
=
bp
->
value
;
return
0
;
ret
[
0
]
=
oss_statDevice
(
"/dev/sound/dsp"
,
err
);
ret
[
1
]
=
oss_statDevice
(
"/dev/dsp"
,
err
+
1
);
if
(
ret
[
0
]
==
0
)
od
->
device
=
strdup
(
"/dev/sound/dsp"
);
else
if
(
ret
[
1
]
==
0
)
od
->
device
=
strdup
(
"/dev/dsp"
);
else
{
if
(
param
)
{
ERROR
(
"Error trying to open default OSS device "
"specified at line %i
\n
"
,
param
->
line
);
}
else
{
ERROR
(
"Error trying to open default OSS "
"device
\n
"
);
}
if
((
ret
[
0
]
==
OSS_STAT_DOESN_T_EXIST
)
&&
(
ret
[
1
]
==
OSS_STAT_DOESN_T_EXIST
))
{
ERROR
(
"Neither /dev/dsp nor /dev/sound/dsp "
"were found
\n
"
);
}
else
if
(
ret
[
0
]
==
OSS_STAT_NOT_CHAR_DEV
)
{
ERROR
(
"/dev/sound/dsp is not a char device"
);
}
else
if
(
ret
[
1
]
==
OSS_STAT_NOT_CHAR_DEV
)
{
ERROR
(
"/dev/dsp is not a char device"
);
}
else
if
(
ret
[
0
]
==
OSS_STAT_NO_PERMS
)
{
ERROR
(
"no permission to access /dev/sound/dsp"
);
}
else
if
(
ret
[
1
]
==
OSS_STAT_NO_PERMS
)
{
ERROR
(
"no permission to access /dev/dsp"
);
}
else
if
(
ret
[
0
]
==
OSS_STAT_OTHER
)
{
ERROR
(
"Error accessing /dev/sound/dsp: %s"
,
strerror
(
err
[
0
]));
}
else
if
(
ret
[
1
]
==
OSS_STAT_OTHER
)
{
ERROR
(
"Error accessing /dev/dsp: %s"
,
strerror
(
err
[
1
]));
}
exit
(
EXIT_FAILURE
);
}
}
}
else
}
od
->
device
=
strdup
(
bp
->
value
);
return
oss_open_default
(
audioOutput
,
param
,
od
);
return
0
;
}
}
static
void
oss_finishDriver
(
AudioOutput
*
audioOutput
)
static
void
oss_finishDriver
(
AudioOutput
*
audioOutput
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment