diff options
Diffstat (limited to 'src/sound.c')
-rw-r--r-- | src/sound.c | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/src/sound.c b/src/sound.c index 2ceefd3bce3..af2369040cc 100644 --- a/src/sound.c +++ b/src/sound.c @@ -113,7 +113,8 @@ enum sound_attr SOUND_ATTR_SENTINEL }; -static void sound_perror P_ ((char *)); +static void alsa_sound_perror P_ ((char *, int)) NO_RETURN; +static void sound_perror P_ ((char *)) NO_RETURN; static void sound_warning P_ ((char *)); static int parse_sound P_ ((Lisp_Object, Lisp_Object *)); @@ -971,7 +972,8 @@ alsa_open (sd) sd->data = p; - if ((err = snd_pcm_open (&p->handle, file, SND_PCM_STREAM_PLAYBACK, 0)) < 0) + err = snd_pcm_open (&p->handle, file, SND_PCM_STREAM_PLAYBACK, 0); + if (err < 0) alsa_sound_perror (file, err); } @@ -993,32 +995,42 @@ alsa_configure (sd) xassert (p->handle != 0); - if ((err = snd_pcm_hw_params_malloc (&p->hwparams)) < 0) + err = snd_pcm_hw_params_malloc (&p->hwparams); + if (err < 0) alsa_sound_perror ("Could not allocate hardware parameter structure", err); - if ((err = snd_pcm_sw_params_malloc (&p->swparams)) < 0) + err = snd_pcm_sw_params_malloc (&p->swparams); + if (err < 0) alsa_sound_perror ("Could not allocate software parameter structure", err); - if ((err = snd_pcm_hw_params_any (p->handle, p->hwparams)) < 0) + err = snd_pcm_hw_params_any (p->handle, p->hwparams); + if (err < 0) alsa_sound_perror ("Could not initialize hardware parameter structure", err); - if ((err = snd_pcm_hw_params_set_access (p->handle, p->hwparams, - SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) + err = snd_pcm_hw_params_set_access (p->handle, p->hwparams, + SND_PCM_ACCESS_RW_INTERLEAVED); + if (err < 0) alsa_sound_perror ("Could not set access type", err); val = sd->format; - if ((err = snd_pcm_hw_params_set_format (p->handle, p->hwparams, val)) < 0) + err = snd_pcm_hw_params_set_format (p->handle, p->hwparams, val); + if (err < 0) alsa_sound_perror ("Could not set sound format", err); val = sd->sample_rate; - if ((err = snd_pcm_hw_params_set_rate_near (p->handle, p->hwparams, &val, 0)) - < 0) + err = snd_pcm_hw_params_set_rate_near (p->handle, p->hwparams, &val, 0); + if (err < 0) alsa_sound_perror ("Could not set sample rate", err); val = sd->channels; - if ((err = snd_pcm_hw_params_set_channels (p->handle, p->hwparams, val)) < 0) + err = snd_pcm_hw_params_set_channels (p->handle, p->hwparams, val); + if (err < 0) alsa_sound_perror ("Could not set channel count", err); + err = snd_pcm_hw_params (p->handle, p->hwparams); + if (err < 0) + alsa_sound_perror ("Could not set parameters", err); + err = snd_pcm_hw_params_get_period_size (p->hwparams, &p->period_size, &dir); if (err < 0) @@ -1028,9 +1040,6 @@ alsa_configure (sd) if (err < 0) alsa_sound_perror("Unable to get buffer size for playback", err); - if ((err = snd_pcm_hw_params (p->handle, p->hwparams)) < 0) - alsa_sound_perror ("Could not set parameters", err); - err = snd_pcm_sw_params_current (p->handle, p->swparams); if (err < 0) alsa_sound_perror ("Unable to determine current swparams for playback", @@ -1063,7 +1072,8 @@ alsa_configure (sd) snd_pcm_sw_params_free (p->swparams); p->swparams = NULL; - if ((err = snd_pcm_prepare (p->handle)) < 0) + err = snd_pcm_prepare (p->handle); + if (err < 0) alsa_sound_perror ("Could not prepare audio interface for use", err); if (sd->volume > 0) @@ -1194,11 +1204,11 @@ alsa_write (sd, buffer, nbytes) while (nwritten < nbytes) { - if ((err = snd_pcm_writei (p->handle, - buffer + nwritten, - (nbytes - nwritten)/fact)) < 0) + err = snd_pcm_writei (p->handle, + buffer + nwritten, + (nbytes - nwritten)/fact); + if (err < 0) { - fprintf(stderr, "Err %d/%s\n", err, snd_strerror(err)); if (err == -EPIPE) { /* under-run */ err = snd_pcm_prepare (p->handle); |