comparison src/sound.c @ 90718:f1d13e615070

Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 523-544) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 168-171) - Update from CVS - Merge from emacs--devo--0 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-150
author Miles Bader <miles@gnu.org>
date Thu, 07 Dec 2006 04:14:14 +0000
parents 8a8e69664178 a7c077b29617
children bc10a33dd40b
comparison
equal deleted inserted replaced
90717:06937e972ad0 90718:f1d13e615070
1013 if (err < 0) 1013 if (err < 0)
1014 alsa_sound_perror ("Could not set access type", err); 1014 alsa_sound_perror ("Could not set access type", err);
1015 1015
1016 val = sd->format; 1016 val = sd->format;
1017 err = snd_pcm_hw_params_set_format (p->handle, p->hwparams, val); 1017 err = snd_pcm_hw_params_set_format (p->handle, p->hwparams, val);
1018 if (err < 0) 1018 if (err < 0)
1019 alsa_sound_perror ("Could not set sound format", err); 1019 alsa_sound_perror ("Could not set sound format", err);
1020 1020
1021 uval = sd->sample_rate; 1021 uval = sd->sample_rate;
1022 err = snd_pcm_hw_params_set_rate_near (p->handle, p->hwparams, &uval, 0); 1022 err = snd_pcm_hw_params_set_rate_near (p->handle, p->hwparams, &uval, 0);
1023 if (err < 0) 1023 if (err < 0)
1024 alsa_sound_perror ("Could not set sample rate", err); 1024 alsa_sound_perror ("Could not set sample rate", err);
1025 1025
1026 val = sd->channels; 1026 val = sd->channels;
1027 err = snd_pcm_hw_params_set_channels (p->handle, p->hwparams, val); 1027 err = snd_pcm_hw_params_set_channels (p->handle, p->hwparams, val);
1028 if (err < 0) 1028 if (err < 0)
1029 alsa_sound_perror ("Could not set channel count", err); 1029 alsa_sound_perror ("Could not set channel count", err);
1030 1030
1070 1070
1071 snd_pcm_hw_params_free (p->hwparams); 1071 snd_pcm_hw_params_free (p->hwparams);
1072 p->hwparams = NULL; 1072 p->hwparams = NULL;
1073 snd_pcm_sw_params_free (p->swparams); 1073 snd_pcm_sw_params_free (p->swparams);
1074 p->swparams = NULL; 1074 p->swparams = NULL;
1075 1075
1076 err = snd_pcm_prepare (p->handle); 1076 err = snd_pcm_prepare (p->handle);
1077 if (err < 0) 1077 if (err < 0)
1078 alsa_sound_perror ("Could not prepare audio interface for use", err); 1078 alsa_sound_perror ("Could not prepare audio interface for use", err);
1079 1079
1080 if (sd->volume > 0) 1080 if (sd->volume > 0)
1081 { 1081 {
1082 int chn; 1082 int chn;
1083 snd_mixer_t *handle; 1083 snd_mixer_t *handle;
1084 snd_mixer_elem_t *e; 1084 snd_mixer_elem_t *e;
1096 if (snd_mixer_selem_has_playback_volume (e)) 1096 if (snd_mixer_selem_has_playback_volume (e))
1097 { 1097 {
1098 long pmin, pmax; 1098 long pmin, pmax;
1099 snd_mixer_selem_get_playback_volume_range (e, &pmin, &pmax); 1099 snd_mixer_selem_get_playback_volume_range (e, &pmin, &pmax);
1100 long vol = pmin + (sd->volume * (pmax - pmin)) / 100; 1100 long vol = pmin + (sd->volume * (pmax - pmin)) / 100;
1101 1101
1102 for (chn = 0; chn <= SND_MIXER_SCHN_LAST; chn++) 1102 for (chn = 0; chn <= SND_MIXER_SCHN_LAST; chn++)
1103 snd_mixer_selem_set_playback_volume (e, chn, vol); 1103 snd_mixer_selem_set_playback_volume (e, chn, vol);
1104 } 1104 }
1105 } 1105 }
1106 snd_mixer_close(handle); 1106 snd_mixer_close(handle);
1228 alsa_sound_perror ("Can't recover from suspend, " 1228 alsa_sound_perror ("Can't recover from suspend, "
1229 "prepare failed", 1229 "prepare failed",
1230 err); 1230 err);
1231 } 1231 }
1232 } 1232 }
1233 else 1233 else
1234 alsa_sound_perror ("Error writing to sound device", err); 1234 alsa_sound_perror ("Error writing to sound device", err);
1235 1235
1236 } 1236 }
1237 else 1237 else
1238 nwritten += err * fact; 1238 nwritten += err * fact;
1239 } 1239 }
1240 } 1240 }
1372 #endif /* WINDOWSNT */ 1372 #endif /* WINDOWSNT */
1373 1373
1374 DEFUN ("play-sound-internal", Fplay_sound_internal, Splay_sound_internal, 1, 1, 0, 1374 DEFUN ("play-sound-internal", Fplay_sound_internal, Splay_sound_internal, 1, 1, 0,
1375 doc: /* Play sound SOUND. 1375 doc: /* Play sound SOUND.
1376 1376
1377 Internal use only, use `play-sound' instead.\n */) 1377 Internal use only, use `play-sound' instead. */)
1378 (sound) 1378 (sound)
1379 Lisp_Object sound; 1379 Lisp_Object sound;
1380 { 1380 {
1381 Lisp_Object attrs[SOUND_ATTR_SENTINEL]; 1381 Lisp_Object attrs[SOUND_ATTR_SENTINEL];
1382 int count = SPECPDL_INDEX (); 1382 int count = SPECPDL_INDEX ();