234 |
static void vox_init P_ ((struct sound_device *)); |
static void vox_init P_ ((struct sound_device *)); |
235 |
static void vox_write P_ ((struct sound_device *, char *, int)); |
static void vox_write P_ ((struct sound_device *, char *, int)); |
236 |
static void sound_perror P_ ((char *)); |
static void sound_perror P_ ((char *)); |
237 |
|
static void sound_warning P_ ((char *)); |
238 |
static int parse_sound P_ ((Lisp_Object, Lisp_Object *)); |
static int parse_sound P_ ((Lisp_Object, Lisp_Object *)); |
239 |
static void find_sound_type P_ ((struct sound *)); |
static void find_sound_type P_ ((struct sound *)); |
240 |
static u_int32_t le2hl P_ ((u_int32_t)); |
static u_int32_t le2hl P_ ((u_int32_t)); |
261 |
sound_perror (msg) |
sound_perror (msg) |
262 |
char *msg; |
char *msg; |
263 |
{ |
{ |
264 |
error ("%s: %s", msg, strerror (errno)); |
turn_on_atimers (1); |
265 |
|
#ifdef SIGIO |
266 |
|
sigunblock (sigmask (SIGIO)); |
267 |
|
#endif |
268 |
|
if (errno != 0) |
269 |
|
error ("%s: %s", msg, strerror (errno)); |
270 |
|
else |
271 |
|
error ("%s", msg); |
272 |
|
} |
273 |
|
|
274 |
|
|
275 |
|
/* Display a warning message. */ |
276 |
|
|
277 |
|
static void |
278 |
|
sound_warning (msg) |
279 |
|
char *msg; |
280 |
|
{ |
281 |
|
message (msg); |
282 |
} |
} |
283 |
|
|
284 |
|
|
434 |
s.fd = openp (Fcons (Vdata_directory, Qnil), |
s.fd = openp (Fcons (Vdata_directory, Qnil), |
435 |
attrs[SOUND_FILE], "", &file, 0); |
attrs[SOUND_FILE], "", &file, 0); |
436 |
if (s.fd < 0) |
if (s.fd < 0) |
437 |
sound_perror ("Open sound file"); |
sound_perror ("Could not open sound file"); |
438 |
|
|
439 |
/* Read the first bytes from the file. */ |
/* Read the first bytes from the file. */ |
440 |
s.header_size = emacs_read (s.fd, s.header, MAX_SOUND_HEADER_BYTES); |
s.header_size = emacs_read (s.fd, s.header, MAX_SOUND_HEADER_BYTES); |
441 |
if (s.header_size < 0) |
if (s.header_size < 0) |
442 |
sound_perror ("Reading sound file header"); |
sound_perror ("Invalid sound file header"); |
443 |
} |
} |
444 |
else |
else |
445 |
{ |
{ |
650 |
sd->write (sd, buffer, nbytes); |
sd->write (sd, buffer, nbytes); |
651 |
|
|
652 |
if (nbytes < 0) |
if (nbytes < 0) |
653 |
sound_perror ("Reading sound file"); |
sound_perror ("Error reading sound file"); |
654 |
} |
} |
655 |
} |
} |
656 |
|
|
740 |
sd->write (sd, buffer, nbytes); |
sd->write (sd, buffer, nbytes); |
741 |
|
|
742 |
if (nbytes < 0) |
if (nbytes < 0) |
743 |
sound_perror ("Reading sound file"); |
sound_perror ("Error reading sound file"); |
744 |
} |
} |
745 |
} |
} |
746 |
|
|
796 |
val = sd->format; |
val = sd->format; |
797 |
if (ioctl (sd->fd, SNDCTL_DSP_SETFMT, &sd->format) < 0 |
if (ioctl (sd->fd, SNDCTL_DSP_SETFMT, &sd->format) < 0 |
798 |
|| val != sd->format) |
|| val != sd->format) |
799 |
sound_perror ("Set sound format"); |
sound_perror ("Could not set sound format"); |
800 |
|
|
801 |
val = sd->channels != 1; |
val = sd->channels != 1; |
802 |
if (ioctl (sd->fd, SNDCTL_DSP_STEREO, &val) < 0 |
if (ioctl (sd->fd, SNDCTL_DSP_STEREO, &val) < 0 |
803 |
|| val != (sd->channels != 1)) |
|| val != (sd->channels != 1)) |
804 |
sound_perror ("Set stereo/mono"); |
sound_perror ("Could not set stereo/mono"); |
805 |
|
|
806 |
/* I think bps and sampling_rate are the same, but who knows. |
/* I think bps and sampling_rate are the same, but who knows. |
807 |
Check this. and use SND_DSP_SPEED for both. */ |
Check this. and use SND_DSP_SPEED for both. */ |
808 |
if (sd->sample_rate > 0) |
if (sd->sample_rate > 0) |
809 |
{ |
{ |
810 |
val = sd->sample_rate; |
val = sd->sample_rate; |
811 |
if (ioctl (sd->fd, SNDCTL_DSP_SPEED, &sd->sample_rate) < 0 |
if (ioctl (sd->fd, SNDCTL_DSP_SPEED, &sd->sample_rate) < 0) |
812 |
|| val != sd->sample_rate) |
sound_perror ("Could not set sound speed"); |
813 |
sound_perror ("Set sound speed"); |
else if (val != sd->sample_rate) |
814 |
|
sound_warning ("Could not set sample rate"); |
815 |
} |
} |
816 |
|
|
817 |
if (sd->volume > 0) |
if (sd->volume > 0) |
930 |
{ |
{ |
931 |
int nwritten = emacs_write (sd->fd, buffer, nbytes); |
int nwritten = emacs_write (sd->fd, buffer, nbytes); |
932 |
if (nwritten < 0) |
if (nwritten < 0) |
933 |
sound_perror ("Writing to sound device"); |
sound_perror ("Error writing to sound device"); |
934 |
} |
} |
935 |
|
|
936 |
|
|