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
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
70 deletions
+63
-70
Makefile.am
src/Makefile.am
+1
-0
audioOutput_oss.c
src/audioOutput_oss.c
+53
-61
volume.c
src/volume.c
+9
-9
No files found.
src/Makefile.am
View file @
1d34894f
...
@@ -58,6 +58,7 @@ mpd_SOURCES = \
...
@@ -58,6 +58,7 @@ mpd_SOURCES = \
audio.c
\
audio.c
\
audioOutput.c
\
audioOutput.c
\
audioOutput_ao.c
\
audioOutput_ao.c
\
audioOutput_oss.c
\
audioOutput_shout.c
\
audioOutput_shout.c
\
buffer2array.c
\
buffer2array.c
\
charConv.c
\
charConv.c
\
...
...
src/audioOutput_oss.c
View file @
1d34894f
...
@@ -18,8 +18,10 @@
...
@@ -18,8 +18,10 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* 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
#ifdef HAVE_OSS
...
@@ -30,7 +32,6 @@
...
@@ -30,7 +32,6 @@
#include <string.h>
#include <string.h>
#include <assert.h>
#include <assert.h>
#include <signal.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/stat.h>
...
@@ -45,7 +46,7 @@
...
@@ -45,7 +46,7 @@
# include <sys/soundcard.h>
# include <sys/soundcard.h>
#endif
/* !(defined(__OpenBSD__) || defined(__NetBSD__) */
#endif
/* !(defined(__OpenBSD__) || defined(__NetBSD__) */
static
typedef
struct
_OssData
{
typedef
struct
_OssData
{
int
fd
;
int
fd
;
char
*
device
;
char
*
device
;
}
OssData
;
}
OssData
;
...
@@ -65,20 +66,19 @@ static void freeOssData(OssData * od) {
...
@@ -65,20 +66,19 @@ static void freeOssData(OssData * od) {
free
(
od
);
free
(
od
);
}
}
static
void
oss_initDriver
(
AudioOutput
*
audioOutput
,
ConfigParam
*
param
)
{
static
int
oss_initDriver
(
AudioOutput
*
audioOutput
,
ConfigParam
*
param
)
{
char
*
test
;
BlockParam
*
bp
=
getBlockParam
(
param
,
"device"
);
BlockParam
*
bp
=
getBlockParam
(
param
,
"device"
);
OssData
*
od
=
newOssData
()
:
OssData
*
od
=
newOssData
()
;
audioOutput
->
data
=
od
;
audioOutput
->
data
=
od
;
if
(
!
bp
)
{
if
(
!
bp
)
{
int
fd
;
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"
);
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"
);
od
->
device
=
strdup
(
"/dev/dsp"
);
}
}
else
{
else
{
...
@@ -92,12 +92,12 @@ static void oss_initDriver(AudioOutput * audioOutput, ConfigParam * param) {
...
@@ -92,12 +92,12 @@ static void oss_initDriver(AudioOutput * audioOutput, ConfigParam * param) {
close
(
od
->
fd
);
close
(
od
->
fd
);
od
->
fd
=
-
1
;
od
->
fd
=
-
1
;
return
;
return
0
;
}
}
od
->
device
=
strdup
(
bp
->
value
);
od
->
device
=
strdup
(
bp
->
value
);
return
;
return
0
;
}
}
static
void
oss_finishDriver
(
AudioOutput
*
audioOutput
)
{
static
void
oss_finishDriver
(
AudioOutput
*
audioOutput
)
{
...
@@ -106,79 +106,71 @@ static void oss_finishDriver(AudioOutput * audioOutput) {
...
@@ -106,79 +106,71 @@ static void oss_finishDriver(AudioOutput * audioOutput) {
freeOssData
(
od
);
freeOssData
(
od
);
}
}
static
int
oss_openDevice
(
AudioOutput
*
audioOutput
,
static
int
oss_openDevice
(
AudioOutput
*
audioOutput
,
AudioFormat
*
audioFormat
)
AudioFormat
*
audioFormat
)
{
{
int
i
=
AFMT_S16_LE
,
err
=
0
;
OssData
*
od
=
audioOutput
->
data
;
if
(
audio_device
&&
!
isCurrentAudioFormat
(
audioFormat
))
#ifdef WORDS_BIGENDIAN
closeAudioDevice
();
int
i
=
AFMT_S16_BE
;
if
(
audio_device
!=
0
)
#else
return
0
;
int
i
=
AFMT_S16_LE
;
#endif
if
(
audioFormat
)
copyAudioFormat
(
&
audio_format
,
audioFormat
);
if
((
od
->
fd
=
open
(
od
->
device
,
O_WRONLY
))
<
0
)
goto
fail
;
blockSignals
();
if
(
ioctl
(
od
->
fd
,
SNDCTL_DSP_SETFMT
,
&
i
))
audio_device
=
open
(
"/dev/dsp"
,
O_WRONLY
);
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
;
if
(
audio_device
<
0
)
err
|=
1
;
return
0
;
if
(
ioctl
(
audio_device
,
SNDCTL_DSP_SETFMT
,
&
i
))
fail:
err
|=
2
;
if
(
od
->
fd
>=
0
)
close
(
od
->
fd
);
if
(
ioctl
(
audio_device
,
SNDCTL_DSP_CHANNELS
,
&
audio_format
.
channels
))
audioOutput
->
open
=
0
;
err
|=
4
;
ERROR
(
"Error opening OSS device
\"
%s
\"
: %s
\n
"
,
od
->
device
,
if
(
ioctl
(
audio_device
,
SNDCTL_DSP_SPEED
,
&
audio_format
.
sampleRate
))
strerror
(
errno
));
err
|=
8
;
return
-
1
;
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
();
static
void
oss_closeDevice
(
AudioOutput
*
audioOutput
)
{
OssData
*
od
=
audioOutput
->
data
;
if
(
err
)
if
(
od
->
fd
>=
0
)
{
ERROR
(
"Error opening /dev/dsp: 0x%x
\n
"
);
close
(
od
->
fd
);
if
(
!
audio_device
)
od
->
fd
=
-
1
;
return
-
1
;
}
return
0
;
audioOutput
->
open
=
0
;
}
}
static
int
oss_playAudio
(
AudioOutput
*
audioOutput
,
char
*
playChunk
,
static
int
oss_playAudio
(
AudioOutput
*
audioOutput
,
char
*
playChunk
,
int
size
)
int
size
)
{
{
int
send
;
OssData
*
od
=
audioOutput
->
data
;
int
ret
;
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
)
{
while
(
size
>
0
)
{
ret
=
write
(
audio_device
,
playChunk
,
send
);
ret
=
write
(
od
->
fd
,
playChunk
,
size
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
audioError
();
ERROR
(
"closing audio device due to write error
\n
"
);
ERROR
(
"closing audio device due to write error
\n
"
);
closeAudioDevice
(
);
oss_closeDevice
(
audioOutput
);
return
-
1
;
return
-
1
;
}
}
playChunk
+=
ret
;
playChunk
+=
ret
;
size
-=
ret
;
size
-=
ret
;
}
}
return
0
;
return
0
;
}
}
static
void
oss_closeDevice
(
AudioOutput
*
audioOutput
)
{
AudioOutputPlugin
ossPlugin
=
if
(
audio_device
)
{
blockSignals
();
close
(
audio_device
);
audio_device
=
0
;
unblockSignals
();
}
}
AudioOutput
ossPlugin
=
{
{
"oss"
,
"oss"
,
oss_initDriver
,
oss_initDriver
,
...
@@ -191,7 +183,7 @@ AudioOutput ossPlugin =
...
@@ -191,7 +183,7 @@ AudioOutput ossPlugin =
#else
/* HAVE OSS */
#else
/* HAVE OSS */
AudioOutput
ossPlugin
=
AudioOutput
Plugin
ossPlugin
=
{
{
NULL
,
NULL
,
NULL
,
NULL
,
...
...
src/volume.c
View file @
1d34894f
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
#include <sys/ioctl.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <fcntl.h>
#include <errno.h>
#include <errno.h>
#if
ndef NO_OSS_MIXER
#if
def HAVE_OSS
#include <sys/soundcard.h>
#include <sys/soundcard.h>
#endif
#endif
#ifdef HAVE_ALSA
#ifdef HAVE_ALSA
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
#define VOLUME_MIXER_ALSA_DEFAULT "default"
#define VOLUME_MIXER_ALSA_DEFAULT "default"
#define VOLUME_MIXER_ALSA_CONTROL_DEFAULT "Master"
#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_TYPE_DEFAULT VOLUME_MIXER_TYPE_OSS
#define VOLUME_MIXER_DEVICE_DEFAULT VOLUME_MIXER_OSS_DEFAULT
#define VOLUME_MIXER_DEVICE_DEFAULT VOLUME_MIXER_OSS_DEFAULT
#else
#else
...
@@ -63,7 +63,7 @@ char * volume_mixerDevice = VOLUME_MIXER_DEVICE_DEFAULT;
...
@@ -63,7 +63,7 @@ char * volume_mixerDevice = VOLUME_MIXER_DEVICE_DEFAULT;
int
volume_softwareSet
=
100
;
int
volume_softwareSet
=
100
;
#if
ndef NO_OSS_MIXER
#if
def HAVE_OSS
int
volume_ossFd
;
int
volume_ossFd
;
int
volume_ossControl
=
SOUND_MIXER_VOLUME
;
int
volume_ossControl
=
SOUND_MIXER_VOLUME
;
#endif
#endif
...
@@ -76,7 +76,7 @@ long volume_alsaMax;
...
@@ -76,7 +76,7 @@ long volume_alsaMax;
int
volume_alsaSet
=
-
1
;
int
volume_alsaSet
=
-
1
;
#endif
#endif
#if
ndef NO_OSS_MIXER
#if
def HAVE_OSS
int
prepOssMixer
(
char
*
device
)
{
int
prepOssMixer
(
char
*
device
)
{
int
devmask
=
0
;
int
devmask
=
0
;
ConfigParam
*
param
;
ConfigParam
*
param
;
...
@@ -335,7 +335,7 @@ int prepMixer(char * device) {
...
@@ -335,7 +335,7 @@ int prepMixer(char * device) {
case
VOLUME_MIXER_TYPE_ALSA
:
case
VOLUME_MIXER_TYPE_ALSA
:
return
prepAlsaMixer
(
device
);
return
prepAlsaMixer
(
device
);
#endif
#endif
#if
ndef NO_OSS_MIXER
#if
def HAVE_OSS
case
VOLUME_MIXER_TYPE_OSS
:
case
VOLUME_MIXER_TYPE_OSS
:
return
prepOssMixer
(
device
);
return
prepOssMixer
(
device
);
#endif
#endif
...
@@ -351,7 +351,7 @@ void finishVolume() {
...
@@ -351,7 +351,7 @@ void finishVolume() {
closeAlsaMixer
();
closeAlsaMixer
();
break
;
break
;
#endif
#endif
#ifndef
NO_OSS_MIXER
#ifndef
HAVE_OSS
case
VOLUME_MIXER_TYPE_OSS
:
case
VOLUME_MIXER_TYPE_OSS
:
closeOssMixer
();
closeOssMixer
();
break
;
break
;
...
@@ -370,7 +370,7 @@ void initVolume() {
...
@@ -370,7 +370,7 @@ void initVolume() {
volume_mixerDevice
=
VOLUME_MIXER_ALSA_DEFAULT
;
volume_mixerDevice
=
VOLUME_MIXER_ALSA_DEFAULT
;
}
}
#endif
#endif
#ifndef
NO_OSS_MIXER
#ifndef
HAVE_OSS
else
if
(
strcmp
(
param
->
value
,
VOLUME_MIXER_OSS
)
==
0
)
{
else
if
(
strcmp
(
param
->
value
,
VOLUME_MIXER_OSS
)
==
0
)
{
volume_mixerType
=
VOLUME_MIXER_TYPE_OSS
;
volume_mixerType
=
VOLUME_MIXER_TYPE_OSS
;
volume_mixerDevice
=
VOLUME_MIXER_OSS_DEFAULT
;
volume_mixerDevice
=
VOLUME_MIXER_OSS_DEFAULT
;
...
@@ -411,7 +411,7 @@ int getVolumeLevel() {
...
@@ -411,7 +411,7 @@ int getVolumeLevel() {
case
VOLUME_MIXER_TYPE_ALSA
:
case
VOLUME_MIXER_TYPE_ALSA
:
return
getAlsaVolumeLevel
();
return
getAlsaVolumeLevel
();
#endif
#endif
#ifndef
NO_OSS_MIXER
#ifndef
HAVE_OSS
case
VOLUME_MIXER_TYPE_OSS
:
case
VOLUME_MIXER_TYPE_OSS
:
return
getOssVolumeLevel
();
return
getOssVolumeLevel
();
#endif
#endif
...
@@ -448,7 +448,7 @@ int changeVolumeLevel(FILE * fp, int change, int rel) {
...
@@ -448,7 +448,7 @@ int changeVolumeLevel(FILE * fp, int change, int rel) {
case
VOLUME_MIXER_TYPE_ALSA
:
case
VOLUME_MIXER_TYPE_ALSA
:
return
changeAlsaVolumeLevel
(
fp
,
change
,
rel
);
return
changeAlsaVolumeLevel
(
fp
,
change
,
rel
);
#endif
#endif
#ifndef
NO_OSS_MIXER
#ifndef
HAVE_OSS
case
VOLUME_MIXER_TYPE_OSS
:
case
VOLUME_MIXER_TYPE_OSS
:
return
changeOssVolumeLevel
(
fp
,
change
,
rel
);
return
changeOssVolumeLevel
(
fp
,
change
,
rel
);
#endif
#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