Esempio n. 1
0
void snd_print_info(snd_type snd)
{
    if (snd->device == SND_DEVICE_AUDIO) {
        if (snd->write_flag == SND_READ) {
            printf("audio input");
        } else {
            printf("audio output");
        }
    } else if (snd->device == SND_DEVICE_MEM) {
        if (snd->write_flag == SND_READ) {
            printf("from memory buffer");
        } else {
            printf("to memory buffer");
        }
    } else {
        printf("header %s", header_to_string(snd->u.file.header));
    }
    printf(", channels %d, mode %s, bits %d, srate %g",
           snd->format.channels,
           snd_mode_to_string(snd->format.mode),
           snd->format.bits, snd->format.srate);
    if (snd->device == SND_DEVICE_MEM) {
        if (snd->write_flag == SND_READ) {
            printf("length %d\n", snd->u.mem.buffer_len);
        } else {
            printf("length %d\n", snd->u.mem.buffer_max);
        }
    } else if (snd->device == SND_DEVICE_FILE &&
               snd->write_flag == SND_READ) {
        printf(", length %d\n", (snd->u.file.end_offset -
                                 snd->u.file.byte_offset) / snd_bytes_per_frame(snd));
    } else printf("\n");
}
Esempio n. 2
0
static
char* make_message_body(const fix_message_data* const data, unsigned* psize)
{
	char* body;
	size_t size;
	FILE* const builder = open_memstream(&body, &size);

	ASSURE(builder);
	header_to_string(builder, &data->hdr);

	switch(data->hdr.MsgType)
	{
		case 'D':
			new_order_single_to_string(builder, &data->order);
			break;
		default:
			error(EXIT_FAILURE, 0, "Unknown message type '%c'", data->hdr.MsgType);
	}

	ASSURE(fclose(builder) == 0);
	*psize = size;
	return body;
}