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
41a4662c
Commit
41a4662c
authored
Mar 10, 2010
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/jack: synchronize all channels
Always use the same number of samples from each channel's ring buffer. This ensures that all channels are kept in sync.
parent
5842015b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
9 deletions
+26
-9
jack_output_plugin.c
src/output/jack_output_plugin.c
+26
-9
No files found.
src/output/jack_output_plugin.c
View file @
41a4662c
...
...
@@ -88,12 +88,31 @@ jack_output_quark(void)
return
g_quark_from_static_string
(
"jack_output"
);
}
/**
* Determine the number of frames guaranteed to be available on all
* channels.
*/
static
jack_nframes_t
mpd_jack_available
(
const
struct
jack_data
*
jd
)
{
size_t
min
=
jack_ringbuffer_read_space
(
jd
->
ringbuffer
[
0
]);
for
(
unsigned
i
=
1
;
i
<
jd
->
audio_format
.
channels
;
++
i
)
{
size_t
current
=
jack_ringbuffer_read_space
(
jd
->
ringbuffer
[
i
]);
if
(
current
<
min
)
min
=
current
;
}
assert
(
min
%
sample_size
==
0
);
return
min
/
sample_size
;
}
static
int
mpd_jack_process
(
jack_nframes_t
nframes
,
void
*
arg
)
{
struct
jack_data
*
jd
=
(
struct
jack_data
*
)
arg
;
jack_default_audio_sample_t
*
out
;
size_t
available
;
if
(
nframes
<=
0
)
return
0
;
...
...
@@ -111,20 +130,18 @@ mpd_jack_process(jack_nframes_t nframes, void *arg)
return
0
;
}
for
(
unsigned
i
=
0
;
i
<
jd
->
audio_format
.
channels
;
++
i
)
{
available
=
jack_ringbuffer_read_space
(
jd
->
ringbuffer
[
i
]);
assert
(
available
%
sample_size
==
0
);
available
/=
sample_size
;
if
(
available
>
nframes
)
available
=
nframes
;
jack_nframes_t
available
=
mpd_jack_available
(
jd
);
if
(
available
>
nframes
)
available
=
nframes
;
for
(
unsigned
i
=
0
;
i
<
jd
->
audio_format
.
channels
;
++
i
)
{
out
=
jack_port_get_buffer
(
jd
->
ports
[
i
],
nframes
);
jack_ringbuffer_read
(
jd
->
ringbuffer
[
i
],
(
char
*
)
out
,
available
*
sample_size
);
while
(
available
<
nframes
)
for
(
jack_nframes_t
f
=
available
;
f
<
nframes
;
++
f
)
/* ringbuffer underrun, fill with silence */
out
[
available
++
]
=
0
.
0
;
out
[
f
]
=
0
.
0
;
}
/* generate silence for the unused source ports */
...
...
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