<|start_filename|>stream_ogg.c<|end_filename|>
#include <stdio.h>

#include "logg.h"

int main(int argc, char** argv)
{
	LOGG_Stream* s;

	if (argc != 2) {
		printf("usage: %s file.ogg\n", argv[0]);
		return 0;
	}

	if (allegro_init() != 0) {
		printf("Error initialising Allegro.\n");
		return 1;
	}

	if (install_sound(DIGI_AUTODETECT, MIDI_NONE, 0) != 0) {
		printf("Error initialising sound: %s\n", allegro_error);
		return 1;
	}
	install_timer();

	s = logg_get_stream(argv[1], 255, 128, 1);
	if (!s) {
		printf("Error getting ogg stream.\n");
		return 1;
	}
	while (logg_update_stream(s)) {
		rest(1);
	}
	logg_destroy_stream(s);
	return 0;
}
END_OF_MAIN()


<|start_filename|>logg-4.4.2.h<|end_filename|>
#ifndef LOGG_H
#define LOGG_H

#ifdef __cplusplus
extern "C" {
#endif

#include <allegro.h>
#include <vorbis/vorbisfile.h>

#define OGG_PAGES_TO_BUFFER 2

typedef struct {
	char *buf[OGG_PAGES_TO_BUFFER];
	int current_page;
	int playing_page;
	AUDIOSTREAM* audio_stream;
	OggVorbis_File ovf;
	int bits;
	int stereo;
	int freq;
	int len;
	char* filename;
	int loop;
	int volume;
	int pan;
} LOGG_Stream;

extern SAMPLE* logg_load(const char* filename);
extern int logg_get_buffer_size();
extern void logg_set_buffer_size(int size);
extern LOGG_Stream* logg_get_stream(const char* filename,
		int volume, int pan, int loop);
extern int logg_update_stream(LOGG_Stream* s);
extern void logg_destroy_stream(LOGG_Stream* s);
extern void logg_stop_stream(LOGG_Stream* s);
extern int logg_restart_stream(LOGG_Stream* s);

#ifdef __cplusplus
}
#endif

#endif

