[Mplayer-cvslog] CVS: main/libmpdemux Makefile, 1.72, 1.73 ai_alsa1x.c, 1.5, 1.6 audio_in.c, 1.8, 1.9 audio_in.h, 1.3, 1.4 tv.c, 1.64, 1.65 tv.h, 1.27, 1.28 tvi_v4l.c, 1.68, 1.69 tvi_v4l2.c, 1.10, 1.11

Jindrich Makovicka CVS henry at mplayerhq.hu
Sun Jan 11 18:07:35 CET 2004


Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/scsi/2/tmp/cvs-serv18040/libmpdemux

Modified Files:
	Makefile ai_alsa1x.c audio_in.c audio_in.h tv.c tv.h tvi_v4l.c 
	tvi_v4l2.c 
Log Message:
ALSA 1.x audio out driver

Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/Makefile,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- Makefile	8 Dec 2003 21:34:05 -0000	1.72
+++ Makefile	11 Jan 2004 17:07:32 -0000	1.73
@@ -3,7 +3,7 @@
 
 include ../config.mak
 
-SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c muxer.c muxer_avi.c muxer_mpeg.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_ty.c demux_ty_osd.c demux_pva.c demux_viv.c demuxer.c dvdnav_stream.c open.c parse_es.c stream.c stream_file.c stream_netstream.c stream_vcd.c stream_null.c stream_ftp.c tv.c tvi_dummy.c tvi_v4l.c tvi_v4l2.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c demux_ogg.c demux_bmp.c cdda.c demux_rawaudio.c demux_rawvideo.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_oss.c audio_in.c demux_smjpeg.c demux_lmlm4.c cue_read.c extension.c demux_gif.c demux_ts.c demux_realaud.c url.c 
+SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c muxer.c muxer_avi.c muxer_mpeg.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_ty.c demux_ty_osd.c demux_pva.c demux_viv.c demuxer.c dvdnav_stream.c open.c parse_es.c stream.c stream_file.c stream_netstream.c stream_vcd.c stream_null.c stream_ftp.c tv.c tvi_dummy.c tvi_v4l.c tvi_v4l2.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c demux_ogg.c demux_bmp.c cdda.c demux_rawaudio.c demux_rawvideo.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_alsa1x.c ai_oss.c audio_in.c demux_smjpeg.c demux_lmlm4.c cue_read.c extension.c demux_gif.c demux_ts.c demux_realaud.c url.c 
 ifeq ($(XMMS_PLUGINS),yes)
 SRCS += demux_xmms.c
 endif 

Index: ai_alsa1x.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/ai_alsa1x.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ai_alsa1x.c	7 Aug 2003 12:24:35 -0000	1.5
+++ ai_alsa1x.c	11 Jan 2004 17:07:32 -0000	1.6
@@ -4,7 +4,7 @@
 
 #include "config.h"
 
-#if defined(USE_TV) && (defined(HAVE_TV_V4L) || defined(HAVE_TV_V4L2)) && defined(HAVE_ALSA9)
+#if defined(USE_TV) && (defined(HAVE_TV_V4L) || defined(HAVE_TV_V4L2)) && defined(HAVE_ALSA1X)
 
 #include <alsa/asoundlib.h>
 #include "audio_in.h"
@@ -14,8 +14,9 @@
 {
     snd_pcm_hw_params_t *params;
     snd_pcm_sw_params_t *swparams;
-    int buffer_size;
+    snd_pcm_uframes_t buffer_size, period_size;
     int err;
+    int dir;
     unsigned int rate;
 
     snd_pcm_hw_params_alloca(&params);
@@ -26,51 +27,69 @@
 	mp_msg(MSGT_TV, MSGL_ERR, "Broken configuration for this PCM: no configurations available\n");
 	return -1;
     }
+
     err = snd_pcm_hw_params_set_access(ai->alsa.handle, params,
 				       SND_PCM_ACCESS_RW_INTERLEAVED);
     if (err < 0) {
 	mp_msg(MSGT_TV, MSGL_ERR, "Access type not available\n");
 	return -1;
     }
+
     err = snd_pcm_hw_params_set_format(ai->alsa.handle, params, SND_PCM_FORMAT_S16_LE);
     if (err < 0) {
 	mp_msg(MSGT_TV, MSGL_ERR, "Sample format not available\n");
 	return -1;
     }
+
     err = snd_pcm_hw_params_set_channels(ai->alsa.handle, params, ai->req_channels);
     if (err < 0) {
-	ai->channels = snd_pcm_hw_params_get_channels(params);
+	snd_pcm_hw_params_get_channels(params, &ai->channels);
 	mp_msg(MSGT_TV, MSGL_ERR, "Channel count not available - reverting to default: %d\n",
 	       ai->channels);
     } else {
 	ai->channels = ai->req_channels;
     }
 
