Example #1
0
int main( int argc, char **argv ) {

	if (argc != 2)
		usage();

	int fd = open(argv[1], O_RDONLY);

	if (!fd) {
		printf("Cannot open %s\n", argv[1]);
		return 1;
	}

	t_packet *p = read_next_packet(fd);
	while(p) {

		int i;
		for (i = 0; i < p->nb_info; i++) {
			char addr[18];
			ba2str(&p->infos[0]->bdaddr, addr);

			printf("%s\n", addr);
		}

		packet_free(p);

		p = read_next_packet(fd);
	} 

	close(fd);
	return 0;
}
vogl_trace_file_reader::trace_file_reader_status_t vogl_trace_file_reader::read_frame_packets(uint32_t frame_index, uint32_t num_frames, vogl_trace_packet_array &packets, uint32_t &actual_frames_read)
{
    VOGL_FUNC_TRACER

    actual_frames_read = 0;

    if (!is_opened())
    {
        vogl_error_printf("%s: Trace file is not open\n", VOGL_FUNCTION_INFO_CSTR);

        VOGL_ASSERT_ALWAYS;

        return cFailed;
    }

    if (!num_frames)
    {
        actual_frames_read = 0;
        return c*K;
    }

    vogl_scoped_location_saver saved_loc(*this);

    if (!seek_to_frame(frame_index))
    {
        vogl_error_printf("%s: Failed seeking to frame %u\n", VOGL_FUNCTION_INFO_CSTR, frame_index);
        return cFailed;
    }

    uint32_t total_frames_read = 0;

    packets.reserve(packets.size() + num_frames * 1000);

    trace_file_reader_status_t status = c*K;
    for (;;)
    {
        status = read_next_packet();
        if (status == cFailed)
        {
            vogl_error_printf("%s: Failed reading from trace file\n", VOGL_FUNCTION_INFO_CSTR);
            break;
        }

        packets.push_back(get_packet_buf());

        if (is_eof_packet())
            break;

        if (is_swap_buffers_packet())
        {
            if (++total_frames_read == num_frames)
                break;
        }
    }

    actual_frames_read = total_frames_read;

    return c*K;
}