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
8364029d
Commit
8364029d
authored
Jan 11, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
output/alsa: move code to PlayRaw()
parent
d842d21b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
23 deletions
+33
-23
AlsaOutputPlugin.cxx
src/output/plugins/AlsaOutputPlugin.cxx
+33
-23
No files found.
src/output/plugins/AlsaOutputPlugin.cxx
View file @
8364029d
...
@@ -141,6 +141,7 @@ struct AlsaOutput {
...
@@ -141,6 +141,7 @@ struct AlsaOutput {
void
Open
(
AudioFormat
&
audio_format
);
void
Open
(
AudioFormat
&
audio_format
);
void
Close
();
void
Close
();
size_t
PlayRaw
(
ConstBuffer
<
void
>
data
);
size_t
Play
(
const
void
*
chunk
,
size_t
size
);
size_t
Play
(
const
void
*
chunk
,
size_t
size
);
void
Drain
();
void
Drain
();
void
Cancel
();
void
Cancel
();
...
@@ -838,6 +839,36 @@ AlsaOutput::Close()
...
@@ -838,6 +839,36 @@ AlsaOutput::Close()
}
}
inline
size_t
inline
size_t
AlsaOutput
::
PlayRaw
(
ConstBuffer
<
void
>
data
)
{
if
(
data
.
IsEmpty
())
return
0
;
assert
(
data
.
size
%
out_frame_size
==
0
);
const
size_t
n_frames
=
data
.
size
/
out_frame_size
;
assert
(
n_frames
>
0
);
while
(
true
)
{
const
auto
frames_written
=
snd_pcm_writei
(
pcm
,
data
.
data
,
n_frames
);
if
(
frames_written
>
0
)
{
period_position
=
(
period_position
+
frames_written
)
%
period_frames
;
return
frames_written
*
out_frame_size
;
}
if
(
frames_written
<
0
&&
frames_written
!=
-
EAGAIN
&&
frames_written
!=
-
EINTR
&&
Recover
(
frames_written
)
<
0
)
throw
FormatRuntimeError
(
"snd_pcm_writei() failed: %s"
,
snd_strerror
(
-
frames_written
));
}
}
inline
size_t
AlsaOutput
::
Play
(
const
void
*
chunk
,
size_t
size
)
AlsaOutput
::
Play
(
const
void
*
chunk
,
size_t
size
)
{
{
assert
(
size
>
0
);
assert
(
size
>
0
);
...
@@ -862,29 +893,8 @@ AlsaOutput::Play(const void *chunk, size_t size)
...
@@ -862,29 +893,8 @@ AlsaOutput::Play(const void *chunk, size_t size)
been played */
been played */
return
size
;
return
size
;
chunk
=
e
.
data
;
const
size_t
bytes_written
=
PlayRaw
(
e
);
size
=
e
.
size
;
return
pcm_export
->
CalcSourceSize
(
bytes_written
);
assert
(
size
%
out_frame_size
==
0
);
size
/=
out_frame_size
;
assert
(
size
>
0
);
while
(
true
)
{
snd_pcm_sframes_t
ret
=
snd_pcm_writei
(
pcm
,
chunk
,
size
);
if
(
ret
>
0
)
{
period_position
=
(
period_position
+
ret
)
%
period_frames
;
size_t
bytes_written
=
ret
*
out_frame_size
;
return
pcm_export
->
CalcSourceSize
(
bytes_written
);
}
if
(
ret
<
0
&&
ret
!=
-
EAGAIN
&&
ret
!=
-
EINTR
&&
Recover
(
ret
)
<
0
)
throw
FormatRuntimeError
(
"snd_pcm_writei() failed: %s"
,
snd_strerror
(
-
ret
));
}
}
}
typedef
AudioOutputWrapper
<
AlsaOutput
>
Wrapper
;
typedef
AudioOutputWrapper
<
AlsaOutput
>
Wrapper
;
...
...
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