-    err = snd_pcm_hw_params_set_rate_near(ai->alsa.handle, params, ai->req_samplerate, 0);
-    assert(err >= 0);
-    rate = err;
+    dir = 0;
+    rate = ai->req_samplerate;
+    err = snd_pcm_hw_params_set_rate_near(ai->alsa.handle, params, &rate, &dir);
+    if (err < 0) {
+	mp_msg(MSGT_TV, MSGL_ERR, "Cannot set samplerate\n");
+    }
     ai->samplerate = rate;
 
+    dir = 0;
     ai->alsa.buffer_time = 1000000;
-    ai->alsa.buffer_time = snd_pcm_hw_params_set_buffer_time_near(ai->alsa.handle, params,
-							       ai->alsa.buffer_time, 0);
-    assert(ai->alsa.buffer_time >= 0);
+    err = snd_pcm_hw_params_set_buffer_time_near(ai->alsa.handle, params,
+						 &ai->alsa.buffer_time, &dir);
+    if (err < 0) {
+	mp_msg(MSGT_TV, MSGL_ERR, "Cannot set buffer time\n");
+    }
+
+    dir = 0;
     ai->alsa.period_time = ai->alsa.buffer_time / 4;
-    ai->alsa.period_time = snd_pcm_hw_params_set_period_time_near(ai->alsa.handle, params,
-							       ai->alsa.period_time, 0);
-    assert(ai->alsa.period_time >= 0);
+    err = snd_pcm_hw_params_set_period_time_near(ai->alsa.handle, params,
+						 &ai->alsa.period_time, &dir);
+    if (err < 0) {
+	mp_msg(MSGT_TV, MSGL_ERR, "Cannot set period time\n");
+    }
+
     err = snd_pcm_hw_params(ai->alsa.handle, params);
     if (err < 0) {
-	mp_msg(MSGT_TV, MSGL_ERR, "Unable to install hw params:");
+	mp_msg(MSGT_TV, MSGL_ERR, "Unable to install hw params: %s\n", snd_strerror(err));
 	snd_pcm_hw_params_dump(params, ai->alsa.log);
 	return -1;
     }
-    ai->alsa.chunk_size = snd_pcm_hw_params_get_period_size(params, 0);
-    buffer_size = snd_pcm_hw_params_get_buffer_size(params);
-    if (ai->alsa.chunk_size == buffer_size) {
+
+    dir = -1;
+    snd_pcm_hw_params_get_period_size(params, &period_size, &dir);
+    snd_pcm_hw_params_get_buffer_size(params, &buffer_size);
+    ai->alsa.chunk_size = period_size;
+    if (period_size == buffer_size) {
 	mp_msg(MSGT_TV, MSGL_ERR, "Can't use period equal to buffer size (%u == %lu)\n", ai->alsa.chunk_size, (long)buffer_size);
 	return -1;
     }
+
     snd_pcm_sw_params_current(ai->alsa.handle, swparams);
     err = snd_pcm_sw_params_set_sleep_min(ai->alsa.handle, swparams,0);
     assert(err >= 0);
@@ -166,4 +185,4 @@
     return -1;
 }
 
-#endif /* HAVE_ALSA9 */
+#endif /* HAVE_ALSA1X */

