comparison libao2/ao_alsa1x.c @ 1146:a84610bb5476

hacked aocontrol_set_device working, and cleaned up a bit
author al3x
date Sun, 17 Jun 2001 17:44:56 +0000
parents 705fa4ac4fed
children c50cd5db2359
comparison
equal deleted inserted replaced
1145:065583b867fd 1146:a84610bb5476
48 static int control(int cmd, int arg) 48 static int control(int cmd, int arg)
49 { 49 {
50 switch(cmd) 50 switch(cmd)
51 { 51 {
52 case AOCONTROL_GET_DEVICE: 52 case AOCONTROL_GET_DEVICE:
53 return(char *)alsa_device; /* egy kicsit brutalis, dehat :) */ 53 return((char *)alsa_device); /* egy kicsit brutalis, dehat :) */
54 case AOCONTROL_SET_DEVICE: 54 case AOCONTROL_SET_DEVICE:
55 {
56 int ret;
57
55 strncpy(alsa_device, (char *)arg, ALSA_DEVICE_SIZE); 58 strncpy(alsa_device, (char *)arg, ALSA_DEVICE_SIZE);
56 break; 59 uninit();
60 ret = init(ao_samplerate, ao_channels, ao_format, 0);
61 if (ret == 0)
62 return(CONTROL_ERROR);
63 else
64 return(CONTROL_OK);
65 }
57 } 66 }
58 return(CONTROL_UNKNOWN); 67 return(CONTROL_UNKNOWN);
59 } 68 }
60 69
61 #undef start 70 #undef start
140 { 149 {
141 printf("alsa-init: memory allocation error: %s\n", snd_strerror(err)); 150 printf("alsa-init: memory allocation error: %s\n", snd_strerror(err));
142 return(0); 151 return(0);
143 } 152 }
144 153
145 if ((alsa_device = malloc(ALSA_DEVICE_SIZE)) == NULL) 154 if (alsa_device == NULL)
146 { 155 {
147 printf("alsa-init: memory allocation error: %s\n", strerror(errno)); 156 if ((alsa_device = malloc(ALSA_DEVICE_SIZE)) == NULL)
148 return(0); 157 {
149 } 158 printf("alsa-init: memory allocation error: %s\n", strerror(errno));
150 159 return(0);
151 snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%d,%d", 160 }
152 snd_pcm_info_get_device(alsa_info), 161
153 snd_pcm_info_get_subdevice(alsa_info)); 162 snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%d,%d",
154 163 snd_pcm_info_get_device(alsa_info),
155 snd_pcm_info_free(alsa_info); 164 snd_pcm_info_get_subdevice(alsa_info));
165
166 snd_pcm_info_free(alsa_info);
167 }
156 168
157 printf("alsa-init: %d soundcard%s found, using: %s\n", cards+1, 169 printf("alsa-init: %d soundcard%s found, using: %s\n", cards+1,
158 (cards >= 0) ? "" : "s", alsa_device); 170 (cards >= 0) ? "" : "s", alsa_device);
159 171
160 if ((err = snd_pcm_open(&alsa_handler, alsa_device, SND_PCM_STREAM_PLAYBACK, 172 if ((err = snd_pcm_open(&alsa_handler, alsa_device, SND_PCM_STREAM_PLAYBACK,
228 printf("alsa-init: unable to get buffer size: %s\n", 240 printf("alsa-init: unable to get buffer size: %s\n",
229 snd_strerror(err)); 241 snd_strerror(err));
230 return(0); 242 return(0);
231 } else 243 } else
232 { 244 {
233 printf("alsa-init: got buffersize %i\n", err);
234 ao_buffersize = err; 245 ao_buffersize = err;
246 if (verbose)
247 printf("alsa-init: got buffersize %i\n", ao_buffersize);
235 } 248 }
236 #endif 249 #endif
237 250
238 #ifdef buffertime 251 #ifdef buffertime
239 { 252 {