Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
541ba4e7
Q
qemu
项目概览
openeuler
/
qemu
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
541ba4e7
编写于
9月 18, 2009
作者:
M
malc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
alsa: use audio_pcm_hw_clip_out
Signed-off-by:
N
malc
<
av1474@comtv.ru
>
上级
ddabec73
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
43 addition
and
45 deletion
+43
-45
audio/alsaaudio.c
audio/alsaaudio.c
+43
-45
未找到文件。
audio/alsaaudio.c
浏览文件 @
541ba4e7
...
...
@@ -42,6 +42,8 @@ struct pollhlp {
typedef
struct
ALSAVoiceOut
{
HWVoiceOut
hw
;
int
wpos
;
int
pending
;
void
*
pcm_buf
;
snd_pcm_t
*
handle
;
struct
pollhlp
pollhlp
;
...
...
@@ -592,7 +594,7 @@ static int alsa_open (int in, struct alsa_params_req *req,
goto
err
;
}
if
((
req
->
override_mask
&
1
)
&&
(
obt
-
req
->
period_size
))
if
((
(
req
->
override_mask
&
1
)
&&
(
obt
-
req
->
period_size
)
))
dolog
(
"Requested period %s %u was rejected, using %lu
\n
"
,
size_in_usec
?
"time"
:
"size"
,
req
->
period_size
,
obt
);
}
...
...
@@ -698,41 +700,19 @@ static snd_pcm_sframes_t alsa_get_avail (snd_pcm_t *handle)
return
avail
;
}
static
int
alsa_run_out
(
HWVoiceOut
*
hw
)
static
void
alsa_write_pending
(
ALSAVoiceOut
*
alsa
)
{
ALSAVoiceOut
*
alsa
=
(
ALSAVoiceOut
*
)
hw
;
int
rpos
,
live
,
decr
;
int
samples
;
uint8_t
*
dst
;
struct
st_sample
*
src
;
snd_pcm_sframes_t
avail
;
HWVoiceOut
*
hw
=
&
alsa
->
hw
;
live
=
audio_pcm_hw_get_live_out
(
hw
);
if
(
!
live
)
{
return
0
;
}
avail
=
alsa_get_avail
(
alsa
->
handle
);
if
(
avail
<
0
)
{
dolog
(
"Could not get number of available playback frames
\n
"
);
return
0
;
}
decr
=
audio_MIN
(
live
,
avail
);
samples
=
decr
;
rpos
=
hw
->
rpos
;
while
(
samples
)
{
int
left_till_end_samples
=
hw
->
samples
-
rpos
;
int
len
=
audio_MIN
(
samples
,
left_till_end_samples
);
snd_pcm_sframes_t
written
;
src
=
hw
->
mix_buf
+
rpos
;
dst
=
advance
(
alsa
->
pcm_buf
,
rpos
<<
hw
->
info
.
shift
);
hw
->
clip
(
dst
,
src
,
len
);
while
(
alsa
->
pending
)
{
int
left_till_end_samples
=
hw
->
samples
-
alsa
->
wpos
;
int
len
=
audio_MIN
(
alsa
->
pending
,
left_till_end_samples
);
char
*
src
=
advance
(
alsa
->
pcm_buf
,
alsa
->
wpos
<<
hw
->
info
.
shift
);
while
(
len
)
{
written
=
snd_pcm_writei
(
alsa
->
handle
,
dst
,
len
);
snd_pcm_sframes_t
written
;
written
=
snd_pcm_writei
(
alsa
->
handle
,
src
,
len
);
if
(
written
<=
0
)
{
switch
(
written
)
{
...
...
@@ -740,13 +720,13 @@ static int alsa_run_out (HWVoiceOut *hw)
if
(
conf
.
verbose
)
{
dolog
(
"Failed to write %d frames (wrote zero)
\n
"
,
len
);
}
goto
exit
;
return
;
case
-
EPIPE
:
if
(
alsa_recover
(
alsa
->
handle
))
{
alsa_logerr
(
written
,
"Failed to write %d frames
\n
"
,
len
);
goto
exit
;
return
;
}
if
(
conf
.
verbose
)
{
dolog
(
"Recovering from playback xrun
\n
"
);
...
...
@@ -759,7 +739,7 @@ static int alsa_run_out (HWVoiceOut *hw)
if
(
alsa_resume
(
alsa
->
handle
))
{
alsa_logerr
(
written
,
"Failed to write %d frames
\n
"
,
len
);
goto
exit
;
return
;
}
if
(
conf
.
verbose
)
{
dolog
(
"Resuming suspended output stream
\n
"
);
...
...
@@ -767,25 +747,43 @@ static int alsa_run_out (HWVoiceOut *hw)
continue
;
case
-
EAGAIN
:
goto
exit
;
return
;
default:
alsa_logerr
(
written
,
"Failed to write %d frames
to
%p
\n
"
,
len
,
dst
);
goto
exit
;
alsa_logerr
(
written
,
"Failed to write %d frames
from
%p
\n
"
,
len
,
src
);
return
;
}
}
rpos
=
(
r
pos
+
written
)
%
hw
->
samples
;
samples
-=
written
;
alsa
->
wpos
=
(
alsa
->
w
pos
+
written
)
%
hw
->
samples
;
alsa
->
pending
-=
written
;
len
-=
written
;
dst
=
advance
(
dst
,
written
<<
hw
->
info
.
shift
);
src
+=
written
;
}
}
}
exit:
hw
->
rpos
=
rpos
;
static
int
alsa_run_out
(
HWVoiceOut
*
hw
)
{
ALSAVoiceOut
*
alsa
=
(
ALSAVoiceOut
*
)
hw
;
int
live
,
decr
;
snd_pcm_sframes_t
avail
;
live
=
audio_pcm_hw_get_live_out
(
hw
);
if
(
!
live
)
{
return
0
;
}
avail
=
alsa_get_avail
(
alsa
->
handle
);
if
(
avail
<
0
)
{
dolog
(
"Could not get number of available playback frames
\n
"
);
return
0
;
}
decr
=
audio_MIN
(
live
,
avail
);
decr
=
audio_pcm_hw_clip_out
(
hw
,
alsa
->
pcm_buf
,
decr
,
alsa
->
pending
);
alsa
->
pending
+=
decr
;
alsa_write_pending
(
alsa
);
return
decr
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录