diff options
author | al3x <al3x@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2001-06-17 17:44:56 +0000 |
---|---|---|
committer | al3x <al3x@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2001-06-17 17:44:56 +0000 |
commit | a71f146139361e46f9f24acc87ef91cb7ad80386 (patch) | |
tree | d16c81cc933f930fe2f9ad5a6ce77cc1eb115325 | |
parent | 39f60a9550de9523d5f1cae976b52f7da134c17d (diff) | |
download | mpv-a71f146139361e46f9f24acc87ef91cb7ad80386.tar.bz2 mpv-a71f146139361e46f9f24acc87ef91cb7ad80386.tar.xz |
hacked aocontrol_set_device working, and cleaned up a bit
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1147 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | libao2/ao_alsa1x.c | 35 | ||||
-rw-r--r-- | libao2/ao_alsa9.c | 35 |
2 files changed, 48 insertions, 22 deletions
diff --git a/libao2/ao_alsa1x.c b/libao2/ao_alsa1x.c index 979f93c869..35c70c361f 100644 --- a/libao2/ao_alsa1x.c +++ b/libao2/ao_alsa1x.c @@ -50,10 +50,19 @@ static int control(int cmd, int arg) switch(cmd) { case AOCONTROL_GET_DEVICE: - return(char *)alsa_device; /* egy kicsit brutalis, dehat :) */ + return((char *)alsa_device); /* egy kicsit brutalis, dehat :) */ case AOCONTROL_SET_DEVICE: + { + int ret; + strncpy(alsa_device, (char *)arg, ALSA_DEVICE_SIZE); - break; + uninit(); + ret = init(ao_samplerate, ao_channels, ao_format, 0); + if (ret == 0) + return(CONTROL_ERROR); + else + return(CONTROL_OK); + } } return(CONTROL_UNKNOWN); } @@ -142,17 +151,20 @@ static int init(int rate_hz, int channels, int format, int flags) return(0); } - if ((alsa_device = malloc(ALSA_DEVICE_SIZE)) == NULL) + if (alsa_device == NULL) { - printf("alsa-init: memory allocation error: %s\n", strerror(errno)); - return(0); - } + if ((alsa_device = malloc(ALSA_DEVICE_SIZE)) == NULL) + { + printf("alsa-init: memory allocation error: %s\n", strerror(errno)); + return(0); + } - snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%d,%d", - snd_pcm_info_get_device(alsa_info), - snd_pcm_info_get_subdevice(alsa_info)); + snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%d,%d", + snd_pcm_info_get_device(alsa_info), + snd_pcm_info_get_subdevice(alsa_info)); - snd_pcm_info_free(alsa_info); + snd_pcm_info_free(alsa_info); + } printf("alsa-init: %d soundcard%s found, using: %s\n", cards+1, (cards >= 0) ? "" : "s", alsa_device); @@ -230,8 +242,9 @@ static int init(int rate_hz, int channels, int format, int flags) return(0); } else { - printf("alsa-init: got buffersize %i\n", err); ao_buffersize = err; + if (verbose) + printf("alsa-init: got buffersize %i\n", ao_buffersize); } #endif diff --git a/libao2/ao_alsa9.c b/libao2/ao_alsa9.c index 979f93c869..35c70c361f 100644 --- a/libao2/ao_alsa9.c +++ b/libao2/ao_alsa9.c @@ -50,10 +50,19 @@ static int control(int cmd, int arg) switch(cmd) { case AOCONTROL_GET_DEVICE: - return(char *)alsa_device; /* egy kicsit brutalis, dehat :) */ + return((char *)alsa_device); /* egy kicsit brutalis, dehat :) */ case AOCONTROL_SET_DEVICE: + { + int ret; + strncpy(alsa_device, (char *)arg, ALSA_DEVICE_SIZE); - break; + uninit(); + ret = init(ao_samplerate, ao_channels, ao_format, 0); + if (ret == 0) + return(CONTROL_ERROR); + else + return(CONTROL_OK); + } } return(CONTROL_UNKNOWN); } @@ -142,17 +151,20 @@ static int init(int rate_hz, int channels, int format, int flags) return(0); } - if ((alsa_device = malloc(ALSA_DEVICE_SIZE)) == NULL) + if (alsa_device == NULL) { - printf("alsa-init: memory allocation error: %s\n", strerror(errno)); - return(0); - } + if ((alsa_device = malloc(ALSA_DEVICE_SIZE)) == NULL) + { + printf("alsa-init: memory allocation error: %s\n", strerror(errno)); + return(0); + } - snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%d,%d", - snd_pcm_info_get_device(alsa_info), - snd_pcm_info_get_subdevice(alsa_info)); + snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%d,%d", + snd_pcm_info_get_device(alsa_info), + snd_pcm_info_get_subdevice(alsa_info)); - snd_pcm_info_free(alsa_info); + snd_pcm_info_free(alsa_info); + } printf("alsa-init: %d soundcard%s found, using: %s\n", cards+1, (cards >= 0) ? "" : "s", alsa_device); @@ -230,8 +242,9 @@ static int init(int rate_hz, int channels, int format, int flags) return(0); } else { - printf("alsa-init: got buffersize %i\n", err); ao_buffersize = err; + if (verbose) + printf("alsa-init: got buffersize %i\n", ao_buffersize); } #endif |