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
38df1754
You need to sign in or sign up before continuing.
Commit
38df1754
authored
Oct 29, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pulse: no CamelCase
parent
2867c8e9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
50 deletions
+51
-50
pulse_plugin.c
src/output/pulse_plugin.c
+49
-48
output_list.c
src/output_list.c
+2
-2
No files found.
src/output/pulse_plugin.c
View file @
38df1754
...
@@ -26,32 +26,32 @@
...
@@ -26,32 +26,32 @@
#define MPD_PULSE_NAME "mpd"
#define MPD_PULSE_NAME "mpd"
#define CONN_ATTEMPT_INTERVAL 60
#define CONN_ATTEMPT_INTERVAL 60
typedef
struct
_PulseD
ata
{
struct
pulse_d
ata
{
struct
audio_output
*
ao
;
struct
audio_output
*
ao
;
pa_simple
*
s
;
pa_simple
*
s
;
char
*
server
;
char
*
server
;
char
*
sink
;
char
*
sink
;
int
connA
ttempts
;
int
num_connect_a
ttempts
;
time_t
last
A
ttempt
;
time_t
last
_connect_a
ttempt
;
}
PulseData
;
};
static
PulseData
*
newPulseD
ata
(
void
)
static
struct
pulse_data
*
pulse_new_d
ata
(
void
)
{
{
PulseD
ata
*
ret
;
struct
pulse_d
ata
*
ret
;
ret
=
xmalloc
(
sizeof
(
PulseData
));
ret
=
xmalloc
(
sizeof
(
*
ret
));
ret
->
s
=
NULL
;
ret
->
s
=
NULL
;
ret
->
server
=
NULL
;
ret
->
server
=
NULL
;
ret
->
sink
=
NULL
;
ret
->
sink
=
NULL
;
ret
->
connA
ttempts
=
0
;
ret
->
num_connect_a
ttempts
=
0
;
ret
->
last
A
ttempt
=
0
;
ret
->
last
_connect_a
ttempt
=
0
;
return
ret
;
return
ret
;
}
}
static
void
freePulseData
(
PulseData
*
pd
)
static
void
pulse_free_data
(
struct
pulse_data
*
pd
)
{
{
if
(
pd
->
server
)
if
(
pd
->
server
)
free
(
pd
->
server
);
free
(
pd
->
server
);
...
@@ -60,20 +60,21 @@ static void freePulseData(PulseData * pd)
...
@@ -60,20 +60,21 @@ static void freePulseData(PulseData * pd)
free
(
pd
);
free
(
pd
);
}
}
static
void
*
pulse_initDriver
(
struct
audio_output
*
ao
,
static
void
*
mpd_unused
const
struct
audio_format
*
audio_format
,
pulse_init
(
struct
audio_output
*
ao
,
ConfigParam
*
param
)
mpd_unused
const
struct
audio_format
*
audio_format
,
ConfigParam
*
param
)
{
{
BlockParam
*
server
=
NULL
;
BlockParam
*
server
=
NULL
;
BlockParam
*
sink
=
NULL
;
BlockParam
*
sink
=
NULL
;
PulseD
ata
*
pd
;
struct
pulse_d
ata
*
pd
;
if
(
param
)
{
if
(
param
)
{
server
=
getBlockParam
(
param
,
"server"
);
server
=
getBlockParam
(
param
,
"server"
);
sink
=
getBlockParam
(
param
,
"sink"
);
sink
=
getBlockParam
(
param
,
"sink"
);
}
}
pd
=
newPulseD
ata
();
pd
=
pulse_new_d
ata
();
pd
->
ao
=
ao
;
pd
->
ao
=
ao
;
pd
->
server
=
server
?
xstrdup
(
server
->
value
)
:
NULL
;
pd
->
server
=
server
?
xstrdup
(
server
->
value
)
:
NULL
;
pd
->
sink
=
sink
?
xstrdup
(
sink
->
value
)
:
NULL
;
pd
->
sink
=
sink
?
xstrdup
(
sink
->
value
)
:
NULL
;
...
@@ -81,14 +82,14 @@ static void *pulse_initDriver(struct audio_output *ao,
...
@@ -81,14 +82,14 @@ static void *pulse_initDriver(struct audio_output *ao,
return
pd
;
return
pd
;
}
}
static
void
pulse_finish
Driver
(
void
*
data
)
static
void
pulse_finish
(
void
*
data
)
{
{
PulseD
ata
*
pd
=
data
;
struct
pulse_d
ata
*
pd
=
data
;
freePulseD
ata
(
pd
);
pulse_free_d
ata
(
pd
);
}
}
static
int
pulse_test
Default
(
void
)
static
int
pulse_test
_default_device
(
void
)
{
{
pa_simple
*
s
;
pa_simple
*
s
;
pa_sample_spec
ss
;
pa_sample_spec
ss
;
...
@@ -111,30 +112,30 @@ static int pulse_testDefault(void)
...
@@ -111,30 +112,30 @@ static int pulse_testDefault(void)
return
0
;
return
0
;
}
}
static
int
pulse_openDevice
(
void
*
data
,
static
int
struct
audio_format
*
audioF
ormat
)
pulse_open
(
void
*
data
,
struct
audio_format
*
audio_f
ormat
)
{
{
PulseD
ata
*
pd
=
data
;
struct
pulse_d
ata
*
pd
=
data
;
pa_sample_spec
ss
;
pa_sample_spec
ss
;
time_t
t
;
time_t
t
;
int
error
;
int
error
;
t
=
time
(
NULL
);
t
=
time
(
NULL
);
if
(
pd
->
connA
ttempts
!=
0
&&
if
(
pd
->
num_connect_a
ttempts
!=
0
&&
(
t
-
pd
->
last
A
ttempt
)
<
CONN_ATTEMPT_INTERVAL
)
(
t
-
pd
->
last
_connect_a
ttempt
)
<
CONN_ATTEMPT_INTERVAL
)
return
-
1
;
return
-
1
;
pd
->
connA
ttempts
++
;
pd
->
num_connect_a
ttempts
++
;
pd
->
last
A
ttempt
=
t
;
pd
->
last
_connect_a
ttempt
=
t
;
/* MPD doesn't support the other pulseaudio sample formats, so
/* MPD doesn't support the other pulseaudio sample formats, so
we just force MPD to send us everything as 16 bit */
we just force MPD to send us everything as 16 bit */
audio
F
ormat
->
bits
=
16
;
audio
_f
ormat
->
bits
=
16
;
ss
.
format
=
PA_SAMPLE_S16NE
;
ss
.
format
=
PA_SAMPLE_S16NE
;
ss
.
rate
=
audio
F
ormat
->
sample_rate
;
ss
.
rate
=
audio
_f
ormat
->
sample_rate
;
ss
.
channels
=
audio
F
ormat
->
channels
;
ss
.
channels
=
audio
_f
ormat
->
channels
;
pd
->
s
=
pa_simple_new
(
pd
->
server
,
MPD_PULSE_NAME
,
PA_STREAM_PLAYBACK
,
pd
->
s
=
pa_simple_new
(
pd
->
server
,
MPD_PULSE_NAME
,
PA_STREAM_PLAYBACK
,
pd
->
sink
,
audio_output_get_name
(
pd
->
ao
),
pd
->
sink
,
audio_output_get_name
(
pd
->
ao
),
...
@@ -144,24 +145,24 @@ static int pulse_openDevice(void *data,
...
@@ -144,24 +145,24 @@ static int pulse_openDevice(void *data,
ERROR
(
"Cannot connect to server in PulseAudio output "
ERROR
(
"Cannot connect to server in PulseAudio output "
"
\"
%s
\"
(attempt %i): %s
\n
"
,
"
\"
%s
\"
(attempt %i): %s
\n
"
,
audio_output_get_name
(
pd
->
ao
),
audio_output_get_name
(
pd
->
ao
),
pd
->
connA
ttempts
,
pa_strerror
(
error
));
pd
->
num_connect_a
ttempts
,
pa_strerror
(
error
));
return
-
1
;
return
-
1
;
}
}
pd
->
connA
ttempts
=
0
;
pd
->
num_connect_a
ttempts
=
0
;
DEBUG
(
"PulseAudio output
\"
%s
\"
connected and playing %i bit, %i "
DEBUG
(
"PulseAudio output
\"
%s
\"
connected and playing %i bit, %i "
"channel audio at %i Hz
\n
"
,
"channel audio at %i Hz
\n
"
,
audio_output_get_name
(
pd
->
ao
),
audio_output_get_name
(
pd
->
ao
),
audio
F
ormat
->
bits
,
audio
_f
ormat
->
bits
,
audio
Format
->
channels
,
audioF
ormat
->
sample_rate
);
audio
_format
->
channels
,
audio_f
ormat
->
sample_rate
);
return
0
;
return
0
;
}
}
static
void
pulse_
dropBufferedAudio
(
void
*
data
)
static
void
pulse_
cancel
(
void
*
data
)
{
{
PulseD
ata
*
pd
=
data
;
struct
pulse_d
ata
*
pd
=
data
;
int
error
;
int
error
;
if
(
pa_simple_flush
(
pd
->
s
,
&
error
)
<
0
)
if
(
pa_simple_flush
(
pd
->
s
,
&
error
)
<
0
)
...
@@ -170,9 +171,9 @@ static void pulse_dropBufferedAudio(void *data)
...
@@ -170,9 +171,9 @@ static void pulse_dropBufferedAudio(void *data)
pa_strerror
(
error
));
pa_strerror
(
error
));
}
}
static
void
pulse_close
Device
(
void
*
data
)
static
void
pulse_close
(
void
*
data
)
{
{
PulseD
ata
*
pd
=
data
;
struct
pulse_d
ata
*
pd
=
data
;
if
(
pd
->
s
)
{
if
(
pd
->
s
)
{
pa_simple_drain
(
pd
->
s
,
NULL
);
pa_simple_drain
(
pd
->
s
,
NULL
);
...
@@ -180,10 +181,10 @@ static void pulse_closeDevice(void *data)
...
@@ -180,10 +181,10 @@ static void pulse_closeDevice(void *data)
}
}
}
}
static
int
pulse_play
Audio
(
void
*
data
,
static
int
pulse_play
(
void
*
data
,
const
char
*
playChunk
,
size_t
size
)
const
char
*
playChunk
,
size_t
size
)
{
{
PulseD
ata
*
pd
=
data
;
struct
pulse_d
ata
*
pd
=
data
;
int
error
;
int
error
;
if
(
pa_simple_write
(
pd
->
s
,
playChunk
,
size
,
&
error
)
<
0
)
{
if
(
pa_simple_write
(
pd
->
s
,
playChunk
,
size
,
&
error
)
<
0
)
{
...
@@ -191,20 +192,20 @@ static int pulse_playAudio(void *data,
...
@@ -191,20 +192,20 @@ static int pulse_playAudio(void *data,
"error: %s
\n
"
,
"error: %s
\n
"
,
audio_output_get_name
(
pd
->
ao
),
audio_output_get_name
(
pd
->
ao
),
pa_strerror
(
error
));
pa_strerror
(
error
));
pulse_close
Device
(
pd
);
pulse_close
(
pd
);
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
}
}
const
struct
audio_output_plugin
pulse
P
lugin
=
{
const
struct
audio_output_plugin
pulse
_p
lugin
=
{
.
name
=
"pulse"
,
.
name
=
"pulse"
,
.
test_default_device
=
pulse_test
Default
,
.
test_default_device
=
pulse_test
_default_device
,
.
init
=
pulse_init
Driver
,
.
init
=
pulse_init
,
.
finish
=
pulse_finish
Driver
,
.
finish
=
pulse_finish
,
.
open
=
pulse_open
Device
,
.
open
=
pulse_open
,
.
play
=
pulse_play
Audio
,
.
play
=
pulse_play
,
.
cancel
=
pulse_
dropBufferedAudio
,
.
cancel
=
pulse_
cancel
,
.
close
=
pulse_close
Device
,
.
close
=
pulse_close
,
};
};
src/output_list.c
View file @
38df1754
...
@@ -27,7 +27,7 @@ extern const struct audio_output_plugin alsaPlugin;
...
@@ -27,7 +27,7 @@ extern const struct audio_output_plugin alsaPlugin;
extern
const
struct
audio_output_plugin
aoPlugin
;
extern
const
struct
audio_output_plugin
aoPlugin
;
extern
const
struct
audio_output_plugin
ossPlugin
;
extern
const
struct
audio_output_plugin
ossPlugin
;
extern
const
struct
audio_output_plugin
osxPlugin
;
extern
const
struct
audio_output_plugin
osxPlugin
;
extern
const
struct
audio_output_plugin
pulse
P
lugin
;
extern
const
struct
audio_output_plugin
pulse
_p
lugin
;
extern
const
struct
audio_output_plugin
mvpPlugin
;
extern
const
struct
audio_output_plugin
mvpPlugin
;
extern
const
struct
audio_output_plugin
jackPlugin
;
extern
const
struct
audio_output_plugin
jackPlugin
;
...
@@ -52,7 +52,7 @@ const struct audio_output_plugin *audio_output_plugins[] = {
...
@@ -52,7 +52,7 @@ const struct audio_output_plugin *audio_output_plugins[] = {
&
osxPlugin
,
&
osxPlugin
,
#endif
#endif
#ifdef HAVE_PULSE
#ifdef HAVE_PULSE
&
pulse
P
lugin
,
&
pulse
_p
lugin
,
#endif
#endif
#ifdef HAVE_MVP
#ifdef HAVE_MVP
&
mvpPlugin
,
&
mvpPlugin
,
...
...
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