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
58c5bee9
Commit
58c5bee9
authored
Oct 29, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output: use bool for return values and flags
Don't return 0/-1 on success/error, but true/false. Instead of int, use bool for storing flags.
parent
03390d8b
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
162 additions
and
153 deletions
+162
-153
audio.c
src/audio.c
+14
-14
audio.h
src/audio.h
+2
-2
alsa_plugin.c
src/output/alsa_plugin.c
+10
-9
ao_plugin.c
src/output/ao_plugin.c
+9
-8
fifo_plugin.c
src/output/fifo_plugin.c
+12
-12
jack_plugin.c
src/output/jack_plugin.c
+8
-8
mvp_plugin.c
src/output/mvp_plugin.c
+15
-13
null_plugin.c
src/output/null_plugin.c
+6
-6
oss_plugin.c
src/output/oss_plugin.c
+17
-16
osx_plugin.c
src/output/osx_plugin.c
+15
-14
pulse_plugin.c
src/output/pulse_plugin.c
+11
-11
shout_plugin.c
src/output/shout_plugin.c
+12
-12
shout_plugin.h
src/output/shout_plugin.h
+1
-1
output_api.c
src/output_api.c
+1
-1
output_api.h
src/output_api.h
+3
-3
output_control.c
src/output_control.c
+5
-4
output_control.h
src/output_control.h
+5
-2
output_init.c
src/output_init.c
+2
-2
output_internal.h
src/output_internal.h
+6
-6
output_thread.c
src/output_thread.c
+4
-4
player_thread.c
src/player_thread.c
+4
-5
No files found.
src/audio.c
View file @
58c5bee9
...
@@ -247,9 +247,9 @@ static void syncAudioDeviceStates(void)
...
@@ -247,9 +247,9 @@ static void syncAudioDeviceStates(void)
}
}
}
}
int
playAudio
(
const
char
*
buffer
,
size_t
length
)
bool
playAudio
(
const
char
*
buffer
,
size_t
length
)
{
{
int
ret
=
-
1
,
err
;
bool
ret
=
false
;
unsigned
int
i
;
unsigned
int
i
;
/* no partial frames allowed */
/* no partial frames allowed */
...
@@ -262,8 +262,8 @@ int playAudio(const char *buffer, size_t length)
...
@@ -262,8 +262,8 @@ int playAudio(const char *buffer, size_t length)
audio_output_play
(
&
audioOutputArray
[
i
],
audio_output_play
(
&
audioOutputArray
[
i
],
buffer
,
length
);
buffer
,
length
);
while
(
1
)
{
while
(
true
)
{
int
finished
=
1
;
bool
finished
=
true
;
for
(
i
=
0
;
i
<
audioOutputArraySize
;
++
i
)
{
for
(
i
=
0
;
i
<
audioOutputArraySize
;
++
i
)
{
struct
audio_output
*
ao
=
&
audioOutputArray
[
i
];
struct
audio_output
*
ao
=
&
audioOutputArray
[
i
];
...
@@ -272,16 +272,16 @@ int playAudio(const char *buffer, size_t length)
...
@@ -272,16 +272,16 @@ int playAudio(const char *buffer, size_t length)
continue
;
continue
;
if
(
audio_output_command_is_finished
(
ao
))
{
if
(
audio_output_command_is_finished
(
ao
))
{
err
=
audio_output_get_result
(
ao
);
bool
success
=
audio_output_get_result
(
ao
);
if
(
!
err
)
if
(
success
)
ret
=
0
;
ret
=
true
;
else
if
(
err
<
0
)
else
/* device should already be
/* device should already be
closed if the play func
closed if the play func
returned an error */
returned an error */
audioDeviceStates
[
i
]
=
true
;
audioDeviceStates
[
i
]
=
true
;
}
else
{
}
else
{
finished
=
0
;
finished
=
false
;
audio_output_signal
(
ao
);
audio_output_signal
(
ao
);
}
}
}
}
...
@@ -295,13 +295,13 @@ int playAudio(const char *buffer, size_t length)
...
@@ -295,13 +295,13 @@ int playAudio(const char *buffer, size_t length)
return
ret
;
return
ret
;
}
}
int
openAudioDevice
(
const
struct
audio_format
*
audioFormat
)
bool
openAudioDevice
(
const
struct
audio_format
*
audioFormat
)
{
{
int
ret
=
-
1
;
bool
ret
=
false
;
unsigned
int
i
;
unsigned
int
i
;
if
(
!
audioOutputArray
)
if
(
!
audioOutputArray
)
return
-
1
;
return
false
;
if
(
audioFormat
!=
NULL
)
if
(
audioFormat
!=
NULL
)
input_audio_format
=
*
audioFormat
;
input_audio_format
=
*
audioFormat
;
...
@@ -310,10 +310,10 @@ int openAudioDevice(const struct audio_format *audioFormat)
...
@@ -310,10 +310,10 @@ int openAudioDevice(const struct audio_format *audioFormat)
for
(
i
=
0
;
i
<
audioOutputArraySize
;
++
i
)
{
for
(
i
=
0
;
i
<
audioOutputArraySize
;
++
i
)
{
if
(
audioOutputArray
[
i
].
open
)
if
(
audioOutputArray
[
i
].
open
)
ret
=
0
;
ret
=
true
;
}
}
if
(
ret
!=
0
)
if
(
!
ret
)
/* close all devices if there was an error */
/* close all devices if there was an error */
closeAudioDevice
();
closeAudioDevice
();
...
...
src/audio.h
View file @
58c5bee9
...
@@ -42,9 +42,9 @@ void initAudioDriver(void);
...
@@ -42,9 +42,9 @@ void initAudioDriver(void);
void
finishAudioDriver
(
void
);
void
finishAudioDriver
(
void
);
int
openAudioDevice
(
const
struct
audio_format
*
audioFormat
);
bool
openAudioDevice
(
const
struct
audio_format
*
audioFormat
);
int
playAudio
(
const
char
*
playChunk
,
size_t
size
);
bool
playAudio
(
const
char
*
playChunk
,
size_t
size
);
void
audio_output_pause_all
(
void
);
void
audio_output_pause_all
(
void
);
...
...
src/output/alsa_plugin.c
View file @
58c5bee9
...
@@ -125,7 +125,7 @@ static void alsa_finishDriver(void *data)
...
@@ -125,7 +125,7 @@ static void alsa_finishDriver(void *data)
freeAlsaData
(
ad
);
freeAlsaData
(
ad
);
}
}
static
int
alsa_testDefault
(
void
)
static
bool
alsa_testDefault
(
void
)
{
{
snd_pcm_t
*
handle
;
snd_pcm_t
*
handle
;
...
@@ -134,11 +134,11 @@ static int alsa_testDefault(void)
...
@@ -134,11 +134,11 @@ static int alsa_testDefault(void)
if
(
ret
)
{
if
(
ret
)
{
WARNING
(
"Error opening default ALSA device: %s
\n
"
,
WARNING
(
"Error opening default ALSA device: %s
\n
"
,
snd_strerror
(
-
ret
));
snd_strerror
(
-
ret
));
return
-
1
;
return
false
;
}
else
}
else
snd_pcm_close
(
handle
);
snd_pcm_close
(
handle
);
return
0
;
return
true
;
}
}
static
snd_pcm_format_t
get_bitformat
(
const
struct
audio_format
*
af
)
static
snd_pcm_format_t
get_bitformat
(
const
struct
audio_format
*
af
)
...
@@ -152,7 +152,7 @@ static snd_pcm_format_t get_bitformat(const struct audio_format *af)
...
@@ -152,7 +152,7 @@ static snd_pcm_format_t get_bitformat(const struct audio_format *af)
return
SND_PCM_FORMAT_UNKNOWN
;
return
SND_PCM_FORMAT_UNKNOWN
;
}
}
static
int
alsa_openDevice
(
void
*
data
,
struct
audio_format
*
audioFormat
)
static
bool
alsa_openDevice
(
void
*
data
,
struct
audio_format
*
audioFormat
)
{
{
AlsaData
*
ad
=
data
;
AlsaData
*
ad
=
data
;
snd_pcm_format_t
bitformat
;
snd_pcm_format_t
bitformat
;
...
@@ -318,7 +318,7 @@ configure_hw:
...
@@ -318,7 +318,7 @@ configure_hw:
"%u Hz
\n
"
,
ad
->
device
,
audioFormat
->
bits
,
"%u Hz
\n
"
,
ad
->
device
,
audioFormat
->
bits
,
channels
,
sample_rate
);
channels
,
sample_rate
);
return
0
;
return
true
;
error:
error:
if
(
cmd
)
{
if
(
cmd
)
{
...
@@ -332,7 +332,7 @@ fail:
...
@@ -332,7 +332,7 @@ fail:
if
(
ad
->
pcmHandle
)
if
(
ad
->
pcmHandle
)
snd_pcm_close
(
ad
->
pcmHandle
);
snd_pcm_close
(
ad
->
pcmHandle
);
ad
->
pcmHandle
=
NULL
;
ad
->
pcmHandle
=
NULL
;
return
-
1
;
return
false
;
}
}
static
int
alsa_errorRecovery
(
AlsaData
*
ad
,
int
err
)
static
int
alsa_errorRecovery
(
AlsaData
*
ad
,
int
err
)
...
@@ -393,7 +393,8 @@ static void alsa_closeDevice(void *data)
...
@@ -393,7 +393,8 @@ static void alsa_closeDevice(void *data)
}
}
}
}
static
int
alsa_playAudio
(
void
*
data
,
const
char
*
playChunk
,
size_t
size
)
static
bool
alsa_playAudio
(
void
*
data
,
const
char
*
playChunk
,
size_t
size
)
{
{
AlsaData
*
ad
=
data
;
AlsaData
*
ad
=
data
;
int
ret
;
int
ret
;
...
@@ -412,7 +413,7 @@ static int alsa_playAudio(void *data, const char *playChunk, size_t size)
...
@@ -412,7 +413,7 @@ static int alsa_playAudio(void *data, const char *playChunk, size_t size)
"error: %s
\n
"
,
ad
->
device
,
"error: %s
\n
"
,
ad
->
device
,
snd_strerror
(
-
errno
));
snd_strerror
(
-
errno
));
alsa_closeDevice
(
ad
);
alsa_closeDevice
(
ad
);
return
-
1
;
return
false
;
}
}
continue
;
continue
;
}
}
...
@@ -421,7 +422,7 @@ static int alsa_playAudio(void *data, const char *playChunk, size_t size)
...
@@ -421,7 +422,7 @@ static int alsa_playAudio(void *data, const char *playChunk, size_t size)
size
-=
ret
;
size
-=
ret
;
}
}
return
0
;
return
true
;
}
}
const
struct
audio_output_plugin
alsaPlugin
=
{
const
struct
audio_output_plugin
alsaPlugin
=
{
...
...
src/output/ao_plugin.c
View file @
58c5bee9
...
@@ -168,8 +168,8 @@ static void audioOutputAo_closeDevice(void *data)
...
@@ -168,8 +168,8 @@ static void audioOutputAo_closeDevice(void *data)
}
}
}
}
static
int
audioOutputAo_openDevice
(
void
*
data
,
static
bool
struct
audio_format
*
audio_format
)
audioOutputAo_openDevice
(
void
*
data
,
struct
audio_format
*
audio_format
)
{
{
ao_sample_format
format
;
ao_sample_format
format
;
AoData
*
ad
=
(
AoData
*
)
data
;
AoData
*
ad
=
(
AoData
*
)
data
;
...
@@ -186,9 +186,9 @@ static int audioOutputAo_openDevice(void *data,
...
@@ -186,9 +186,9 @@ static int audioOutputAo_openDevice(void *data,
ad
->
device
=
ao_open_live
(
ad
->
driverId
,
&
format
,
ad
->
options
);
ad
->
device
=
ao_open_live
(
ad
->
driverId
,
&
format
,
ad
->
options
);
if
(
ad
->
device
==
NULL
)
if
(
ad
->
device
==
NULL
)
return
-
1
;
return
false
;
return
0
;
return
true
;
}
}
/**
/**
...
@@ -208,13 +208,14 @@ static int ao_play_deconst(ao_device *device, const void *output_samples,
...
@@ -208,13 +208,14 @@ static int ao_play_deconst(ao_device *device, const void *output_samples,
return
ao_play
(
device
,
u
.
out
,
num_bytes
);
return
ao_play
(
device
,
u
.
out
,
num_bytes
);
}
}
static
int
audioOutputAo_play
(
void
*
data
,
const
char
*
playChunk
,
size_t
size
)
static
bool
audioOutputAo_play
(
void
*
data
,
const
char
*
playChunk
,
size_t
size
)
{
{
AoData
*
ad
=
(
AoData
*
)
data
;
AoData
*
ad
=
(
AoData
*
)
data
;
size_t
chunk_size
;
size_t
chunk_size
;
if
(
ad
->
device
==
NULL
)
if
(
ad
->
device
==
NULL
)
return
-
1
;
return
false
;
while
(
size
>
0
)
{
while
(
size
>
0
)
{
chunk_size
=
(
size_t
)
ad
->
writeSize
>
size
chunk_size
=
(
size_t
)
ad
->
writeSize
>
size
...
@@ -224,14 +225,14 @@ static int audioOutputAo_play(void *data, const char *playChunk, size_t size)
...
@@ -224,14 +225,14 @@ static int audioOutputAo_play(void *data, const char *playChunk, size_t size)
audioOutputAo_error
();
audioOutputAo_error
();
ERROR
(
"closing audio device due to write error
\n
"
);
ERROR
(
"closing audio device due to write error
\n
"
);
audioOutputAo_closeDevice
(
ad
);
audioOutputAo_closeDevice
(
ad
);
return
-
1
;
return
false
;
}
}
playChunk
+=
chunk_size
;
playChunk
+=
chunk_size
;
size
-=
chunk_size
;
size
-=
chunk_size
;
}
}
return
0
;
return
true
;
}
}
const
struct
audio_output_plugin
aoPlugin
=
{
const
struct
audio_output_plugin
aoPlugin
=
{
...
...
src/output/fifo_plugin.c
View file @
58c5bee9
...
@@ -128,17 +128,17 @@ static int checkFifo(FifoData *fd)
...
@@ -128,17 +128,17 @@ static int checkFifo(FifoData *fd)
return
0
;
return
0
;
}
}
static
int
openFifo
(
FifoData
*
fd
)
static
bool
openFifo
(
FifoData
*
fd
)
{
{
if
(
checkFifo
(
fd
)
<
0
)
if
(
checkFifo
(
fd
)
<
0
)
return
-
1
;
return
false
;
fd
->
input
=
open
(
fd
->
path
,
O_RDONLY
|
O_NONBLOCK
);
fd
->
input
=
open
(
fd
->
path
,
O_RDONLY
|
O_NONBLOCK
);
if
(
fd
->
input
<
0
)
{
if
(
fd
->
input
<
0
)
{
ERROR
(
"Could not open FIFO
\"
%s
\"
for reading: %s
\n
"
,
ERROR
(
"Could not open FIFO
\"
%s
\"
for reading: %s
\n
"
,
fd
->
path
,
strerror
(
errno
));
fd
->
path
,
strerror
(
errno
));
closeFifo
(
fd
);
closeFifo
(
fd
);
return
-
1
;
return
false
;
}
}
fd
->
output
=
open
(
fd
->
path
,
O_WRONLY
|
O_NONBLOCK
);
fd
->
output
=
open
(
fd
->
path
,
O_WRONLY
|
O_NONBLOCK
);
...
@@ -146,10 +146,10 @@ static int openFifo(FifoData *fd)
...
@@ -146,10 +146,10 @@ static int openFifo(FifoData *fd)
ERROR
(
"Could not open FIFO
\"
%s
\"
for writing: %s
\n
"
,
ERROR
(
"Could not open FIFO
\"
%s
\"
for writing: %s
\n
"
,
fd
->
path
,
strerror
(
errno
));
fd
->
path
,
strerror
(
errno
));
closeFifo
(
fd
);
closeFifo
(
fd
);
return
-
1
;
return
false
;
}
}
return
0
;
return
true
;
}
}
static
void
*
fifo_initDriver
(
mpd_unused
struct
audio_output
*
ao
,
static
void
*
fifo_initDriver
(
mpd_unused
struct
audio_output
*
ao
,
...
@@ -175,7 +175,7 @@ static void *fifo_initDriver(mpd_unused struct audio_output *ao,
...
@@ -175,7 +175,7 @@ static void *fifo_initDriver(mpd_unused struct audio_output *ao,
fd
=
newFifoData
();
fd
=
newFifoData
();
fd
->
path
=
path
;
fd
->
path
=
path
;
if
(
openFifo
(
fd
)
<
0
)
{
if
(
!
openFifo
(
fd
)
)
{
freeFifoData
(
fd
);
freeFifoData
(
fd
);
return
NULL
;
return
NULL
;
}
}
...
@@ -191,7 +191,7 @@ static void fifo_finishDriver(void *data)
...
@@ -191,7 +191,7 @@ static void fifo_finishDriver(void *data)
freeFifoData
(
fd
);
freeFifoData
(
fd
);
}
}
static
int
fifo_openDevice
(
void
*
data
,
static
bool
fifo_openDevice
(
void
*
data
,
struct
audio_format
*
audio_format
)
struct
audio_format
*
audio_format
)
{
{
FifoData
*
fd
=
(
FifoData
*
)
data
;
FifoData
*
fd
=
(
FifoData
*
)
data
;
...
@@ -201,7 +201,7 @@ static int fifo_openDevice(void *data,
...
@@ -201,7 +201,7 @@ static int fifo_openDevice(void *data,
fd
->
timer
=
timer_new
(
audio_format
);
fd
->
timer
=
timer_new
(
audio_format
);
return
0
;
return
true
;
}
}
static
void
fifo_closeDevice
(
void
*
data
)
static
void
fifo_closeDevice
(
void
*
data
)
...
@@ -231,8 +231,8 @@ static void fifo_dropBufferedAudio(void *data)
...
@@ -231,8 +231,8 @@ static void fifo_dropBufferedAudio(void *data)
}
}
}
}
static
int
fifo_playAudio
(
void
*
data
,
static
bool
const
char
*
playChunk
,
size_t
size
)
fifo_playAudio
(
void
*
data
,
const
char
*
playChunk
,
size_t
size
)
{
{
FifoData
*
fd
=
(
FifoData
*
)
data
;
FifoData
*
fd
=
(
FifoData
*
)
data
;
size_t
offset
=
0
;
size_t
offset
=
0
;
...
@@ -260,14 +260,14 @@ static int fifo_playAudio(void *data,
...
@@ -260,14 +260,14 @@ static int fifo_playAudio(void *data,
ERROR
(
"Closing FIFO output
\"
%s
\"
due to write error: "
ERROR
(
"Closing FIFO output
\"
%s
\"
due to write error: "
"%s
\n
"
,
fd
->
path
,
strerror
(
errno
));
"%s
\n
"
,
fd
->
path
,
strerror
(
errno
));
fifo_closeDevice
(
fd
);
fifo_closeDevice
(
fd
);
return
-
1
;
return
false
;
}
}
size
-=
bytes
;
size
-=
bytes
;
offset
+=
bytes
;
offset
+=
bytes
;
}
}
return
0
;
return
true
;
}
}
const
struct
audio_output_plugin
fifoPlugin
=
{
const
struct
audio_output_plugin
fifoPlugin
=
{
...
...
src/output/jack_plugin.c
View file @
58c5bee9
...
@@ -242,10 +242,10 @@ mpd_jack_init(struct audio_output *ao,
...
@@ -242,10 +242,10 @@ mpd_jack_init(struct audio_output *ao,
return
jd
;
return
jd
;
}
}
static
int
static
bool
mpd_jack_test_default_device
(
void
)
mpd_jack_test_default_device
(
void
)
{
{
return
0
;
return
true
;
}
}
static
int
static
int
...
@@ -328,7 +328,7 @@ mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format)
...
@@ -328,7 +328,7 @@ mpd_jack_connect(struct jack_data *jd, struct audio_format *audio_format)
return
1
;
return
1
;
}
}
static
int
static
bool
mpd_jack_open
(
void
*
data
,
struct
audio_format
*
audio_format
)
mpd_jack_open
(
void
*
data
,
struct
audio_format
*
audio_format
)
{
{
struct
jack_data
*
jd
=
data
;
struct
jack_data
*
jd
=
data
;
...
@@ -337,12 +337,12 @@ mpd_jack_open(void *data, struct audio_format *audio_format)
...
@@ -337,12 +337,12 @@ mpd_jack_open(void *data, struct audio_format *audio_format)
if
(
jd
->
client
==
NULL
&&
mpd_jack_connect
(
jd
,
audio_format
)
<
0
)
{
if
(
jd
->
client
==
NULL
&&
mpd_jack_connect
(
jd
,
audio_format
)
<
0
)
{
mpd_jack_client_free
(
jd
);
mpd_jack_client_free
(
jd
);
return
-
1
;
return
false
;
}
}
set_audioformat
(
jd
,
audio_format
);
set_audioformat
(
jd
,
audio_format
);
return
0
;
return
true
;
}
}
static
void
static
void
...
@@ -422,7 +422,7 @@ mpd_jack_write_samples(struct jack_data *jd, const void *src,
...
@@ -422,7 +422,7 @@ mpd_jack_write_samples(struct jack_data *jd, const void *src,
}
}
}
}
static
int
static
bool
mpd_jack_play
(
void
*
data
,
const
char
*
buff
,
size_t
size
)
mpd_jack_play
(
void
*
data
,
const
char
*
buff
,
size_t
size
)
{
{
struct
jack_data
*
jd
=
data
;
struct
jack_data
*
jd
=
data
;
...
@@ -433,7 +433,7 @@ mpd_jack_play(void *data, const char *buff, size_t size)
...
@@ -433,7 +433,7 @@ mpd_jack_play(void *data, const char *buff, size_t size)
ERROR
(
"Refusing to play, because there is no client thread.
\n
"
);
ERROR
(
"Refusing to play, because there is no client thread.
\n
"
);
mpd_jack_client_free
(
jd
);
mpd_jack_client_free
(
jd
);
audio_output_closed
(
jd
->
ao
);
audio_output_closed
(
jd
->
ao
);
return
0
;
return
true
;
}
}
assert
(
size
%
frame_size
==
0
);
assert
(
size
%
frame_size
==
0
);
...
@@ -462,7 +462,7 @@ mpd_jack_play(void *data, const char *buff, size_t size)
...
@@ -462,7 +462,7 @@ mpd_jack_play(void *data, const char *buff, size_t size)
}
}
return
0
;
return
true
;
}
}
const
struct
audio_output_plugin
jackPlugin
=
{
const
struct
audio_output_plugin
jackPlugin
=
{
...
...
src/output/mvp_plugin.c
View file @
58c5bee9
...
@@ -81,7 +81,7 @@ static unsigned pcmfrequencies[][3] = {
...
@@ -81,7 +81,7 @@ static unsigned pcmfrequencies[][3] = {
static
const
unsigned
numfrequencies
=
static
const
unsigned
numfrequencies
=
sizeof
(
pcmfrequencies
)
/
sizeof
(
pcmfrequencies
[
0
]);
sizeof
(
pcmfrequencies
)
/
sizeof
(
pcmfrequencies
[
0
]);
static
int
mvp_testDefault
(
void
)
static
bool
mvp_testDefault
(
void
)
{
{
int
fd
;
int
fd
;
...
@@ -89,13 +89,13 @@ static int mvp_testDefault(void)
...
@@ -89,13 +89,13 @@ static int mvp_testDefault(void)
if
(
fd
)
{
if
(
fd
)
{
close
(
fd
);
close
(
fd
);
return
0
;
return
true
;
}
}
WARNING
(
"Error opening PCM device
\"
/dev/adec_pcm
\"
: %s
\n
"
,
WARNING
(
"Error opening PCM device
\"
/dev/adec_pcm
\"
: %s
\n
"
,
strerror
(
errno
));
strerror
(
errno
));
return
-
1
;
return
false
;
}
}
static
void
*
mvp_initDriver
(
mpd_unused
struct
audio_output
*
audio_output
,
static
void
*
mvp_initDriver
(
mpd_unused
struct
audio_output
*
audio_output
,
...
@@ -178,7 +178,8 @@ static int mvp_setPcmParams(MvpData * md, unsigned long rate, int channels,
...
@@ -178,7 +178,8 @@ static int mvp_setPcmParams(MvpData * md, unsigned long rate, int channels,
return
0
;
return
0
;
}
}
static
int
mvp_openDevice
(
void
*
data
,
struct
audio_format
*
audioFormat
)
static
bool
mvp_openDevice
(
void
*
data
,
struct
audio_format
*
audioFormat
)
{
{
MvpData
*
md
=
data
;
MvpData
*
md
=
data
;
long
long
int
stc
=
0
;
long
long
int
stc
=
0
;
...
@@ -186,24 +187,24 @@ static int mvp_openDevice(void *data, struct audio_format *audioFormat)
...
@@ -186,24 +187,24 @@ static int mvp_openDevice(void *data, struct audio_format *audioFormat)
if
((
md
->
fd
=
open
(
"/dev/adec_pcm"
,
O_RDWR
|
O_NONBLOCK
))
<
0
)
{
if
((
md
->
fd
=
open
(
"/dev/adec_pcm"
,
O_RDWR
|
O_NONBLOCK
))
<
0
)
{
ERROR
(
"Error opening /dev/adec_pcm: %s
\n
"
,
strerror
(
errno
));
ERROR
(
"Error opening /dev/adec_pcm: %s
\n
"
,
strerror
(
errno
));
return
-
1
;
return
false
;
}
}
if
(
ioctl
(
md
->
fd
,
MVP_SET_AUD_SRC
,
1
)
<
0
)
{
if
(
ioctl
(
md
->
fd
,
MVP_SET_AUD_SRC
,
1
)
<
0
)
{
ERROR
(
"Error setting audio source: %s
\n
"
,
strerror
(
errno
));
ERROR
(
"Error setting audio source: %s
\n
"
,
strerror
(
errno
));
return
-
1
;
return
false
;
}
}
if
(
ioctl
(
md
->
fd
,
MVP_SET_AUD_STREAMTYPE
,
0
)
<
0
)
{
if
(
ioctl
(
md
->
fd
,
MVP_SET_AUD_STREAMTYPE
,
0
)
<
0
)
{
ERROR
(
"Error setting audio streamtype: %s
\n
"
,
strerror
(
errno
));
ERROR
(
"Error setting audio streamtype: %s
\n
"
,
strerror
(
errno
));
return
-
1
;
return
false
;
}
}
if
(
ioctl
(
md
->
fd
,
MVP_SET_AUD_FORMAT
,
&
mix
)
<
0
)
{
if
(
ioctl
(
md
->
fd
,
MVP_SET_AUD_FORMAT
,
&
mix
)
<
0
)
{
ERROR
(
"Error setting audio format: %s
\n
"
,
strerror
(
errno
));
ERROR
(
"Error setting audio format: %s
\n
"
,
strerror
(
errno
));
return
-
1
;
return
false
;
}
}
ioctl
(
md
->
fd
,
MVP_SET_AUD_STC
,
&
stc
);
ioctl
(
md
->
fd
,
MVP_SET_AUD_STC
,
&
stc
);
if
(
ioctl
(
md
->
fd
,
MVP_SET_AUD_BYPASS
,
1
)
<
0
)
{
if
(
ioctl
(
md
->
fd
,
MVP_SET_AUD_BYPASS
,
1
)
<
0
)
{
ERROR
(
"Error setting audio streamtype: %s
\n
"
,
strerror
(
errno
));
ERROR
(
"Error setting audio streamtype: %s
\n
"
,
strerror
(
errno
));
return
-
1
;
return
false
;
}
}
#ifdef WORDS_BIGENDIAN
#ifdef WORDS_BIGENDIAN
mvp_setPcmParams
(
md
,
audioFormat
->
sample_rate
,
audioFormat
->
channels
,
mvp_setPcmParams
(
md
,
audioFormat
->
sample_rate
,
audioFormat
->
channels
,
...
@@ -213,7 +214,7 @@ static int mvp_openDevice(void *data, struct audio_format *audioFormat)
...
@@ -213,7 +214,7 @@ static int mvp_openDevice(void *data, struct audio_format *audioFormat)
1
,
audioFormat
->
bits
);
1
,
audioFormat
->
bits
);
#endif
#endif
md
->
audio_format
=
*
audioFormat
;
md
->
audio_format
=
*
audioFormat
;
return
0
;
return
true
;
}
}
static
void
mvp_closeDevice
(
void
*
data
)
static
void
mvp_closeDevice
(
void
*
data
)
...
@@ -235,7 +236,8 @@ static void mvp_dropBufferedAudio(void *data)
...
@@ -235,7 +236,8 @@ static void mvp_dropBufferedAudio(void *data)
}
}
}
}
static
int
mvp_playAudio
(
void
*
data
,
const
char
*
playChunk
,
size_t
size
)
static
bool
mvp_playAudio
(
void
*
data
,
const
char
*
playChunk
,
size_t
size
)
{
{
MvpData
*
md
=
data
;
MvpData
*
md
=
data
;
ssize_t
ret
;
ssize_t
ret
;
...
@@ -252,12 +254,12 @@ static int mvp_playAudio(void *data, const char *playChunk, size_t size)
...
@@ -252,12 +254,12 @@ static int mvp_playAudio(void *data, const char *playChunk, size_t size)
ERROR
(
"closing mvp PCM device due to write error: "
ERROR
(
"closing mvp PCM device due to write error: "
"%s
\n
"
,
strerror
(
errno
));
"%s
\n
"
,
strerror
(
errno
));
mvp_closeDevice
(
md
);
mvp_closeDevice
(
md
);
return
-
1
;
return
false
;
}
}
playChunk
+=
ret
;
playChunk
+=
ret
;
size
-=
ret
;
size
-=
ret
;
}
}
return
0
;
return
true
;
}
}
const
struct
audio_output_plugin
mvpPlugin
=
{
const
struct
audio_output_plugin
mvpPlugin
=
{
...
...
src/output/null_plugin.c
View file @
58c5bee9
...
@@ -33,13 +33,13 @@ static void *null_initDriver(mpd_unused struct audio_output *audioOutput,
...
@@ -33,13 +33,13 @@ static void *null_initDriver(mpd_unused struct audio_output *audioOutput,
return
nd
;
return
nd
;
}
}
static
int
null_openDevice
(
void
*
data
,
static
bool
struct
audio_format
*
audio_format
)
null_openDevice
(
void
*
data
,
struct
audio_format
*
audio_format
)
{
{
struct
null_data
*
nd
=
data
;
struct
null_data
*
nd
=
data
;
nd
->
timer
=
timer_new
(
audio_format
);
nd
->
timer
=
timer_new
(
audio_format
);
return
0
;
return
true
;
}
}
static
void
null_closeDevice
(
void
*
data
)
static
void
null_closeDevice
(
void
*
data
)
...
@@ -52,8 +52,8 @@ static void null_closeDevice(void *data)
...
@@ -52,8 +52,8 @@ static void null_closeDevice(void *data)
}
}
}
}
static
int
null_playAudio
(
void
*
data
,
static
bool
mpd_unused
const
char
*
playChunk
,
size_t
size
)
null_playAudio
(
void
*
data
,
mpd_unused
const
char
*
playChunk
,
size_t
size
)
{
{
struct
null_data
*
nd
=
data
;
struct
null_data
*
nd
=
data
;
Timer
*
timer
=
nd
->
timer
;
Timer
*
timer
=
nd
->
timer
;
...
@@ -65,7 +65,7 @@ static int null_playAudio(void *data,
...
@@ -65,7 +65,7 @@ static int null_playAudio(void *data,
timer_add
(
timer
,
size
);
timer_add
(
timer
,
size
);
return
0
;
return
true
;
}
}
static
void
null_dropBufferedAudio
(
void
*
data
)
static
void
null_dropBufferedAudio
(
void
*
data
)
...
...
src/output/oss_plugin.c
View file @
58c5bee9
...
@@ -322,20 +322,20 @@ static int oss_statDevice(const char *device, int *stErrno)
...
@@ -322,20 +322,20 @@ static int oss_statDevice(const char *device, int *stErrno)
static
const
char
*
default_devices
[]
=
{
"/dev/sound/dsp"
,
"/dev/dsp"
};
static
const
char
*
default_devices
[]
=
{
"/dev/sound/dsp"
,
"/dev/dsp"
};
static
int
oss_testDefault
(
void
)
static
bool
oss_testDefault
(
void
)
{
{
int
fd
,
i
;
int
fd
,
i
;
for
(
i
=
ARRAY_SIZE
(
default_devices
);
--
i
>=
0
;
)
{
for
(
i
=
ARRAY_SIZE
(
default_devices
);
--
i
>=
0
;
)
{
if
((
fd
=
open
(
default_devices
[
i
],
O_WRONLY
))
>=
0
)
{
if
((
fd
=
open
(
default_devices
[
i
],
O_WRONLY
))
>=
0
)
{
xclose
(
fd
);
xclose
(
fd
);
return
0
;
return
true
;
}
}
WARNING
(
"Error opening OSS device
\"
%s
\"
: %s
\n
"
,
WARNING
(
"Error opening OSS device
\"
%s
\"
: %s
\n
"
,
default_devices
[
i
],
strerror
(
errno
));
default_devices
[
i
],
strerror
(
errno
));
}
}
return
-
1
;
return
false
;
}
}
static
void
*
oss_open_default
(
ConfigParam
*
param
)
static
void
*
oss_open_default
(
ConfigParam
*
param
)
...
@@ -438,7 +438,7 @@ static void oss_close(OssData * od)
...
@@ -438,7 +438,7 @@ static void oss_close(OssData * od)
od
->
fd
=
-
1
;
od
->
fd
=
-
1
;
}
}
static
int
oss_open
(
OssData
*
od
)
static
bool
oss_open
(
OssData
*
od
)
{
{
int
tmp
;
int
tmp
;
...
@@ -486,23 +486,24 @@ static int oss_open(OssData *od)
...
@@ -486,23 +486,24 @@ static int oss_open(OssData *od)
goto
fail
;
goto
fail
;
}
}
return
0
;
return
true
;
fail:
fail:
oss_close
(
od
);
oss_close
(
od
);
return
-
1
;
return
false
;
}
}
static
int
oss_openDevice
(
void
*
data
,
static
bool
struct
audio_format
*
audioFormat
)
oss_openDevice
(
void
*
data
,
struct
audio_format
*
audioFormat
)
{
{
int
ret
;
bool
ret
;
OssData
*
od
=
data
;
OssData
*
od
=
data
;
od
->
audio_format
=
*
audioFormat
;
od
->
audio_format
=
*
audioFormat
;
if
((
ret
=
oss_open
(
od
))
<
0
)
ret
=
oss_open
(
od
);
return
ret
;
if
(
!
ret
)
return
false
;
*
audioFormat
=
od
->
audio_format
;
*
audioFormat
=
od
->
audio_format
;
...
@@ -531,15 +532,15 @@ static void oss_dropBufferedAudio(void *data)
...
@@ -531,15 +532,15 @@ static void oss_dropBufferedAudio(void *data)
}
}
}
}
static
int
oss_playAudio
(
void
*
data
,
static
bool
const
char
*
playChunk
,
size_t
size
)
oss_playAudio
(
void
*
data
,
const
char
*
playChunk
,
size_t
size
)
{
{
OssData
*
od
=
data
;
OssData
*
od
=
data
;
ssize_t
ret
;
ssize_t
ret
;
/* reopen the device since it was closed by dropBufferedAudio */
/* reopen the device since it was closed by dropBufferedAudio */
if
(
od
->
fd
<
0
&&
oss_open
(
od
)
<
0
)
if
(
od
->
fd
<
0
&&
oss_open
(
od
)
<
0
)
return
-
1
;
return
false
;
while
(
size
>
0
)
{
while
(
size
>
0
)
{
ret
=
write
(
od
->
fd
,
playChunk
,
size
);
ret
=
write
(
od
->
fd
,
playChunk
,
size
);
...
@@ -549,13 +550,13 @@ static int oss_playAudio(void *data,
...
@@ -549,13 +550,13 @@ static int oss_playAudio(void *data,
ERROR
(
"closing oss device
\"
%s
\"
due to write error: "
ERROR
(
"closing oss device
\"
%s
\"
due to write error: "
"%s
\n
"
,
od
->
device
,
strerror
(
errno
));
"%s
\n
"
,
od
->
device
,
strerror
(
errno
));
oss_closeDevice
(
od
);
oss_closeDevice
(
od
);
return
-
1
;
return
false
;
}
}
playChunk
+=
ret
;
playChunk
+=
ret
;
size
-=
ret
;
size
-=
ret
;
}
}
return
0
;
return
true
;
}
}
const
struct
audio_output_plugin
ossPlugin
=
{
const
struct
audio_output_plugin
ossPlugin
=
{
...
...
src/output/osx_plugin.c
View file @
58c5bee9
...
@@ -49,7 +49,7 @@ static OsxData *newOsxData()
...
@@ -49,7 +49,7 @@ static OsxData *newOsxData()
return
ret
;
return
ret
;
}
}
static
int
osx_testDefault
()
static
bool
osx_testDefault
()
{
{
/*AudioUnit au;
/*AudioUnit au;
ComponentDescription desc;
ComponentDescription desc;
...
@@ -74,7 +74,7 @@ static int osx_testDefault()
...
@@ -74,7 +74,7 @@ static int osx_testDefault()
CloseComponent(au); */
CloseComponent(au); */
return
0
;
return
true
;
}
}
static
int
osx_initDriver
(
struct
audio_output
*
audioOutput
,
static
int
osx_initDriver
(
struct
audio_output
*
audioOutput
,
...
@@ -212,8 +212,9 @@ static OSStatus osx_render(void *vdata,
...
@@ -212,8 +212,9 @@ static OSStatus osx_render(void *vdata,
return
0
;
return
0
;
}
}
static
int
osx_openDevice
(
struct
audio_output
*
audioOutput
,
static
bool
struct
audio_format
*
audioFormat
)
osx_openDevice
(
struct
audio_output
*
audioOutput
,
struct
audio_format
*
audioFormat
)
{
{
OsxData
*
od
=
(
OsxData
*
)
audioOutput
->
data
;
OsxData
*
od
=
(
OsxData
*
)
audioOutput
->
data
;
ComponentDescription
desc
;
ComponentDescription
desc
;
...
@@ -230,18 +231,18 @@ static int osx_openDevice(struct audio_output *audioOutput,
...
@@ -230,18 +231,18 @@ static int osx_openDevice(struct audio_output *audioOutput,
comp
=
FindNextComponent
(
NULL
,
&
desc
);
comp
=
FindNextComponent
(
NULL
,
&
desc
);
if
(
comp
==
0
)
{
if
(
comp
==
0
)
{
ERROR
(
"Error finding OS X component
\n
"
);
ERROR
(
"Error finding OS X component
\n
"
);
return
-
1
;
return
false
;
}
}
if
(
OpenAComponent
(
comp
,
&
od
->
au
)
!=
noErr
)
{
if
(
OpenAComponent
(
comp
,
&
od
->
au
)
!=
noErr
)
{
ERROR
(
"Unable to open OS X component
\n
"
);
ERROR
(
"Unable to open OS X component
\n
"
);
return
-
1
;
return
false
;
}
}
if
(
AudioUnitInitialize
(
od
->
au
)
!=
0
)
{
if
(
AudioUnitInitialize
(
od
->
au
)
!=
0
)
{
CloseComponent
(
od
->
au
);
CloseComponent
(
od
->
au
);
ERROR
(
"Unable to initialize OS X audio unit
\n
"
);
ERROR
(
"Unable to initialize OS X audio unit
\n
"
);
return
-
1
;
return
false
;
}
}
callback
.
inputProc
=
osx_render
;
callback
.
inputProc
=
osx_render
;
...
@@ -253,7 +254,7 @@ static int osx_openDevice(struct audio_output *audioOutput,
...
@@ -253,7 +254,7 @@ static int osx_openDevice(struct audio_output *audioOutput,
AudioUnitUninitialize
(
od
->
au
);
AudioUnitUninitialize
(
od
->
au
);
CloseComponent
(
od
->
au
);
CloseComponent
(
od
->
au
);
ERROR
(
"unable to set callback for OS X audio unit
\n
"
);
ERROR
(
"unable to set callback for OS X audio unit
\n
"
);
return
-
1
;
return
false
;
}
}
streamDesc
.
mSampleRate
=
audioFormat
->
sample_rate
;
streamDesc
.
mSampleRate
=
audioFormat
->
sample_rate
;
...
@@ -275,7 +276,7 @@ static int osx_openDevice(struct audio_output *audioOutput,
...
@@ -275,7 +276,7 @@ static int osx_openDevice(struct audio_output *audioOutput,
AudioUnitUninitialize
(
od
->
au
);
AudioUnitUninitialize
(
od
->
au
);
CloseComponent
(
od
->
au
);
CloseComponent
(
od
->
au
);
ERROR
(
"Unable to set format on OS X device
\n
"
);
ERROR
(
"Unable to set format on OS X device
\n
"
);
return
-
1
;
return
false
;
}
}
/* create a buffer of 1s */
/* create a buffer of 1s */
...
@@ -286,11 +287,11 @@ static int osx_openDevice(struct audio_output *audioOutput,
...
@@ -286,11 +287,11 @@ static int osx_openDevice(struct audio_output *audioOutput,
od
->
pos
=
0
;
od
->
pos
=
0
;
od
->
len
=
0
;
od
->
len
=
0
;
return
0
;
return
true
;
}
}
static
int
osx_play
(
struct
audio_output
*
audioOutput
,
static
bool
const
char
*
playChunk
,
size_t
size
)
osx_play
(
struct
audio_output
*
audioOutput
,
const
char
*
playChunk
,
size_t
size
)
{
{
OsxData
*
od
=
(
OsxData
*
)
audioOutput
->
data
;
OsxData
*
od
=
(
OsxData
*
)
audioOutput
->
data
;
size_t
bytesToCopy
;
size_t
bytesToCopy
;
...
@@ -304,7 +305,7 @@ static int osx_play(struct audio_output *audioOutput,
...
@@ -304,7 +305,7 @@ static int osx_play(struct audio_output *audioOutput,
err
=
AudioOutputUnitStart
(
od
->
au
);
err
=
AudioOutputUnitStart
(
od
->
au
);
if
(
err
)
{
if
(
err
)
{
ERROR
(
"unable to start audio output: %i
\n
"
,
err
);
ERROR
(
"unable to start audio output: %i
\n
"
,
err
);
return
-
1
;
return
false
;
}
}
}
}
...
@@ -345,7 +346,7 @@ static int osx_play(struct audio_output *audioOutput,
...
@@ -345,7 +346,7 @@ static int osx_play(struct audio_output *audioOutput,
pthread_mutex_unlock
(
&
od
->
mutex
);
pthread_mutex_unlock
(
&
od
->
mutex
);
/* DEBUG("osx_play: leave\n"); */
/* DEBUG("osx_play: leave\n"); */
return
0
;
return
true
;
}
}
const
struct
audio_output_plugin
osxPlugin
=
{
const
struct
audio_output_plugin
osxPlugin
=
{
...
...
src/output/pulse_plugin.c
View file @
58c5bee9
...
@@ -86,7 +86,7 @@ static void pulse_finish(void *data)
...
@@ -86,7 +86,7 @@ static void pulse_finish(void *data)
pulse_free_data
(
pd
);
pulse_free_data
(
pd
);
}
}
static
int
pulse_test_default_device
(
void
)
static
bool
pulse_test_default_device
(
void
)
{
{
pa_simple
*
s
;
pa_simple
*
s
;
pa_sample_spec
ss
;
pa_sample_spec
ss
;
...
@@ -101,15 +101,15 @@ static int pulse_test_default_device(void)
...
@@ -101,15 +101,15 @@ static int pulse_test_default_device(void)
if
(
!
s
)
{
if
(
!
s
)
{
g_message
(
"Cannot connect to default PulseAudio server: %s
\n
"
,
g_message
(
"Cannot connect to default PulseAudio server: %s
\n
"
,
pa_strerror
(
error
));
pa_strerror
(
error
));
return
-
1
;
return
false
;
}
}
pa_simple_free
(
s
);
pa_simple_free
(
s
);
return
0
;
return
true
;
}
}
static
int
static
bool
pulse_open
(
void
*
data
,
struct
audio_format
*
audio_format
)
pulse_open
(
void
*
data
,
struct
audio_format
*
audio_format
)
{
{
struct
pulse_data
*
pd
=
data
;
struct
pulse_data
*
pd
=
data
;
...
@@ -121,7 +121,7 @@ pulse_open(void *data, struct audio_format *audio_format)
...
@@ -121,7 +121,7 @@ pulse_open(void *data, struct audio_format *audio_format)
if
(
pd
->
num_connect_attempts
!=
0
&&
if
(
pd
->
num_connect_attempts
!=
0
&&
(
t
-
pd
->
last_connect_attempt
)
<
CONN_ATTEMPT_INTERVAL
)
(
t
-
pd
->
last_connect_attempt
)
<
CONN_ATTEMPT_INTERVAL
)
return
-
1
;
return
false
;
pd
->
num_connect_attempts
++
;
pd
->
num_connect_attempts
++
;
pd
->
last_connect_attempt
=
t
;
pd
->
last_connect_attempt
=
t
;
...
@@ -143,7 +143,7 @@ pulse_open(void *data, struct audio_format *audio_format)
...
@@ -143,7 +143,7 @@ pulse_open(void *data, struct audio_format *audio_format)
"
\"
%s
\"
(attempt %i): %s
\n
"
,
"
\"
%s
\"
(attempt %i): %s
\n
"
,
audio_output_get_name
(
pd
->
ao
),
audio_output_get_name
(
pd
->
ao
),
pd
->
num_connect_attempts
,
pa_strerror
(
error
));
pd
->
num_connect_attempts
,
pa_strerror
(
error
));
return
-
1
;
return
false
;
}
}
pd
->
num_connect_attempts
=
0
;
pd
->
num_connect_attempts
=
0
;
...
@@ -154,7 +154,7 @@ pulse_open(void *data, struct audio_format *audio_format)
...
@@ -154,7 +154,7 @@ pulse_open(void *data, struct audio_format *audio_format)
audio_format
->
bits
,
audio_format
->
bits
,
audio_format
->
channels
,
audio_format
->
sample_rate
);
audio_format
->
channels
,
audio_format
->
sample_rate
);
return
0
;
return
true
;
}
}
static
void
pulse_cancel
(
void
*
data
)
static
void
pulse_cancel
(
void
*
data
)
...
@@ -179,8 +179,8 @@ static void pulse_close(void *data)
...
@@ -179,8 +179,8 @@ static void pulse_close(void *data)
}
}
}
}
static
int
pulse_play
(
void
*
data
,
static
bool
const
char
*
playChunk
,
size_t
size
)
pulse_play
(
void
*
data
,
const
char
*
playChunk
,
size_t
size
)
{
{
struct
pulse_data
*
pd
=
data
;
struct
pulse_data
*
pd
=
data
;
int
error
;
int
error
;
...
@@ -191,10 +191,10 @@ static int pulse_play(void *data,
...
@@ -191,10 +191,10 @@ static int pulse_play(void *data,
audio_output_get_name
(
pd
->
ao
),
audio_output_get_name
(
pd
->
ao
),
pa_strerror
(
error
));
pa_strerror
(
error
));
pulse_close
(
pd
);
pulse_close
(
pd
);
return
-
1
;
return
false
;
}
}
return
0
;
return
true
;
}
}
const
struct
audio_output_plugin
pulse_plugin
=
{
const
struct
audio_output_plugin
pulse_plugin
=
{
...
...
src/output/shout_plugin.c
View file @
58c5bee9
...
@@ -354,7 +354,7 @@ static void close_shout_conn(struct shout_data * sd)
...
@@ -354,7 +354,7 @@ static void close_shout_conn(struct shout_data * sd)
shout_get_error
(
sd
->
shout_conn
));
shout_get_error
(
sd
->
shout_conn
));
}
}
sd
->
opened
=
0
;
sd
->
opened
=
false
;
}
}
static
void
my_shout_finish_driver
(
void
*
data
)
static
void
my_shout_finish_driver
(
void
*
data
)
...
@@ -465,27 +465,27 @@ static int open_shout_conn(void *data)
...
@@ -465,27 +465,27 @@ static int open_shout_conn(void *data)
write_page
(
sd
);
write_page
(
sd
);
sd
->
shout_error
=
0
;
sd
->
shout_error
=
0
;
sd
->
opened
=
1
;
sd
->
opened
=
true
;
sd
->
tag_to_send
=
1
;
sd
->
tag_to_send
=
1
;
sd
->
conn_attempts
=
0
;
sd
->
conn_attempts
=
0
;
return
0
;
return
0
;
}
}
static
int
my_shout_open_device
(
void
*
data
,
static
bool
my_shout_open_device
(
void
*
data
,
struct
audio_format
*
audio_format
)
struct
audio_format
*
audio_format
)
{
{
struct
shout_data
*
sd
=
(
struct
shout_data
*
)
data
;
struct
shout_data
*
sd
=
(
struct
shout_data
*
)
data
;
if
(
!
sd
->
opened
&&
open_shout_conn
(
sd
)
<
0
)
if
(
!
sd
->
opened
&&
open_shout_conn
(
sd
)
<
0
)
return
-
1
;
return
false
;
if
(
sd
->
timer
)
if
(
sd
->
timer
)
timer_free
(
sd
->
timer
);
timer_free
(
sd
->
timer
);
sd
->
timer
=
timer_new
(
audio_format
);
sd
->
timer
=
timer_new
(
audio_format
);
return
0
;
return
true
;
}
}
static
void
send_metadata
(
struct
shout_data
*
sd
)
static
void
send_metadata
(
struct
shout_data
*
sd
)
...
@@ -508,8 +508,8 @@ static void send_metadata(struct shout_data * sd)
...
@@ -508,8 +508,8 @@ static void send_metadata(struct shout_data * sd)
sd
->
tag_to_send
=
0
;
sd
->
tag_to_send
=
0
;
}
}
static
int
my_shout_play
(
void
*
data
,
static
bool
const
char
*
chunk
,
size_t
size
)
my_shout_play
(
void
*
data
,
const
char
*
chunk
,
size_t
size
)
{
{
struct
shout_data
*
sd
=
(
struct
shout_data
*
)
data
;
struct
shout_data
*
sd
=
(
struct
shout_data
*
)
data
;
int
status
;
int
status
;
...
@@ -526,24 +526,24 @@ static int my_shout_play(void *data,
...
@@ -526,24 +526,24 @@ static int my_shout_play(void *data,
status
=
open_shout_conn
(
sd
);
status
=
open_shout_conn
(
sd
);
if
(
status
<
0
)
{
if
(
status
<
0
)
{
my_shout_close_device
(
sd
);
my_shout_close_device
(
sd
);
return
-
1
;
return
false
;
}
else
if
(
status
>
0
)
{
}
else
if
(
status
>
0
)
{
timer_sync
(
sd
->
timer
);
timer_sync
(
sd
->
timer
);
return
0
;
return
true
;
}
}
}
}
if
(
sd
->
encoder
->
encode_func
(
sd
,
chunk
,
size
))
{
if
(
sd
->
encoder
->
encode_func
(
sd
,
chunk
,
size
))
{
my_shout_close_device
(
sd
);
my_shout_close_device
(
sd
);
return
-
1
;
return
false
;
}
}
if
(
write_page
(
sd
)
<
0
)
{
if
(
write_page
(
sd
)
<
0
)
{
my_shout_close_device
(
sd
);
my_shout_close_device
(
sd
);
return
-
1
;
return
false
;
}
}
return
0
;
return
true
;
}
}
static
void
my_shout_pause
(
void
*
data
)
static
void
my_shout_pause
(
void
*
data
)
...
...
src/output/shout_plugin.h
View file @
58c5bee9
...
@@ -65,7 +65,7 @@ struct shout_data {
...
@@ -65,7 +65,7 @@ struct shout_data {
float
quality
;
float
quality
;
int
bitrate
;
int
bitrate
;
int
opened
;
bool
opened
;
struct
tag
*
tag
;
struct
tag
*
tag
;
int
tag_to_send
;
int
tag_to_send
;
...
...
src/output_api.c
View file @
58c5bee9
...
@@ -30,7 +30,7 @@ void audio_output_closed(struct audio_output *ao)
...
@@ -30,7 +30,7 @@ void audio_output_closed(struct audio_output *ao)
{
{
assert
(
ao
->
open
);
assert
(
ao
->
open
);
ao
->
open
=
0
;
ao
->
open
=
false
;
}
}
bool
audio_output_is_pending
(
const
struct
audio_output
*
ao
)
bool
audio_output_is_pending
(
const
struct
audio_output
*
ao
)
...
...
src/output_api.h
View file @
58c5bee9
...
@@ -45,7 +45,7 @@ struct audio_output_plugin {
...
@@ -45,7 +45,7 @@ struct audio_output_plugin {
* Test if this plugin can provide a default output, in case
* Test if this plugin can provide a default output, in case
* none has been configured. This method is optional.
* none has been configured. This method is optional.
*/
*/
int
(
*
test_default_device
)(
void
);
bool
(
*
test_default_device
)(
void
);
/**
/**
* Configure and initialize the device, but do not open it
* Configure and initialize the device, but do not open it
...
@@ -73,12 +73,12 @@ struct audio_output_plugin {
...
@@ -73,12 +73,12 @@ struct audio_output_plugin {
* @param audio_format the audio format in which data is going
* @param audio_format the audio format in which data is going
* to be delivered; may be modified by the plugin
* to be delivered; may be modified by the plugin
*/
*/
int
(
*
open
)(
void
*
data
,
struct
audio_format
*
audio_format
);
bool
(
*
open
)(
void
*
data
,
struct
audio_format
*
audio_format
);
/**
/**
* Play a chunk of audio data.
* Play a chunk of audio data.
*/
*/
int
(
*
play
)(
void
*
data
,
const
char
*
playChunk
,
size_t
size
);
bool
(
*
play
)(
void
*
data
,
const
char
*
playChunk
,
size_t
size
);
/**
/**
* Pause the device. If supported, it may perform a special
* Pause the device. If supported, it may perform a special
...
...
src/output_control.c
View file @
58c5bee9
...
@@ -51,14 +51,15 @@ static void ao_command_async(struct audio_output *ao,
...
@@ -51,14 +51,15 @@ static void ao_command_async(struct audio_output *ao,
notify_signal
(
&
ao
->
notify
);
notify_signal
(
&
ao
->
notify
);
}
}
int
audio_output_open
(
struct
audio_output
*
audioOutput
,
bool
const
struct
audio_format
*
audioFormat
)
audio_output_open
(
struct
audio_output
*
audioOutput
,
const
struct
audio_format
*
audioFormat
)
{
{
int
ret
=
0
;
bool
ret
=
true
;
if
(
audioOutput
->
open
&&
if
(
audioOutput
->
open
&&
audio_format_equals
(
audioFormat
,
&
audioOutput
->
inAudioFormat
))
{
audio_format_equals
(
audioFormat
,
&
audioOutput
->
inAudioFormat
))
{
return
0
;
return
true
;
}
}
audioOutput
->
inAudioFormat
=
*
audioFormat
;
audioOutput
->
inAudioFormat
=
*
audioFormat
;
...
...
src/output_control.h
View file @
58c5bee9
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include "conf.h"
#include "conf.h"
#include <stddef.h>
#include <stddef.h>
#include <stdbool.h>
struct
audio_output
;
struct
audio_output
;
struct
audio_output_plugin
;
struct
audio_output_plugin
;
...
@@ -29,8 +30,10 @@ struct audio_format;
...
@@ -29,8 +30,10 @@ struct audio_format;
struct
tag
;
struct
tag
;
int
audio_output_init
(
struct
audio_output
*
,
ConfigParam
*
param
);
int
audio_output_init
(
struct
audio_output
*
,
ConfigParam
*
param
);
int
audio_output_open
(
struct
audio_output
*
audioOutput
,
const
struct
audio_format
*
audioFormat
);
bool
audio_output_open
(
struct
audio_output
*
audioOutput
,
const
struct
audio_format
*
audioFormat
);
/**
/**
* Wakes up the audio output thread. This is part of a workaround for
* Wakes up the audio output thread. This is part of a workaround for
...
...
src/output_init.c
View file @
58c5bee9
...
@@ -67,7 +67,7 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param)
...
@@ -67,7 +67,7 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param)
if
(
plugin
->
test_default_device
)
{
if
(
plugin
->
test_default_device
)
{
WARNING
(
"Attempting to detect a %s audio "
WARNING
(
"Attempting to detect a %s audio "
"device
\n
"
,
plugin
->
name
);
"device
\n
"
,
plugin
->
name
);
if
(
plugin
->
test_default_device
()
==
0
)
{
if
(
plugin
->
test_default_device
())
{
WARNING
(
"Successfully detected a %s "
WARNING
(
"Successfully detected a %s "
"audio device
\n
"
,
plugin
->
name
);
"audio device
\n
"
,
plugin
->
name
);
break
;
break
;
...
@@ -85,7 +85,7 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param)
...
@@ -85,7 +85,7 @@ int audio_output_init(struct audio_output *ao, ConfigParam * param)
ao
->
name
=
name
;
ao
->
name
=
name
;
ao
->
plugin
=
plugin
;
ao
->
plugin
=
plugin
;
ao
->
open
=
0
;
ao
->
open
=
false
;
ao
->
convBuffer
=
NULL
;
ao
->
convBuffer
=
NULL
;
ao
->
convBufferLen
=
0
;
ao
->
convBufferLen
=
0
;
...
...
src/output_internal.h
View file @
58c5bee9
...
@@ -43,7 +43,7 @@ struct audio_output {
...
@@ -43,7 +43,7 @@ struct audio_output {
/**
/**
* Is the device (already) open and functional?
* Is the device (already) open and functional?
*/
*/
int
open
;
bool
open
;
/**
/**
* The audio_format in which audio data is received from the
* The audio_format in which audio data is received from the
...
@@ -98,9 +98,9 @@ struct audio_output {
...
@@ -98,9 +98,9 @@ struct audio_output {
}
args
;
}
args
;
/**
/**
* Result value of the command.
Generally, "0"
means success.
* Result value of the command.
true
means success.
*/
*/
int
result
;
bool
result
;
};
};
/**
/**
...
@@ -109,19 +109,19 @@ struct audio_output {
...
@@ -109,19 +109,19 @@ struct audio_output {
*/
*/
extern
struct
notify
audio_output_client_notify
;
extern
struct
notify
audio_output_client_notify
;
static
inline
int
static
inline
bool
audio_output_is_open
(
const
struct
audio_output
*
ao
)
audio_output_is_open
(
const
struct
audio_output
*
ao
)
{
{
return
ao
->
open
;
return
ao
->
open
;
}
}
static
inline
int
static
inline
bool
audio_output_command_is_finished
(
const
struct
audio_output
*
ao
)
audio_output_command_is_finished
(
const
struct
audio_output
*
ao
)
{
{
return
ao
->
command
==
AO_COMMAND_NONE
;
return
ao
->
command
==
AO_COMMAND_NONE
;
}
}
static
inline
int
static
inline
bool
audio_output_get_result
(
const
struct
audio_output
*
ao
)
audio_output_get_result
(
const
struct
audio_output
*
ao
)
{
{
return
ao
->
result
;
return
ao
->
result
;
...
...
src/output_thread.c
View file @
58c5bee9
...
@@ -74,7 +74,7 @@ static void ao_pause(struct audio_output *ao)
...
@@ -74,7 +74,7 @@ static void ao_pause(struct audio_output *ao)
}
else
{
}
else
{
/* pause is not supported - simply close the device */
/* pause is not supported - simply close the device */
ao
->
plugin
->
close
(
ao
->
data
);
ao
->
plugin
->
close
(
ao
->
data
);
ao
->
open
=
0
;
ao
->
open
=
false
;
ao_command_finished
(
ao
);
ao_command_finished
(
ao
);
}
}
}
}
...
@@ -94,8 +94,8 @@ static void *audio_output_task(void *arg)
...
@@ -94,8 +94,8 @@ static void *audio_output_task(void *arg)
&
ao
->
outAudioFormat
);
&
ao
->
outAudioFormat
);
assert
(
!
ao
->
open
);
assert
(
!
ao
->
open
);
if
(
ao
->
result
==
0
)
if
(
ao
->
result
==
true
)
ao
->
open
=
1
;
ao
->
open
=
true
;
ao_command_finished
(
ao
);
ao_command_finished
(
ao
);
break
;
break
;
...
@@ -103,7 +103,7 @@ static void *audio_output_task(void *arg)
...
@@ -103,7 +103,7 @@ static void *audio_output_task(void *arg)
case
AO_COMMAND_CLOSE
:
case
AO_COMMAND_CLOSE
:
assert
(
ao
->
open
);
assert
(
ao
->
open
);
ao
->
plugin
->
close
(
ao
->
data
);
ao
->
plugin
->
close
(
ao
->
data
);
ao
->
open
=
0
;
ao
->
open
=
false
;
ao_command_finished
(
ao
);
ao_command_finished
(
ao
);
break
;
break
;
...
...
src/player_thread.c
View file @
58c5bee9
...
@@ -156,7 +156,7 @@ static void processDecodeInput(struct player *player)
...
@@ -156,7 +156,7 @@ static void processDecodeInput(struct player *player)
audio_output_pause_all
();
audio_output_pause_all
();
pc
.
state
=
PLAYER_STATE_PAUSE
;
pc
.
state
=
PLAYER_STATE_PAUSE
;
}
else
{
}
else
{
if
(
openAudioDevice
(
NULL
)
>=
0
)
{
if
(
openAudioDevice
(
NULL
))
{
pc
.
state
=
PLAYER_STATE_PLAY
;
pc
.
state
=
PLAYER_STATE_PLAY
;
}
else
{
}
else
{
char
tmp
[
MPD_PATH_MAX
];
char
tmp
[
MPD_PATH_MAX
];
...
@@ -215,8 +215,7 @@ static int playChunk(ob_chunk * chunk,
...
@@ -215,8 +215,7 @@ static int playChunk(ob_chunk * chunk,
pcm_volume
(
chunk
->
data
,
chunk
->
chunkSize
,
pcm_volume
(
chunk
->
data
,
chunk
->
chunkSize
,
format
,
pc
.
softwareVolume
);
format
,
pc
.
softwareVolume
);
if
(
playAudio
(
chunk
->
data
,
if
(
!
playAudio
(
chunk
->
data
,
chunk
->
chunkSize
))
chunk
->
chunkSize
)
<
0
)
return
-
1
;
return
-
1
;
pc
.
totalPlayTime
+=
sizeToTime
*
chunk
->
chunkSize
;
pc
.
totalPlayTime
+=
sizeToTime
*
chunk
->
chunkSize
;
...
@@ -288,7 +287,7 @@ static void do_play(void)
...
@@ -288,7 +287,7 @@ static void do_play(void)
else
if
(
!
decoder_is_starting
())
{
else
if
(
!
decoder_is_starting
())
{
/* the decoder is ready and ok */
/* the decoder is ready and ok */
player
.
decoder_starting
=
false
;
player
.
decoder_starting
=
false
;
if
(
openAudioDevice
(
&
(
ob
.
audioFormat
))
<
0
)
{
if
(
!
openAudioDevice
(
&
ob
.
audioFormat
)
)
{
char
tmp
[
MPD_PATH_MAX
];
char
tmp
[
MPD_PATH_MAX
];
assert
(
dc
.
next_song
==
NULL
||
dc
.
next_song
->
url
!=
NULL
);
assert
(
dc
.
next_song
==
NULL
||
dc
.
next_song
->
url
!=
NULL
);
pc
.
errored_song
=
dc
.
next_song
;
pc
.
errored_song
=
dc
.
next_song
;
...
@@ -439,7 +438,7 @@ static void do_play(void)
...
@@ -439,7 +438,7 @@ static void do_play(void)
unsigned
num_frames
=
CHUNK_SIZE
/
frame_size
;
unsigned
num_frames
=
CHUNK_SIZE
/
frame_size
;
/*DEBUG("waiting for decoded audio, play silence\n");*/
/*DEBUG("waiting for decoded audio, play silence\n");*/
if
(
playAudio
(
silence
,
num_frames
*
frame_size
)
<
0
)
if
(
!
playAudio
(
silence
,
num_frames
*
frame_size
)
)
break
;
break
;
}
}
}
}
...
...
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