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
1d34894f
Commit
1d34894f
authored
Oct 30, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish integrating in np's oss stuff
git-svn-id:
https://svn.musicpd.org/mpd/trunk@2413
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
657bec26
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
72 deletions
+65
-72
Makefile.am
src/Makefile.am
+1
-0
audioOutput_oss.c
src/audioOutput_oss.c
+55
-63
volume.c
src/volume.c
+9
-9
No files found.
src/Makefile.am
View file @
1d34894f
...
...
@@ -58,6 +58,7 @@ mpd_SOURCES = \
audio.c
\
audioOutput.c
\
audioOutput_ao.c
\
audioOutput_oss.c
\
audioOutput_shout.c
\
buffer2array.c
\
charConv.c
\
...
...
src/audioOutput_oss.c
View file @
1d34894f
...
...
@@ -18,8 +18,10 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "../config.h"
#include "audioOutput.h"
#include
"audio.h"
#include
<stdlib.h>
#ifdef HAVE_OSS
...
...
@@ -30,7 +32,6 @@
#include <string.h>
#include <assert.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
...
...
@@ -45,7 +46,7 @@
# include <sys/soundcard.h>
#endif
/* !(defined(__OpenBSD__) || defined(__NetBSD__) */
static
typedef
struct
_OssData
{
typedef
struct
_OssData
{
int
fd
;
char
*
device
;
}
OssData
;
...
...
@@ -65,20 +66,19 @@ static void freeOssData(OssData * od) {
free
(
od
);
}
static
void
oss_initDriver
(
AudioOutput
*
audioOutput
,
ConfigParam
*
param
)
{
char
*
test
;
static
int
oss_initDriver
(
AudioOutput
*
audioOutput
,
ConfigParam
*
param
)
{
BlockParam
*
bp
=
getBlockParam
(
param
,
"device"
);
OssData
*
od
=
newOssData
()
:
OssData
*
od
=
newOssData
()
;
audioOutput
->
data
=
od
;
if
(
!
bp
)
{
int
fd
;
if
(
0
<=
(
fd
=
f
open
(
"/dev/sound/dsp"
,
O_WRONLY
|
O_NONBLOCK
)))
{
if
(
0
<=
(
fd
=
open
(
"/dev/sound/dsp"
,
O_WRONLY
|
O_NONBLOCK
)))
{
od
->
device
=
strdup
(
"/dev/sound/dsp"
);
}
else
if
(
0
<=
(
fd
=
f
open
(
"/dev/dsp"
,
O_WRONLY
|
O_NONBLOCK
)))
{
else
if
(
0
<=
(
fd
=
open
(
"/dev/dsp"
,
O_WRONLY
|
O_NONBLOCK
)))
{
od
->
device
=
strdup
(
"/dev/dsp"
);
}
else
{
...
...
@@ -92,12 +92,12 @@ static void oss_initDriver(AudioOutput * audioOutput, ConfigParam * param) {
close
(
od
->
fd
);
od
->
fd
=
-
1
;
return
;
return
0
;
}
od
->
device
=
strdup
(
bp
->
value
);
return
;
return
0
;
}
static
void
oss_finishDriver
(
AudioOutput
*
audioOutput
)
{
...
...
@@ -106,79 +106,71 @@ static void oss_finishDriver(AudioOutput * audioOutput) {
freeOssData
(
od
);
}
static
int
oss_openDevice
(
AudioOutput
*
audioOutput
,
AudioFormat
*
audioFormat
)
static
int
oss_openDevice
(
AudioOutput
*
audioOutput
,
AudioFormat
*
audioFormat
)
{
int
i
=
AFMT_S16_LE
,
err
=
0
;
if
(
audio_device
&&
!
isCurrentAudioFormat
(
audioFormat
))
closeAudioDevice
();
if
(
audio_device
!=
0
)
return
0
;
if
(
audioFormat
)
copyAudioFormat
(
&
audio_format
,
audioFormat
);
blockSignals
();
audio_device
=
open
(
"/dev/dsp"
,
O_WRONLY
);
if
(
audio_device
<
0
)
err
|=
1
;
if
(
ioctl
(
audio_device
,
SNDCTL_DSP_SETFMT
,
&
i
))
err
|=
2
;
if
(
ioctl
(
audio_device
,
SNDCTL_DSP_CHANNELS
,
&
audio_format
.
channels
))
err
|=
4
;
if
(
ioctl
(
audio_device
,
SNDCTL_DSP_SPEED
,
&
audio_format
.
sampleRate
))
err
|=
8
;
if
(
ioctl
(
audio_device
,
SNDCTL_DSP_SAMPLESIZE
,
&
audio_format
.
bits
))
err
|=
16
;
/*i = 1; if (ioctl(audio_device,SNDCTL_DSP_STEREO,&i)) err != 32; */
unblockSignals
();
OssData
*
od
=
audioOutput
->
data
;
#ifdef WORDS_BIGENDIAN
int
i
=
AFMT_S16_BE
;
#else
int
i
=
AFMT_S16_LE
;
#endif
if
(
err
)
ERROR
(
"Error opening /dev/dsp: 0x%x
\n
"
);
if
(
!
audio_device
)
return
-
1
;
if
((
od
->
fd
=
open
(
od
->
device
,
O_WRONLY
))
<
0
)
goto
fail
;
if
(
ioctl
(
od
->
fd
,
SNDCTL_DSP_SETFMT
,
&
i
))
goto
fail
;
if
(
ioctl
(
od
->
fd
,
SNDCTL_DSP_CHANNELS
,
&
audioFormat
->
channels
))
goto
fail
;
if
(
ioctl
(
od
->
fd
,
SNDCTL_DSP_SPEED
,
&
audioFormat
->
sampleRate
))
goto
fail
;
if
(
ioctl
(
od
->
fd
,
SNDCTL_DSP_SAMPLESIZE
,
&
audioFormat
->
bits
))
goto
fail
;
/*i = 1; if (ioctl(od->fd,SNDCTL_DSP_STEREO,&i)) err != 32; */
audioOutput
->
open
=
1
;
return
0
;
fail:
if
(
od
->
fd
>=
0
)
close
(
od
->
fd
);
audioOutput
->
open
=
0
;
ERROR
(
"Error opening OSS device
\"
%s
\"
: %s
\n
"
,
od
->
device
,
strerror
(
errno
));
return
-
1
;
}
static
void
oss_closeDevice
(
AudioOutput
*
audioOutput
)
{
OssData
*
od
=
audioOutput
->
data
;
if
(
od
->
fd
>=
0
)
{
close
(
od
->
fd
);
od
->
fd
=
-
1
;
}
audioOutput
->
open
=
0
;
}
static
int
oss_playAudio
(
AudioOutput
*
audioOutput
,
char
*
playChunk
,
int
size
)
{
int
send
;
OssData
*
od
=
audioOutput
->
data
;
int
ret
;
if
(
audio_device
==
0
)
{
ERROR
(
"trying to play w/o the audio device being open!
\n
"
);
return
-
1
;
}
send
=
audio_write_size
>
size
?
size
:
audio_write_size
;
while
(
size
>
0
)
{
ret
=
write
(
audio_device
,
playChunk
,
send
);
ret
=
write
(
od
->
fd
,
playChunk
,
size
);
if
(
ret
<
0
)
{
audioError
();
ERROR
(
"closing audio device due to write error
\n
"
);
closeAudioDevice
(
);
oss_closeDevice
(
audioOutput
);
return
-
1
;
}
playChunk
+=
ret
;
size
-=
ret
;
playChunk
+=
ret
;
size
-=
ret
;
}
return
0
;
}
static
void
oss_closeDevice
(
AudioOutput
*
audioOutput
)
{
if
(
audio_device
)
{
blockSignals
();
close
(
audio_device
);
audio_device
=
0
;
unblockSignals
();
}
}
AudioOutput
ossPlugin
=
AudioOutputPlugin
ossPlugin
=
{
"oss"
,
oss_initDriver
,
...
...
@@ -191,7 +183,7 @@ AudioOutput ossPlugin =
#else
/* HAVE OSS */
AudioOutput
ossPlugin
=
AudioOutput
Plugin
ossPlugin
=
{
NULL
,
NULL
,
...
...
src/volume.c
View file @
1d34894f
...
...
@@ -29,7 +29,7 @@
#include <sys/ioctl.h>
#include <fcntl.h>
#include <errno.h>
#if
ndef NO_OSS_MIXER
#if
def HAVE_OSS
#include <sys/soundcard.h>
#endif
#ifdef HAVE_ALSA
...
...
@@ -45,7 +45,7 @@
#define VOLUME_MIXER_ALSA_DEFAULT "default"
#define VOLUME_MIXER_ALSA_CONTROL_DEFAULT "Master"
#if
ndef NO_OSS_MIXER
#if
def HAVE_OSS
#define VOLUME_MIXER_TYPE_DEFAULT VOLUME_MIXER_TYPE_OSS
#define VOLUME_MIXER_DEVICE_DEFAULT VOLUME_MIXER_OSS_DEFAULT
#else
...
...
@@ -63,7 +63,7 @@ char * volume_mixerDevice = VOLUME_MIXER_DEVICE_DEFAULT;
int
volume_softwareSet
=
100
;
#if
ndef NO_OSS_MIXER
#if
def HAVE_OSS
int
volume_ossFd
;
int
volume_ossControl
=
SOUND_MIXER_VOLUME
;
#endif
...
...
@@ -76,7 +76,7 @@ long volume_alsaMax;
int
volume_alsaSet
=
-
1
;
#endif
#if
ndef NO_OSS_MIXER
#if
def HAVE_OSS
int
prepOssMixer
(
char
*
device
)
{
int
devmask
=
0
;
ConfigParam
*
param
;
...
...
@@ -335,7 +335,7 @@ int prepMixer(char * device) {
case
VOLUME_MIXER_TYPE_ALSA
:
return
prepAlsaMixer
(
device
);
#endif
#if
ndef NO_OSS_MIXER
#if
def HAVE_OSS
case
VOLUME_MIXER_TYPE_OSS
:
return
prepOssMixer
(
device
);
#endif
...
...
@@ -351,7 +351,7 @@ void finishVolume() {
closeAlsaMixer
();
break
;
#endif
#ifndef
NO_OSS_MIXER
#ifndef
HAVE_OSS
case
VOLUME_MIXER_TYPE_OSS
:
closeOssMixer
();
break
;
...
...
@@ -370,7 +370,7 @@ void initVolume() {
volume_mixerDevice
=
VOLUME_MIXER_ALSA_DEFAULT
;
}
#endif
#ifndef
NO_OSS_MIXER
#ifndef
HAVE_OSS
else
if
(
strcmp
(
param
->
value
,
VOLUME_MIXER_OSS
)
==
0
)
{
volume_mixerType
=
VOLUME_MIXER_TYPE_OSS
;
volume_mixerDevice
=
VOLUME_MIXER_OSS_DEFAULT
;
...
...
@@ -411,7 +411,7 @@ int getVolumeLevel() {
case
VOLUME_MIXER_TYPE_ALSA
:
return
getAlsaVolumeLevel
();
#endif
#ifndef
NO_OSS_MIXER
#ifndef
HAVE_OSS
case
VOLUME_MIXER_TYPE_OSS
:
return
getOssVolumeLevel
();
#endif
...
...
@@ -448,7 +448,7 @@ int changeVolumeLevel(FILE * fp, int change, int rel) {
case
VOLUME_MIXER_TYPE_ALSA
:
return
changeAlsaVolumeLevel
(
fp
,
change
,
rel
);
#endif
#ifndef
NO_OSS_MIXER
#ifndef
HAVE_OSS
case
VOLUME_MIXER_TYPE_OSS
:
return
changeOssVolumeLevel
(
fp
,
change
,
rel
);
#endif
...
...
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