summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJames Stembridge <jstembridge@users.sourceforge.net>2004-03-05 20:25:04 +0000
committerJames Stembridge <jstembridge@users.sourceforge.net>2004-03-05 20:25:04 +0000
commit8eb1fc1d134743228c8e0fca8b954207ebfcd0fe (patch)
tree4f80cc6eabeff24912e5963c4e62e69cf3a5f4e4 /src
parentabc5d21f14dccc2bebe6e4ab272a9ca735df4f95 (diff)
downloadxine-lib-8eb1fc1d134743228c8e0fca8b954207ebfcd0fe.tar.gz
xine-lib-8eb1fc1d134743228c8e0fca8b954207ebfcd0fe.tar.bz2
Factor out some common code
CVS patchset: 6220 CVS date: 2004/03/05 20:25:04
Diffstat (limited to 'src')
-rw-r--r--src/input/input_v4l.c39
1 files changed, 16 insertions, 23 deletions
diff --git a/src/input/input_v4l.c b/src/input/input_v4l.c
index 0ab585888..6cd236ac8 100644
--- a/src/input/input_v4l.c
+++ b/src/input/input_v4l.c
@@ -1031,34 +1031,27 @@ static int open_video_capture_device(v4l_input_plugin_t *this)
static int open_audio_capture_device(v4l_input_plugin_t *this)
{
#ifdef HAVE_ALSA
- lprintf("audio: Opening PCM Device\n");
+ int mode = 0;
+
+ lprintf("open_audio_capture_device\n");
/* Allocate the snd_pcm_hw_params_t structure on the stack. */
snd_pcm_hw_params_alloca(&this->pcm_hwparams);
+ /* If we are not capturing video, open the sound device in blocking mode,
+ * otherwise xine gets too many NULL bufs and doesn't seem to handle them
+ * correctly. If we are capturing video, open the sound device in non-
+ * blocking mode, otherwise we will loose video frames while waiting */
+ if(!this->audio_only)
+ mode = SND_PCM_NONBLOCK;
+
/* Open the PCM device. */
- if (this->audio_only) {
- /* Open the sound device in blocking mode if we are not capturing video,
- * otherwise xine gets to many NULL bufs and doesn't seem to handle
- * them correctly
- */
- if (snd_pcm_open(&this->pcm_handle, this->pcm_name, this->pcm_stream, 0) < 0) {
- xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
- "input_v4l: Error opening PCM device %s\n", this->pcm_name);
- this->audio_capture = 0;
- }
- } else
- if (snd_pcm_open(&this->pcm_handle, this->pcm_name,
- this->pcm_stream, SND_PCM_NONBLOCK) < 0) {
- /* Open the sound device in non blocking mode when capturing video data
- * too, otherwise we will loose videoframes because we keep on waiting
- * for an audio fragment
- */
- xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
- "input_v4l: Error opening PCM device %s\n", this->pcm_name);
- this->audio_capture = 0;
- }
-
+ if(snd_pcm_open(&this->pcm_handle, this->pcm_name, this->pcm_stream, mode) < 0) {
+ xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
+ "input_v4l: Error opening PCM device: %s\n", this->pcm_name);
+ this->audio_capture = 0;
+ }
+
/* Get parameters */
if (this->audio_capture &&
(snd_pcm_hw_params_any(this->pcm_handle, this->pcm_hwparams) < 0)) {