summaryrefslogtreecommitdiffstats
path: root/libao2
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2009-09-04 19:49:35 +0300
committerUoti Urpala <uau@glyph.nonexistent.invalid>2009-09-04 19:49:35 +0300
commit0e1b7765be878491565cf5e471f22b15e106164c (patch)
tree422e500c289335182a2a64934dcabf10b95e32dc /libao2
parenta9618c1c6fe9424dfaeb1677348e0382d7252554 (diff)
parentdcfd043ea8d0c46929aad78596314d837c290d39 (diff)
downloadmpv-0e1b7765be878491565cf5e471f22b15e106164c.tar.bz2
mpv-0e1b7765be878491565cf5e471f22b15e106164c.tar.xz
Merge svn changes up to r29644
Diffstat (limited to 'libao2')
-rw-r--r--libao2/ao_alsa.c85
-rw-r--r--libao2/ao_dart.c2
-rw-r--r--libao2/ao_dsound.c2
-rw-r--r--libao2/ao_jack.c2
-rw-r--r--libao2/ao_mpegpes.c2
-rw-r--r--libao2/ao_openal.c2
-rw-r--r--libao2/ao_pcm.c2
7 files changed, 10 insertions, 87 deletions
diff --git a/libao2/ao_alsa.c b/libao2/ao_alsa.c
index 92e827ea7e..d6b9175f52 100644
--- a/libao2/ao_alsa.c
+++ b/libao2/ao_alsa.c
@@ -72,11 +72,8 @@ static snd_pcm_format_t alsa_format;
static snd_pcm_hw_params_t *alsa_hwparams;
static snd_pcm_sw_params_t *alsa_swparams;
-/* 16 sets buffersize to 16 * chunksize is as default 1024
- * which seems to be good avarge for most situations
- * so buffersize is 16384 frames by default */
-static int alsa_fragcount = 16;
-static snd_pcm_uframes_t chunk_size = 1024;
+static unsigned int alsa_buffer_time = 500000; /* 0.5 s */
+static unsigned int alsa_fragcount = 16;
static size_t bytes_per_sample;
@@ -88,9 +85,6 @@ static snd_pcm_sframes_t prepause_frames;
#define ALSA_DEVICE_SIZE 256
-#undef BUFFERTIME
-#define SET_CHUNKSIZE
-
static void alsa_error_handler(const char *file, int line, const char *function,
int err, const char *format, ...)
{
@@ -337,9 +331,10 @@ static int init(int rate_hz, int channels, int format, int flags)
int err;
int block;
strarg_t device;
+ snd_pcm_uframes_t chunk_size;
snd_pcm_uframes_t bufsize;
snd_pcm_uframes_t boundary;
- opt_t subopts[] = {
+ const opt_t subopts[] = {
{"block", OPT_ARG_BOOL, &block, NULL},
{"device", OPT_ARG_STR, &device, (opt_test_f)str_maxlen},
{NULL}
@@ -494,41 +489,6 @@ static int init(int rate_hz, int channels, int format, int flags)
open_mode = 0;
}
- //sets buff/chunksize if its set manually
- if (ao_data.buffersize) {
- switch (ao_data.buffersize)
- {
- case 1:
- alsa_fragcount = 16;
- chunk_size = 512;
- mp_msg(MSGT_AO,MSGL_V,"alsa-init: buffersize set manually to 8192\n");
- mp_msg(MSGT_AO,MSGL_V,"alsa-init: chunksize set manually to 512\n");
- break;
- case 2:
- alsa_fragcount = 8;
- chunk_size = 1024;
- mp_msg(MSGT_AO,MSGL_V,"alsa-init: buffersize set manually to 8192\n");
- mp_msg(MSGT_AO,MSGL_V,"alsa-init: chunksize set manually to 1024\n");
- break;
- case 3:
- alsa_fragcount = 32;
- chunk_size = 512;
- mp_msg(MSGT_AO,MSGL_V,"alsa-init: buffersize set manually to 16384\n");
- mp_msg(MSGT_AO,MSGL_V,"alsa-init: chunksize set manually to 512\n");
- break;
- case 4:
- alsa_fragcount = 16;
- chunk_size = 1024;
- mp_msg(MSGT_AO,MSGL_V,"alsa-init: buffersize set manually to 16384\n");
- mp_msg(MSGT_AO,MSGL_V,"alsa-init: chunksize set manually to 1024\n");
- break;
- default:
- alsa_fragcount = 16;
- chunk_size = 1024;
- break;
- }
- }
-
if (!alsa_handler) {
//modes = 0, SND_PCM_NONBLOCK, SND_PCM_ASYNC
if ((err = try_open_device(alsa_device, open_mode, format == AF_FORMAT_AC3)) < 0)
@@ -621,57 +581,20 @@ static int init(int rate_hz, int channels, int format, int flags)
bytes_per_sample *= ao_data.channels;
ao_data.bps = ao_data.samplerate * bytes_per_sample;
-#ifdef BUFFERTIME
- {
- int alsa_buffer_time = 500000; /* original 60 */
- int alsa_period_time;
- alsa_period_time = alsa_buffer_time/4;
if ((err = snd_pcm_hw_params_set_buffer_time_near(alsa_handler, alsa_hwparams,
&alsa_buffer_time, NULL)) < 0)
{
mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to set buffer time near: %s\n",
snd_strerror(err));
return 0;
- } else
- alsa_buffer_time = err;
-
- if ((err = snd_pcm_hw_params_set_period_time_near(alsa_handler, alsa_hwparams,
- &alsa_period_time, NULL)) < 0)
- /* original: alsa_buffer_time/ao_data.bps */
- {
- mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to set period time: %s\n",
- snd_strerror(err));
- return 0;
}
- mp_tmsg(MSGT_AO,MSGL_INFO,"[AO_ALSA] buffer_time: %d, period_time :%d\n",
- alsa_buffer_time, err);
- }
-#endif//end SET_BUFFERTIME
-#ifdef SET_CHUNKSIZE
- {
- //set chunksize
- if ((err = snd_pcm_hw_params_set_period_size_near(alsa_handler, alsa_hwparams,
- &chunk_size, NULL)) < 0)
- {
- mp_tmsg(MSGT_AO,MSGL_ERR,"[AO ALSA] Unable to set period size(%ld): %s\n",
- chunk_size, snd_strerror(err));
- return 0;
- }
- else {
- mp_msg(MSGT_AO,MSGL_V,"alsa-init: chunksize set to %li\n", chunk_size);
- }
if ((err = snd_pcm_hw_params_set_periods_near(alsa_handler, alsa_hwparams,
&alsa_fragcount, NULL)) < 0) {
mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to set periods: %s\n",
snd_strerror(err));
return 0;
}
- else {
- mp_msg(MSGT_AO,MSGL_V,"alsa-init: fragcount=%i\n", alsa_fragcount);
- }
- }
-#endif//end SET_CHUNKSIZE
/* finally install hardware parameters */
if ((err = snd_pcm_hw_params(alsa_handler, alsa_hwparams)) < 0)
diff --git a/libao2/ao_dart.c b/libao2/ao_dart.c
index 6038418203..58ee4d1886 100644
--- a/libao2/ao_dart.c
+++ b/libao2/ao_dart.c
@@ -146,7 +146,7 @@ static int init(int rate, int channels, int format, int flags)
int nDartSamples = DEFAULT_DART_SAMPLES;
int nBytesPerSample;
- opt_t subopts[] = {
+ const opt_t subopts[] = {
{"share", OPT_ARG_BOOL, &fShare, NULL},
{"bufsize", OPT_ARG_INT, &nDartSamples, (opt_test_f)int_non_neg},
{NULL}
diff --git a/libao2/ao_dsound.c b/libao2/ao_dsound.c
index 4197c30e27..fc069dad5e 100644
--- a/libao2/ao_dsound.c
+++ b/libao2/ao_dsound.c
@@ -223,7 +223,7 @@ static int InitDirectSound(void)
HRESULT (WINAPI *OurDirectSoundCreate)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN);
HRESULT (WINAPI *OurDirectSoundEnumerate)(LPDSENUMCALLBACKA, LPVOID);
int device_index=0;
- opt_t subopts[] = {
+ const opt_t subopts[] = {
{"device", OPT_ARG_INT, &device_num,NULL},
{NULL}
};
diff --git a/libao2/ao_jack.c b/libao2/ao_jack.c
index 14bb1c90dd..0d2492c02b 100644
--- a/libao2/ao_jack.c
+++ b/libao2/ao_jack.c
@@ -208,7 +208,7 @@ static int init(int rate, int channels, int format, int flags) {
char *port_name = NULL;
char *client_name = NULL;
int autostart = 0;
- opt_t subopts[] = {
+ const opt_t subopts[] = {
{"port", OPT_ARG_MSTRZ, &port_name, NULL},
{"name", OPT_ARG_MSTRZ, &client_name, NULL},
{"estimate", OPT_ARG_BOOL, &estimate, NULL},
diff --git a/libao2/ao_mpegpes.c b/libao2/ao_mpegpes.c
index 096f7bade5..47a75d7545 100644
--- a/libao2/ao_mpegpes.c
+++ b/libao2/ao_mpegpes.c
@@ -158,7 +158,7 @@ static int preinit(const char *arg)
int card = -1;
char *ao_file = NULL;
- opt_t subopts[] = {
+ const opt_t subopts[] = {
{"card", OPT_ARG_INT, &card, NULL},
{"file", OPT_ARG_MSTRZ, &ao_file, NULL},
{NULL}
diff --git a/libao2/ao_openal.c b/libao2/ao_openal.c
index 3cf7d43a9d..030304007c 100644
--- a/libao2/ao_openal.c
+++ b/libao2/ao_openal.c
@@ -106,7 +106,7 @@ static int init(int rate, int channels, int format, int flags) {
ALCint freq = 0;
ALCint attribs[] = {ALC_FREQUENCY, rate, 0, 0};
int i;
- opt_t subopts[] = {
+ const opt_t subopts[] = {
{NULL}
};
if (subopt_parse(ao_subdevice, subopts) != 0) {
diff --git a/libao2/ao_pcm.c b/libao2/ao_pcm.c
index 94e0c438aa..31a94b0c25 100644
--- a/libao2/ao_pcm.c
+++ b/libao2/ao_pcm.c
@@ -94,7 +94,7 @@ static int control(int cmd,void *arg){
// return: 1=success 0=fail
static int init(int rate,int channels,int format,int flags){
int bits;
- opt_t subopts[] = {
+ const opt_t subopts[] = {
{"waveheader", OPT_ARG_BOOL, &ao_pcm_waveheader, NULL},
{"file", OPT_ARG_MSTRZ, &ao_outputfilename, NULL},
{"fast", OPT_ARG_BOOL, &fast, NULL},