Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
9d168976
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9d168976
编写于
9月 18, 2009
作者:
M
malc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
oss: use audio_pcm_hw_clip_out
Signed-off-by:
N
malc
<
av1474@comtv.ru
>
上级
541ba4e7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
46 addition
and
47 deletion
+46
-47
audio/ossaudio.c
audio/ossaudio.c
+46
-47
未找到文件。
audio/ossaudio.c
浏览文件 @
9d168976
...
@@ -42,9 +42,11 @@ typedef struct OSSVoiceOut {
...
@@ -42,9 +42,11 @@ typedef struct OSSVoiceOut {
HWVoiceOut
hw
;
HWVoiceOut
hw
;
void
*
pcm_buf
;
void
*
pcm_buf
;
int
fd
;
int
fd
;
int
wpos
;
int
nfrags
;
int
nfrags
;
int
fragsize
;
int
fragsize
;
int
mmapped
;
int
mmapped
;
int
pending
;
}
OSSVoiceOut
;
}
OSSVoiceOut
;
typedef
struct
OSSVoiceIn
{
typedef
struct
OSSVoiceIn
{
...
@@ -347,13 +349,50 @@ static int oss_open (int in, struct oss_params *req,
...
@@ -347,13 +349,50 @@ static int oss_open (int in, struct oss_params *req,
return
-
1
;
return
-
1
;
}
}
static
void
oss_write_pending
(
OSSVoiceOut
*
oss
)
{
HWVoiceOut
*
hw
=
&
oss
->
hw
;
if
(
oss
->
mmapped
)
{
return
;
}
while
(
oss
->
pending
)
{
int
samples_written
;
ssize_t
bytes_written
;
int
samples_till_end
=
hw
->
samples
-
oss
->
wpos
;
int
samples_to_write
=
audio_MIN
(
oss
->
pending
,
samples_till_end
);
int
bytes_to_write
=
samples_to_write
<<
hw
->
info
.
shift
;
void
*
pcm
=
advance
(
oss
->
pcm_buf
,
oss
->
wpos
<<
hw
->
info
.
shift
);
bytes_written
=
write
(
oss
->
fd
,
pcm
,
bytes_to_write
);
if
(
bytes_written
<
0
)
{
if
(
errno
!=
EAGAIN
)
{
oss_logerr
(
errno
,
"failed to write %d bytes
\n
"
,
bytes_to_write
);
}
break
;
}
if
(
bytes_written
&
hw
->
info
.
align
)
{
dolog
(
"misaligned write asked for %d, but got %zd
\n
"
,
bytes_to_write
,
bytes_written
);
return
;
}
samples_written
=
bytes_written
>>
hw
->
info
.
shift
;
oss
->
pending
-=
samples_written
;
oss
->
wpos
=
(
oss
->
wpos
+
samples_written
)
%
hw
->
samples
;
if
(
bytes_written
-
bytes_to_write
)
{
break
;
}
}
}
static
int
oss_run_out
(
HWVoiceOut
*
hw
)
static
int
oss_run_out
(
HWVoiceOut
*
hw
)
{
{
OSSVoiceOut
*
oss
=
(
OSSVoiceOut
*
)
hw
;
OSSVoiceOut
*
oss
=
(
OSSVoiceOut
*
)
hw
;
int
err
,
rpos
,
live
,
decr
;
int
err
,
live
,
decr
;
int
samples
;
uint8_t
*
dst
;
struct
st_sample
*
src
;
struct
audio_buf_info
abinfo
;
struct
audio_buf_info
abinfo
;
struct
count_info
cntinfo
;
struct
count_info
cntinfo
;
int
bufsize
;
int
bufsize
;
...
@@ -408,50 +447,10 @@ static int oss_run_out (HWVoiceOut *hw)
...
@@ -408,50 +447,10 @@ static int oss_run_out (HWVoiceOut *hw)
}
}
}
}
samples
=
decr
;
decr
=
audio_pcm_hw_clip_out
(
hw
,
oss
->
pcm_buf
,
decr
,
oss
->
pending
);
rpos
=
hw
->
rpos
;
oss
->
pending
+=
decr
;
while
(
samples
)
{
oss_write_pending
(
oss
);
int
left_till_end_samples
=
hw
->
samples
-
rpos
;
int
convert_samples
=
audio_MIN
(
samples
,
left_till_end_samples
);
src
=
hw
->
mix_buf
+
rpos
;
dst
=
advance
(
oss
->
pcm_buf
,
rpos
<<
hw
->
info
.
shift
);
hw
->
clip
(
dst
,
src
,
convert_samples
);
if
(
!
oss
->
mmapped
)
{
int
written
;
written
=
write
(
oss
->
fd
,
dst
,
convert_samples
<<
hw
->
info
.
shift
);
/* XXX: follow errno recommendations ? */
if
(
written
==
-
1
)
{
oss_logerr
(
errno
,
"Failed to write %d bytes of audio data from %p
\n
"
,
convert_samples
<<
hw
->
info
.
shift
,
dst
);
continue
;
}
if
(
written
!=
convert_samples
<<
hw
->
info
.
shift
)
{
int
wsamples
=
written
>>
hw
->
info
.
shift
;
int
wbytes
=
wsamples
<<
hw
->
info
.
shift
;
if
(
wbytes
!=
written
)
{
dolog
(
"warning: Misaligned write %d (requested %d), "
"alignment %d
\n
"
,
wbytes
,
written
,
hw
->
info
.
align
+
1
);
}
decr
-=
wsamples
;
rpos
=
(
rpos
+
wsamples
)
%
hw
->
samples
;
break
;
}
}
rpos
=
(
rpos
+
convert_samples
)
%
hw
->
samples
;
samples
-=
convert_samples
;
}
hw
->
rpos
=
rpos
;
return
decr
;
return
decr
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录