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
e06dd129
Commit
e06dd129
authored
Feb 04, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/alsa: move code to alsa_write_silence()
parent
00baddcd
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
14 deletions
+23
-14
AlsaOutputPlugin.cxx
src/output/AlsaOutputPlugin.cxx
+23
-14
No files found.
src/output/AlsaOutputPlugin.cxx
View file @
e06dd129
...
...
@@ -682,6 +682,28 @@ alsa_open(struct audio_output *ao, struct audio_format *audio_format, GError **e
return
true
;
}
/**
* Write silence to the ALSA device.
*/
static
void
alsa_write_silence
(
AlsaOutput
*
ad
,
snd_pcm_uframes_t
nframes
)
{
size_t
nbytes
=
nframes
*
ad
->
out_frame_size
;
void
*
buffer
=
g_malloc
(
nbytes
);
snd_pcm_hw_params_t
*
params
;
snd_pcm_format_t
format
;
unsigned
channels
;
snd_pcm_hw_params_alloca
(
&
params
);
snd_pcm_hw_params_current
(
ad
->
pcm
,
params
);
snd_pcm_hw_params_get_format
(
params
,
&
format
);
snd_pcm_hw_params_get_channels
(
params
,
&
channels
);
snd_pcm_format_set_silence
(
format
,
buffer
,
nframes
*
channels
);
ad
->
writei
(
ad
->
pcm
,
buffer
,
nframes
);
g_free
(
buffer
);
}
static
int
alsa_recover
(
AlsaOutput
*
ad
,
int
err
)
{
...
...
@@ -732,20 +754,7 @@ alsa_drain(struct audio_output *ao)
period */
snd_pcm_uframes_t
nframes
=
ad
->
period_frames
-
ad
->
period_position
;
size_t
nbytes
=
nframes
*
ad
->
out_frame_size
;
void
*
buffer
=
g_malloc
(
nbytes
);
snd_pcm_hw_params_t
*
params
;
snd_pcm_format_t
format
;
unsigned
channels
;
snd_pcm_hw_params_alloca
(
&
params
);
snd_pcm_hw_params_current
(
ad
->
pcm
,
params
);
snd_pcm_hw_params_get_format
(
params
,
&
format
);
snd_pcm_hw_params_get_channels
(
params
,
&
channels
);
snd_pcm_format_set_silence
(
format
,
buffer
,
nframes
*
channels
);
ad
->
writei
(
ad
->
pcm
,
buffer
,
nframes
);
g_free
(
buffer
);
alsa_write_silence
(
ad
,
nframes
);
}
snd_pcm_drain
(
ad
->
pcm
);
...
...
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