static Xen g_mus_header_writable(Xen head, Xen data) { #define H_mus_header_writable "(" S_mus_header_writable " header-type sample-type) returns " PROC_TRUE " if the header can handle the sample type" Xen_check_type(Xen_is_integer(head), head, 1, S_mus_header_writable, "a header type"); Xen_check_type(Xen_is_integer(data), data, 2, S_mus_header_writable, "a sample type"); return(C_bool_to_Xen_boolean(mus_header_writable((mus_header_t)Xen_integer_to_C_int(head), (mus_sample_t)Xen_integer_to_C_int(data)))); }
int open_temp_file(const char *ofile, int chans, file_info *hdr, io_error_t *err) { /* returns io fd */ int ofd, sl_err = MUS_NO_ERROR; if (!(mus_header_writable(hdr->type, hdr->format))) { hdr->type = default_output_header_type(ss); if (mus_header_writable(hdr->type, default_output_data_format(ss))) hdr->format = default_output_data_format(ss); else { /* was default_output_* here, but that's for the user's output, not ours */ hdr->type = MUS_NEXT; hdr->format = MUS_OUT_FORMAT; } } (*err) = snd_write_header(ofile, hdr->type, hdr->srate, chans, 0, hdr->format, hdr->comment, hdr->loops); if ((*err) != IO_NO_ERROR) { /* -1 as fd */ return(-1); } ofd = snd_reopen_write(ofile); if (ofd == -1) { (*err) = IO_CANT_REOPEN_FILE; return(-1); } hdr->data_location = mus_header_data_location(); /* header might have changed size (aiff extras) */ sl_err = snd_file_open_descriptors(ofd, ofile, hdr->format, hdr->data_location, chans, hdr->type); if (sl_err != MUS_NO_ERROR) (*err) = sndlib_error_to_snd(sl_err); lseek(ofd, hdr->data_location, SEEK_SET); return(ofd); }