Index: audio_in.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/audio_in.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- audio_in.c	7 Aug 2003 12:24:35 -0000	1.8
+++ audio_in.c	11 Jan 2004 17:07:32 -0000	1.9
@@ -24,7 +24,7 @@
     ai->samplesize = -1;
 
     switch (ai->type) {
-#ifdef HAVE_ALSA9	  
+#if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
     case AUDIO_IN_ALSA:
 	ai->alsa.handle = NULL;
 	ai->alsa.log = NULL;
@@ -46,7 +46,7 @@
 {
     
     switch (ai->type) {
-#ifdef HAVE_ALSA9	  
+#if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
     case AUDIO_IN_ALSA:
 	if (ai_alsa_init(ai) < 0) return -1;
 	ai->setup = 1;
@@ -66,7 +66,7 @@
 int audio_in_set_samplerate(audio_in_t *ai, int rate)
 {
     switch (ai->type) {
-#ifdef HAVE_ALSA9	  
+#if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
     case AUDIO_IN_ALSA:
 	ai->req_samplerate = rate;
 	if (!ai->setup) return 0;
@@ -88,7 +88,7 @@
 int audio_in_set_channels(audio_in_t *ai, int channels)
 {
     switch (ai->type) {
-#ifdef HAVE_ALSA9	  
+#if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
     case AUDIO_IN_ALSA:
 	ai->req_channels = channels;
 	if (!ai->setup) return 0;
@@ -109,12 +109,12 @@
 
 int audio_in_set_device(audio_in_t *ai, char *device)
 {
-#ifdef HAVE_ALSA9	  
+#if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
     int i;
 #endif
     if (ai->setup) return -1;
     switch (ai->type) {
-#ifdef HAVE_ALSA9	  
+#if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
     case AUDIO_IN_ALSA:
 	if (ai->alsa.device) free(ai->alsa.device);
 	ai->alsa.device = strdup(device);
@@ -139,7 +139,7 @@
 {
     if (ai->setup) {
 	switch (ai->type) {
-#ifdef HAVE_ALSA9	  
+#if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
 	case AUDIO_IN_ALSA:
 	    if (ai->alsa.log)
 		snd_output_close(ai->alsa.log);
@@ -163,7 +163,7 @@
 int audio_in_start_capture(audio_in_t *ai)
 {
     switch (ai->type) {
-#ifdef HAVE_ALSA9	  
+#if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
     case AUDIO_IN_ALSA:
 	return snd_pcm_start(ai->alsa.handle);
 #endif
@@ -181,7 +181,7 @@
     int ret;
     
     switch (ai->type) {
-#ifdef HAVE_ALSA9	  
+#if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
     case AUDIO_IN_ALSA:
 	ret = snd_pcm_readi(ai->alsa.handle, buffer, ai->alsa.chunk_size);
 	if (ret != ai->alsa.chunk_size) {

Index: audio_in.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/audio_in.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- audio_in.h	28 Dec 2002 13:39:51 -0000	1.3
+++ audio_in.h	11 Jan 2004 17:07:32 -0000	1.4
@@ -6,7 +6,7 @@
 
 #include "config.h"
 
-#ifdef HAVE_ALSA9
+#if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
 #include <alsa/asoundlib.h>
 
 typedef struct {
@@ -43,7 +43,7 @@
     int bytes_per_sample;
     int samplesize;
     
-#ifdef HAVE_ALSA9
+#if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
     ai_alsa_t alsa;
 #endif
 #ifdef USE_OSS_AUDIO
@@ -60,7 +60,7 @@
 int audio_in_start_capture(audio_in_t *ai);
 int audio_in_read_chunk(audio_in_t *ai, unsigned char *buffer);
 
-#ifdef HAVE_ALSA9
+#if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
 int ai_alsa_setup(audio_in_t *ai);
 int ai_alsa_init(audio_in_t *ai);
 int ai_alsa_xrun(audio_in_t *ai);

Index: tv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tv.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -r1.64 -r1.65
--- tv.c	6 Sep 2003 00:24:05 -0000	1.64
+++ tv.c	11 Jan 2004 17:07:32 -0000	1.65
@@ -70,7 +70,7 @@
 int tv_param_mjpeg = 0;
 int tv_param_decimation = 2;
 int tv_param_quality = 90;
-#ifdef HAVE_ALSA9
+#if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
 int tv_param_alsa = 0;
 #endif
 char* tv_param_adevice = NULL;

Index: tv.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tv.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- tv.h	6 Sep 2003 00:24:05 -0000	1.27
+++ tv.h	11 Jan 2004 17:07:32 -0000	1.28
@@ -40,7 +40,7 @@
 extern int tv_param_mjpeg;
 extern int tv_param_decimation;
 extern int tv_param_quality;
-#ifdef HAVE_ALSA9
+#if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
 extern int tv_param_alsa;
 #endif
 extern char* tv_param_adevice;

Index: tvi_v4l.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tvi_v4l.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -r1.68 -r1.69
--- tvi_v4l.c	18 Dec 2003 10:39:55 -0000	1.68
+++ tvi_v4l.c	11 Jan 2004 17:07:32 -0000	1.69
@@ -636,7 +636,7 @@
     /* audio init */
     if (!tv_param_noaudio) {
 	
-#ifdef HAVE_ALSA9
+#if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
 	if (tv_param_alsa)
 	    audio_in_init(&priv->audio_in, AUDIO_IN_ALSA);
 	else

Index: tvi_v4l2.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/tvi_v4l2.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- tvi_v4l2.c	19 Dec 2003 09:38:10 -0000	1.10
+++ tvi_v4l2.c	11 Jan 2004 17:07:32 -0000	1.11
@@ -1047,7 +1047,7 @@
     
     /* audio init */
     if (!tv_param_noaudio) {
-#ifdef HAVE_ALSA9
+#if defined(HAVE_ALSA9) || defined(HAVE_ALSA1X)
 	if (tv_param_alsa)
 	    audio_in_init(&priv->audio_in, AUDIO_IN_ALSA);
 	else




More information about the MPlayer-cvslog mailing list