[Mplayer-cvslog] CVS: main/libao2 ao_alsa9.c,1.3,1.4
Felix Buenemann
atmosfear at users.sourceforge.net
Thu Jun 14 20:00:15 CEST 2001
Update of /cvsroot/mplayer/main/libao2
In directory usw-pr-cvs1:/tmp/cvs-serv2286
Modified Files:
ao_alsa9.c
Log Message:
Hacked it working, still needs fixings!
Index: ao_alsa9.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_alsa9.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** ao_alsa9.c 2001/06/12 15:42:21 1.3
--- ao_alsa9.c 2001/06/14 18:00:13 1.4
***************
*** 42,45 ****
--- 42,48 ----
#define ALSA_DEVICE_SIZE 48
+ static int alsa_fragsize = 8192; /* 4096 */
+ static int alsa_fragcount = 8;
+
/* to set/get/query special features/parameters */
static int control(int cmd, int arg)
***************
*** 55,60 ****
return(CONTROL_UNKNOWN);
}
- #define start
/*
open & setup audio device
--- 58,69 ----
return(CONTROL_UNKNOWN);
}
+
+ #undef start
+ #define buffersize
+ #undef buffertime
+ #define set_period
+ #undef sw_params
+ #undef set_start_mode
/*
open & setup audio device
***************
*** 82,89 ****
}
- ao_format = format;
- ao_channels = channels - 1;
ao_samplerate = rate_hz;
! ao_bps = ao_samplerate*(ao_channels+1);
ao_outburst = OUTBURST;
ao_buffersize = 16384;
--- 91,98 ----
}
ao_samplerate = rate_hz;
! ao_bps = channels; /* really this is bytes per frame so bad varname */
! ao_format = format;
! ao_channels = channels;
ao_outburst = OUTBURST;
ao_buffersize = 16384;
***************
*** 127,131 ****
break;
}
!
if ((err = snd_pcm_info_malloc(&alsa_info)) < 0)
{
--- 136,140 ----
break;
}
!
if ((err = snd_pcm_info_malloc(&alsa_info)) < 0)
{
***************
*** 190,208 ****
}
! if ((err = snd_pcm_hw_params_set_rate(alsa_handler, alsa_hwparams,
ao_samplerate, 0)) < 0)
{
! printf("alsa-init: unable to set channels: %s\n",
snd_strerror(err));
return(0);
}
{
! int fragment_size = 4096;
! int fragment_count = 8;
! snd_pcm_hw_params_set_period_size(alsa_handler, alsa_hwparams, fragment_size / 4, 0);
! snd_pcm_hw_params_set_periods(alsa_handler, alsa_hwparams, fragment_count, 0);
}
!
#ifdef buffersize
if ((err = snd_pcm_hw_params_get_buffer_size(alsa_hwparams)) < 0)
--- 199,226 ----
}
! if ((err = snd_pcm_hw_params_set_rate_near(alsa_handler, alsa_hwparams,
ao_samplerate, 0)) < 0)
{
! printf("alsa-init: unable to set samplerate: %s\n",
snd_strerror(err));
return(0);
}
+ #ifdef set_period
{
! if ((err = snd_pcm_hw_params_set_period_size(alsa_handler, alsa_hwparams, alsa_fragsize / 4, 0)) < 0)
! {
! printf("alsa-init: unable to set periodsize: %s\n",
! snd_strerror(err));
! return(0);
! }
! if ((err = snd_pcm_hw_params_set_periods(alsa_handler, alsa_hwparams, alsa_fragcount, 0)) < 0)
! {
! printf("alsa-init: unable to set periods: %s\n",
! snd_strerror(err));
! return(0);
! }
}
! #endif
#ifdef buffersize
if ((err = snd_pcm_hw_params_get_buffer_size(alsa_hwparams)) < 0)
***************
*** 212,216 ****
--- 230,237 ----
return(0);
} else
+ {
+ printf("alsa-init: got buffersize %i\n", err);
ao_buffersize = err;
+ }
#endif
***************
*** 235,238 ****
--- 256,261 ----
return(0);
}
+ printf("alsa-init: buffer_time: %d, period_time :%d\n",
+ alsa_buffer_time, err);
}
#endif
***************
*** 244,248 ****
return(0);
}
!
if ((err = snd_pcm_sw_params_current(alsa_handler, alsa_swparams)) < 0)
{
--- 267,272 ----
return(0);
}
!
! #ifdef sw_params
if ((err = snd_pcm_sw_params_current(alsa_handler, alsa_swparams)) < 0)
{
***************
*** 252,255 ****
--- 276,280 ----
}
+ #ifdef set_start_mode
if ((err = snd_pcm_sw_params_set_start_mode(alsa_handler, alsa_swparams,
SND_PCM_START_DATA)) < 0)
***************
*** 259,262 ****
--- 284,288 ----
return(0);
}
+ #endif
if ((err = snd_pcm_sw_params(alsa_handler, alsa_swparams)) < 0)
***************
*** 267,272 ****
}
! snd_pcm_sw_params_default(alsa_handler, alsa_swparams);
!
if ((err = snd_pcm_prepare(alsa_handler)) < 0)
{
--- 293,298 ----
}
! // snd_pcm_sw_params_default(alsa_handler, alsa_swparams);
! #endif
if ((err = snd_pcm_prepare(alsa_handler)) < 0)
{
***************
*** 288,293 ****
}
#endif
! printf("AUDIO: %d Hz/%d channels/%d bps/%d bytes buffer/%s\n",
! ao_samplerate, ao_channels+1, ao_bps, ao_buffersize,
snd_pcm_format_description(alsa_format));
return(1);
--- 314,319 ----
}
#endif
! printf("AUDIO: %d Hz/%d channels/%d bpf/%d bytes buffer/%s\n",
! ao_samplerate, ao_channels, ao_bps, ao_buffersize,
snd_pcm_format_description(alsa_format));
return(1);
***************
*** 396,418 ****
int got_len;
! if ((got_len = snd_pcm_writei(alsa_handler, data, len/4)) != len/4)
{
if (got_len == -EPIPE) /* underrun? */
{
printf("alsa-play: alsa underrun, resetting stream\n");
! if ((len = snd_pcm_prepare(alsa_handler)) < 0)
{
! printf("alsa-play: playback prepare error: %s\n", snd_strerror(len));
return(0);
}
! if ((len = snd_pcm_writei(alsa_handler, data, len)) != len)
{
printf("alsa-play: write error after reset: %s - giving up\n",
! snd_strerror(len));
return(0);
}
return(len); /* 2nd write was ok */
}
- printf("alsa-play: output error: %s\n", snd_strerror(len));
}
return(len);
--- 422,443 ----
int got_len;
! if ((got_len = snd_pcm_writei(alsa_handler, data, (len/ao_bps))) != (len/ao_bps))
{
if (got_len == -EPIPE) /* underrun? */
{
printf("alsa-play: alsa underrun, resetting stream\n");
! if ((got_len = snd_pcm_prepare(alsa_handler)) < 0)
{
! printf("alsa-play: playback prepare error: %s\n", snd_strerror(got_len));
return(0);
}
! if ((got_len = snd_pcm_writei(alsa_handler, data, (len/ao_bps))) != (len/ao_bps))
{
printf("alsa-play: write error after reset: %s - giving up\n",
! snd_strerror(got_len));
return(0);
}
return(len); /* 2nd write was ok */
}
}
return(len);
***************
*** 484,485 ****
--- 509,511 ----
return(ret);
}
+
_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog
More information about the MPlayer-cvslog
mailing list