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
1ff39476
Commit
1ff39476
authored
Oct 21, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/jack: implement the "pause" method
Don't disconnect from JACK during pause.
parent
acfd9a73
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-0
NEWS
NEWS
+1
-0
jack_output_plugin.c
src/output/jack_output_plugin.c
+41
-0
No files found.
NEWS
View file @
1ff39476
...
@@ -32,6 +32,7 @@ ver 0.16 (20??/??/??)
...
@@ -32,6 +32,7 @@ ver 0.16 (20??/??/??)
- pulse: announce "media.role=music"
- pulse: announce "media.role=music"
- pulse: renamed context to "Music Player Daemon"
- pulse: renamed context to "Music Player Daemon"
- pulse: connect to server on MPD startup, implement pause
- pulse: connect to server on MPD startup, implement pause
- jack: don't disconnect during pause
* mixers:
* mixers:
- removed support for legacy mixer configuration
- removed support for legacy mixer configuration
- reimplemented software volume as mixer+filter plugin
- reimplemented software volume as mixer+filter plugin
...
...
src/output/jack_output_plugin.c
View file @
1ff39476
...
@@ -58,6 +58,12 @@ struct jack_data {
...
@@ -58,6 +58,12 @@ struct jack_data {
jack_ringbuffer_t
*
ringbuffer
[
2
];
jack_ringbuffer_t
*
ringbuffer
[
2
];
bool
shutdown
;
bool
shutdown
;
/**
* While this flag is set, the "process" callback generates
* silence.
*/
bool
pause
;
};
};
/**
/**
...
@@ -116,6 +122,19 @@ mpd_jack_process(jack_nframes_t nframes, void *arg)
...
@@ -116,6 +122,19 @@ mpd_jack_process(jack_nframes_t nframes, void *arg)
if
(
nframes
<=
0
)
if
(
nframes
<=
0
)
return
0
;
return
0
;
if
(
jd
->
pause
)
{
/* generate silence while MPD is paused */
for
(
unsigned
i
=
0
;
i
<
G_N_ELEMENTS
(
jd
->
ringbuffer
);
++
i
)
{
out
=
jack_port_get_buffer
(
jd
->
ports
[
i
],
nframes
);
for
(
jack_nframes_t
f
=
0
;
f
<
nframes
;
++
f
)
out
[
f
]
=
0
.
0
;
}
return
0
;
}
for
(
unsigned
i
=
0
;
i
<
G_N_ELEMENTS
(
jd
->
ringbuffer
);
++
i
)
{
for
(
unsigned
i
=
0
;
i
<
G_N_ELEMENTS
(
jd
->
ringbuffer
);
++
i
)
{
available
=
jack_ringbuffer_read_space
(
jd
->
ringbuffer
[
i
]);
available
=
jack_ringbuffer_read_space
(
jd
->
ringbuffer
[
i
]);
assert
(
available
%
sample_size
==
0
);
assert
(
available
%
sample_size
==
0
);
...
@@ -308,6 +327,8 @@ mpd_jack_open(void *data, struct audio_format *audio_format, GError **error)
...
@@ -308,6 +327,8 @@ mpd_jack_open(void *data, struct audio_format *audio_format, GError **error)
assert
(
jd
!=
NULL
);
assert
(
jd
!=
NULL
);
jd
->
pause
=
false
;
if
(
!
mpd_jack_connect
(
jd
,
error
))
{
if
(
!
mpd_jack_connect
(
jd
,
error
))
{
mpd_jack_client_free
(
jd
);
mpd_jack_client_free
(
jd
);
return
false
;
return
false
;
...
@@ -405,6 +426,8 @@ mpd_jack_play(void *data, const void *chunk, size_t size, GError **error)
...
@@ -405,6 +426,8 @@ mpd_jack_play(void *data, const void *chunk, size_t size, GError **error)
const
size_t
frame_size
=
audio_format_frame_size
(
&
jd
->
audio_format
);
const
size_t
frame_size
=
audio_format_frame_size
(
&
jd
->
audio_format
);
size_t
space
=
0
,
space1
;
size_t
space
=
0
,
space1
;
jd
->
pause
=
false
;
assert
(
size
%
frame_size
==
0
);
assert
(
size
%
frame_size
==
0
);
size
/=
frame_size
;
size
/=
frame_size
;
...
@@ -438,6 +461,23 @@ mpd_jack_play(void *data, const void *chunk, size_t size, GError **error)
...
@@ -438,6 +461,23 @@ mpd_jack_play(void *data, const void *chunk, size_t size, GError **error)
return
size
*
frame_size
;
return
size
*
frame_size
;
}
}
static
bool
mpd_jack_pause
(
void
*
data
)
{
struct
jack_data
*
jd
=
data
;
if
(
jd
->
shutdown
)
return
false
;
jd
->
pause
=
true
;
/* due to a MPD API limitation, we have to sleep a little bit
here, to avoid hogging the CPU */
g_usleep
(
50000
);
return
true
;
}
const
struct
audio_output_plugin
jack_output_plugin
=
{
const
struct
audio_output_plugin
jack_output_plugin
=
{
.
name
=
"jack"
,
.
name
=
"jack"
,
.
test_default_device
=
mpd_jack_test_default_device
,
.
test_default_device
=
mpd_jack_test_default_device
,
...
@@ -446,5 +486,6 @@ const struct audio_output_plugin jack_output_plugin = {
...
@@ -446,5 +486,6 @@ const struct audio_output_plugin jack_output_plugin = {
.
open
=
mpd_jack_open
,
.
open
=
mpd_jack_open
,
.
play
=
mpd_jack_play
,
.
play
=
mpd_jack_play
,
.
cancel
=
mpd_jack_cancel
,
.
cancel
=
mpd_jack_cancel
,
.
pause
=
mpd_jack_pause
,
.
close
=
mpd_jack_close
,
.
close
=
mpd_jack_close
,
};
};
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