提交 38cc9b60 编写于 作者: J Jindrich Makovicka 提交者: malc

issue snd_pcm_start() when capturing audio

snd_pcm_start() starts the capture process and ensures that the events
are delivered to the poll handler. Without the call, capture can be started
only when there is simultaneous playback running.
Signed-off-by: NJindrich Makovicka <makovick@gmail.com>
Signed-off-by: Nmalc <av1474@comtv.ru>
上级 22d948a2
...@@ -843,11 +843,15 @@ static int alsa_init_out (HWVoiceOut *hw, struct audsettings *as) ...@@ -843,11 +843,15 @@ static int alsa_init_out (HWVoiceOut *hw, struct audsettings *as)
return 0; return 0;
} }
static int alsa_voice_ctl (snd_pcm_t *handle, const char *typ, int pause) #define VOICE_CTL_PAUSE 0
#define VOICE_CTL_PREPARE 1
#define VOICE_CTL_START 2
static int alsa_voice_ctl (snd_pcm_t *handle, const char *typ, int ctl)
{ {
int err; int err;
if (pause) { if (ctl == VOICE_CTL_PAUSE) {
err = snd_pcm_drop (handle); err = snd_pcm_drop (handle);
if (err < 0) { if (err < 0) {
alsa_logerr (err, "Could not stop %s\n", typ); alsa_logerr (err, "Could not stop %s\n", typ);
...@@ -860,6 +864,13 @@ static int alsa_voice_ctl (snd_pcm_t *handle, const char *typ, int pause) ...@@ -860,6 +864,13 @@ static int alsa_voice_ctl (snd_pcm_t *handle, const char *typ, int pause)
alsa_logerr (err, "Could not prepare handle for %s\n", typ); alsa_logerr (err, "Could not prepare handle for %s\n", typ);
return -1; return -1;
} }
if (ctl == VOICE_CTL_START) {
err = snd_pcm_start(handle);
if (err < 0) {
alsa_logerr (err, "Could not start handle for %s\n", typ);
return -1;
}
}
} }
return 0; return 0;
...@@ -884,7 +895,7 @@ static int alsa_ctl_out (HWVoiceOut *hw, int cmd, ...) ...@@ -884,7 +895,7 @@ static int alsa_ctl_out (HWVoiceOut *hw, int cmd, ...)
poll_mode = 0; poll_mode = 0;
} }
hw->poll_mode = poll_mode; hw->poll_mode = poll_mode;
return alsa_voice_ctl (alsa->handle, "playback", 0); return alsa_voice_ctl (alsa->handle, "playback", VOICE_CTL_PREPARE);
} }
case VOICE_DISABLE: case VOICE_DISABLE:
...@@ -893,7 +904,7 @@ static int alsa_ctl_out (HWVoiceOut *hw, int cmd, ...) ...@@ -893,7 +904,7 @@ static int alsa_ctl_out (HWVoiceOut *hw, int cmd, ...)
hw->poll_mode = 0; hw->poll_mode = 0;
alsa_fini_poll (&alsa->pollhlp); alsa_fini_poll (&alsa->pollhlp);
} }
return alsa_voice_ctl (alsa->handle, "playback", 1); return alsa_voice_ctl (alsa->handle, "playback", VOICE_CTL_PAUSE);
} }
return -1; return -1;
...@@ -1106,7 +1117,7 @@ static int alsa_ctl_in (HWVoiceIn *hw, int cmd, ...) ...@@ -1106,7 +1117,7 @@ static int alsa_ctl_in (HWVoiceIn *hw, int cmd, ...)
} }
hw->poll_mode = poll_mode; hw->poll_mode = poll_mode;
return alsa_voice_ctl (alsa->handle, "capture", 0); return alsa_voice_ctl (alsa->handle, "capture", VOICE_CTL_START);
} }
case VOICE_DISABLE: case VOICE_DISABLE:
...@@ -1115,7 +1126,7 @@ static int alsa_ctl_in (HWVoiceIn *hw, int cmd, ...) ...@@ -1115,7 +1126,7 @@ static int alsa_ctl_in (HWVoiceIn *hw, int cmd, ...)
hw->poll_mode = 0; hw->poll_mode = 0;
alsa_fini_poll (&alsa->pollhlp); alsa_fini_poll (&alsa->pollhlp);
} }
return alsa_voice_ctl (alsa->handle, "capture", 1); return alsa_voice_ctl (alsa->handle, "capture", VOICE_CTL_PAUSE);
} }
return -1; return -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册