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
8b08ee82
You need to sign in or sign up before continuing.
Commit
8b08ee82
authored
Nov 02, 2004
by
Warren Dukes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
begin work on avuton's disabling and enabling of individual audio outputs
git-svn-id:
https://svn.musicpd.org/mpd/trunk@2483
09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent
54679d90
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
6 deletions
+67
-6
audio.c
src/audio.c
+67
-6
No files found.
src/audio.c
View file @
8b08ee82
...
...
@@ -21,6 +21,7 @@
#include "conf.h"
#include "log.h"
#include "sig_handlers.h"
#include "command.h"
#include <stdlib.h>
#include <string.h>
...
...
@@ -31,6 +32,14 @@ static AudioFormat audio_format;
static
AudioFormat
*
audio_configFormat
=
NULL
;
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_uint8
audioOpened
=
0
;
void
copyAudioFormat
(
AudioFormat
*
dest
,
AudioFormat
*
src
)
{
if
(
!
src
)
return
;
...
...
@@ -41,9 +50,6 @@ int cmpAudioFormat(AudioFormat * f1, AudioFormat * f2) {
return
memcmp
(
f1
,
f2
,
sizeof
(
AudioFormat
));
}
static
AudioOutput
**
audioOutputArray
=
NULL
;
static
int
audioOutputArraySize
=
0
;
extern
AudioOutputPlugin
aoPlugin
;
extern
AudioOutputPlugin
shoutPlugin
;
extern
AudioOutputPlugin
ossPlugin
;
...
...
@@ -58,12 +64,21 @@ void initAudioDriver() {
loadAudioOutputPlugin
(
&
ossPlugin
);
while
((
param
=
getNextConfigParam
(
CONF_AUDIO_OUTPUT
,
param
)))
{
if
(
audioOutputArraySize
==
255
)
{
ERROR
(
"only up to 255 audio output devices are "
"supported"
);
exit
(
EXIT_FAILURE
);
}
i
=
audioOutputArraySize
++
;
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 "
...
...
@@ -173,6 +188,7 @@ void finishAudioDriver() {
finishAudioOutput
(
audioOutputArray
[
i
]);
}
free
(
audioEnabledArray
);
free
(
audioOutputArray
);
audioOutputArray
=
NULL
;
audioOutputArraySize
=
0
;
...
...
@@ -198,12 +214,23 @@ int openAudioDevice(AudioFormat * audioFormat) {
}
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
;
}
if
(
ret
==
0
)
audioOpened
=
1
;
else
{
/* close all devices if there was an error */
for
(
i
=
0
;
i
<
audioOutputArraySize
;
i
++
)
{
closeAudioOutput
(
audioOutputArray
[
i
]);
}
audioOpened
=
0
;
}
return
ret
;
}
...
...
@@ -211,7 +238,10 @@ int playAudio(char * playChunk, int size) {
int
ret
=
-
1
;
int
i
;
/* put some here to determine if enabled array changed */
for
(
i
=
0
;
i
<
audioOutputArraySize
;
i
++
)
{
if
(
!
audioEnabledArray
[
i
])
continue
;
if
(
0
==
playAudioOutput
(
audioOutputArray
[
i
],
playChunk
,
size
))
{
ret
=
0
;
}
...
...
@@ -221,14 +251,15 @@ int playAudio(char * playChunk, int size) {
}
int
isAudioDeviceOpen
()
{
int
ret
=
0
;
/*
int ret = 0;
int i;
for(i = 0; i < audioOutputArraySize; i++) {
if(!audioEnabledArray[i]) continue;
ret |= audioOutputArray[i]->open;
}
}
*/
return
ret
;
return
audioOpened
;
}
void
closeAudioDevice
()
{
...
...
@@ -237,6 +268,8 @@ void closeAudioDevice() {
for
(
i
=
0
;
i
<
audioOutputArraySize
;
i
++
)
{
closeAudioOutput
(
audioOutputArray
[
i
]);
}
audioOpened
=
0
;
}
void
sendMetadataToAudioDevice
(
MpdTag
*
tag
)
{
...
...
@@ -246,3 +279,31 @@ void sendMetadataToAudioDevice(MpdTag * tag) {
sendMetadataToAudioOutput
(
audioOutputArray
[
i
],
tag
);
}
}
int
enableAudioDevice
(
FILE
*
fp
,
int
device
)
{
if
(
device
<
0
||
device
>=
audioOutputArraySize
)
{
commandError
(
fp
,
ACK_ERROR_ARG
,
"audio output device id %i "
"doesn't exist
\n
"
,
device
);
return
-
1
;
}
audioEnabledArray
[
device
]
=
1
;
/*if(audioOpened && !audioOutputArray[device]->open) {
openAudioOutput(audioOutputArray[device], &audio_format);
}*/
return
0
;
}
int
disableAudioDevice
(
FILE
*
fp
,
int
device
)
{
if
(
device
<
0
||
device
>=
audioOutputArraySize
)
{
commandError
(
fp
,
ACK_ERROR_ARG
,
"audio output device id %i "
"doesn't exist
\n
"
,
device
);
return
-
1
;
}
audioEnabledArray
[
device
]
=
0
;
/*closeAudioOutput(audioOutputArray[device]);*/
return
0
;
}
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