Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
713a98f8
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,发现更多精彩内容 >>
提交
713a98f8
编写于
9月 12, 2009
作者:
M
malc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
audio: poll mode infrastructure
Signed-off-by:
N
malc
<
av1474@comtv.ru
>
上级
435c247a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
87 addition
and
11 deletion
+87
-11
audio/audio.c
audio/audio.c
+83
-11
audio/audio_int.h
audio/audio_int.h
+4
-0
未找到文件。
audio/audio.c
浏览文件 @
713a98f8
...
...
@@ -34,6 +34,7 @@
/* #define DEBUG_LIVE */
/* #define DEBUG_OUT */
/* #define DEBUG_CAPTURE */
/* #define DEBUG_POLL */
#define SW_NAME(sw) (sw)->name ? (sw)->name : "unknown"
...
...
@@ -64,6 +65,8 @@ static struct {
}
period
;
int
plive
;
int
log_to_monitor
;
int
try_poll_in
;
int
try_poll_out
;
}
conf
=
{
.
fixed_out
=
{
/* DAC fixed settings */
.
enabled
=
1
,
...
...
@@ -92,6 +95,8 @@ static struct {
.
period
=
{
.
hertz
=
250
},
.
plive
=
0
,
.
log_to_monitor
=
0
,
.
try_poll_in
=
1
,
.
try_poll_out
=
1
,
};
static
AudioState
glob_audio_state
;
...
...
@@ -1082,6 +1087,47 @@ static void audio_pcm_print_info (const char *cap, struct audio_pcm_info *info)
#undef DAC
#include "audio_template.h"
/*
* Timer
*/
static
void
audio_timer
(
void
*
opaque
)
{
AudioState
*
s
=
opaque
;
audio_run
(
"timer"
);
qemu_mod_timer
(
s
->
ts
,
qemu_get_clock
(
vm_clock
)
+
conf
.
period
.
ticks
);
}
static
int
audio_is_timer_needed
(
void
)
{
HWVoiceIn
*
hwi
=
NULL
;
HWVoiceOut
*
hwo
=
NULL
;
while
((
hwo
=
audio_pcm_hw_find_any_enabled_out
(
hwo
)))
{
if
(
!
hwo
->
poll_mode
)
return
1
;
}
while
((
hwi
=
audio_pcm_hw_find_any_enabled_in
(
hwi
)))
{
if
(
!
hwi
->
poll_mode
)
return
1
;
}
return
0
;
}
static
void
audio_reset_timer
(
void
)
{
AudioState
*
s
=
&
glob_audio_state
;
if
(
audio_is_timer_needed
())
{
qemu_mod_timer
(
s
->
ts
,
qemu_get_clock
(
vm_clock
)
+
1
);
}
else
{
qemu_del_timer
(
s
->
ts
);
}
}
/*
* Public API
*/
int
AUD_write
(
SWVoiceOut
*
sw
,
void
*
buf
,
int
size
)
{
int
bytes
;
...
...
@@ -1142,7 +1188,8 @@ void AUD_set_active_out (SWVoiceOut *sw, int on)
if
(
!
hw
->
enabled
)
{
hw
->
enabled
=
1
;
if
(
s
->
vm_running
)
{
hw
->
pcm_ops
->
ctl_out
(
hw
,
VOICE_ENABLE
);
hw
->
pcm_ops
->
ctl_out
(
hw
,
VOICE_ENABLE
,
conf
.
try_poll_out
);
audio_reset_timer
();
}
}
}
...
...
@@ -1186,7 +1233,7 @@ void AUD_set_active_in (SWVoiceIn *sw, int on)
if
(
!
hw
->
enabled
)
{
hw
->
enabled
=
1
;
if
(
s
->
vm_running
)
{
hw
->
pcm_ops
->
ctl_in
(
hw
,
VOICE_ENABLE
);
hw
->
pcm_ops
->
ctl_in
(
hw
,
VOICE_ENABLE
,
conf
.
try_poll_in
);
}
}
sw
->
total_hw_samples_acquired
=
hw
->
total_samples_captured
;
...
...
@@ -1480,15 +1527,29 @@ static void audio_run_capture (AudioState *s)
}
}
static
void
audio_timer
(
void
*
opaque
)
void
audio_run
(
const
char
*
msg
)
{
AudioState
*
s
=
opaqu
e
;
AudioState
*
s
=
&
glob_audio_stat
e
;
audio_run_out
(
s
);
audio_run_in
(
s
);
audio_run_capture
(
s
);
#ifdef DEBUG_POLL
{
static
double
prevtime
;
double
currtime
;
struct
timeval
tv
;
qemu_mod_timer
(
s
->
ts
,
qemu_get_clock
(
vm_clock
)
+
conf
.
period
.
ticks
);
if
(
gettimeofday
(
&
tv
,
NULL
))
{
perror
(
"audio_run: gettimeofday"
);
return
;
}
currtime
=
tv
.
tv_sec
+
tv
.
tv_usec
*
1e-6
;
dolog
(
"Elapsed since last %s: %f
\n
"
,
msg
,
currtime
-
prevtime
);
prevtime
=
currtime
;
}
#endif
}
static
struct
audio_option
audio_options
[]
=
{
...
...
@@ -1523,6 +1584,12 @@ static struct audio_option audio_options[] = {
.
valp
=
&
conf
.
fixed_out
.
nb_voices
,
.
descr
=
"Number of voices for DAC"
},
{
.
name
=
"DAC_TRY_POLL"
,
.
tag
=
AUD_OPT_BOOL
,
.
valp
=
&
conf
.
try_poll_out
,
.
descr
=
"Attempt using poll mode for DAC"
},
/* ADC */
{
.
name
=
"ADC_FIXED_SETTINGS"
,
...
...
@@ -1554,6 +1621,12 @@ static struct audio_option audio_options[] = {
.
valp
=
&
conf
.
fixed_in
.
nb_voices
,
.
descr
=
"Number of voices for ADC"
},
{
.
name
=
"ADC_TRY_POLL"
,
.
tag
=
AUD_OPT_BOOL
,
.
valp
=
&
conf
.
try_poll_out
,
.
descr
=
"Attempt using poll mode for ADC"
},
/* Misc */
{
.
name
=
"TIMER_PERIOD"
,
...
...
@@ -1571,7 +1644,7 @@ static struct audio_option audio_options[] = {
.
name
=
"LOG_TO_MONITOR"
,
.
tag
=
AUD_OPT_BOOL
,
.
valp
=
&
conf
.
log_to_monitor
,
.
descr
=
"
p
rint logging messages to monitor instead of stderr"
.
descr
=
"
P
rint logging messages to monitor instead of stderr"
},
{
/* End of list */
}
};
...
...
@@ -1676,12 +1749,13 @@ static void audio_vm_change_state_handler (void *opaque, int running,
s
->
vm_running
=
running
;
while
((
hwo
=
audio_pcm_hw_find_any_enabled_out
(
hwo
)))
{
hwo
->
pcm_ops
->
ctl_out
(
hwo
,
op
);
hwo
->
pcm_ops
->
ctl_out
(
hwo
,
op
,
conf
.
try_poll_out
);
}
while
((
hwi
=
audio_pcm_hw_find_any_enabled_in
(
hwi
)))
{
hwi
->
pcm_ops
->
ctl_in
(
hwi
,
op
);
hwi
->
pcm_ops
->
ctl_in
(
hwi
,
op
,
conf
.
try_poll_in
);
}
audio_reset_timer
();
}
static
void
audio_atexit
(
void
)
...
...
@@ -1739,6 +1813,7 @@ static void audio_init (void)
size_t
i
;
int
done
=
0
;
const
char
*
drvname
;
VMChangeStateEntry
*
e
;
AudioState
*
s
=
&
glob_audio_state
;
if
(
s
->
drv
)
{
...
...
@@ -1812,8 +1887,6 @@ static void audio_init (void)
}
}
VMChangeStateEntry
*
e
;
if
(
conf
.
period
.
hertz
<=
0
)
{
if
(
conf
.
period
.
hertz
<
0
)
{
dolog
(
"warning: Timer period is negative - %d "
...
...
@@ -1833,7 +1906,6 @@ static void audio_init (void)
LIST_INIT
(
&
s
->
card_head
);
register_savevm
(
"audio"
,
0
,
1
,
audio_save
,
audio_load
,
s
);
qemu_mod_timer
(
s
->
ts
,
qemu_get_clock
(
vm_clock
)
+
conf
.
period
.
ticks
);
}
void
AUD_register_card
(
const
char
*
name
,
QEMUSoundCard
*
card
)
...
...
audio/audio_int.h
浏览文件 @
713a98f8
...
...
@@ -68,6 +68,7 @@ typedef struct SWVoiceCap SWVoiceCap;
typedef
struct
HWVoiceOut
{
int
enabled
;
int
poll_mode
;
int
pending_disable
;
struct
audio_pcm_info
info
;
...
...
@@ -87,6 +88,7 @@ typedef struct HWVoiceOut {
typedef
struct
HWVoiceIn
{
int
enabled
;
int
poll_mode
;
struct
audio_pcm_info
info
;
t_sample
*
conv
;
...
...
@@ -222,6 +224,8 @@ int audio_pcm_hw_get_live_out2 (HWVoiceOut *hw, int *nb_live);
int
audio_bug
(
const
char
*
funcname
,
int
cond
);
void
*
audio_calloc
(
const
char
*
funcname
,
int
nmemb
,
size_t
size
);
void
audio_run
(
const
char
*
msg
);
#define VOICE_ENABLE 1
#define VOICE_DISABLE 2
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录