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
69176148
Commit
69176148
authored
Nov 02, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enabling and disabling individual audioOutputs is mostly done, just need
to add the command hooks git-svn-id:
https://svn.musicpd.org/mpd/trunk@2484
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
8b08ee82
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
29 deletions
+43
-29
audio.c
src/audio.c
+38
-27
audio.h
src/audio.h
+3
-0
main.c
src/main.c
+1
-1
playerData.h
src/playerData.h
+1
-1
No files found.
src/audio.c
View file @
69176148
...
...
@@ -22,6 +22,7 @@
#include "log.h"
#include "sig_handlers.h"
#include "command.h"
#include "playerData.h"
#include <stdlib.h>
#include <string.h>
...
...
@@ -36,7 +37,8 @@ static AudioOutput ** audioOutputArray = NULL;
static
mpd_uint8
audioOutputArraySize
=
0
;
/* the audioEnabledArray should be stuck into shared memory, and then disable
and enable in playAudio() routine */
static
mpd_uint8
*
audioEnabledArray
=
NULL
;
static
mpd_sint8
*
pdAudioDevicesEnabled
=
NULL
;
static
mpd_sint8
myAudioDevicesEnabled
[
AUDIO_MAX_DEVICES
];
static
mpd_uint8
audioOpened
=
0
;
...
...
@@ -54,6 +56,7 @@ extern AudioOutputPlugin aoPlugin;
extern
AudioOutputPlugin
shoutPlugin
;
extern
AudioOutputPlugin
ossPlugin
;
/* make sure initPlayerData is called before this function!! */
void
initAudioDriver
()
{
ConfigParam
*
param
=
NULL
;
int
i
;
...
...
@@ -63,8 +66,15 @@ void initAudioDriver() {
loadAudioOutputPlugin
(
&
shoutPlugin
);
loadAudioOutputPlugin
(
&
ossPlugin
);
pdAudioDevicesEnabled
=
(
getPlayerData
())
->
audioDeviceEnabled
;
for
(
i
=
0
;
i
<
AUDIO_MAX_DEVICES
;
i
++
)
{
pdAudioDevicesEnabled
[
i
]
=
1
;
myAudioDevicesEnabled
[
i
]
=
1
;
}
while
((
param
=
getNextConfigParam
(
CONF_AUDIO_OUTPUT
,
param
)))
{
if
(
audioOutputArraySize
==
255
)
{
if
(
audioOutputArraySize
==
AUDIO_MAX_DEVICES
)
{
ERROR
(
"only up to 255 audio output devices are "
"supported"
);
exit
(
EXIT_FAILURE
);
...
...
@@ -74,11 +84,8 @@ void initAudioDriver() {
audioOutputArray
=
realloc
(
audioOutputArray
,
audioOutputArraySize
*
sizeof
(
AudioOutput
*
));
audioEnabledArray
=
realloc
(
audioEnabledArray
,
audioOutputArraySize
*
sizeof
(
mpd_uint8
));
audioOutputArray
[
i
]
=
newAudioOutput
(
param
);
audioEnabledArray
[
i
]
=
1
;
if
(
!
audioOutputArray
[
i
])
{
ERROR
(
"problems configuring output device defined at "
...
...
@@ -188,10 +195,11 @@ void finishAudioDriver() {
finishAudioOutput
(
audioOutputArray
[
i
]);
}
free
(
audioEnabledArray
);
free
(
audioOutputArray
);
audioOutputArray
=
NULL
;
audioOutputArraySize
=
0
;
/* don't set to zero cause we're gonna use this for enabling
and disabling devices */
/*audioOutputArraySize = 0;*/
}
int
isCurrentAudioFormat
(
AudioFormat
*
audioFormat
)
{
...
...
@@ -202,6 +210,19 @@ int isCurrentAudioFormat(AudioFormat * audioFormat) {
return
1
;
}
inline
void
syncAudioDevicesEnabledArrays
()
{
int
i
;
memcpy
(
myAudioDevicesEnabled
,
pdAudioDevicesEnabled
,
AUDIO_MAX_DEVICES
);
for
(
i
=
0
;
i
<
audioOutputArraySize
;
i
++
)
{
if
(
myAudioDevicesEnabled
[
i
])
{
openAudioOutput
(
audioOutputArray
[
i
],
&
audio_format
);
}
else
closeAudioOutput
(
audioOutputArray
[
i
]);
}
}
int
openAudioDevice
(
AudioFormat
*
audioFormat
)
{
int
isCurrentFormat
=
isCurrentAudioFormat
(
audioFormat
);
int
ret
=
-
1
;
...
...
@@ -213,11 +234,9 @@ int openAudioDevice(AudioFormat * audioFormat) {
copyAudioFormat
(
&
audio_format
,
audioFormat
);
}
syncAudioDevicesEnabledArrays
();
for
(
i
=
0
;
i
<
audioOutputArraySize
;
i
++
)
{
if
(
!
audioEnabledArray
[
i
])
continue
;
if
(
!
audioOutputArray
[
i
]
->
open
||
!
isCurrentFormat
)
{
openAudioOutput
(
audioOutputArray
[
i
],
&
audio_format
);
}
if
(
audioOutputArray
[
i
]
->
open
)
ret
=
0
;
}
...
...
@@ -238,10 +257,14 @@ int playAudio(char * playChunk, int size) {
int
ret
=
-
1
;
int
i
;
/* put some here to determine if enabled array changed */
if
(
0
!=
memcmp
(
pdAudioDevicesEnabled
,
myAudioDevicesEnabled
,
AUDIO_MAX_DEVICES
))
{
syncAudioDevicesEnabledArrays
();
}
for
(
i
=
0
;
i
<
audioOutputArraySize
;
i
++
)
{
if
(
!
audioEnabledArray
[
i
])
continue
;
if
(
!
myAudioDevicesEnabled
[
i
])
continue
;
if
(
0
==
playAudioOutput
(
audioOutputArray
[
i
],
playChunk
,
size
))
{
ret
=
0
;
}
...
...
@@ -251,14 +274,6 @@ int playAudio(char * playChunk, int size) {
}
int
isAudioDeviceOpen
()
{
/*int ret = 0;
int i;
for(i = 0; i < audioOutputArraySize; i++) {
if(!audioEnabledArray[i]) continue;
ret |= audioOutputArray[i]->open;
}*/
return
audioOpened
;
}
...
...
@@ -287,10 +302,7 @@ int enableAudioDevice(FILE * fp, int device) {
return
-
1
;
}
audioEnabledArray
[
device
]
=
1
;
/*if(audioOpened && !audioOutputArray[device]->open) {
openAudioOutput(audioOutputArray[device], &audio_format);
}*/
pdAudioDevicesEnabled
[
device
]
=
1
;
return
0
;
}
...
...
@@ -302,8 +314,7 @@ int disableAudioDevice(FILE * fp, int device) {
return
-
1
;
}
audioEnabledArray
[
device
]
=
0
;
/*closeAudioOutput(audioOutputArray[device]);*/
pdAudioDevicesEnabled
[
device
]
=
0
;
return
0
;
}
src/audio.h
View file @
69176148
...
...
@@ -28,6 +28,8 @@
#define AUDIO_AO_DRIVER_DEFAULT "default"
#define AUDIO_MAX_DEVICES 8
typedef
struct
_AudioFormat
{
volatile
mpd_sint8
channels
;
volatile
mpd_uint32
sampleRate
;
...
...
@@ -42,6 +44,7 @@ void getOutputAudioFormat(AudioFormat * inFormat, AudioFormat * outFormat);
int
parseAudioConfig
(
AudioFormat
*
audioFormat
,
char
*
conf
);
/* make sure initPlayerData is called before this function!! */
void
initAudioConfig
();
void
finishAudioConfig
();
...
...
src/main.c
View file @
69176148
...
...
@@ -427,9 +427,9 @@ int main(int argc, char * argv[]) {
openDB
(
&
options
,
argv
[
0
]);
initCommands
();
initPlayerData
();
initAudioConfig
();
initAudioDriver
();
initPlayerData
();
initVolume
();
initInterfaces
();
initInputStream
();
...
...
src/playerData.h
View file @
69176148
...
...
@@ -37,6 +37,7 @@ typedef struct _PlayerData {
OutputBuffer
buffer
;
PlayerControl
playerControl
;
DecoderControl
decoderControl
;
mpd_sint8
audioDeviceEnabled
[
AUDIO_MAX_DEVICES
];
}
PlayerData
;
void
initPlayerData
();
...
...
@@ -46,4 +47,3 @@ PlayerData * getPlayerData();
void
freePlayerData
();
#endif
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
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