[xiph-commits] r3579 - in liboggplay/trunk: . src src/examples src/examples/mac src/examples/mac/English.lproj src/examples/mac/English.lproj/gplayer.nib src/examples/mac/gplayer.xcodeproj src/tools src/tools/mac src/tools/mac/English.lproj/gplayer.nib src/tools/mac/gplayer.xcodeproj

conrad at svn.annodex.net conrad at svn.annodex.net
Thu May 1 21:35:29 PDT 2008


Author: conrad
Date: 2008-05-01 21:35:28 -0700 (Thu, 01 May 2008)
New Revision: 3579

Added:
   liboggplay/trunk/src/examples/
   liboggplay/trunk/src/examples/Makefile.am
   liboggplay/trunk/src/examples/dump-all-streams.c
   liboggplay/trunk/src/examples/dump_some_frames.py
   liboggplay/trunk/src/examples/get-stream-info.c
   liboggplay/trunk/src/examples/glut-player.c
   liboggplay/trunk/src/examples/mac-player.c
   liboggplay/trunk/src/examples/mac/
   liboggplay/trunk/src/examples/mac/English.lproj/
   liboggplay/trunk/src/examples/mac/English.lproj/gplayer.nib/
   liboggplay/trunk/src/examples/mac/English.lproj/gplayer.nib/classes.nib
   liboggplay/trunk/src/examples/mac/English.lproj/gplayer.nib/info.nib
   liboggplay/trunk/src/examples/mac/English.lproj/gplayer.nib/objects.xib
   liboggplay/trunk/src/examples/mac/Info.plist
   liboggplay/trunk/src/examples/mac/gplayer.xcodeproj/
   liboggplay/trunk/src/examples/mac/gplayer.xcodeproj/project.pbxproj
   liboggplay/trunk/src/examples/win32-player.c
Removed:
   liboggplay/trunk/src/tools/dump-all-streams.c
   liboggplay/trunk/src/tools/dump_some_frames.py
   liboggplay/trunk/src/tools/get-stream-info.c
   liboggplay/trunk/src/tools/glut-player.c
   liboggplay/trunk/src/tools/mac-player.c
   liboggplay/trunk/src/tools/mac/English.lproj/gplayer.nib/classes.nib
   liboggplay/trunk/src/tools/mac/English.lproj/gplayer.nib/info.nib
   liboggplay/trunk/src/tools/mac/English.lproj/gplayer.nib/objects.xib
   liboggplay/trunk/src/tools/mac/Info.plist
   liboggplay/trunk/src/tools/mac/gplayer.xcodeproj/project.pbxproj
   liboggplay/trunk/src/tools/win32-player.c
Modified:
   liboggplay/trunk/configure.ac
   liboggplay/trunk/src/Makefile.am
   liboggplay/trunk/src/tools/Makefile.am
Log:
move examples into separate dir src/examples


Modified: liboggplay/trunk/configure.ac
===================================================================
--- liboggplay/trunk/configure.ac	2008-05-01 09:40:13 UTC (rev 3578)
+++ liboggplay/trunk/configure.ac	2008-05-02 04:35:28 UTC (rev 3579)
@@ -177,6 +177,7 @@
 dnl
 PKG_CHECK_MODULES(IMLIB2, imlib2, HAVE_IMLIB2="yes", HAVE_IMLIB2="no")
 if test "x$HAVE_IMLIB2" = "xyes" ; then
+  oggplay_tools="$oggplay_tools dump-first-frame"
   AC_DEFINE(HAVE_IMLIB2, [], [Define if have Imlib2])
   AC_SUBST(IMLIB2_LIBS)
   AC_SUBST(IMLIB2_CFLAGS)
@@ -370,6 +371,7 @@
 src/Makefile
 src/liboggplay/Makefile
 src/liboggplay/Version_script
+src/examples/Makefile
 src/tools/Makefile
 src/tests/Makefile
 oggplay.pc
@@ -388,7 +390,7 @@
 
     $oggplay_tools
 
-  Examples (./src/tools):
+  Examples (./src/examples):
 
     $oggplay_examples $oggplay_glut
 

Modified: liboggplay/trunk/src/Makefile.am
===================================================================
--- liboggplay/trunk/src/Makefile.am	2008-05-01 09:40:13 UTC (rev 3578)
+++ liboggplay/trunk/src/Makefile.am	2008-05-02 04:35:28 UTC (rev 3579)
@@ -1,4 +1,4 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS = liboggplay tools tests
+SUBDIRS = liboggplay examples tools tests
 

Copied: liboggplay/trunk/src/examples/Makefile.am (from rev 3577, liboggplay/trunk/src/tools/Makefile.am)
===================================================================
--- liboggplay/trunk/src/examples/Makefile.am	                        (rev 0)
+++ liboggplay/trunk/src/examples/Makefile.am	2008-05-02 04:35:28 UTC (rev 3579)
@@ -0,0 +1,45 @@
+## Process this file with automake to produce Makefile.in
+
+EXTRA_DIST= \
+	mac/Info.plist \
+	mac/English.lproj/gplayer.nib \
+	mac/English.lproj/gplayer.nib/classes.nib \
+	mac/English.lproj/gplayer.nib/info.nib \
+	mac/English.lproj/gplayer.nib/objects.xib \
+	mac/gplayer.xcodeproj/project.pbxproj
+
+AM_CFLAGS = -Wall \
+            @OGGZ_CFLAGS@ @THEORA_CFLAGS@ @FISHSOUND_CFLAGS@ @KATE_CFLAGS@
+
+INCLUDES = -I$(top_srcdir)/include
+
+OGGPLAYDIR = ../liboggplay
+OGGPLAY_LIBS = $(OGGPLAYDIR)/liboggplay.la @OGGZ_LIBS@ @THEORA_LIBS@ \
+	       @FISHSOUND_LIBS@ @KATE_LIBS@ @SEMAPHORE_LIBS@
+
+if HAVE_GLUT
+glut_tools = glut-player
+endif
+
+if HAVE_LIBSNDFILE1
+sndfile_tools = dump-all-streams
+endif
+
+# Tools
+
+noinst_PROGRAMS = get-stream-info $(glut_tools) $(sndfile_tools)
+
+get_stream_info_SOURCES = get-stream-info.c
+get_stream_info_LDADD = $(OGGPLAY_LIBS) 
+
+dump_all_streams_SOURCES = dump-all-streams.c
+dump_all_streams_CFLAGS = $(AM_CFLAGS) @SNDFILE_CFLAGS@
+dump_all_streams_LDADD = $(OGGPLAY_LIBS) @SNDFILE_LIBS@ 
+
+glut_player_SOURCES = glut-player.c
+glut_player_LDADD = $(OGGPLAY_LIBS) @GLUT_LIBS@
+if MACOS
+# Automake 1.6 doesn't recoginze -framework arguments as libraries
+# so we must pass them through LDFLAGS
+glut_player_LDFLAGS = @GLUT_FRAMEWORKS@
+endif

Copied: liboggplay/trunk/src/examples/dump-all-streams.c (from rev 3577, liboggplay/trunk/src/tools/dump-all-streams.c)
===================================================================
--- liboggplay/trunk/src/examples/dump-all-streams.c	                        (rev 0)
+++ liboggplay/trunk/src/examples/dump-all-streams.c	2008-05-02 04:35:28 UTC (rev 3579)
@@ -0,0 +1,168 @@
+#include "config.h"
+
+#include <oggplay/oggplay.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sndfile.h>
+
+static int n_frames = 0;
+
+void
+dump_video_data (OggPlay * player, int track_num, OggPlayVideoData * video_data,
+                   int frame) {
+
+  char              fname[256];
+  FILE            * f;
+  FILE            * g;
+  int               i;
+  unsigned char   * ptr;
+  unsigned char   * ptr2;
+  int               y_width;
+  int               y_height;
+  int               uv_width;
+  int               uv_height;
+
+  sprintf(fname, "y_frame%d", frame);
+  f = fopen(fname, "w");
+  
+  oggplay_get_video_y_size(player, track_num, &y_width, &y_height);
+  oggplay_get_video_uv_size(player, track_num, &uv_width, &uv_height);
+  
+  ptr = video_data->y;
+  
+  for (i = 0; i < y_height; i++) {
+    fwrite(ptr, 1, y_width, f);
+    ptr += y_width;
+  }
+
+  fclose(f);
+
+  sprintf(fname, "u_frame%d", frame);
+  f = fopen(fname, "w");
+  sprintf(fname, "v_frame%d", frame);
+  g = fopen(fname, "w");
+
+  ptr = video_data->u;
+  ptr2 = video_data->v;
+  
+  for (i = 0; i < uv_height; i++) {
+    fwrite(ptr, 1, uv_width, f);
+    fwrite(ptr2, 1, uv_width, g);
+    ptr += uv_width;
+    ptr2 += uv_width;
+  }
+
+  fclose(f);
+  fclose(g);
+  
+}
+
+static SNDFILE * sndfile = NULL;
+
+void
+dump_audio_data (OggPlay * player, int track, OggPlayAudioData * data, 
+                int size) {
+
+  if (sndfile == NULL) {
+    SF_INFO sfinfo;
+    oggplay_get_audio_samplerate(player, track, &(sfinfo.samplerate));
+    oggplay_get_audio_channels(player, track, &(sfinfo.channels));
+    sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
+    printf("%d %d %d\n", sfinfo.samplerate, sfinfo.channels, sfinfo.format);
+
+    sndfile = sf_open ("audio", SFM_WRITE, &sfinfo);
+  }
+
+  sf_writef_float (sndfile, (float *)data, size);
+  
+}
+
+int
+dump_streams_callback (OggPlay *player, int num_tracks, 
+                       OggPlayCallbackInfo **track_info, void *user) {
+
+  int                   i;
+  int                   j;
+  OggPlayDataHeader  ** headers;
+  OggPlayVideoData    * video_data;
+  OggPlayAudioData    * audio_data;
+  int                   required;
+  OggPlayDataType       type;
+
+  for (i = 0; i < num_tracks; i++) {
+    type = oggplay_callback_info_get_type(track_info[i]);
+    headers = oggplay_callback_info_get_headers(track_info[i]);
+
+    switch (type) {
+      case OGGPLAY_INACTIVE:
+        break;
+      case OGGPLAY_YUV_VIDEO:
+        /*
+         * there should only be one record
+         */
+        video_data = oggplay_callback_info_get_video_data(headers[0]);
+        dump_video_data(player, i, video_data, n_frames);
+        break;
+      case OGGPLAY_FLOATS_AUDIO:
+        required = oggplay_callback_info_get_required(track_info[i]);
+        for (j = 0; j < required; j++) {
+          int size;
+          size = oggplay_callback_info_get_record_size(headers[j]);
+          audio_data = oggplay_callback_info_get_audio_data(headers[j]);
+          dump_audio_data(player, i, audio_data, size);
+        }
+      default:
+        break;
+    }
+  }
+  
+  n_frames++;
+
+  return 0;
+}
+
+int
+main (int argc, char * argv[]) {
+
+  OggPlay       * player;
+  OggPlayReader * reader;
+  int             i;
+
+  if (argc < 2) {
+    printf ("please provide a filename\n");
+    exit (1);
+  }
+  
+  reader = oggplay_file_reader_new(argv[1]);
+
+  player = oggplay_open_with_reader(reader);
+
+  if (player == NULL) {
+    printf ("could not initialise oggplay with this file\n");
+    exit (1);
+  }
+
+  printf ("there are %d tracks\n", oggplay_get_num_tracks (player));
+  
+  for (i = 0; i < oggplay_get_num_tracks (player); i++) {
+    printf("Track %d is of type %s\n", i, 
+                    oggplay_get_track_typename (player, i));
+    if (oggplay_get_track_type (player, i) == OGGZ_CONTENT_THEORA) {
+      oggplay_set_callback_num_frames (player, i, 1);
+    }
+
+    if (oggplay_set_track_active(player, i) < 0) {
+      printf("\tNote: Could not set this track active!\n");
+    }
+  }
+
+  oggplay_set_data_callback(player, dump_streams_callback, NULL);
+  oggplay_start_decoding(player);
+
+  sf_close(sndfile);
+  
+  printf("there were %d frames\n", n_frames);
+
+  return 0;
+}

Copied: liboggplay/trunk/src/examples/dump_some_frames.py (from rev 3577, liboggplay/trunk/src/tools/dump_some_frames.py)
===================================================================
--- liboggplay/trunk/src/examples/dump_some_frames.py	                        (rev 0)
+++ liboggplay/trunk/src/examples/dump_some_frames.py	2008-05-02 04:35:28 UTC (rev 3579)
@@ -0,0 +1,64 @@
+import sys
+import Image
+from oggplay import *
+from xml.dom.ext.reader import Sax2
+from xml import xpath
+
+video_name = sys.argv[1]
+timelist = sys.argv[2]
+outname = sys.argv[3]
+f = open(timelist)
+
+reader = Sax2.Reader()
+doc = reader.fromStream(f)
+times = xpath.Evaluate('descendant::clip/@start', doc.documentElement)
+times = map(lambda a: a.nodeValue, times)
+f.close()
+
+def string_to_ms(time):
+  stime = time.split(":")
+  out = 0
+  mul = 1
+  while len(stime) > 0:
+    out += mul * float(stime[-1])
+    mul *= 60
+    del stime[-1]
+  return (int(out * 1000 + 500), time)
+
+times = map(string_to_ms, times)
+
+if video_name[:7] == "http://":
+  reader = oggplay_tcp_reader_new(video_name, None, 80)
+else:
+  reader = oggplay_file_reader_new(video_name)
+
+player = oggplay_open_with_reader(reader)
+
+for i in range(oggplay_get_num_tracks(player)):
+  global video
+  if oggplay_get_track_type(player, i) == OGGZ_CONTENT_THEORA:
+    oggplay_set_callback_num_frames(player, i, 1)
+    video = i
+  oggplay_set_track_active(player, i)
+
+pos = 0
+
+def data_callback(player, track_info):
+  global pos
+  headers = oggplay_callback_info_get_headers(track_info[video])
+  time = oggplay_callback_info_get_presentation_time(headers[0])
+  if time >= times[pos][0]:  
+    rgba = oggplay_generate_frame(player, video, headers[0])
+    image = Image.fromstring("RGBA", rgba[1], rgba[0])
+    fname = outname + ".png_t=" + times[pos][1]
+    pos += 1
+    print "saving", fname
+    image.save(fname, "PNG")
+    if pos == len(times):
+      return -1
+  return 0
+
+if len(times) == 0:
+  exit(0)
+oggplay_set_data_pycallback(player, data_callback)
+oggplay_start_decoding(player)

Copied: liboggplay/trunk/src/examples/get-stream-info.c (from rev 3577, liboggplay/trunk/src/tools/get-stream-info.c)
===================================================================
--- liboggplay/trunk/src/examples/get-stream-info.c	                        (rev 0)
+++ liboggplay/trunk/src/examples/get-stream-info.c	2008-05-02 04:35:28 UTC (rev 3579)
@@ -0,0 +1,34 @@
+#include "config.h"
+
+#include <oggplay/oggplay.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (int argc, char * argv[]) {
+
+  OggPlay       * player;
+  OggPlayReader * reader;
+  int             i;
+
+  if (argc < 2) {
+    printf ("please provide a filename\n");
+    exit (1);
+  }
+  
+  reader = oggplay_file_reader_new(argv[1]);
+
+  player = oggplay_open_with_reader(reader);
+
+  if (player == NULL) {
+    printf ("could not initialise oggplay with this file\n");
+    exit (1);
+  }
+
+  for (i = 0; i < oggplay_get_num_tracks (player); i++) {
+    printf("Track %d is of type %s\n", i, 
+                    oggplay_get_track_typename (player, i));
+  }
+ 
+  return 0; 
+}

Copied: liboggplay/trunk/src/examples/glut-player.c (from rev 3577, liboggplay/trunk/src/tools/glut-player.c)
===================================================================
--- liboggplay/trunk/src/examples/glut-player.c	                        (rev 0)
+++ liboggplay/trunk/src/examples/glut-player.c	2008-05-02 04:35:28 UTC (rev 3579)
@@ -0,0 +1,570 @@
+#include "config.h"
+
+#include <oggplay/oggplay.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <string.h>
+#include <stdint.h>
+
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/ioctl.h>
+
+#include <pthread.h>
+#include <semaphore.h>
+
+#ifdef __APPLE__
+#include <GLUT/glut.h>
+#else
+#include <GL/glut.h>
+#include <GL/gl.h>
+#endif
+
+#include <unistd.h>
+#include <fcntl.h>
+
+#if !(defined(__APPLE__) || defined(WIN32))
+#define USE_AUDIO 1
+#else
+#define USE_AUDIO 0
+#endif
+
+#if USE_AUDIO
+#include <sys/soundcard.h>
+
+#include <math.h>
+#endif
+
+#include <assert.h>
+
+static int n_frames = 0;
+
+#ifdef DEBUG
+static long long total_audio_bytes = 0;
+static int target_audio_rate = 0;
+#endif
+
+static GLuint texture;
+
+static unsigned char *texture_bits = NULL;
+static int texture_width;
+static int texture_height;
+static float texture_wscale;
+static float texture_hscale;
+static int window_width;
+static int window_height;
+
+static OggPlay    * player = NULL;
+
+static sem_t        stop_sem;
+
+
+static int video_track;
+static int audio_track;
+
+#define DISPLAY_FRAMES 1
+
+#define PERIOD_SIZE   512
+
+void
+handle_video_data (OggPlay * player, int track_num, 
+                    OggPlayVideoData * video_data, int frame) {
+
+  int               y_width;
+  int               y_height;
+  int               uv_width;
+  int               uv_height;
+  int               po2_width;
+  int               po2_height;  
+  OggPlayYUVChannels      yuv;
+  OggPlayRGBChannels      rgb;
+
+  oggplay_get_video_y_size(player, track_num, &y_width, &y_height);
+  if (y_width != window_width)
+  {
+#if DISPLAY_FRAMES
+    glutReshapeWindow(y_width, y_height);
+#endif
+    window_width = y_width;
+    window_height = y_height;
+    printf("New window size is (%d, %d)\n", window_width, window_height);
+  }
+    
+  oggplay_get_video_uv_size(player, track_num, &uv_width, &uv_height);
+  //assert(uv_width == y_width / 2);
+  //assert(uv_height == y_height / 2);
+  
+  for (po2_width = 1; po2_width < y_width; po2_width <<= 1);
+  for (po2_height = 1; po2_height < y_height; po2_height <<= 1);
+  texture_wscale = (float) y_width / po2_width;
+  texture_hscale = (float) y_height / po2_height;
+
+  if (texture_bits == NULL) {
+
+    texture_bits = calloc(1, po2_width * po2_height * 4);
+    texture_width = po2_width;
+    texture_height = po2_height;    
+    
+  } else if (texture_width != po2_width || texture_height != po2_height) {
+
+    free(texture_bits);
+    
+    texture_bits = calloc(1, po2_width * po2_height * 4);
+    texture_width = po2_width;
+    texture_height = po2_height;
+  }
+
+  /*
+   * Convert the YUV data to RGB, using platform-specific optimisations
+   * where possible.
+   */
+  yuv.ptry = video_data->y;
+  yuv.ptru = video_data->u;
+  yuv.ptrv = video_data->v;
+  yuv.uv_width = uv_width;
+  yuv.uv_height = uv_height;  
+  yuv.y_width = y_width;
+  yuv.y_height = y_height;  
+  
+  rgb.ptro = texture_bits;
+  rgb.rgb_width = texture_width;
+  rgb.rgb_height = texture_height;  
+
+  oggplay_yuv2rgb(&yuv, &rgb);
+
+}
+
+static int              rate = 16000;
+static int              channels = 2;
+static int              fps_denom = 1000;
+static int              fps_num = 25000;
+
+#if USE_AUDIO
+
+static int              snd_fd = -1;
+
+void
+float_to_short_array(const float* in, short* out, int len) {
+        int i = 0;
+        float scaled_value = 0;
+        for(i = 0; i < len; i++) {
+                scaled_value = floorf(0.5 + 32768 * in[i]);
+                if (in[i] < 0) {
+                   out[i] = (scaled_value < -32768.0) ? -32768 : (short)scaled_value;
+                } else {
+                   out[i] = (scaled_value > 32767.0) ? 32767 : (short)scaled_value;
+                }
+        }
+}
+
+void init_audio() {
+  int             tmp;
+
+  snd_fd = open("/dev/dsp", O_WRONLY, 0);
+#ifdef DEBUG
+  target_audio_rate = (int)(rate * channels * sizeof(short) / 25);
+#endif
+  tmp = AFMT_S16_LE;
+  ioctl(snd_fd, SNDCTL_DSP_SETFMT, &tmp);
+  ioctl(snd_fd, SNDCTL_DSP_CHANNELS, &channels);
+  ioctl(snd_fd, SNDCTL_DSP_SPEED, &rate);
+}
+
+static short *buffer = NULL;
+static int buffer_length = 0;
+
+void
+handle_audio_data (OggPlay * player, int track, OggPlayAudioData * data,
+                int size) {
+
+  if (snd_fd == -1) {
+    init_audio();
+  }
+ 
+  if (buffer_length < size) {
+    buffer = realloc(buffer, size * sizeof (short) * 2);
+    buffer_length = size;
+  }
+  
+  float_to_short_array((float *)data, buffer, size * 2);
+ 
+  write(snd_fd, buffer, size * 2 * sizeof(short));
+}
+
+#endif
+
+static int        window;
+static long       ld_time;
+
+void display_frame(void) {
+  int                     i;
+  OggPlayDataHeader    ** headers;
+  OggPlayVideoData      * video_data;
+#if USE_AUDIO
+  OggPlayAudioData      * audio_data;
+  count_info              tsc;
+  int                     j;
+#endif
+  int                     required;
+  OggPlayDataType         type;
+  int                     num_tracks;
+  OggPlayCallbackInfo  ** track_info;  
+  static unsigned int     target      = 0;
+#ifdef DEBUG
+  int 			  bytes_per_frame = 0;
+#endif
+  struct timespec         ts;
+
+  ts.tv_sec = 0;
+  num_tracks = oggplay_get_num_tracks (player);
+
+  //nice(5);
+  
+  //while (1) { 
+    track_info = oggplay_buffer_retrieve_next(player);
+    
+    if (track_info == NULL) {
+      ts.tv_nsec = 40000000;
+      nanosleep(&ts, NULL);      
+      return;
+    }
+#if USE_AUDIO
+    if (rate > 0) {
+      ioctl(snd_fd, SNDCTL_DSP_GETOPTR, &tsc);
+      long long bytes = tsc.bytes;
+      long long offset = (target - (bytes * 10000 / rate / 4)) * 100;
+#else
+    {
+      long long offset = 400 * 100;
+#endif
+      target += 400;
+    
+#if DISPLAY_FRAMES
+      if (offset > 0) {
+        ts.tv_nsec = offset * 1000;
+        nanosleep(&ts, NULL);
+      }
+#endif
+    }
+
+    for (i = 0; i < num_tracks; i++) {
+      type = oggplay_callback_info_get_type(track_info[i]);
+      headers = oggplay_callback_info_get_headers(track_info[i]);
+ 
+      switch (type) {
+        case OGGPLAY_INACTIVE:
+          break;
+        case OGGPLAY_YUV_VIDEO:
+          /*
+           * there should only be one record
+           */
+          required = oggplay_callback_info_get_required(track_info[i]);
+          video_data = oggplay_callback_info_get_video_data(headers[0]);
+          ld_time = oggplay_callback_info_get_presentation_time(headers[0]);
+          handle_video_data(player, i, video_data, n_frames);
+          /*
+          printf("video fst %ld lst %ld\n",
+            oggplay_callback_info_get_presentation_time(headers[0]), 
+            oggplay_callback_info_get_presentation_time(headers[required - 1]));
+          */
+          break;
+        case OGGPLAY_FLOATS_AUDIO:
+#if USE_AUDIO
+        required = oggplay_callback_info_get_required(track_info[i]);
+        /*
+        printf("audio fst %ld lst %ld\n",
+            oggplay_callback_info_get_presentation_time(headers[0]), 
+            oggplay_callback_info_get_presentation_time(headers[required - 1]));
+        */
+        int total_size = 0;
+    	  for (j = 0; j < required; j++) {
+          int size;
+          size = oggplay_callback_info_get_record_size(headers[j]);
+    	    audio_data = oggplay_callback_info_get_audio_data(headers[j]);
+#ifdef DEBUG
+	        bytes_per_frame += size * 4; // size * channels
+#endif
+          handle_audio_data(player, i, audio_data, size);
+          total_size += size;
+        }
+#endif          
+        break;
+        case OGGPLAY_CMML:
+          if (oggplay_callback_info_get_required(track_info[i]) > 0)
+            printf("%s\n", oggplay_callback_info_get_text_data(headers[0]));
+          break;
+
+        case OGGPLAY_KATE:
+          required = oggplay_callback_info_get_required(track_info[i]);
+          for (j = 0; j < required; j++) {
+            printf("[%d] [duration %ld] %s\n",
+                i,
+                oggplay_callback_info_get_record_size(headers[j]),
+                oggplay_callback_info_get_text_data(headers[j]));
+          }
+          break;
+
+        default:
+          break;
+      }
+    }
+  
+    n_frames++;
+#ifdef DEBUG
+    total_audio_bytes += bytes_per_frame;
+    printf("Processing frame: %d | audio B/s: %d | average audio B/s %f | targetaudio rate %d B/s\n", n_frames, bytes_per_frame, (float)(total_audio_bytes/n_frames), target_audio_rate); 
+    bytes_per_frame = 0;
+#endif    
+#if DISPLAY_FRAMES
+#if USE_AUDIO
+    ioctl(snd_fd, SNDCTL_DSP_GETOPTR, &tsc);
+#endif
+    glutPostRedisplay();
+    //show_window();
+#endif
+    oggplay_buffer_release (player, track_info);
+  //}
+}
+
+typedef enum {
+  SEEK_FORWARD,
+  SEEK_BACKWARD
+} MessageEnum;
+
+MessageEnum         msg;
+static sem_t        msg_sem;
+
+
+void key_pressed(unsigned char k, int a, int b) {
+
+  if (k == 'q') {
+#if DISPLAY_FRAMES
+    glutDestroyWindow(window);
+#endif
+    if (texture_bits != NULL) {
+      free(texture_bits);
+    }
+    oggplay_close(player);
+    exit(0);
+  } else if (k == 'l') {
+    msg = SEEK_FORWARD;
+    sem_post(&msg_sem);
+  } else if (k == 'k') {
+    msg = SEEK_BACKWARD;
+    sem_post(&msg_sem);
+  }
+  
+}
+
+#if DISPLAY_FRAMES
+void show_window(void) {
+
+  if (texture_bits != NULL) 
+  {
+
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture_width, 
+                    texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 
+                    texture_bits);
+
+  }
+  
+  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+  glBegin(GL_QUADS);
+  glTexCoord2f(0.0, texture_hscale);
+  glVertex2f(-1,-1);
+  glTexCoord2f(texture_wscale, texture_hscale);
+  glVertex2f(1,-1);
+  glTexCoord2f(texture_wscale, 0.0);
+  glVertex2f(1,1);
+  glTexCoord2f(0.0, 0.0);
+  glVertex2f(-1,1);
+  glEnd();
+  glutSwapBuffers();
+
+}
+#endif
+
+static int              saved_avail = 0;
+
+void *drive_decoding(void *arg) {
+
+  while (1) { 
+    OggPlayErrorCode r;
+    int avail;
+
+    if (sem_trywait(&msg_sem) == 0) {
+      if (msg == SEEK_FORWARD) {
+        if (oggplay_seek(player, ld_time + 5000) == E_OGGPLAY_CANT_SEEK) {
+          printf("can't seek forwards!\n");
+        }
+      } else if (msg == SEEK_BACKWARD) {
+        if (oggplay_seek(player, ld_time - 5000) == E_OGGPLAY_CANT_SEEK) {
+          printf("cant seek backwards!\n");
+        }
+      }
+      msg = 0;
+    }
+    
+    r = E_OGGPLAY_TIMEOUT;
+    while (r == E_OGGPLAY_TIMEOUT) {
+      r = oggplay_step_decoding(player);
+    }
+    
+    avail = oggplay_get_available(player);
+    if (avail != saved_avail) {
+      saved_avail = avail;
+      //printf("available: %d\n", avail);
+    }
+
+
+    if (r != E_OGGPLAY_CONTINUE && r != E_OGGPLAY_USER_INTERRUPT) {
+      printf("hmm, totally bogus, dude.  r is %d\n", r);
+      // wait for display thread to finish
+      sem_wait(&stop_sem);
+#if DISPLAY_FRAMES
+      glutDestroyWindow(window);
+#endif
+      pthread_exit(NULL);
+    }
+  }
+}
+
+int
+main (int argc, char * argv[]) {
+
+  OggPlayReader * reader;
+  int             i;
+  pthread_t       thread;
+
+  if (argc < 2) {
+    printf ("please provide a filename\n");
+    exit (1);
+  }
+ 
+  if (strncmp(argv[1], "http://", 7) == 0) {
+    reader = oggplay_tcp_reader_new(argv[1], NULL, 0);
+  } else {
+    reader = oggplay_file_reader_new(argv[1]);
+  }
+
+  player = oggplay_open_with_reader(reader);
+
+  if (player == NULL) {
+    printf ("could not initialise oggplay with this file\n");
+    exit (1);
+  }
+
+  printf ("there are %d tracks\n", oggplay_get_num_tracks (player));
+ 
+  video_track = -1; 
+  for (i = 0; i < oggplay_get_num_tracks (player); i++) {
+    printf("Track %d is of type %s\n", i, 
+                    oggplay_get_track_typename (player, i));
+    if (oggplay_get_track_type (player, i) == OGGZ_CONTENT_THEORA) {
+      int ret;
+      oggplay_set_callback_num_frames (player, i, 1);
+      video_track = i;
+      ret = oggplay_get_video_fps(player, i , &fps_denom, &fps_num);
+    }
+    else if 
+    (
+      oggplay_get_track_type (player, i) == OGGZ_CONTENT_VORBIS
+      ||
+      oggplay_get_track_type (player, i) == OGGZ_CONTENT_SPEEX
+    ) 
+    {
+      int ret;
+      audio_track = i;      
+      oggplay_set_offset(player, i, 250L);
+      ret = oggplay_get_audio_samplerate(player, i , &rate);
+      ret = oggplay_get_audio_channels(player, i, &channels);
+      printf("samplerate: %d channels: %d\n", rate, channels);
+    }
+    else if (oggplay_get_track_type (player, i) == OGGZ_CONTENT_KATE) {
+      const char *category = "<unknown>", *language = "<unknown>";
+      int ret = oggplay_get_kate_category(player, i, &category);
+      ret = oggplay_get_kate_language(player, i, &language);
+      printf("category %s, language %s\n", category, language);
+    }
+
+    if (oggplay_set_track_active(player, i) < 0) {
+      printf("\tNote: Could not set this track active!\n");
+    }
+  }
+
+  if (video_track == -1) {
+    oggplay_set_callback_num_frames(player, audio_track, 2048);
+  }
+
+#if DISPLAY_FRAMES
+  glutInit(&argc, argv);
+  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
+  glutInitWindowPosition(100, 100);
+  glutInitWindowSize(400, 400);
+#endif
+  window_width = 400;
+  window_height = 400;
+#if DISPLAY_FRAMES
+  window = glutCreateWindow("glut player");
+#endif
+
+  oggplay_use_buffer(player, 20);
+  
+  sem_init(&stop_sem, 1, 1);
+  sem_wait(&stop_sem);
+
+  sem_init(&msg_sem, 1, 1);
+  sem_wait(&msg_sem);
+  
+  pthread_create(&thread, NULL, drive_decoding, NULL);
+  
+#if DISPLAY_FRAMES
+  glutIdleFunc(&display_frame);  
+  glutDisplayFunc(&show_window);
+  glutKeyboardFunc(&key_pressed);
+  //glutDisplayFunc(&empty);
+
+  glEnable(GL_TEXTURE_2D);
+  glDisable(GL_CULL_FACE);
+  glBindTexture(GL_TEXTURE_2D, texture);
+  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+  glGenTextures(1, &texture);
+
+  glutMainLoop();
+
+#else
+  for (i = 0; i < 100; i++) {
+    display_frame();
+  }
+  while (1) {
+    key_pressed('l', 0, 0);
+    for (i = 0; i < 10; i++) {
+      display_frame();
+    }
+    key_pressed('l', 0, 0);
+    for (i = 0; i < 10; i++) {
+      display_frame();
+    }
+    key_pressed('l', 0, 0);
+    for (i = 0; i < 100; i++) {
+      display_frame();
+    }
+    key_pressed('k', 0, 0);
+    for (i = 0; i < 100; i++) {
+      display_frame();
+    }
+  }
+ key_pressed('q', 0, 0);
+#endif
+ 
+  printf("there were %d frames\n", n_frames);
+  
+  return 0;
+}
+

Copied: liboggplay/trunk/src/examples/mac/English.lproj/gplayer.nib/classes.nib (from rev 3577, liboggplay/trunk/src/tools/mac/English.lproj/gplayer.nib/classes.nib)
===================================================================
--- liboggplay/trunk/src/examples/mac/English.lproj/gplayer.nib/classes.nib	                        (rev 0)
+++ liboggplay/trunk/src/examples/mac/English.lproj/gplayer.nib/classes.nib	2008-05-02 04:35:28 UTC (rev 3579)
@@ -0,0 +1,4 @@
+{
+IBClasses = ();
+IBVersion = 1;
+}

Copied: liboggplay/trunk/src/examples/mac/English.lproj/gplayer.nib/info.nib (from rev 3577, liboggplay/trunk/src/tools/mac/English.lproj/gplayer.nib/info.nib)
===================================================================
--- liboggplay/trunk/src/examples/mac/English.lproj/gplayer.nib/info.nib	                        (rev 0)
+++ liboggplay/trunk/src/examples/mac/English.lproj/gplayer.nib/info.nib	2008-05-02 04:35:28 UTC (rev 3579)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IBDocumentLocation</key>
+	<string>69 64 356 240 0 0 1280 1002 </string>
+	<key>IBEditorPositions</key>
+	<dict>
+		<key>29</key>
+		<string>100 368 151 44 0 0 1280 1002 </string>
+	</dict>
+	<key>IBFramework Version</key>
+	<string>446.1</string>
+	<key>IBOldestOS</key>
+	<integer>3</integer>
+	<key>IBOpenObjects</key>
+	<array>
+		<integer>166</integer>
+	</array>
+	<key>IBSystem Version</key>
+	<string>8P135</string>
+	<key>targetFramework</key>
+	<string>IBCarbonFramework</string>
+</dict>
+</plist>

Copied: liboggplay/trunk/src/examples/mac/English.lproj/gplayer.nib/objects.xib (from rev 3577, liboggplay/trunk/src/tools/mac/English.lproj/gplayer.nib/objects.xib)
===================================================================
--- liboggplay/trunk/src/examples/mac/English.lproj/gplayer.nib/objects.xib	                        (rev 0)
+++ liboggplay/trunk/src/examples/mac/English.lproj/gplayer.nib/objects.xib	2008-05-02 04:35:28 UTC (rev 3579)
@@ -0,0 +1,116 @@
+<?xml version="1.0" standalone="yes"?>
+<object class="NSIBObjectData">
+  <string name="targetFramework">IBCarbonFramework</string>
+  <object name="rootObject" class="NSCustomObject" id="1">
+    <string name="customClass">NSApplication</string>
+  </object>
+  <array count="14" name="allObjects">
+    <object class="IBCarbonMenu" id="29">
+      <string name="title">main</string>
+      <array count="2" name="items">
+        <object class="IBCarbonMenuItem" id="185">
+          <string name="title">gplayer</string>
+          <object name="submenu" class="IBCarbonMenu" id="184">
+            <string name="title">gplayer</string>
+            <array count="1" name="items">
+              <object class="IBCarbonMenuItem" id="187">
+                <string name="title">About gplayer</string>
+                <int name="keyEquivalentModifier">0</int>
+                <ostype name="command">abou</ostype>
+              </object>
+            </array>
+            <string name="name">_NSAppleMenu</string>
+          </object>
+        </object>
+        <object class="IBCarbonMenuItem" id="192">
+          <string name="title">Window</string>
+          <object name="submenu" class="IBCarbonMenu" id="195">
+            <string name="title">Window</string>
+            <array count="6" name="items">
+              <object class="IBCarbonMenuItem" id="190">
+                <boolean name="dynamic">TRUE</boolean>
+                <string name="title">Minimize</string>
+                <string name="keyEquivalent">m</string>
+                <ostype name="command">mini</ostype>
+              </object>
+              <object class="IBCarbonMenuItem" id="191">
+                <boolean name="dynamic">TRUE</boolean>
+                <string name="title">Minimize All</string>
+                <string name="keyEquivalent">m</string>
+                <int name="keyEquivalentModifier">1572864</int>
+                <ostype name="command">mina</ostype>
+              </object>
+              <object class="IBCarbonMenuItem" id="197">
+                <string name="title">Zoom</string>
+                <ostype name="command">zoom</ostype>
+              </object>
+              <object class="IBCarbonMenuItem" id="194">
+                <boolean name="separator">TRUE</boolean>
+              </object>
+              <object class="IBCarbonMenuItem" id="196">
+                <boolean name="dynamic">TRUE</boolean>
+                <string name="title">Bring All to Front</string>
+                <ostype name="command">bfrt</ostype>
+              </object>
+              <object class="IBCarbonMenuItem" id="193">
+                <boolean name="dynamic">TRUE</boolean>
+                <string name="title">Arrange in Front</string>
+                <int name="keyEquivalentModifier">1572864</int>
+                <ostype name="command">frnt</ostype>
+              </object>
+            </array>
+            <string name="name">_NSWindowsMenu</string>
+          </object>
+        </object>
+      </array>
+      <string name="name">_NSMainMenu</string>
+    </object>
+    <object class="IBCarbonWindow" id="166">
+      <string name="windowRect">210 252 570 732 </string>
+      <string name="title">Window</string>
+      <object name="rootControl" class="IBCarbonRootControl" id="167">
+        <string name="bounds">0 0 360 480 </string>
+      </object>
+      <boolean name="liveResize">TRUE</boolean>
+      <int name="windowPosition">4</int>
+      <boolean name="isConstrained">FALSE</boolean>
+    </object>
+    <reference idRef="167"/>
+    <reference idRef="184"/>
+    <reference idRef="185"/>
+    <reference idRef="187"/>
+    <reference idRef="190"/>
+    <reference idRef="191"/>
+    <reference idRef="192"/>
+    <reference idRef="193"/>
+    <reference idRef="194"/>
+    <reference idRef="195"/>
+    <reference idRef="196"/>
+    <reference idRef="197"/>
+  </array>
+  <array count="14" name="allParents">
+    <reference idRef="1"/>
+    <reference idRef="1"/>
+    <reference idRef="166"/>
+    <reference idRef="185"/>
+    <reference idRef="29"/>
+    <reference idRef="184"/>
+    <reference idRef="195"/>
+    <reference idRef="195"/>
+    <reference idRef="29"/>
+    <reference idRef="195"/>
+    <reference idRef="195"/>
+    <reference idRef="192"/>
+    <reference idRef="195"/>
+    <reference idRef="195"/>
+  </array>
+  <dictionary count="3" name="nameTable">
+    <string>Files Owner</string>
+    <reference idRef="1"/>
+    <string>MenuBar</string>
+    <reference idRef="29"/>
+    <string>ViewWindow</string>
+    <reference idRef="166"/>
+  </dictionary>
+  <unsigned_int name="nextObjectID">216</unsigned_int>
+</object>

Copied: liboggplay/trunk/src/examples/mac/Info.plist (from rev 3577, liboggplay/trunk/src/tools/mac/Info.plist)
===================================================================
--- liboggplay/trunk/src/examples/mac/Info.plist	                        (rev 0)
+++ liboggplay/trunk/src/examples/mac/Info.plist	2008-05-02 04:35:28 UTC (rev 3579)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleExecutable</key>
+	<string>gplayer</string>
+	<key>CFBundleIconFile</key>
+	<string></string>
+	<key>CFBundleIdentifier</key>
+	<string>com.annodex.gplayer</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundlePackageType</key>
+	<string>APPL</string>
+	<key>CFBundleSignature</key>
+	<string>AXVM</string>
+	<key>CFBundleVersion</key>
+	<string>1.0</string>
+	<key>CSResourcesFileMapped</key>
+	<true/>
+</dict>
+</plist>

Copied: liboggplay/trunk/src/examples/mac/gplayer.xcodeproj/project.pbxproj (from rev 3577, liboggplay/trunk/src/tools/mac/gplayer.xcodeproj/project.pbxproj)
===================================================================
--- liboggplay/trunk/src/examples/mac/gplayer.xcodeproj/project.pbxproj	                        (rev 0)
+++ liboggplay/trunk/src/examples/mac/gplayer.xcodeproj/project.pbxproj	2008-05-02 04:35:28 UTC (rev 3579)
@@ -0,0 +1,339 @@
+// !$*UTF8*$!
+{
+	archiveVersion = 1;
+	classes = {
+	};
+	objectVersion = 42;
+	objects = {
+
+/* Begin PBXBuildFile section */
+		2C0FCDE40BF2ADE30082632E /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 2C0FCDE30BF2ADE30082632E /* Info.plist */; };
+		2C1B4BD70BDD8BBE003DE877 /* liboggplay.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C1B4AE30BDC9C06003DE877 /* liboggplay.dylib */; };
+		2C1B4BFF0BDD92D4003DE877 /* liboggz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C1B4BE10BDD8ED6003DE877 /* liboggz.dylib */; };
+		2C1B4C090BDD964C003DE877 /* libogg in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C1B4C080BDD964C003DE877 /* libogg */; };
+		2C5798AE0BE06EC900D285C7 /* libspeex.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C5798AB0BE06EC900D285C7 /* libspeex.dylib */; };
+		2C5798AF0BE06EC900D285C7 /* libtheora in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C5798AC0BE06EC900D285C7 /* libtheora */; };
+		2C5798B00BE06EC900D285C7 /* libvorbis in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C5798AD0BE06EC900D285C7 /* libvorbis */; };
+		2C6733C80BF2A6760036EADB /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C6733C70BF2A6760036EADB /* Carbon.framework */; };
+		2C6733CB0BF2A6840036EADB /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C6733CA0BF2A6840036EADB /* OpenGL.framework */; };
+		2C6733DA0BF2A6D60036EADB /* mac-player.c in Sources */ = {isa = PBXBuildFile; fileRef = 2C6733D90BF2A6D60036EADB /* mac-player.c */; };
+		2C83ADB90BEEB709004C14F4 /* AGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C83ADB80BEEB709004C14F4 /* AGL.framework */; };
+		2CA20F7A0BDD9DB7003EE25C /* libfishsound.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CA20F790BDD9DB7003EE25C /* libfishsound.dylib */; };
+		2CA20F950BDD9F3F003EE25C /* libvorbisenc in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CA20F940BDD9F3F003EE25C /* libvorbisenc */; };
+		8D0C4E8E0486CD37000505A6 /* gplayer.nib in Resources */ = {isa = PBXBuildFile; fileRef = 02345980000FD03B11CA0E72 /* gplayer.nib */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+		1870340FFE93FCAF11CA0CD7 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/gplayer.nib; sourceTree = "<group>"; };
+		2C0FCDE30BF2ADE30082632E /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
+		2C1B4AE30BDC9C06003DE877 /* liboggplay.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = liboggplay.dylib; path = ../../liboggplay/.libs/liboggplay.dylib; sourceTree = SOURCE_ROOT; };
+		2C1B4BE10BDD8ED6003DE877 /* liboggz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = liboggz.dylib; path = /usr/local/lib/liboggz.dylib; sourceTree = "<absolute>"; };
+		2C1B4C080BDD964C003DE877 /* libogg */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libogg; path = /usr/local/lib/libogg; sourceTree = "<absolute>"; };
+		2C5798AB0BE06EC900D285C7 /* libspeex.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libspeex.dylib; path = /usr/local/lib/libspeex.dylib; sourceTree = "<absolute>"; };
+		2C5798AC0BE06EC900D285C7 /* libtheora */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libtheora; path = /usr/local/lib/libtheora; sourceTree = "<absolute>"; };
+		2C5798AD0BE06EC900D285C7 /* libvorbis */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libvorbis; path = /usr/local/lib/libvorbis; sourceTree = "<absolute>"; };
+		2C6733C70BF2A6760036EADB /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
+		2C6733CA0BF2A6840036EADB /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; };
+		2C6733D90BF2A6D60036EADB /* mac-player.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = "mac-player.c"; path = "../mac-player.c"; sourceTree = "<group>"; };
+		2C83ADB80BEEB709004C14F4 /* AGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AGL.framework; path = /System/Library/Frameworks/AGL.framework; sourceTree = "<absolute>"; };
+		2CA20F790BDD9DB7003EE25C /* libfishsound.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libfishsound.dylib; path = /usr/local/lib/libfishsound.dylib; sourceTree = "<absolute>"; };
+		2CA20F940BDD9F3F003EE25C /* libvorbisenc */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libvorbisenc; path = /usr/local/lib/libvorbisenc; sourceTree = "<absolute>"; };
+		8D0C4E970486CD37000505A6 /* gplayer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = gplayer.app; sourceTree = BUILT_PRODUCTS_DIR; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+		8D0C4E910486CD37000505A6 /* Frameworks */ = {
+			isa = PBXFrameworksBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				2C1B4BD70BDD8BBE003DE877 /* liboggplay.dylib in Frameworks */,
+				2C1B4BFF0BDD92D4003DE877 /* liboggz.dylib in Frameworks */,
+				2C1B4C090BDD964C003DE877 /* libogg in Frameworks */,
+				2CA20F7A0BDD9DB7003EE25C /* libfishsound.dylib in Frameworks */,
+				2CA20F950BDD9F3F003EE25C /* libvorbisenc in Frameworks */,
+				2C5798AE0BE06EC900D285C7 /* libspeex.dylib in Frameworks */,
+				2C5798AF0BE06EC900D285C7 /* libtheora in Frameworks */,
+				2C5798B00BE06EC900D285C7 /* libvorbis in Frameworks */,
+				2C83ADB90BEEB709004C14F4 /* AGL.framework in Frameworks */,
+				2C6733C80BF2A6760036EADB /* Carbon.framework in Frameworks */,
+				2C6733CB0BF2A6840036EADB /* OpenGL.framework in Frameworks */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+		195DF8CFFE9D517E11CA2CBB /* Products */ = {
+			isa = PBXGroup;
+			children = (
+				8D0C4E970486CD37000505A6 /* gplayer.app */,
+			);
+			name = Products;
+			sourceTree = "<group>";
+		};
+		20286C29FDCF999611CA2CEA /* gplayer */ = {
+			isa = PBXGroup;
+			children = (
+				20286C2AFDCF999611CA2CEA /* Sources */,
+				20286C2CFDCF999611CA2CEA /* Resources */,
+				20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */,
+				195DF8CFFE9D517E11CA2CBB /* Products */,
+			);
+			name = gplayer;
+			sourceTree = "<group>";
+		};
+		20286C2AFDCF999611CA2CEA /* Sources */ = {
+			isa = PBXGroup;
+			children = (
+				2C6733D90BF2A6D60036EADB /* mac-player.c */,
+			);
+			name = Sources;
+			sourceTree = "<group>";
+		};
+		20286C2CFDCF999611CA2CEA /* Resources */ = {
+			isa = PBXGroup;
+			children = (
+				2C0FCDE30BF2ADE30082632E /* Info.plist */,
+				02345980000FD03B11CA0E72 /* gplayer.nib */,
+			);
+			name = Resources;
+			sourceTree = "<group>";
+		};
+		20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */ = {
+			isa = PBXGroup;
+			children = (
+				2C6733C70BF2A6760036EADB /* Carbon.framework */,
+				2C83ADB80BEEB709004C14F4 /* AGL.framework */,
+				2C6733CA0BF2A6840036EADB /* OpenGL.framework */,
+				2C1B4C080BDD964C003DE877 /* libogg */,
+				2C5798AC0BE06EC900D285C7 /* libtheora */,
+				2C5798AD0BE06EC900D285C7 /* libvorbis */,
+				2CA20F940BDD9F3F003EE25C /* libvorbisenc */,
+				2C1B4BE10BDD8ED6003DE877 /* liboggz.dylib */,
+				2C1B4AE30BDC9C06003DE877 /* liboggplay.dylib */,
+				2C5798AB0BE06EC900D285C7 /* libspeex.dylib */,
+				2CA20F790BDD9DB7003EE25C /* libfishsound.dylib */,
+			);
+			name = "External Frameworks and Libraries";
+			sourceTree = "<group>";
+		};
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+		8D0C4E890486CD37000505A6 /* gplayer */ = {
+			isa = PBXNativeTarget;
+			buildConfigurationList = C0E91AC508A95435008D54AB /* Build configuration list for PBXNativeTarget "gplayer" */;
+			buildPhases = (
+				8D0C4E8C0486CD37000505A6 /* Resources */,
+				8D0C4E8F0486CD37000505A6 /* Sources */,
+				8D0C4E910486CD37000505A6 /* Frameworks */,
+			);
+			buildRules = (
+			);
+			dependencies = (
+			);
+			name = gplayer;
+			productInstallPath = "$(HOME)/Applications";
+			productName = gplayer;
+			productReference = 8D0C4E970486CD37000505A6 /* gplayer.app */;
+			productType = "com.apple.product-type.application";
+		};
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+		20286C28FDCF999611CA2CEA /* Project object */ = {
+			isa = PBXProject;
+			buildConfigurationList = C0E91AC908A95435008D54AB /* Build configuration list for PBXProject "gplayer" */;
+			hasScannedForEncodings = 1;
+			mainGroup = 20286C29FDCF999611CA2CEA /* gplayer */;
+			projectDirPath = "";
+			targets = (
+				8D0C4E890486CD37000505A6 /* gplayer */,
+			);
+		};
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+		8D0C4E8C0486CD37000505A6 /* Resources */ = {
+			isa = PBXResourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				8D0C4E8E0486CD37000505A6 /* gplayer.nib in Resources */,
+				2C0FCDE40BF2ADE30082632E /* Info.plist in Resources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+		8D0C4E8F0486CD37000505A6 /* Sources */ = {
+			isa = PBXSourcesBuildPhase;
+			buildActionMask = 2147483647;
+			files = (
+				2C6733DA0BF2A6D60036EADB /* mac-player.c in Sources */,
+			);
+			runOnlyForDeploymentPostprocessing = 0;
+		};
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+		02345980000FD03B11CA0E72 /* gplayer.nib */ = {
+			isa = PBXVariantGroup;
+			children = (
+				1870340FFE93FCAF11CA0CD7 /* English */,
+			);
+			name = gplayer.nib;
+			sourceTree = "<group>";
+		};
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+		C0E91AC608A95435008D54AB /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ARCHS = "$(NATIVE_ARCH)";
+				COPY_PHASE_STRIP = NO;
+				GCC_DYNAMIC_NO_PIC = YES;
+				GCC_ENABLE_FIX_AND_CONTINUE = YES;
+				GCC_MODEL_TUNING = G5;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_PRECOMPILE_PREFIX_HEADER = NO;
+				GCC_PREFIX_HEADER = "";
+				GCC_WARN_UNINITIALIZED_AUTOS = NO;
+				GCC_WARN_UNUSED_FUNCTION = NO;
+				GCC_WARN_UNUSED_LABEL = NO;
+				GCC_WARN_UNUSED_PARAMETER = NO;
+				GCC_WARN_UNUSED_VALUE = NO;
+				GCC_WARN_UNUSED_VARIABLE = NO;
+				GENERATE_PKGINFO_FILE = NO;
+				HEADER_SEARCH_PATHS = (
+					../../..,
+					../../../include,
+					/usr/local/include,
+				);
+				INFOPLIST_EXPAND_BUILD_SETTINGS = YES;
+				INFOPLIST_FILE = Info.plist;
+				INSTALL_PATH = "$(HOME)/Applications";
+				LIBRARY_SEARCH_PATHS = (
+					"$(LIBRARY_SEARCH_PATHS)",
+					"$(SRCROOT)/../../liboggplay/.libs",
+					/usr/local/lib,
+				);
+				PREBINDING = NO;
+				PRODUCT_NAME = gplayer;
+				WRAPPER_EXTENSION = app;
+				ZERO_LINK = NO;
+			};
+			name = Debug;
+		};
+		C0E91AC708A95435008D54AB /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ARCHS = "$(NATIVE_ARCH)";
+				GCC_DYNAMIC_NO_PIC = YES;
+				GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
+				GCC_MODEL_TUNING = G5;
+				GCC_PRECOMPILE_PREFIX_HEADER = NO;
+				GCC_PREFIX_HEADER = "";
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GENERATE_PKGINFO_FILE = NO;
+				HEADER_SEARCH_PATHS = (
+					../../..,
+					../../../include,
+					/usr/local/include,
+				);
+				INFOPLIST_EXPAND_BUILD_SETTINGS = YES;
+				INFOPLIST_FILE = Info.plist;
+				INSTALL_PATH = "$(HOME)/Applications";
+				LIBRARY_SEARCH_PATHS = (
+					"$(LIBRARY_SEARCH_PATHS)",
+					"$(SRCROOT)/../../liboggplay/.libs",
+					/usr/local/lib,
+				);
+				PREBINDING = NO;
+				PRODUCT_NAME = gplayer;
+				STRIP_INSTALLED_PRODUCT = YES;
+				WRAPPER_EXTENSION = app;
+				ZERO_LINK = NO;
+			};
+			name = Release;
+		};
+		C0E91ACA08A95435008D54AB /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				GCC_CW_ASM_SYNTAX = NO;
+				GCC_ENABLE_CPP_EXCEPTIONS = YES;
+				GCC_ENABLE_CPP_RTTI = YES;
+				GCC_ENABLE_PASCAL_STRINGS = NO;
+				GCC_MODEL_TUNING = G5;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				GCC_WARN_ABOUT_POINTER_SIGNEDNESS = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_MISSING_PARENTHESES = YES;
+				GCC_WARN_SHADOW = YES;
+				GCC_WARN_SIGN_COMPARE = YES;
+				GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GCC_WARN_UNKNOWN_PRAGMAS = YES;
+				GCC_WARN_UNUSED_FUNCTION = YES;
+				GCC_WARN_UNUSED_LABEL = YES;
+				GCC_WARN_UNUSED_PARAMETER = YES;
+				GCC_WARN_UNUSED_VALUE = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				PREBINDING = NO;
+				SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
+				STRIP_INSTALLED_PRODUCT = NO;
+			};
+			name = Debug;
+		};
+		C0E91ACB08A95435008D54AB /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				GCC_CW_ASM_SYNTAX = NO;
+				GCC_ENABLE_CPP_EXCEPTIONS = YES;
+				GCC_ENABLE_CPP_RTTI = YES;
+				GCC_ENABLE_PASCAL_STRINGS = NO;
+				GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
+				GCC_WARN_ABOUT_POINTER_SIGNEDNESS = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_MISSING_PARENTHESES = YES;
+				GCC_WARN_SHADOW = YES;
+				GCC_WARN_SIGN_COMPARE = YES;
+				GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
+				GCC_WARN_UNINITIALIZED_AUTOS = YES;
+				GCC_WARN_UNKNOWN_PRAGMAS = YES;
+				GCC_WARN_UNUSED_FUNCTION = YES;
+				GCC_WARN_UNUSED_LABEL = YES;
+				GCC_WARN_UNUSED_PARAMETER = YES;
+				GCC_WARN_UNUSED_VALUE = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				PREBINDING = NO;
+				SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
+			};
+			name = Release;
+		};
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+		C0E91AC508A95435008D54AB /* Build configuration list for PBXNativeTarget "gplayer" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				C0E91AC608A95435008D54AB /* Debug */,
+				C0E91AC708A95435008D54AB /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		C0E91AC908A95435008D54AB /* Build configuration list for PBXProject "gplayer" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				C0E91ACA08A95435008D54AB /* Debug */,
+				C0E91ACB08A95435008D54AB /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+/* End XCConfigurationList section */
+	};
+	rootObject = 20286C28FDCF999611CA2CEA /* Project object */;
+}

Copied: liboggplay/trunk/src/examples/mac-player.c (from rev 3577, liboggplay/trunk/src/tools/mac-player.c)
===================================================================
--- liboggplay/trunk/src/examples/mac-player.c	                        (rev 0)
+++ liboggplay/trunk/src/examples/mac-player.c	2008-05-02 04:35:28 UTC (rev 3579)
@@ -0,0 +1,461 @@
+#include <AGL/agl.h>
+#include <pthread.h>
+#include <oggplay/oggplay.h>
+
+#define N_OGG_BUFS    20
+
+static OggPlayReader    *reader       = NULL;
+static OggPlay          *player       = NULL;
+static IBNibRef          nibRef       = NULL;
+static AGLContext        aglContext   = NULL;
+static MPSemaphoreID     sem          = NULL;
+static bool              run_display  = TRUE;
+static pthread_t         decode_thread;
+static pthread_t         display_thread;
+static WindowRef         window;
+static int               n_frames     = 0;
+static GLuint            texture      = 0;
+static unsigned char    *texture_bits = NULL;
+static int               texture_width;
+static int               texture_height;
+static float             texture_wscale;
+static float             texture_hscale;
+//static Rect              window_bounds;
+
+
+// All GL calls must be made in the same thread, so any initialisations that
+// have a corresponding shutdown must be performed by the display thread
+// (rather than at the end of the main function, where most other shutdowns
+// are being handled).
+bool
+init_gl() {
+  CGrafPtr        port;
+  AGLPixelFormat  aglPixelFormat;
+  GLint           pixelAttr[] = {
+    AGL_RGBA,
+    AGL_DOUBLEBUFFER,
+    AGL_PIXEL_SIZE, 32,
+    AGL_ACCELERATED,
+    AGL_NONE
+  };
+
+  // Initialise the AGL drawing context and attach it to the window's graphics port.
+  port = GetWindowPort(window);
+  if (port == NULL) {
+    printf("GetWindowPort failed\n");
+    return FALSE;
+  }
+
+  aglPixelFormat = aglChoosePixelFormat(NULL, 0, pixelAttr);
+  if (aglPixelFormat == NULL) {
+    printf("aglChoosePixelFormat failed\n");
+    return FALSE;
+  }
+
+  aglContext = aglCreateContext(aglPixelFormat, NULL);
+  aglDestroyPixelFormat(aglPixelFormat);
+  if (aglContext == NULL) {
+    printf("aglCreateContext failed\n");
+    return FALSE;
+  }
+
+  if (!aglSetDrawable(aglContext, port)) {
+    printf("aglSetDrawable failed\n");
+    return FALSE;
+  }
+
+  if (!aglSetCurrentContext(aglContext)) {
+    printf("aglSetCurrentContext failed\n");
+    return FALSE;
+  }
+
+  // Prepare GL for drawing a 2d texture (image).
+  glEnable(GL_TEXTURE_2D);
+  glDisable(GL_CULL_FACE);
+  glGenTextures(1, &texture);
+  glBindTexture(GL_TEXTURE_2D, texture);
+  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+  if (glGetError() != GL_NO_ERROR) {
+    printf("An OpenGL function call failed\n");
+    return FALSE;
+  }
+  return TRUE;
+}
+
+
+static void
+update_gl_texture()
+{
+  if (texture_bits != NULL) {
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture_width,
+        texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture_bits);
+  }
+  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+  glBegin(GL_QUADS);
+  glTexCoord2f(0.0, texture_hscale);
+  glVertex2f(-1,-1);
+  glTexCoord2f(texture_wscale, texture_hscale);
+  glVertex2f(1,-1);
+  glTexCoord2f(texture_wscale, 0.0);
+  glVertex2f(1,1);
+  glTexCoord2f(0.0, 0.0);
+  glVertex2f(-1,1);
+  glEnd();
+  aglSwapBuffers(aglContext);
+}
+
+
+static void
+shutdown_gl() {
+  if (texture != 0)
+    glDeleteTextures(1, &texture);
+  if (aglContext != NULL)
+    aglDestroyContext(aglContext);
+}
+
+
+static void
+handle_video_data(int track_num, OggPlayVideoData *video_data) {
+  int                 y_width;
+  int                 y_height;
+  int                 uv_width;
+  int                 uv_height;
+  int                 po2_width;
+  int                 po2_height;
+  OggPlayYUVChannels  yuv;
+  OggPlayRGBChannels  rgb;
+
+  oggplay_get_video_y_size(player, track_num, &y_width, &y_height);
+/*
+  if (y_width != window_bounds.right - window_bounds.left) {
+    window_bounds.right = window_bounds.left + y_width;
+    window_bounds.bottom = window_bounds.top + y_height;
+    SetWindowBounds(window, kWindowContentRgn, &window_bounds);
+  }
+*/
+
+  oggplay_get_video_uv_size(player, track_num, &uv_width, &uv_height);
+  assert(uv_width == y_width / 2);
+  assert(uv_height == y_height / 2);
+  
+  for (po2_width = 1; po2_width < y_width; po2_width <<= 1);
+  for (po2_height = 1; po2_height < y_height; po2_height <<= 1);
+  texture_wscale = (float)y_width / po2_width;
+  texture_hscale = (float)y_height / po2_height;
+
+  if (texture_bits == NULL) {
+    texture_bits = calloc(1, po2_width * po2_height * 4);
+    texture_width = po2_width;
+    texture_height = po2_height;    
+  } else if (texture_width != po2_width || texture_height != po2_height) {
+    free(texture_bits);
+    texture_bits = calloc(1, po2_width * po2_height * 4);
+    texture_width = po2_width;
+    texture_height = po2_height;
+  }
+  
+  yuv.ptry = video_data->y;
+  yuv.ptru = video_data->u;
+  yuv.ptrv = video_data->v;
+  yuv.uv_width = uv_width;
+  yuv.uv_height = uv_height;  
+  yuv.y_width = y_width;
+  yuv.y_height = y_height;  
+  
+  rgb.ptro = texture_bits;
+  rgb.rgb_width = texture_width;
+  rgb.rgb_height = texture_height;  
+  
+  oggplay_yuv2rgb(&yuv, &rgb);
+}
+
+
+static void *
+display_frame(void *arg) {
+#pragma unused(arg)
+  OggPlayDataHeader     **headers;
+  OggPlayVideoData       *video_data;
+  int                     required;
+  OggPlayDataType         type;
+  int                     num_tracks;
+  OggPlayCallbackInfo   **track_info;  
+  int                     i;
+  
+  if (!init_gl()) {
+    shutdown_gl();
+    return NULL;
+  }
+
+  num_tracks = oggplay_get_num_tracks(player);
+
+  // run_display will be set if the window is closed, so we can
+  // terminate this thread gracefully and perform appropriate shutdown.
+  while (run_display) {
+
+    track_info = oggplay_buffer_retrieve_next(player);
+    if (track_info == NULL) {
+      struct timespec ts;
+      ts.tv_nsec = 40000000;
+      nanosleep(&ts, NULL);
+      continue;
+    }
+
+    for (i = 0; i < num_tracks; i++) {
+      type = oggplay_callback_info_get_type(track_info[i]);
+      headers = oggplay_callback_info_get_headers(track_info[i]);
+      
+      switch (type) {
+        case OGGPLAY_INACTIVE:
+          break;
+
+        case OGGPLAY_YUV_VIDEO:
+          required = oggplay_callback_info_get_required(track_info[i]);
+          video_data = oggplay_callback_info_get_video_data(headers[0]);
+          handle_video_data(i, video_data);
+          break;
+
+        case OGGPLAY_FLOATS_AUDIO:
+          break;
+
+        case OGGPLAY_CMML:
+          if (oggplay_callback_info_get_required(track_info[i]) > 0)
+            printf("%s\n", oggplay_callback_info_get_text_data(headers[0]));
+          break;
+
+        case OGGPLAY_KATE:
+          required = oggplay_callback_info_get_required(track_info[i]);
+          for (j = 0; j < required; j++)
+            printf("[%d] %s\n", j, oggplay_callback_info_get_text_data(headers[j]));
+          break;
+
+        default:
+          break;
+      }
+    }
+    
+    update_gl_texture();
+    n_frames++;
+    //printf("%d\n", n_frames);
+
+    oggplay_buffer_release(player, track_info);
+    MPSignalSemaphore(sem);
+  }
+
+  shutdown_gl();
+  return NULL;
+}
+
+
+void *
+drive_decoding(void *arg) {
+#pragma unused(arg)
+  while (1) {
+    OggPlayErrorCode result;
+    MPWaitOnSemaphore(sem, kDurationForever);
+    result = oggplay_step_decoding(player);
+    if (result != E_OGGPLAY_CONTINUE && result != E_OGGPLAY_USER_INTERRUPT) {
+      printf("*** oggplay_step_decoding() failed in drive_decoding() ***\n");
+      return NULL;
+    }
+  }
+}
+
+
+// The window and app event handlers have been left as skeletons here in case
+// we ever want to add multiple windows or other application behaviours.
+static OSStatus
+WindowEventHandler(EventHandlerCallRef caller, EventRef event, void *arg) {
+#pragma unused(caller, arg)
+  OSStatus    result = eventNotHandledErr;
+  UInt32      class = GetEventClass(event);
+  UInt32      kind  = GetEventKind(event);
+
+  switch (class) {
+    case kEventClassWindow: {
+      WindowRef   winRef;
+      GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(winRef), NULL, &winRef);
+      switch (kind) {
+        case kEventWindowBoundsChanged:
+          //GetWindowBounds(window, kWindowContentRgn, &window_bounds);
+          break;
+        case kEventWindowClosed:
+          // Signal the display thread to shut down.
+          run_display = FALSE;
+          break;
+      } //switch (kind)
+      break;
+    } // case kEventClassWindow
+  } //switch (class)
+  return result;
+}
+
+static OSStatus
+AppEventHandler(EventHandlerCallRef caller, EventRef event, void *arg) {
+#pragma unused(caller, arg)
+  OSStatus    result = eventNotHandledErr;
+  UInt32      class = GetEventClass(event);
+  UInt32      kind  = GetEventKind(event);
+
+  switch (class) {
+    case kEventClassApplication: {
+      switch (kind) {
+        case kEventAppQuit:
+          // Signal the display thread to shut down.
+          run_display = FALSE;
+          break;
+      } // switch (kind)
+    } // case kEventClassApplication
+
+    case kEventClassCommand: {
+      HICommandExtended   cmd;
+      GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(cmd), NULL, &cmd);
+      switch (kind) {
+        case kEventCommandProcess: {
+          switch (cmd.commandID) {
+            case kHICommandOpen:
+              //-- file open handling would go here --
+              break;
+          } //switch (cmd.commandID)
+          break;
+        } // case kEventCommandProcess
+      } //switch (kind)
+      break;
+    } // case kEventClassCommand
+
+  } //switch (class)
+  return result;
+}
+
+
+static bool
+InitApp() {
+  EventTypeSpec     appEvents[] = {
+    { kEventClassApplication, kEventAppQuit        },
+    { kEventClassCommand,     kEventCommandProcess }
+  };
+  EventTypeSpec     winEvents[] = {
+    { kEventClassWindow, kEventWindowBoundsChanged },
+    { kEventClassWindow, kEventWindowClosed        }
+  };
+
+  // Create a Nib reference, passing the name of the nib file (without the .nib extension).
+  // CreateNibReference only searches in the application bundle.
+  if (CreateNibReference(CFSTR("gplayer"), &nibRef) != noErr) {
+    printf("CreateNibReference failed\n");
+    return FALSE;
+  }
+  
+  // Once the nib reference is created, set the menu bar.
+  if (SetMenuBarFromNib(nibRef, CFSTR("MenuBar")) != noErr) {
+    printf("SetMenuBarFromNib failed\n");
+    return FALSE;
+  }
+  
+  // Create a window, using the settings from the nib file. The default close event
+  // handler apparently releases the resources for this, so we don't need any calls
+  // to ReleaseWindow()... I hope.
+  if (CreateWindowFromNib(nibRef, CFSTR("ViewWindow"), &window) != noErr) {
+    printf("CreateWindowFromNib failed\n");
+    return FALSE;
+  }
+  //GetWindowBounds(window, kWindowContentRgn, &window_bounds);
+
+  // Install the window and application event handlers.
+  if (InstallApplicationEventHandler(NewEventHandlerUPP(AppEventHandler),
+              GetEventTypeCount(appEvents), appEvents, NULL, NULL) != noErr) {
+    printf("InstallApplicationEventHandler failed\n");
+    return FALSE;
+  }
+
+  if (InstallWindowEventHandler(window, NewEventHandlerUPP(WindowEventHandler),
+              GetEventTypeCount(winEvents), winEvents, NULL, NULL) != noErr) {
+    printf("InstallWindowEventHandler failed\n");
+    return FALSE;
+  }
+
+  // The window is hidden on creation, so show it.
+  ShowWindow(window);
+  return TRUE;
+}
+
+
+int
+main(int argc, char *argv[]) {
+  char *media;
+  int   i;
+
+  // Open the requested AXV file (use a default if not provided).
+  if (argc > 1) {
+    media = argv[1];
+  } else {
+    media = "http://media.annodex.net/cmmlwiki/SFD2005-Trailer.axv";
+    printf("No source provided; using default\n");
+  }
+  if (strncmp(media, "http://", 7) == 0) {
+    reader = oggplay_tcp_reader_new(media);
+  } else {
+    reader = oggplay_file_reader_new(media);
+  }
+  if (reader == NULL) {
+    printf("oggplay_file_reader_new failed\n");
+    return 1;
+  }
+  player = oggplay_open_with_reader(reader);
+  if (player == NULL) {
+    printf("Could not initialise oggplay with this file\n");
+    goto done;
+  }
+  
+  printf("There are %d tracks\n", oggplay_get_num_tracks(player));
+  for (i = 0; i < oggplay_get_num_tracks(player); i++) {
+    printf("Track %d is of type %s\n", i, oggplay_get_track_typename(player, i));
+    switch (oggplay_get_track_type(player, i)) {
+      case OGGZ_CONTENT_THEORA:
+        oggplay_set_callback_num_frames(player, i, 1);
+        break;
+      case OGGZ_CONTENT_VORBIS:
+        oggplay_set_offset(player, i, 250L);
+        break;
+    }
+    if (oggplay_set_track_active(player, i) < 0)
+      printf("\tNote: could not set this track active!\n");
+  }
+  oggplay_use_buffer(player, N_OGG_BUFS);
+  
+  // Create the display window.
+  if (!InitApp())
+    goto done;
+
+  // Set up the semaphore used to coordinate decoding and displaying.
+  if (MPCreateSemaphore(N_OGG_BUFS, N_OGG_BUFS, &sem) != noErr) {
+    printf("Failed to create decoding semaphore\n");
+    goto done;
+  }
+
+  // Kick off one thread to continually decode the AXV file, and another
+  // to display when frames become available.
+  if (pthread_create(&decode_thread, NULL, drive_decoding, NULL) != 0) {
+    printf("pthread_create failed\n");
+    goto done;
+  }
+  if (pthread_create(&display_thread, NULL, display_frame, NULL) != 0) {
+    printf("pthread_create failed\n");
+    goto done;
+  }
+
+  RunApplicationEventLoop();
+
+done:
+  if (sem != NULL)
+    MPDeleteSemaphore(sem);
+  if (nibRef != NULL)
+    DisposeNibReference(nibRef);
+  //-- should destroy player here (currently there is no function to do this) --
+  if (reader != NULL)
+    reader->destroy(reader);
+  return 0;
+}

Copied: liboggplay/trunk/src/examples/win32-player.c (from rev 3577, liboggplay/trunk/src/tools/win32-player.c)
===================================================================
--- liboggplay/trunk/src/examples/win32-player.c	                        (rev 0)
+++ liboggplay/trunk/src/examples/win32-player.c	2008-05-02 04:35:28 UTC (rev 3579)
@@ -0,0 +1,898 @@
+#include "config_win32.h"
+
+#include <oggplay/oggplay.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <windows.h>
+
+#define OPENGL 0
+
+#if OPENGL
+#include <glut.h> // requires OpenGL for Win32
+#endif /* !OPENGL */
+
+#define USE_AUDIO 1
+
+#if USE_AUDIO
+#include <mmreg.h>
+#include <math.h>
+#endif
+
+#include <assert.h>
+
+static int            n_frames = 0;
+static DWORD			    position = 0;
+static UINT				    target = 0;
+static DWORD          rate = 0;
+static UINT				    channels = 2;
+static BOOL				    buffering = TRUE;
+static BOOL				    audio_opened = FALSE;
+
+static UINT          total_bytes = 0;
+
+#if OPENGL
+static GLuint texture;
+#endif
+
+#define OGGPLAY_BUFFER_SIZE 20
+#define BLOCK_SIZE  2560
+#define BLOCK_COUNT 4
+
+static unsigned char  *texture_bits = NULL;
+static int            texture_width;
+static int            texture_height;
+static float          texture_wscale;
+static float          texture_hscale;
+static int            window_width;
+static int            window_height;
+static int            window_style;
+
+static OggPlay*       player = NULL;
+
+static CRITICAL_SECTION waveCriticalSection;
+static HWAVEOUT			    hWaveOut;
+static WAVEHDR*         waveBlocks = NULL;
+static volatile int     waveFreeBlockCount;
+static int              waveCurrentBlock;
+
+static HANDLE			      audio_synch;
+typedef struct {
+  HANDLE           decode_thread;
+  HANDLE           display_thread;
+} Player_Info;
+
+
+// oggplay buffer underrun semaphore
+static HANDLE           sem;
+static HWAVEOUT         audio_dev;
+
+static int video_track;
+static int audio_track;
+
+
+#define APPLICATIONNAME TEXT("OggPlay Media Player\0")
+#define CLASSNAME       TEXT("OggPlayMediaPlayer\0")
+
+#if OPENGL
+static int        window;
+#else
+static HWND        window;
+#endif /*OPENGL*/
+
+#define DISPLAY_FRAMES 1
+
+#define CLAMP(v) (v > 255 ? 255 : v < 0 ? 0 : v)
+
+
+void
+handle_video_data (OggPlay * player, int track_num, 
+                    OggPlayVideoData * video_data, int frame) {
+
+  int               i;      
+  int               y_width;
+  int               y_height;
+  int               uv_width;
+  int               uv_height;
+  int               po2_width;
+  int               po2_height;  
+  int				style;
+  OggPlayYUVChannels      yuv;
+  OggPlayRGBChannels      rgb;  
+  RECT				r;
+
+#if 0  
+  unsigned char*     ptry;
+  unsigned char*     ptru;
+  unsigned char*     ptrv;
+  unsigned char*     ptro;
+  unsigned char*     ptro2;
+#endif
+
+  oggplay_get_video_y_size(player, track_num, &y_width, &y_height);
+  if (y_width != window_width)
+  {
+#if DISPLAY_FRAMES
+#if OPENGL
+	glutReshapeWindow(y_width, y_height);
+#else    
+    style = window_style & ~ WS_OVERLAPPED;
+    GetClientRect(window, &r);
+	r.right = r.left + y_width + 5;
+	r.bottom = r.top + y_height + 5;
+	// allow for the border, title size, etc.
+	AdjustWindowRect(&r, style, FALSE);
+	SetWindowPos(window, HWND_TOP, 0, 0, 
+        r.right - r.left, r.bottom - r.top,
+		SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | SWP_NOMOVE | 
+		SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_NOZORDER | SWP_SHOWWINDOW);
+	UpdateWindow(window);
+#endif /* !OPENGL */
+#endif;
+    window_width = y_width;
+    window_height = y_height;
+  }
+    
+  oggplay_get_video_uv_size(player, track_num, &uv_width, &uv_height);
+  assert(uv_width == y_width / 2);
+  assert(uv_height == y_height / 2);
+  
+  for (po2_width = 1; po2_width < y_width; po2_width <<= 1);
+  for (po2_height = 1; po2_height < y_height; po2_height <<= 1);
+  texture_wscale = (float) y_width / po2_width;
+  texture_hscale = (float) y_height / po2_height;
+
+  if (texture_bits == NULL) {
+
+    texture_bits = (unsigned char*)calloc(1, po2_width * po2_height * 4);
+    texture_width = po2_width;
+    texture_height = po2_height;    
+    
+  } else if (texture_width != po2_width || texture_height != po2_height) {
+
+    free(texture_bits);
+    
+    texture_bits = (unsigned char*)calloc(1, po2_width * po2_height * 4);
+    texture_width = po2_width;
+    texture_height = po2_height;
+  }
+
+  /*
+   *  R = Y + 1.140V
+   *  G = Y - 0.395U - 0.581V
+   *  B = Y + 2.032U
+   */
+    
+#if 1
+  
+  yuv.ptry = video_data->y;
+  yuv.ptru = video_data->u;
+  yuv.ptrv = video_data->v;
+  yuv.uv_width = uv_width;
+  yuv.uv_height = uv_height;  
+  yuv.y_width = y_width;
+  yuv.y_height = y_height;  
+  
+  rgb.ptro = texture_bits;
+  rgb.rgb_width = texture_width;
+  rgb.rgb_height = texture_height;  
+
+#if OPENGL
+  oggplay_yuv2rgb(&yuv, &rgb);
+#else
+  oggplay_yuv2bgr(&yuv, &rgb);
+#endif 
+
+#else
+  ptry = video_data->y;
+  ptru = video_data->u;
+  ptrv = video_data->v;
+  ptro = texture_bits;
+
+  for (i = 0; i < y_height; i++) {
+    int j;
+    ptro2 = ptro;
+    for (j = 0; j < y_width; j += 2) {
+
+      short pr, pg, pb;
+      short r, g, b;
+      
+    //pr = ((128 + (ptrv[j/2] - 128) * 292) >> 8) - 16; /* 1.14 * 256 */
+      pr = (-41344 + ptrv[j/2] * 292) >> 8;
+    //pg = ((128 - (ptru[j/2] - 128) * 101 - (ptrv[j/2] - 128) * 149) >> 8)-16; 
+    //                                /* 0.395 & 0.581 */
+      pg = (28032 - ptru[j/2] * 101 - ptrv[j/2] * 149) >> 8;
+    //pb = ((128 + (ptru[j/2] - 128) * 520) >> 8) - 16; /* 2.032 */
+      pb = (-70528 + ptru[j/2] * 520) >> 8;
+
+      r = ptry[j] + pr;
+      g = ptry[j] + pg;
+      b = ptry[j] + pb;
+
+      *ptro2++ = CLAMP(r);
+      *ptro2++ = CLAMP(g);
+      *ptro2++ = CLAMP(b);
+      
+      r = ptry[j + 1] + pr;
+      g = ptry[j + 1] + pg;
+      b = ptry[j + 1] + pb;
+      
+      *ptro2++ = CLAMP(b);
+      *ptro2++ = CLAMP(g);
+      *ptro2++ = CLAMP(r);
+    }
+    ptry += y_width;
+    if (i & 1) {
+      ptru += uv_width;
+      ptrv += uv_width;
+    }
+    ptro += po2_width * 3;
+  }
+  
+  
+#endif
+ 
+}
+
+#if USE_AUDIO
+
+void
+float_to_short_array(const float* in, short* out, int len) {
+        int i = 0;
+        float scaled_value = 0;		
+        for(i = 0; i < len; i++) {				
+                scaled_value = floorf(0.5 + 32768 * in[i]);
+                if (in[i] < 0) {
+                   out[i] = (scaled_value < -32768.0) ? -32768 : (short)scaled_value;
+                } else {
+                   out[i] = (scaled_value > 32767.0) ? 32767 : (short)scaled_value;
+                }
+        }
+}
+
+WAVEHDR* allocateBlocks(int size, int count)
+{
+    unsigned char* buffer;    
+    int i;
+    WAVEHDR* blocks;
+    DWORD totalBufferSize = (size + sizeof(WAVEHDR)) * count;
+    
+    /*
+     * allocate memory for the entire set in one go     
+     */    
+    if((buffer = HeapAlloc(
+        GetProcessHeap(), 
+        HEAP_ZERO_MEMORY, 
+        totalBufferSize
+        )) == NULL) {
+        printf("Memory allocation error\n");
+        ExitProcess(1);
+    }
+
+    /*
+     * and set up the pointers to each bit
+     */
+    blocks = (WAVEHDR*)buffer;
+    buffer += sizeof(WAVEHDR) * count;
+    for(i = 0; i < count; i++) {
+        blocks[i].dwBufferLength = size;
+        blocks[i].lpData = buffer;
+        buffer += size;
+    }
+    
+    return blocks;
+}
+
+void freeBlocks(WAVEHDR* blockArray)
+{    
+	  /* 
+     * and this is why allocateBlocks works the way it does     
+     */     
+    HeapFree(GetProcessHeap(), 0, blockArray);
+}
+
+static void CALLBACK waveOutProc(
+    HWAVEOUT hWaveOut, 
+    UINT uMsg, 
+    DWORD dwInstance,  
+    DWORD dwParam1,    
+    DWORD dwParam2     
+)
+{
+    /*
+     * pointer to free block counter
+     */
+    int* freeBlockCounter = (int*)dwInstance;
+    /*
+     * ignore calls that occur due to openining and closing the
+     * device.
+     */
+    if(uMsg != WOM_DONE)
+        return;
+
+    EnterCriticalSection(&waveCriticalSection);
+    (*freeBlockCounter)++;
+    /*if ((*freeBlockCounter) == 1) 
+       SetEvent(audio_synch);*/
+    LeaveCriticalSection(&waveCriticalSection);	
+}
+
+void openAudio(OggPlay * player, int track) {
+	WAVEFORMATEX wfx;		
+	UINT fps = 25; // get from the stream information
+	UINT supported = FALSE;
+		
+	waveBlocks         = allocateBlocks(BLOCK_SIZE, BLOCK_COUNT);
+	waveFreeBlockCount = BLOCK_COUNT;
+  waveCurrentBlock   = 0;  
+ 	wfx.nSamplesPerSec  = (DWORD)rate;  /* sample rate */
+  wfx.wBitsPerSample  = 16;     /* sample size */
+  wfx.nChannels       = channels;      /* channels    */
+  wfx.cbSize          = 0;      /* size of _extra_ info */
+  wfx.wFormatTag      = WAVE_FORMAT_PCM;
+  wfx.nBlockAlign     = (wfx.wBitsPerSample * wfx.nChannels) >> 3;
+  wfx.nAvgBytesPerSec = wfx.nBlockAlign * wfx.nSamplesPerSec;
+	// target sample size in bytes for each frame
+	target				= wfx.nAvgBytesPerSec / fps; 	
+
+	supported = waveOutOpen(NULL, WAVE_MAPPER, &wfx, (DWORD_PTR)0, (DWORD_PTR)0, 
+		WAVE_FORMAT_QUERY);
+	if (supported == MMSYSERR_NOERROR) { // audio device sucessfully opened
+		waveOutOpen((LPHWAVEOUT)&hWaveOut, WAVE_MAPPER, &wfx, 
+	      (DWORD_PTR)waveOutProc, (DWORD_PTR)&waveFreeBlockCount, CALLBACK_FUNCTION);
+		//printf("Audio device sucessfully opened\n");
+	} else if (supported == WAVERR_BADFORMAT) {
+       printf("Requested format not supported...\n");
+       ExitProcess(1);
+	} else {
+       printf("Error opening default audio device. Exiting...\n");
+       ExitProcess(1);
+	}	
+  return;
+}
+
+
+void writeAudio(LPSTR data, int samples)
+{    
+	WAVEHDR* current;	
+  int bytes;
+	int remain;
+
+  current = &waveBlocks[waveCurrentBlock];
+  
+  while(samples > 0) {
+      /* 
+       * first make sure the header we're going to use is unprepared
+       */
+      if(current->dwFlags & WHDR_PREPARED) 
+          waveOutUnprepareHeader(hWaveOut, current, sizeof(WAVEHDR));
+	
+	    bytes = sizeof(short) * samples;
+      total_bytes += bytes;
+      if(bytes < (int)(BLOCK_SIZE - current->dwUser)) {						
+	  	    float_to_short_array((float*)data, (short*)(current->lpData + current->dwUser), samples);						
+		      //memcpy(current->lpData + current->dwUser, data, size);
+          current->dwUser += bytes;
+          break;
+      }
+	
+      // bytes is even as BLOCK_SIZE and dwUser are even too
+      bytes = BLOCK_SIZE - current->dwUser;
+	    remain = bytes / sizeof(short); // samples left in the buffer		
+      float_to_short_array((float*)data, (short*)(current->lpData + current->dwUser), remain);
+  		//memcpy(current->lpData + current->dwUser, data, remain);
+      samples -= remain;
+      data += 2 * bytes;		
+	    current->dwBufferLength = BLOCK_SIZE;
+	    waveOutPrepareHeader(hWaveOut, current, sizeof(WAVEHDR));
+	    waveOutWrite(hWaveOut, current, sizeof(WAVEHDR));
+      if (buffering == TRUE) {
+        printf("Total bytes %d\n", total_bytes);
+      }
+      buffering = FALSE;		
+      
+      EnterCriticalSection(&waveCriticalSection);
+      waveFreeBlockCount--;
+      LeaveCriticalSection(&waveCriticalSection);
+      /*
+       * wait for a block to become free
+       */
+      while (!waveFreeBlockCount) {        
+        //printf("All audio buffer blocks empty\n");        
+        //WaitForSingleObject(audio_synch, INFINITE);
+        Sleep(10);
+      }		  
+		
+      /*
+       * point to the next block
+       */
+      waveCurrentBlock++;
+      waveCurrentBlock %= BLOCK_COUNT;		
+
+      current = &waveBlocks[waveCurrentBlock];
+      current->dwUser = 0;
+  }
+}
+
+void 
+closeAudio() {
+  int i;
+  /*
+   * wait for all blocks to complete
+   */
+  while(waveFreeBlockCount < BLOCK_COUNT)
+	  Sleep(10);
+
+ /*
+  * unprepare any blocks that are still prepared
+  */
+  for(i = 0; i < waveFreeBlockCount; i++) 
+    if(waveBlocks[i].dwFlags & WHDR_PREPARED)
+	  waveOutUnprepareHeader(hWaveOut, &waveBlocks[i], sizeof(WAVEHDR));
+
+  freeBlocks(waveBlocks);
+  waveOutClose(hWaveOut);
+    
+}
+
+void
+handle_audio_data (OggPlay * player, int track, OggPlayAudioData * data, 
+                int size) {		
+	if (audio_opened == FALSE) {
+		openAudio(player, track);
+		audio_opened = TRUE;
+
+	}
+	writeAudio((LPSTR)data, size);  
+}
+#endif
+
+#if !OPENGL
+DWORD WINAPI display_frame(void *arg) {
+#else 
+void display_frame(void) {
+#endif
+  int                     i;
+  int                     j;
+  OggPlayDataHeader    ** headers;
+  OggPlayVideoData      * video_data;
+#if USE_AUDIO
+  OggPlayAudioData      * audio_data;
+#endif
+  int					  size;
+  int                     required;
+  OggPlayDataType         type;
+  int                     num_tracks;
+  OggPlayCallbackInfo  ** track_info;  
+  DWORD				            offset = 0;  
+  DWORD                   delay;
+  MMTIME                  mm;
+
+  delay = 40; // 40ms timeslots @ 25 fps
+
+  num_tracks = oggplay_get_num_tracks (player);
+
+  //nice(5);
+
+#if !OPENGL
+  while (1) { 
+#endif
+    track_info = oggplay_buffer_retrieve_next(player);
+    if (track_info == NULL) {
+#if DISPLAY_FRAMES
+      Sleep(delay);      
+
+#if OPENGL            
+      return;
+#else
+      continue;
+#endif
+    }
+#endif
+    // make sure the playback rate is correct
+	  if (buffering == FALSE) {		
+		  mm.wType = TIME_BYTES;		
+		  waveOutGetPosition(hWaveOut, &mm, sizeof(MMTIME));						  
+      if (target > (DWORD)mm.u.cb - position) {						  
+        offset = (target - (DWORD)mm.u.cb + position) * delay / target;												                               
+        Sleep(offset);
+		  }      
+		  position = (DWORD)mm.u.cb;
+	  }
+    for (i = 0; i < num_tracks; i++) {
+      type = oggplay_callback_info_get_type(track_info[i]);
+      headers = oggplay_callback_info_get_headers(track_info[i]);
+    
+      switch (type) {
+        case OGGPLAY_INACTIVE:
+          break;
+        case OGGPLAY_YUV_VIDEO:
+          /*
+           * there should only be one record
+           */
+          required = oggplay_callback_info_get_required(track_info[i]);
+          if (required == 0) {
+            oggplay_buffer_free_info(track_info);
+            oggplay_buffer_release_next(player);            
+            goto next_frame;
+            }
+          video_data = oggplay_callback_info_get_video_data(headers[0]);
+          //printf("video presentation time: %llx\n",
+          //        oggplay_callback_info_get_presentation_time(headers[0]));
+          handle_video_data(player, i, video_data, n_frames);
+          break;
+        case OGGPLAY_FLOATS_AUDIO:
+#if USE_AUDIO
+          required = oggplay_callback_info_get_required(track_info[i]);          
+          // fill in fist and second buffer          
+          for (j = 0; j < required; j++) {      
+              size = oggplay_callback_info_get_record_size(headers[j]);
+              audio_data = oggplay_callback_info_get_audio_data(headers[j]);  
+              handle_audio_data(player, i, audio_data, channels * size);            
+          }          
+          //printf("audio presentation time: %llx\n",
+          //        oggplay_callback_info_get_presentation_time(headers[j]));                    
+#endif    
+          break;
+        case OGGPLAY_CMML:
+          if (oggplay_callback_info_get_required(track_info[i]) > 0)
+            printf("%s\n", oggplay_callback_info_get_text_data(headers[0]));
+          break;
+
+        case OGGPLAY_KATE:
+          required = oggplay_callback_info_get_required(track_info[i]);
+          for (j = 0; j < required; j++)
+            printf("[%d] %s\n", j, oggplay_callback_info_get_text_data(headers[j]));
+          break;
+
+        default:
+          break;
+      }
+    }    
+    n_frames++;
+    
+#if DISPLAY_FRAMES
+#if USE_AUDIO
+#ifdef WIN32	
+	//QueryPerformanceCounter(&last_tick_count);
+#endif
+#endif
+#if OPENGL
+    glutPostRedisplay();	
+#else
+    // send WM_PAINT to the player window
+	InvalidateRect(window, NULL, TRUE);
+	UpdateWindow(window);
+#endif
+#endif /* DISPLAY_FRAMES */
+ 
+    oggplay_buffer_free_info(track_info);
+    oggplay_buffer_release_next (player);
+
+next_frame:
+    ReleaseSemaphore(sem, 1, NULL);
+#if !OPENGL
+  }
+#endif  
+}
+
+#if DISPLAY_FRAMES
+void show_window(void) {
+
+#if OPENGL
+  if (texture_bits != NULL) 
+  {
+
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture_width, 
+                    texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 
+                    texture_bits);
+
+  }
+  
+  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+  glBegin(GL_QUADS);
+  glTexCoord2f(0.0, texture_hscale);
+  glVertex2f(-1,-1);
+  glTexCoord2f(texture_wscale, texture_hscale);
+  glVertex2f(1,-1);  
+  glTexCoord2f(texture_wscale, 0.0);
+  glVertex2f(1,1);
+  glTexCoord2f(0.0, 0.0);
+  glVertex2f(-1,1);
+  glEnd();
+  glutSwapBuffers();
+#endif
+}
+#endif
+
+
+DWORD WINAPI drive_decoding(void *arg) {
+
+  while (1) { 
+    OggPlayErrorCode r;
+    WaitForSingleObject(sem, INFINITE);   
+
+	r = oggplay_step_decoding(player);
+
+    if (r != E_OGGPLAY_CONTINUE && r != E_OGGPLAY_USER_INTERRUPT) {
+#if DISPLAY_FRAMES
+#if OPENGL
+	  glutDestroyWindow(window);
+#endif
+#endif
+      // stop all treads and close the window 
+      SendMessage(window, WM_CLOSE, (WPARAM)0, (LPARAM)0);
+      Sleep(10);
+    }
+  }
+}
+
+
+#if !OPENGL
+void CreateDDBitmap(HDC hdc, HBITMAP* hBitmap) {
+
+	BITMAPINFOHEADER bih;
+	BITMAPINFO bmi;
+
+	// fill in BITMAPINFOHEADER
+	ZeroMemory(&bih, sizeof(BITMAPINFOHEADER));
+	bih.biClrImportant = 0;
+	bih.biClrUsed = 0;
+	bih.biXPelsPerMeter = 0;
+	bih.biYPelsPerMeter = 0;
+	bih.biSize = 40;
+	bih.biWidth = texture_width;
+	bih.biHeight = -texture_height;
+	bih.biPlanes = 1;
+	bih.biBitCount = 32;
+	bih.biCompression = BI_RGB;				
+	bih.biSizeImage = ((bih.biWidth * 32 + 31) & ~31) /8 * (-bih.biHeight);
+        //(((bih.biWidth * bih.biBitCount / 8) + 3) & ~3) * bih.biHeight;
+	
+	// fill in BITMAPINFO
+	ZeroMemory(&bmi, sizeof(BITMAPINFO));
+	bmi.bmiHeader = bih;	
+		
+	// create bitmap from raw rgb bits
+	SetDIBits(hdc, (*hBitmap), 0, texture_height, texture_bits, 
+						&bmi, DIB_RGB_COLORS);
+	/*SetDIBitsToDevice(hdc, 0, 0, texture_width, texture_height, 
+						0, 0, 0, texture_height, texture_bits, &bmi, DIB_RGB_COLORS);*/
+	return;
+}
+
+LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+	PAINTSTRUCT ps;	
+	RECT r;
+	HDC hdc, hdcMem;
+	HBITMAP hbmOld, hbm;
+
+	BITMAP bm;
+	Player_Info* info = NULL;	
+
+    switch(message)
+    {
+		case WM_PAINT : {							
+		    hdc = BeginPaint(window, &ps);
+        GetClientRect(window, &r);
+				/* FIXME: very performance costly operations, use global context? */
+				hdcMem = CreateCompatibleDC(hdc);
+				hbm = CreateCompatibleBitmap(hdc, texture_width, texture_height);
+				CreateDDBitmap(hdc, &hbm);
+				hbmOld = SelectObject(hdcMem, hbm);
+				
+				if ((r.right - r.left != window_width) ||
+					(r.bottom - r.top != window_height)) {
+					StretchBlt(hdc, r.left, r.top, r.right - r.left, r.bottom - r.top, 
+						hdcMem, r.left, r.top, r.left + window_width, r.top + window_height,
+						SRCCOPY);
+				} else  {				
+					BitBlt(hdc, 0, 0, window_width, window_height, hdcMem, 
+						    0, 0, SRCCOPY);
+				}
+				//restore the initial state
+				SelectObject(hdcMem, hbmOld);
+				DeleteObject(hbm);
+                DeleteDC(hdcMem);                
+				EndPaint(window, &ps);
+			}
+			break;
+		case WM_CLOSE: {
+				info = (Player_Info*)GetWindowLong(window, GWL_USERDATA);
+				TerminateThread(info->decode_thread, (DWORD)0);
+        TerminateThread(info->display_thread, (DWORD)0);
+        CloseHandle(info->decode_thread);
+				CloseHandle(info->display_thread);
+        ExitProcess(0);
+        /*SuspendThread(info->decode_thread);
+				SuspendThread(info->display_thread);*/
+			}
+            break;
+        
+		case WM_DESTROY: {				
+				PostQuitMessage(0);
+			}
+            break;		
+		default:
+            return DefWindowProc(hWnd, message, wParam, lParam);
+
+	}
+	return 0;
+}
+
+int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int 
+				   nCmdShow) {
+#else
+int
+main (int argc, char * argv[]) {
+#endif
+	
+  OggPlayReader * reader;
+  int             i;  
+
+  MSG			  msg = {0};
+  WNDCLASSEX	  wc;
+  Player_Info	  info;
+  DWORD			  dec_id;
+  DWORD			  disp_id;  
+  LONG        offset = 0L;
+  BOOL fGotMessage;
+
+#if OPENGL
+  if (argc < 2) {
+    printf ("please provide a filename\n");
+    exit (1);
+  }
+ 
+  if (strncmp(argv[1], "http://", 7) == 0) {
+    reader = oggplay_tcp_reader_new();
+  } else {
+    reader = oggplay_file_reader_new();
+  }
+
+  player = oggplay_open_with_reader(reader, argv[1]);
+#else
+  reader = oggplay_file_reader_new();
+  //reader = oggplay_tcp_reader_new();
+  //player = oggplay_open_with_reader(reader, "http://media.annodex.net/cmmlwiki/SFD2005-Trailer.axv");
+  player = oggplay_open_with_reader(reader, "E:\\_marcin\\_devel\\ogg_play\\index.anx");
+#endif
+
+  if (player == NULL) {
+    printf ("could not initialise oggplay with this file\n");
+    return 1;
+  }
+
+  printf ("there are %d tracks\n", oggplay_get_num_tracks (player));
+  
+  for (i = 0; i < oggplay_get_num_tracks (player); i++) {
+    printf("Track %d is of type %s\n", i, 
+                    oggplay_get_track_typename (player, i));
+    if (oggplay_get_track_type (player, i) == OGGZ_CONTENT_THEORA) {
+      oggplay_set_callback_num_frames (player, i, 1);
+      video_track = i;
+    }
+    else if (oggplay_get_track_type (player, i) == OGGZ_CONTENT_VORBIS) {
+      audio_track = i;
+      channels = 2;//oggplay_get_audio_channels(player, audio_track);
+  	  if (!channels)
+	  	  printf("Problems reading channel information\n");				
+	    rate = 16000;//oggplay_get_audio_samplerate(player, audio_track);
+  	  if (!rate)
+	  	  printf("Problems retreiving sample rate information\n");    
+      // calculate audio offset in [ms]
+      offset = (LONG)(1000 * BLOCK_SIZE * BLOCK_COUNT / channels / sizeof(short) / rate);      
+      printf("Calculated offset: %d\n", offset);
+      oggplay_set_offset(player, i, offset); 
+    }
+
+    if (oggplay_set_track_active(player, i) < 0) {
+      printf("\tNote: Could not set this track active!\n");
+    }
+  }
+
+#if DISPLAY_FRAMES
+#if OPENGL
+  glutInit(&argc, argv);
+  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
+  glutInitWindowPosition(100, 100);
+  glutInitWindowSize(400, 400);
+#endif /* !OPENGL */
+#endif /* !DISPLAY_FRAMES */
+  window_width = 400;
+  window_height = 400;
+#if DISPLAY_FRAMES
+#if OPENGL
+  window = glutCreateWindow("glut player");
+#else
+  // InitApplication
+  ZeroMemory(&wc, sizeof(WNDCLASSEX));
+  wc.cbSize = sizeof(WNDCLASSEX);
+  wc.style = 0; // thick frame?
+  wc.lpfnWndProc = WndProc;
+  wc.cbClsExtra = 0;
+  wc.cbWndExtra = 0;
+  wc.hInstance = hInstance;
+  wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
+  wc.hCursor = LoadCursor(NULL, IDC_ARROW);
+  wc.lpszMenuName = NULL;
+  wc.lpszClassName = CLASSNAME;	
+  
+  if (!RegisterClassEx(&wc)) {
+  // end of InitApplication
+ 	  printf("Window registration failed\n");
+	  return 1;
+  }
+  window_style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
+  // InitInstance
+  window = CreateWindowEx(WS_EX_CLIENTEDGE, CLASSNAME, APPLICATIONNAME, window_style, 
+						CW_USEDEFAULT, CW_USEDEFAULT, window_width, window_height,
+						NULL, NULL, hInstance, NULL);
+  // InitInstance
+  if (window == NULL) {
+	  printf("Window creation failed\n");		  
+	  return 1;  
+  }
+  // display and update window
+
+#endif
+#endif // DISPLAY_FRAMES
+
+  oggplay_use_buffer(player, OGGPLAY_BUFFER_SIZE);
+
+  audio_synch = CreateEvent(0, FALSE, FALSE, 0);
+  sem = CreateSemaphore(NULL, (long)OGGPLAY_BUFFER_SIZE, (long)OGGPLAY_BUFFER_SIZE, NULL);
+  
+  InitializeCriticalSection(&waveCriticalSection);
+  info.decode_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)drive_decoding, NULL, 0, &dec_id);  
+#if !OPENGL
+  info.display_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)display_frame, NULL, 0, &disp_id);    
+  SetWindowLong(window, GWL_USERDATA, (long)&info); 
+#endif
+
+#if DISPLAY_FRAMES
+#if OPENGL
+  glutIdleFunc(&display_frame);  
+  glutDisplayFunc(&show_window);
+  //glutDisplayFunc(&empty);
+
+  glEnable(GL_TEXTURE_2D);
+  glDisable(GL_CULL_FACE);
+  glBindTexture(GL_TEXTURE_2D, texture);
+  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+  glGenTextures(1, &texture);
+
+  //nice(5);
+  
+  glutMainLoop();
+#else
+
+  // process window messages  
+  while ((fGotMessage = GetMessage(&msg, (HWND) NULL, 0, 0)) != 0 && fGotMessage != -1) 
+  { 
+	  TranslateMessage(&msg); 
+	  DispatchMessage(&msg); 
+  }
+  DeleteCriticalSection(&waveCriticalSection);  
+#endif  
+
+
+#else
+  while (1) {
+    display_frame(NULL);
+  }
+#endif /* !DISPLAY_FRAMES */
+ 
+  printf("there were %d frames\n", n_frames);
+
+#if !OPENGL
+	return msg.wParam; 
+	UNREFERENCED_PARAMETER(lpCmdLine); 
+#endif
+}

Modified: liboggplay/trunk/src/tools/Makefile.am
===================================================================
--- liboggplay/trunk/src/tools/Makefile.am	2008-05-01 09:40:13 UTC (rev 3578)
+++ liboggplay/trunk/src/tools/Makefile.am	2008-05-02 04:35:28 UTC (rev 3579)
@@ -1,13 +1,5 @@
 ## Process this file with automake to produce Makefile.in
 
-EXTRA_DIST= \
-	mac/Info.plist \
-	mac/English.lproj/gplayer.nib \
-	mac/English.lproj/gplayer.nib/classes.nib \
-	mac/English.lproj/gplayer.nib/info.nib \
-	mac/English.lproj/gplayer.nib/objects.xib \
-	mac/gplayer.xcodeproj/project.pbxproj
-
 AM_CFLAGS = -Wall \
             @OGGZ_CFLAGS@ @THEORA_CFLAGS@ @FISHSOUND_CFLAGS@ @KATE_CFLAGS@
 
@@ -17,14 +9,6 @@
 OGGPLAY_LIBS = $(OGGPLAYDIR)/liboggplay.la @OGGZ_LIBS@ @THEORA_LIBS@ \
 	       @FISHSOUND_LIBS@ @KATE_LIBS@ @SEMAPHORE_LIBS@
 
-if HAVE_GLUT
-glut_tools = glut-player
-endif
-
-if HAVE_LIBSNDFILE1
-sndfile_tools = dump-all-streams
-endif
-
 if HAVE_IMLIB2
 imlib2_tools = dump-first-frame
 endif
@@ -32,26 +16,11 @@
 # Tools
 
 bin_PROGRAMS = oggplay-info $(imlib2_tools)
-noinst_PROGRAMS = get-stream-info $(glut_tools) $(sndfile_tools)
 
 oggplay_info_SOURCES = oggplay-info.c
 oggplay_info_LDADD = $(OGGPLAY_LIBS) 
 
-get_stream_info_SOURCES = get-stream-info.c
-get_stream_info_LDADD = $(OGGPLAY_LIBS) 
-
-dump_all_streams_SOURCES = dump-all-streams.c
-dump_all_streams_CFLAGS = $(AM_CFLAGS) @SNDFILE_CFLAGS@
-dump_all_streams_LDADD = $(OGGPLAY_LIBS) @SNDFILE_LIBS@ 
-
 dump_first_frame_SOURCES = dump-first-frame.c
 dump_first_frame_CFLAGS = $(AM_CFLAGS) @IMLIB2_CFLAGS@
 dump_first_frame_LDADD = $(OGGPLAY_LIBS) @IMLIB2_LIBS@
 
-glut_player_SOURCES = glut-player.c
-glut_player_LDADD = $(OGGPLAY_LIBS) @GLUT_LIBS@
-if MACOS
-# Automake 1.6 doesn't recoginze -framework arguments as libraries
-# so we must pass them through LDFLAGS
-glut_player_LDFLAGS = @GLUT_FRAMEWORKS@
-endif

Deleted: liboggplay/trunk/src/tools/dump-all-streams.c
===================================================================
--- liboggplay/trunk/src/tools/dump-all-streams.c	2008-05-01 09:40:13 UTC (rev 3578)
+++ liboggplay/trunk/src/tools/dump-all-streams.c	2008-05-02 04:35:28 UTC (rev 3579)
@@ -1,168 +0,0 @@
-#include "config.h"
-
-#include <oggplay/oggplay.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <sndfile.h>
-
-static int n_frames = 0;
-
-void
-dump_video_data (OggPlay * player, int track_num, OggPlayVideoData * video_data,
-                   int frame) {
-
-  char              fname[256];
-  FILE            * f;
-  FILE            * g;
-  int               i;
-  unsigned char   * ptr;
-  unsigned char   * ptr2;
-  int               y_width;
-  int               y_height;
-  int               uv_width;
-  int               uv_height;
-
-  sprintf(fname, "y_frame%d", frame);
-  f = fopen(fname, "w");
-  
-  oggplay_get_video_y_size(player, track_num, &y_width, &y_height);
-  oggplay_get_video_uv_size(player, track_num, &uv_width, &uv_height);
-  
-  ptr = video_data->y;
-  
-  for (i = 0; i < y_height; i++) {
-    fwrite(ptr, 1, y_width, f);
-    ptr += y_width;
-  }
-
-  fclose(f);
-
-  sprintf(fname, "u_frame%d", frame);
-  f = fopen(fname, "w");
-  sprintf(fname, "v_frame%d", frame);
-  g = fopen(fname, "w");
-
-  ptr = video_data->u;
-  ptr2 = video_data->v;
-  
-  for (i = 0; i < uv_height; i++) {
-    fwrite(ptr, 1, uv_width, f);
-    fwrite(ptr2, 1, uv_width, g);
-    ptr += uv_width;
-    ptr2 += uv_width;
-  }
-
-  fclose(f);
-  fclose(g);
-  
-}
-
-static SNDFILE * sndfile = NULL;
-
-void
-dump_audio_data (OggPlay * player, int track, OggPlayAudioData * data, 
-                int size) {
-
-  if (sndfile == NULL) {
-    SF_INFO sfinfo;
-    oggplay_get_audio_samplerate(player, track, &(sfinfo.samplerate));
-    oggplay_get_audio_channels(player, track, &(sfinfo.channels));
-    sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
-    printf("%d %d %d\n", sfinfo.samplerate, sfinfo.channels, sfinfo.format);
-
-    sndfile = sf_open ("audio", SFM_WRITE, &sfinfo);
-  }
-
-  sf_writef_float (sndfile, (float *)data, size);
-  
-}
-
-int
-dump_streams_callback (OggPlay *player, int num_tracks, 
-                       OggPlayCallbackInfo **track_info, void *user) {
-
-  int                   i;
-  int                   j;
-  OggPlayDataHeader  ** headers;
-  OggPlayVideoData    * video_data;
-  OggPlayAudioData    * audio_data;
-  int                   required;
-  OggPlayDataType       type;
-
-  for (i = 0; i < num_tracks; i++) {
-    type = oggplay_callback_info_get_type(track_info[i]);
-    headers = oggplay_callback_info_get_headers(track_info[i]);
-
-    switch (type) {
-      case OGGPLAY_INACTIVE:
-        break;
-      case OGGPLAY_YUV_VIDEO:
-        /*
-         * there should only be one record
-         */
-        video_data = oggplay_callback_info_get_video_data(headers[0]);
-        dump_video_data(player, i, video_data, n_frames);
-        break;
-      case OGGPLAY_FLOATS_AUDIO:
-        required = oggplay_callback_info_get_required(track_info[i]);
-        for (j = 0; j < required; j++) {
-          int size;
-          size = oggplay_callback_info_get_record_size(headers[j]);
-          audio_data = oggplay_callback_info_get_audio_data(headers[j]);
-          dump_audio_data(player, i, audio_data, size);
-        }
-      default:
-        break;
-    }
-  }
-  
-  n_frames++;
-
-  return 0;
-}
-
-int
-main (int argc, char * argv[]) {
-
-  OggPlay       * player;
-  OggPlayReader * reader;
-  int             i;
-
-  if (argc < 2) {
-    printf ("please provide a filename\n");
-    exit (1);
-  }
-  
-  reader = oggplay_file_reader_new(argv[1]);
-
-  player = oggplay_open_with_reader(reader);
-
-  if (player == NULL) {
-    printf ("could not initialise oggplay with this file\n");
-    exit (1);
-  }
-
-  printf ("there are %d tracks\n", oggplay_get_num_tracks (player));
-  
-  for (i = 0; i < oggplay_get_num_tracks (player); i++) {
-    printf("Track %d is of type %s\n", i, 
-                    oggplay_get_track_typename (player, i));
-    if (oggplay_get_track_type (player, i) == OGGZ_CONTENT_THEORA) {
-      oggplay_set_callback_num_frames (player, i, 1);
-    }
-
-    if (oggplay_set_track_active(player, i) < 0) {
-      printf("\tNote: Could not set this track active!\n");
-    }
-  }
-
-  oggplay_set_data_callback(player, dump_streams_callback, NULL);
-  oggplay_start_decoding(player);
-
-  sf_close(sndfile);
-  
-  printf("there were %d frames\n", n_frames);
-
-  return 0;
-}

Deleted: liboggplay/trunk/src/tools/dump_some_frames.py
===================================================================
--- liboggplay/trunk/src/tools/dump_some_frames.py	2008-05-01 09:40:13 UTC (rev 3578)
+++ liboggplay/trunk/src/tools/dump_some_frames.py	2008-05-02 04:35:28 UTC (rev 3579)
@@ -1,64 +0,0 @@
-import sys
-import Image
-from oggplay import *
-from xml.dom.ext.reader import Sax2
-from xml import xpath
-
-video_name = sys.argv[1]
-timelist = sys.argv[2]
-outname = sys.argv[3]
-f = open(timelist)
-
-reader = Sax2.Reader()
-doc = reader.fromStream(f)
-times = xpath.Evaluate('descendant::clip/@start', doc.documentElement)
-times = map(lambda a: a.nodeValue, times)
-f.close()
-
-def string_to_ms(time):
-  stime = time.split(":")
-  out = 0
-  mul = 1
-  while len(stime) > 0:
-    out += mul * float(stime[-1])
-    mul *= 60
-    del stime[-1]
-  return (int(out * 1000 + 500), time)
-
-times = map(string_to_ms, times)
-
-if video_name[:7] == "http://":
-  reader = oggplay_tcp_reader_new(video_name, None, 80)
-else:
-  reader = oggplay_file_reader_new(video_name)
-
-player = oggplay_open_with_reader(reader)
-
-for i in range(oggplay_get_num_tracks(player)):
-  global video
-  if oggplay_get_track_type(player, i) == OGGZ_CONTENT_THEORA:
-    oggplay_set_callback_num_frames(player, i, 1)
-    video = i
-  oggplay_set_track_active(player, i)
-
-pos = 0
-
-def data_callback(player, track_info):
-  global pos
-  headers = oggplay_callback_info_get_headers(track_info[video])
-  time = oggplay_callback_info_get_presentation_time(headers[0])
-  if time >= times[pos][0]:  
-    rgba = oggplay_generate_frame(player, video, headers[0])
-    image = Image.fromstring("RGBA", rgba[1], rgba[0])
-    fname = outname + ".png_t=" + times[pos][1]
-    pos += 1
-    print "saving", fname
-    image.save(fname, "PNG")
-    if pos == len(times):
-      return -1
-  return 0
-
-if len(times) == 0:
-  exit(0)
-oggplay_set_data_pycallback(player, data_callback)
-oggplay_start_decoding(player)

Deleted: liboggplay/trunk/src/tools/get-stream-info.c
===================================================================
--- liboggplay/trunk/src/tools/get-stream-info.c	2008-05-01 09:40:13 UTC (rev 3578)
+++ liboggplay/trunk/src/tools/get-stream-info.c	2008-05-02 04:35:28 UTC (rev 3579)
@@ -1,34 +0,0 @@
-#include "config.h"
-
-#include <oggplay/oggplay.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-int
-main (int argc, char * argv[]) {
-
-  OggPlay       * player;
-  OggPlayReader * reader;
-  int             i;
-
-  if (argc < 2) {
-    printf ("please provide a filename\n");
-    exit (1);
-  }
-  
-  reader = oggplay_file_reader_new(argv[1]);
-
-  player = oggplay_open_with_reader(reader);
-
-  if (player == NULL) {
-    printf ("could not initialise oggplay with this file\n");
-    exit (1);
-  }
-
-  for (i = 0; i < oggplay_get_num_tracks (player); i++) {
-    printf("Track %d is of type %s\n", i, 
-                    oggplay_get_track_typename (player, i));
-  }
- 
-  return 0; 
-}

Deleted: liboggplay/trunk/src/tools/glut-player.c
===================================================================
--- liboggplay/trunk/src/tools/glut-player.c	2008-05-01 09:40:13 UTC (rev 3578)
+++ liboggplay/trunk/src/tools/glut-player.c	2008-05-02 04:35:28 UTC (rev 3579)
@@ -1,570 +0,0 @@
-#include "config.h"
-
-#include <oggplay/oggplay.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <string.h>
-#include <stdint.h>
-
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <sys/ioctl.h>
-
-#include <pthread.h>
-#include <semaphore.h>
-
-#ifdef __APPLE__
-#include <GLUT/glut.h>
-#else
-#include <GL/glut.h>
-#include <GL/gl.h>
-#endif
-
-#include <unistd.h>
-#include <fcntl.h>
-
-#if !(defined(__APPLE__) || defined(WIN32))
-#define USE_AUDIO 1
-#else
-#define USE_AUDIO 0
-#endif
-
-#if USE_AUDIO
-#include <sys/soundcard.h>
-
-#include <math.h>
-#endif
-
-#include <assert.h>
-
-static int n_frames = 0;
-
-#ifdef DEBUG
-static long long total_audio_bytes = 0;
-static int target_audio_rate = 0;
-#endif
-
-static GLuint texture;
-
-static unsigned char *texture_bits = NULL;
-static int texture_width;
-static int texture_height;
-static float texture_wscale;
-static float texture_hscale;
-static int window_width;
-static int window_height;
-
-static OggPlay    * player = NULL;
-
-static sem_t        stop_sem;
-
-
-static int video_track;
-static int audio_track;
-
-#define DISPLAY_FRAMES 1
-
-#define PERIOD_SIZE   512
-
-void
-handle_video_data (OggPlay * player, int track_num, 
-                    OggPlayVideoData * video_data, int frame) {
-
-  int               y_width;
-  int               y_height;
-  int               uv_width;
-  int               uv_height;
-  int               po2_width;
-  int               po2_height;  
-  OggPlayYUVChannels      yuv;
-  OggPlayRGBChannels      rgb;
-
-  oggplay_get_video_y_size(player, track_num, &y_width, &y_height);
-  if (y_width != window_width)
-  {
-#if DISPLAY_FRAMES
-    glutReshapeWindow(y_width, y_height);
-#endif
-    window_width = y_width;
-    window_height = y_height;
-    printf("New window size is (%d, %d)\n", window_width, window_height);
-  }
-    
-  oggplay_get_video_uv_size(player, track_num, &uv_width, &uv_height);
-  //assert(uv_width == y_width / 2);
-  //assert(uv_height == y_height / 2);
-  
-  for (po2_width = 1; po2_width < y_width; po2_width <<= 1);
-  for (po2_height = 1; po2_height < y_height; po2_height <<= 1);
-  texture_wscale = (float) y_width / po2_width;
-  texture_hscale = (float) y_height / po2_height;
-
-  if (texture_bits == NULL) {
-
-    texture_bits = calloc(1, po2_width * po2_height * 4);
-    texture_width = po2_width;
-    texture_height = po2_height;    
-    
-  } else if (texture_width != po2_width || texture_height != po2_height) {
-
-    free(texture_bits);
-    
-    texture_bits = calloc(1, po2_width * po2_height * 4);
-    texture_width = po2_width;
-    texture_height = po2_height;
-  }
-
-  /*
-   * Convert the YUV data to RGB, using platform-specific optimisations
-   * where possible.
-   */
-  yuv.ptry = video_data->y;
-  yuv.ptru = video_data->u;
-  yuv.ptrv = video_data->v;
-  yuv.uv_width = uv_width;
-  yuv.uv_height = uv_height;  
-  yuv.y_width = y_width;
-  yuv.y_height = y_height;  
-  
-  rgb.ptro = texture_bits;
-  rgb.rgb_width = texture_width;
-  rgb.rgb_height = texture_height;  
-
-  oggplay_yuv2rgb(&yuv, &rgb);
-
-}
-
-static int              rate = 16000;
-static int              channels = 2;
-static int              fps_denom = 1000;
-static int              fps_num = 25000;
-
-#if USE_AUDIO
-
-static int              snd_fd = -1;
-
-void
-float_to_short_array(const float* in, short* out, int len) {
-        int i = 0;
-        float scaled_value = 0;
-        for(i = 0; i < len; i++) {
-                scaled_value = floorf(0.5 + 32768 * in[i]);
-                if (in[i] < 0) {
-                   out[i] = (scaled_value < -32768.0) ? -32768 : (short)scaled_value;
-                } else {
-                   out[i] = (scaled_value > 32767.0) ? 32767 : (short)scaled_value;
-                }
-        }
-}
-
-void init_audio() {
-  int             tmp;
-
-  snd_fd = open("/dev/dsp", O_WRONLY, 0);
-#ifdef DEBUG
-  target_audio_rate = (int)(rate * channels * sizeof(short) / 25);
-#endif
-  tmp = AFMT_S16_LE;
-  ioctl(snd_fd, SNDCTL_DSP_SETFMT, &tmp);
-  ioctl(snd_fd, SNDCTL_DSP_CHANNELS, &channels);
-  ioctl(snd_fd, SNDCTL_DSP_SPEED, &rate);
-}
-
-static short *buffer = NULL;
-static int buffer_length = 0;
-
-void
-handle_audio_data (OggPlay * player, int track, OggPlayAudioData * data,
-                int size) {
-
-  if (snd_fd == -1) {
-    init_audio();
-  }
- 
-  if (buffer_length < size) {
-    buffer = realloc(buffer, size * sizeof (short) * 2);
-    buffer_length = size;
-  }
-  
-  float_to_short_array((float *)data, buffer, size * 2);
- 
-  write(snd_fd, buffer, size * 2 * sizeof(short));
-}
-
-#endif
-
-static int        window;
-static long       ld_time;
-
-void display_frame(void) {
-  int                     i;
-  OggPlayDataHeader    ** headers;
-  OggPlayVideoData      * video_data;
-#if USE_AUDIO
-  OggPlayAudioData      * audio_data;
-  count_info              tsc;
-  int                     j;
-#endif
-  int                     required;
-  OggPlayDataType         type;
-  int                     num_tracks;
-  OggPlayCallbackInfo  ** track_info;  
-  static unsigned int     target      = 0;
-#ifdef DEBUG
-  int 			  bytes_per_frame = 0;
-#endif
-  struct timespec         ts;
-
-  ts.tv_sec = 0;
-  num_tracks = oggplay_get_num_tracks (player);
-
-  //nice(5);
-  
-  //while (1) { 
-    track_info = oggplay_buffer_retrieve_next(player);
-    
-    if (track_info == NULL) {
-      ts.tv_nsec = 40000000;
-      nanosleep(&ts, NULL);      
-      return;
-    }
-#if USE_AUDIO
-    if (rate > 0) {
-      ioctl(snd_fd, SNDCTL_DSP_GETOPTR, &tsc);
-      long long bytes = tsc.bytes;
-      long long offset = (target - (bytes * 10000 / rate / 4)) * 100;
-#else
-    {
-      long long offset = 400 * 100;
-#endif
-      target += 400;
-    
-#if DISPLAY_FRAMES
-      if (offset > 0) {
-        ts.tv_nsec = offset * 1000;
-        nanosleep(&ts, NULL);
-      }
-#endif
-    }
-
-    for (i = 0; i < num_tracks; i++) {
-      type = oggplay_callback_info_get_type(track_info[i]);
-      headers = oggplay_callback_info_get_headers(track_info[i]);
- 
-      switch (type) {
-        case OGGPLAY_INACTIVE:
-          break;
-        case OGGPLAY_YUV_VIDEO:
-          /*
-           * there should only be one record
-           */
-          required = oggplay_callback_info_get_required(track_info[i]);
-          video_data = oggplay_callback_info_get_video_data(headers[0]);
-          ld_time = oggplay_callback_info_get_presentation_time(headers[0]);
-          handle_video_data(player, i, video_data, n_frames);
-          /*
-          printf("video fst %ld lst %ld\n",
-            oggplay_callback_info_get_presentation_time(headers[0]), 
-            oggplay_callback_info_get_presentation_time(headers[required - 1]));
-          */
-          break;
-        case OGGPLAY_FLOATS_AUDIO:
-#if USE_AUDIO
-        required = oggplay_callback_info_get_required(track_info[i]);
-        /*
-        printf("audio fst %ld lst %ld\n",
-            oggplay_callback_info_get_presentation_time(headers[0]), 
-            oggplay_callback_info_get_presentation_time(headers[required - 1]));
-        */
-        int total_size = 0;
-    	  for (j = 0; j < required; j++) {
-          int size;
-          size = oggplay_callback_info_get_record_size(headers[j]);
-    	    audio_data = oggplay_callback_info_get_audio_data(headers[j]);
-#ifdef DEBUG
-	        bytes_per_frame += size * 4; // size * channels
-#endif
-          handle_audio_data(player, i, audio_data, size);
-          total_size += size;
-        }
-#endif          
-        break;
-        case OGGPLAY_CMML:
-          if (oggplay_callback_info_get_required(track_info[i]) > 0)
-            printf("%s\n", oggplay_callback_info_get_text_data(headers[0]));
-          break;
-
-        case OGGPLAY_KATE:
-          required = oggplay_callback_info_get_required(track_info[i]);
-          for (j = 0; j < required; j++) {
-            printf("[%d] [duration %ld] %s\n",
-                i,
-                oggplay_callback_info_get_record_size(headers[j]),
-                oggplay_callback_info_get_text_data(headers[j]));
-          }
-          break;
-
-        default:
-          break;
-      }
-    }
-  
-    n_frames++;
-#ifdef DEBUG
-    total_audio_bytes += bytes_per_frame;
-    printf("Processing frame: %d | audio B/s: %d | average audio B/s %f | targetaudio rate %d B/s\n", n_frames, bytes_per_frame, (float)(total_audio_bytes/n_frames), target_audio_rate); 
-    bytes_per_frame = 0;
-#endif    
-#if DISPLAY_FRAMES
-#if USE_AUDIO
-    ioctl(snd_fd, SNDCTL_DSP_GETOPTR, &tsc);
-#endif
-    glutPostRedisplay();
-    //show_window();
-#endif
-    oggplay_buffer_release (player, track_info);
-  //}
-}
-
-typedef enum {
-  SEEK_FORWARD,
-  SEEK_BACKWARD
-} MessageEnum;
-
-MessageEnum         msg;
-static sem_t        msg_sem;
-
-
-void key_pressed(unsigned char k, int a, int b) {
-
-  if (k == 'q') {
-#if DISPLAY_FRAMES
-    glutDestroyWindow(window);
-#endif
-    if (texture_bits != NULL) {
-      free(texture_bits);
-    }
-    oggplay_close(player);
-    exit(0);
-  } else if (k == 'l') {
-    msg = SEEK_FORWARD;
-    sem_post(&msg_sem);
-  } else if (k == 'k') {
-    msg = SEEK_BACKWARD;
-    sem_post(&msg_sem);
-  }
-  
-}
-
-#if DISPLAY_FRAMES
-void show_window(void) {
-
-  if (texture_bits != NULL) 
-  {
-
-    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture_width, 
-                    texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 
-                    texture_bits);
-
-  }
-  
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-  glBegin(GL_QUADS);
-  glTexCoord2f(0.0, texture_hscale);
-  glVertex2f(-1,-1);
-  glTexCoord2f(texture_wscale, texture_hscale);
-  glVertex2f(1,-1);
-  glTexCoord2f(texture_wscale, 0.0);
-  glVertex2f(1,1);
-  glTexCoord2f(0.0, 0.0);
-  glVertex2f(-1,1);
-  glEnd();
-  glutSwapBuffers();
-
-}
-#endif
-
-static int              saved_avail = 0;
-
-void *drive_decoding(void *arg) {
-
-  while (1) { 
-    OggPlayErrorCode r;
-    int avail;
-
-    if (sem_trywait(&msg_sem) == 0) {
-      if (msg == SEEK_FORWARD) {
-        if (oggplay_seek(player, ld_time + 5000) == E_OGGPLAY_CANT_SEEK) {
-          printf("can't seek forwards!\n");
-        }
-      } else if (msg == SEEK_BACKWARD) {
-        if (oggplay_seek(player, ld_time - 5000) == E_OGGPLAY_CANT_SEEK) {
-          printf("cant seek backwards!\n");
-        }
-      }
-      msg = 0;
-    }
-    
-    r = E_OGGPLAY_TIMEOUT;
-    while (r == E_OGGPLAY_TIMEOUT) {
-      r = oggplay_step_decoding(player);
-    }
-    
-    avail = oggplay_get_available(player);
-    if (avail != saved_avail) {
-      saved_avail = avail;
-      //printf("available: %d\n", avail);
-    }
-
-
-    if (r != E_OGGPLAY_CONTINUE && r != E_OGGPLAY_USER_INTERRUPT) {
-      printf("hmm, totally bogus, dude.  r is %d\n", r);
-      // wait for display thread to finish
-      sem_wait(&stop_sem);
-#if DISPLAY_FRAMES
-      glutDestroyWindow(window);
-#endif
-      pthread_exit(NULL);
-    }
-  }
-}
-
-int
-main (int argc, char * argv[]) {
-
-  OggPlayReader * reader;
-  int             i;
-  pthread_t       thread;
-
-  if (argc < 2) {
-    printf ("please provide a filename\n");
-    exit (1);
-  }
- 
-  if (strncmp(argv[1], "http://", 7) == 0) {
-    reader = oggplay_tcp_reader_new(argv[1], NULL, 0);
-  } else {
-    reader = oggplay_file_reader_new(argv[1]);
-  }
-
-  player = oggplay_open_with_reader(reader);
-
-  if (player == NULL) {
-    printf ("could not initialise oggplay with this file\n");
-    exit (1);
-  }
-
-  printf ("there are %d tracks\n", oggplay_get_num_tracks (player));
- 
-  video_track = -1; 
-  for (i = 0; i < oggplay_get_num_tracks (player); i++) {
-    printf("Track %d is of type %s\n", i, 
-                    oggplay_get_track_typename (player, i));
-    if (oggplay_get_track_type (player, i) == OGGZ_CONTENT_THEORA) {
-      int ret;
-      oggplay_set_callback_num_frames (player, i, 1);
-      video_track = i;
-      ret = oggplay_get_video_fps(player, i , &fps_denom, &fps_num);
-    }
-    else if 
-    (
-      oggplay_get_track_type (player, i) == OGGZ_CONTENT_VORBIS
-      ||
-      oggplay_get_track_type (player, i) == OGGZ_CONTENT_SPEEX
-    ) 
-    {
-      int ret;
-      audio_track = i;      
-      oggplay_set_offset(player, i, 250L);
-      ret = oggplay_get_audio_samplerate(player, i , &rate);
-      ret = oggplay_get_audio_channels(player, i, &channels);
-      printf("samplerate: %d channels: %d\n", rate, channels);
-    }
-    else if (oggplay_get_track_type (player, i) == OGGZ_CONTENT_KATE) {
-      const char *category = "<unknown>", *language = "<unknown>";
-      int ret = oggplay_get_kate_category(player, i, &category);
-      ret = oggplay_get_kate_language(player, i, &language);
-      printf("category %s, language %s\n", category, language);
-    }
-
-    if (oggplay_set_track_active(player, i) < 0) {
-      printf("\tNote: Could not set this track active!\n");
-    }
-  }
-
-  if (video_track == -1) {
-    oggplay_set_callback_num_frames(player, audio_track, 2048);
-  }
-
-#if DISPLAY_FRAMES
-  glutInit(&argc, argv);
-  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
-  glutInitWindowPosition(100, 100);
-  glutInitWindowSize(400, 400);
-#endif
-  window_width = 400;
-  window_height = 400;
-#if DISPLAY_FRAMES
-  window = glutCreateWindow("glut player");
-#endif
-
-  oggplay_use_buffer(player, 20);
-  
-  sem_init(&stop_sem, 1, 1);
-  sem_wait(&stop_sem);
-
-  sem_init(&msg_sem, 1, 1);
-  sem_wait(&msg_sem);
-  
-  pthread_create(&thread, NULL, drive_decoding, NULL);
-  
-#if DISPLAY_FRAMES
-  glutIdleFunc(&display_frame);  
-  glutDisplayFunc(&show_window);
-  glutKeyboardFunc(&key_pressed);
-  //glutDisplayFunc(&empty);
-
-  glEnable(GL_TEXTURE_2D);
-  glDisable(GL_CULL_FACE);
-  glBindTexture(GL_TEXTURE_2D, texture);
-  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
-  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
-  glGenTextures(1, &texture);
-
-  glutMainLoop();
-
-#else
-  for (i = 0; i < 100; i++) {
-    display_frame();
-  }
-  while (1) {
-    key_pressed('l', 0, 0);
-    for (i = 0; i < 10; i++) {
-      display_frame();
-    }
-    key_pressed('l', 0, 0);
-    for (i = 0; i < 10; i++) {
-      display_frame();
-    }
-    key_pressed('l', 0, 0);
-    for (i = 0; i < 100; i++) {
-      display_frame();
-    }
-    key_pressed('k', 0, 0);
-    for (i = 0; i < 100; i++) {
-      display_frame();
-    }
-  }
- key_pressed('q', 0, 0);
-#endif
- 
-  printf("there were %d frames\n", n_frames);
-  
-  return 0;
-}
-

Deleted: liboggplay/trunk/src/tools/mac/English.lproj/gplayer.nib/classes.nib
===================================================================
--- liboggplay/trunk/src/tools/mac/English.lproj/gplayer.nib/classes.nib	2008-05-01 09:40:13 UTC (rev 3578)
+++ liboggplay/trunk/src/tools/mac/English.lproj/gplayer.nib/classes.nib	2008-05-02 04:35:28 UTC (rev 3579)
@@ -1,4 +0,0 @@
-{
-IBClasses = ();
-IBVersion = 1;
-}

Deleted: liboggplay/trunk/src/tools/mac/English.lproj/gplayer.nib/info.nib
===================================================================
--- liboggplay/trunk/src/tools/mac/English.lproj/gplayer.nib/info.nib	2008-05-01 09:40:13 UTC (rev 3578)
+++ liboggplay/trunk/src/tools/mac/English.lproj/gplayer.nib/info.nib	2008-05-02 04:35:28 UTC (rev 3579)
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>IBDocumentLocation</key>
-	<string>69 64 356 240 0 0 1280 1002 </string>
-	<key>IBEditorPositions</key>
-	<dict>
-		<key>29</key>
-		<string>100 368 151 44 0 0 1280 1002 </string>
-	</dict>
-	<key>IBFramework Version</key>
-	<string>446.1</string>
-	<key>IBOldestOS</key>
-	<integer>3</integer>
-	<key>IBOpenObjects</key>
-	<array>
-		<integer>166</integer>
-	</array>
-	<key>IBSystem Version</key>
-	<string>8P135</string>
-	<key>targetFramework</key>
-	<string>IBCarbonFramework</string>
-</dict>
-</plist>

Deleted: liboggplay/trunk/src/tools/mac/English.lproj/gplayer.nib/objects.xib
===================================================================
--- liboggplay/trunk/src/tools/mac/English.lproj/gplayer.nib/objects.xib	2008-05-01 09:40:13 UTC (rev 3578)
+++ liboggplay/trunk/src/tools/mac/English.lproj/gplayer.nib/objects.xib	2008-05-02 04:35:28 UTC (rev 3579)
@@ -1,116 +0,0 @@
-<?xml version="1.0" standalone="yes"?>
-<object class="NSIBObjectData">
-  <string name="targetFramework">IBCarbonFramework</string>
-  <object name="rootObject" class="NSCustomObject" id="1">
-    <string name="customClass">NSApplication</string>
-  </object>
-  <array count="14" name="allObjects">
-    <object class="IBCarbonMenu" id="29">
-      <string name="title">main</string>
-      <array count="2" name="items">
-        <object class="IBCarbonMenuItem" id="185">
-          <string name="title">gplayer</string>
-          <object name="submenu" class="IBCarbonMenu" id="184">
-            <string name="title">gplayer</string>
-            <array count="1" name="items">
-              <object class="IBCarbonMenuItem" id="187">
-                <string name="title">About gplayer</string>
-                <int name="keyEquivalentModifier">0</int>
-                <ostype name="command">abou</ostype>
-              </object>
-            </array>
-            <string name="name">_NSAppleMenu</string>
-          </object>
-        </object>
-        <object class="IBCarbonMenuItem" id="192">
-          <string name="title">Window</string>
-          <object name="submenu" class="IBCarbonMenu" id="195">
-            <string name="title">Window</string>
-            <array count="6" name="items">
-              <object class="IBCarbonMenuItem" id="190">
-                <boolean name="dynamic">TRUE</boolean>
-                <string name="title">Minimize</string>
-                <string name="keyEquivalent">m</string>
-                <ostype name="command">mini</ostype>
-              </object>
-              <object class="IBCarbonMenuItem" id="191">
-                <boolean name="dynamic">TRUE</boolean>
-                <string name="title">Minimize All</string>
-                <string name="keyEquivalent">m</string>
-                <int name="keyEquivalentModifier">1572864</int>
-                <ostype name="command">mina</ostype>
-              </object>
-              <object class="IBCarbonMenuItem" id="197">
-                <string name="title">Zoom</string>
-                <ostype name="command">zoom</ostype>
-              </object>
-              <object class="IBCarbonMenuItem" id="194">
-                <boolean name="separator">TRUE</boolean>
-              </object>
-              <object class="IBCarbonMenuItem" id="196">
-                <boolean name="dynamic">TRUE</boolean>
-                <string name="title">Bring All to Front</string>
-                <ostype name="command">bfrt</ostype>
-              </object>
-              <object class="IBCarbonMenuItem" id="193">
-                <boolean name="dynamic">TRUE</boolean>
-                <string name="title">Arrange in Front</string>
-                <int name="keyEquivalentModifier">1572864</int>
-                <ostype name="command">frnt</ostype>
-              </object>
-            </array>
-            <string name="name">_NSWindowsMenu</string>
-          </object>
-        </object>
-      </array>
-      <string name="name">_NSMainMenu</string>
-    </object>
-    <object class="IBCarbonWindow" id="166">
-      <string name="windowRect">210 252 570 732 </string>
-      <string name="title">Window</string>
-      <object name="rootControl" class="IBCarbonRootControl" id="167">
-        <string name="bounds">0 0 360 480 </string>
-      </object>
-      <boolean name="liveResize">TRUE</boolean>
-      <int name="windowPosition">4</int>
-      <boolean name="isConstrained">FALSE</boolean>
-    </object>
-    <reference idRef="167"/>
-    <reference idRef="184"/>
-    <reference idRef="185"/>
-    <reference idRef="187"/>
-    <reference idRef="190"/>
-    <reference idRef="191"/>
-    <reference idRef="192"/>
-    <reference idRef="193"/>
-    <reference idRef="194"/>
-    <reference idRef="195"/>
-    <reference idRef="196"/>
-    <reference idRef="197"/>
-  </array>
-  <array count="14" name="allParents">
-    <reference idRef="1"/>
-    <reference idRef="1"/>
-    <reference idRef="166"/>
-    <reference idRef="185"/>
-    <reference idRef="29"/>
-    <reference idRef="184"/>
-    <reference idRef="195"/>
-    <reference idRef="195"/>
-    <reference idRef="29"/>
-    <reference idRef="195"/>
-    <reference idRef="195"/>
-    <reference idRef="192"/>
-    <reference idRef="195"/>
-    <reference idRef="195"/>
-  </array>
-  <dictionary count="3" name="nameTable">
-    <string>Files Owner</string>
-    <reference idRef="1"/>
-    <string>MenuBar</string>
-    <reference idRef="29"/>
-    <string>ViewWindow</string>
-    <reference idRef="166"/>
-  </dictionary>
-  <unsigned_int name="nextObjectID">216</unsigned_int>
-</object>

Deleted: liboggplay/trunk/src/tools/mac/Info.plist
===================================================================
--- liboggplay/trunk/src/tools/mac/Info.plist	2008-05-01 09:40:13 UTC (rev 3578)
+++ liboggplay/trunk/src/tools/mac/Info.plist	2008-05-02 04:35:28 UTC (rev 3579)
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
-	<key>CFBundleDevelopmentRegion</key>
-	<string>English</string>
-	<key>CFBundleExecutable</key>
-	<string>gplayer</string>
-	<key>CFBundleIconFile</key>
-	<string></string>
-	<key>CFBundleIdentifier</key>
-	<string>com.annodex.gplayer</string>
-	<key>CFBundleInfoDictionaryVersion</key>
-	<string>6.0</string>
-	<key>CFBundlePackageType</key>
-	<string>APPL</string>
-	<key>CFBundleSignature</key>
-	<string>AXVM</string>
-	<key>CFBundleVersion</key>
-	<string>1.0</string>
-	<key>CSResourcesFileMapped</key>
-	<true/>
-</dict>
-</plist>

Deleted: liboggplay/trunk/src/tools/mac/gplayer.xcodeproj/project.pbxproj
===================================================================
--- liboggplay/trunk/src/tools/mac/gplayer.xcodeproj/project.pbxproj	2008-05-01 09:40:13 UTC (rev 3578)
+++ liboggplay/trunk/src/tools/mac/gplayer.xcodeproj/project.pbxproj	2008-05-02 04:35:28 UTC (rev 3579)
@@ -1,339 +0,0 @@
-// !$*UTF8*$!
-{
-	archiveVersion = 1;
-	classes = {
-	};
-	objectVersion = 42;
-	objects = {
-
-/* Begin PBXBuildFile section */
-		2C0FCDE40BF2ADE30082632E /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 2C0FCDE30BF2ADE30082632E /* Info.plist */; };
-		2C1B4BD70BDD8BBE003DE877 /* liboggplay.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C1B4AE30BDC9C06003DE877 /* liboggplay.dylib */; };
-		2C1B4BFF0BDD92D4003DE877 /* liboggz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C1B4BE10BDD8ED6003DE877 /* liboggz.dylib */; };
-		2C1B4C090BDD964C003DE877 /* libogg in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C1B4C080BDD964C003DE877 /* libogg */; };
-		2C5798AE0BE06EC900D285C7 /* libspeex.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C5798AB0BE06EC900D285C7 /* libspeex.dylib */; };
-		2C5798AF0BE06EC900D285C7 /* libtheora in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C5798AC0BE06EC900D285C7 /* libtheora */; };
-		2C5798B00BE06EC900D285C7 /* libvorbis in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C5798AD0BE06EC900D285C7 /* libvorbis */; };
-		2C6733C80BF2A6760036EADB /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C6733C70BF2A6760036EADB /* Carbon.framework */; };
-		2C6733CB0BF2A6840036EADB /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C6733CA0BF2A6840036EADB /* OpenGL.framework */; };
-		2C6733DA0BF2A6D60036EADB /* mac-player.c in Sources */ = {isa = PBXBuildFile; fileRef = 2C6733D90BF2A6D60036EADB /* mac-player.c */; };
-		2C83ADB90BEEB709004C14F4 /* AGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C83ADB80BEEB709004C14F4 /* AGL.framework */; };
-		2CA20F7A0BDD9DB7003EE25C /* libfishsound.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CA20F790BDD9DB7003EE25C /* libfishsound.dylib */; };
-		2CA20F950BDD9F3F003EE25C /* libvorbisenc in Frameworks */ = {isa = PBXBuildFile; fileRef = 2CA20F940BDD9F3F003EE25C /* libvorbisenc */; };
-		8D0C4E8E0486CD37000505A6 /* gplayer.nib in Resources */ = {isa = PBXBuildFile; fileRef = 02345980000FD03B11CA0E72 /* gplayer.nib */; };
-/* End PBXBuildFile section */
-
-/* Begin PBXFileReference section */
-		1870340FFE93FCAF11CA0CD7 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/gplayer.nib; sourceTree = "<group>"; };
-		2C0FCDE30BF2ADE30082632E /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
-		2C1B4AE30BDC9C06003DE877 /* liboggplay.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = liboggplay.dylib; path = ../../liboggplay/.libs/liboggplay.dylib; sourceTree = SOURCE_ROOT; };
-		2C1B4BE10BDD8ED6003DE877 /* liboggz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = liboggz.dylib; path = /usr/local/lib/liboggz.dylib; sourceTree = "<absolute>"; };
-		2C1B4C080BDD964C003DE877 /* libogg */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libogg; path = /usr/local/lib/libogg; sourceTree = "<absolute>"; };
-		2C5798AB0BE06EC900D285C7 /* libspeex.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libspeex.dylib; path = /usr/local/lib/libspeex.dylib; sourceTree = "<absolute>"; };
-		2C5798AC0BE06EC900D285C7 /* libtheora */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libtheora; path = /usr/local/lib/libtheora; sourceTree = "<absolute>"; };
-		2C5798AD0BE06EC900D285C7 /* libvorbis */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libvorbis; path = /usr/local/lib/libvorbis; sourceTree = "<absolute>"; };
-		2C6733C70BF2A6760036EADB /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
-		2C6733CA0BF2A6840036EADB /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; };
-		2C6733D90BF2A6D60036EADB /* mac-player.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = "mac-player.c"; path = "../mac-player.c"; sourceTree = "<group>"; };
-		2C83ADB80BEEB709004C14F4 /* AGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AGL.framework; path = /System/Library/Frameworks/AGL.framework; sourceTree = "<absolute>"; };
-		2CA20F790BDD9DB7003EE25C /* libfishsound.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libfishsound.dylib; path = /usr/local/lib/libfishsound.dylib; sourceTree = "<absolute>"; };
-		2CA20F940BDD9F3F003EE25C /* libvorbisenc */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libvorbisenc; path = /usr/local/lib/libvorbisenc; sourceTree = "<absolute>"; };
-		8D0C4E970486CD37000505A6 /* gplayer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = gplayer.app; sourceTree = BUILT_PRODUCTS_DIR; };
-/* End PBXFileReference section */
-
-/* Begin PBXFrameworksBuildPhase section */
-		8D0C4E910486CD37000505A6 /* Frameworks */ = {
-			isa = PBXFrameworksBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				2C1B4BD70BDD8BBE003DE877 /* liboggplay.dylib in Frameworks */,
-				2C1B4BFF0BDD92D4003DE877 /* liboggz.dylib in Frameworks */,
-				2C1B4C090BDD964C003DE877 /* libogg in Frameworks */,
-				2CA20F7A0BDD9DB7003EE25C /* libfishsound.dylib in Frameworks */,
-				2CA20F950BDD9F3F003EE25C /* libvorbisenc in Frameworks */,
-				2C5798AE0BE06EC900D285C7 /* libspeex.dylib in Frameworks */,
-				2C5798AF0BE06EC900D285C7 /* libtheora in Frameworks */,
-				2C5798B00BE06EC900D285C7 /* libvorbis in Frameworks */,
-				2C83ADB90BEEB709004C14F4 /* AGL.framework in Frameworks */,
-				2C6733C80BF2A6760036EADB /* Carbon.framework in Frameworks */,
-				2C6733CB0BF2A6840036EADB /* OpenGL.framework in Frameworks */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXFrameworksBuildPhase section */
-
-/* Begin PBXGroup section */
-		195DF8CFFE9D517E11CA2CBB /* Products */ = {
-			isa = PBXGroup;
-			children = (
-				8D0C4E970486CD37000505A6 /* gplayer.app */,
-			);
-			name = Products;
-			sourceTree = "<group>";
-		};
-		20286C29FDCF999611CA2CEA /* gplayer */ = {
-			isa = PBXGroup;
-			children = (
-				20286C2AFDCF999611CA2CEA /* Sources */,
-				20286C2CFDCF999611CA2CEA /* Resources */,
-				20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */,
-				195DF8CFFE9D517E11CA2CBB /* Products */,
-			);
-			name = gplayer;
-			sourceTree = "<group>";
-		};
-		20286C2AFDCF999611CA2CEA /* Sources */ = {
-			isa = PBXGroup;
-			children = (
-				2C6733D90BF2A6D60036EADB /* mac-player.c */,
-			);
-			name = Sources;
-			sourceTree = "<group>";
-		};
-		20286C2CFDCF999611CA2CEA /* Resources */ = {
-			isa = PBXGroup;
-			children = (
-				2C0FCDE30BF2ADE30082632E /* Info.plist */,
-				02345980000FD03B11CA0E72 /* gplayer.nib */,
-			);
-			name = Resources;
-			sourceTree = "<group>";
-		};
-		20286C32FDCF999611CA2CEA /* External Frameworks and Libraries */ = {
-			isa = PBXGroup;
-			children = (
-				2C6733C70BF2A6760036EADB /* Carbon.framework */,
-				2C83ADB80BEEB709004C14F4 /* AGL.framework */,
-				2C6733CA0BF2A6840036EADB /* OpenGL.framework */,
-				2C1B4C080BDD964C003DE877 /* libogg */,
-				2C5798AC0BE06EC900D285C7 /* libtheora */,
-				2C5798AD0BE06EC900D285C7 /* libvorbis */,
-				2CA20F940BDD9F3F003EE25C /* libvorbisenc */,
-				2C1B4BE10BDD8ED6003DE877 /* liboggz.dylib */,
-				2C1B4AE30BDC9C06003DE877 /* liboggplay.dylib */,
-				2C5798AB0BE06EC900D285C7 /* libspeex.dylib */,
-				2CA20F790BDD9DB7003EE25C /* libfishsound.dylib */,
-			);
-			name = "External Frameworks and Libraries";
-			sourceTree = "<group>";
-		};
-/* End PBXGroup section */
-
-/* Begin PBXNativeTarget section */
-		8D0C4E890486CD37000505A6 /* gplayer */ = {
-			isa = PBXNativeTarget;
-			buildConfigurationList = C0E91AC508A95435008D54AB /* Build configuration list for PBXNativeTarget "gplayer" */;
-			buildPhases = (
-				8D0C4E8C0486CD37000505A6 /* Resources */,
-				8D0C4E8F0486CD37000505A6 /* Sources */,
-				8D0C4E910486CD37000505A6 /* Frameworks */,
-			);
-			buildRules = (
-			);
-			dependencies = (
-			);
-			name = gplayer;
-			productInstallPath = "$(HOME)/Applications";
-			productName = gplayer;
-			productReference = 8D0C4E970486CD37000505A6 /* gplayer.app */;
-			productType = "com.apple.product-type.application";
-		};
-/* End PBXNativeTarget section */
-
-/* Begin PBXProject section */
-		20286C28FDCF999611CA2CEA /* Project object */ = {
-			isa = PBXProject;
-			buildConfigurationList = C0E91AC908A95435008D54AB /* Build configuration list for PBXProject "gplayer" */;
-			hasScannedForEncodings = 1;
-			mainGroup = 20286C29FDCF999611CA2CEA /* gplayer */;
-			projectDirPath = "";
-			targets = (
-				8D0C4E890486CD37000505A6 /* gplayer */,
-			);
-		};
-/* End PBXProject section */
-
-/* Begin PBXResourcesBuildPhase section */
-		8D0C4E8C0486CD37000505A6 /* Resources */ = {
-			isa = PBXResourcesBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				8D0C4E8E0486CD37000505A6 /* gplayer.nib in Resources */,
-				2C0FCDE40BF2ADE30082632E /* Info.plist in Resources */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXResourcesBuildPhase section */
-
-/* Begin PBXSourcesBuildPhase section */
-		8D0C4E8F0486CD37000505A6 /* Sources */ = {
-			isa = PBXSourcesBuildPhase;
-			buildActionMask = 2147483647;
-			files = (
-				2C6733DA0BF2A6D60036EADB /* mac-player.c in Sources */,
-			);
-			runOnlyForDeploymentPostprocessing = 0;
-		};
-/* End PBXSourcesBuildPhase section */
-
-/* Begin PBXVariantGroup section */
-		02345980000FD03B11CA0E72 /* gplayer.nib */ = {
-			isa = PBXVariantGroup;
-			children = (
-				1870340FFE93FCAF11CA0CD7 /* English */,
-			);
-			name = gplayer.nib;
-			sourceTree = "<group>";
-		};
-/* End PBXVariantGroup section */
-
-/* Begin XCBuildConfiguration section */
-		C0E91AC608A95435008D54AB /* Debug */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				ARCHS = "$(NATIVE_ARCH)";
-				COPY_PHASE_STRIP = NO;
-				GCC_DYNAMIC_NO_PIC = YES;
-				GCC_ENABLE_FIX_AND_CONTINUE = YES;
-				GCC_MODEL_TUNING = G5;
-				GCC_OPTIMIZATION_LEVEL = 0;
-				GCC_PRECOMPILE_PREFIX_HEADER = NO;
-				GCC_PREFIX_HEADER = "";
-				GCC_WARN_UNINITIALIZED_AUTOS = NO;
-				GCC_WARN_UNUSED_FUNCTION = NO;
-				GCC_WARN_UNUSED_LABEL = NO;
-				GCC_WARN_UNUSED_PARAMETER = NO;
-				GCC_WARN_UNUSED_VALUE = NO;
-				GCC_WARN_UNUSED_VARIABLE = NO;
-				GENERATE_PKGINFO_FILE = NO;
-				HEADER_SEARCH_PATHS = (
-					../../..,
-					../../../include,
-					/usr/local/include,
-				);
-				INFOPLIST_EXPAND_BUILD_SETTINGS = YES;
-				INFOPLIST_FILE = Info.plist;
-				INSTALL_PATH = "$(HOME)/Applications";
-				LIBRARY_SEARCH_PATHS = (
-					"$(LIBRARY_SEARCH_PATHS)",
-					"$(SRCROOT)/../../liboggplay/.libs",
-					/usr/local/lib,
-				);
-				PREBINDING = NO;
-				PRODUCT_NAME = gplayer;
-				WRAPPER_EXTENSION = app;
-				ZERO_LINK = NO;
-			};
-			name = Debug;
-		};
-		C0E91AC708A95435008D54AB /* Release */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				ARCHS = "$(NATIVE_ARCH)";
-				GCC_DYNAMIC_NO_PIC = YES;
-				GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
-				GCC_MODEL_TUNING = G5;
-				GCC_PRECOMPILE_PREFIX_HEADER = NO;
-				GCC_PREFIX_HEADER = "";
-				GCC_WARN_UNINITIALIZED_AUTOS = YES;
-				GENERATE_PKGINFO_FILE = NO;
-				HEADER_SEARCH_PATHS = (
-					../../..,
-					../../../include,
-					/usr/local/include,
-				);
-				INFOPLIST_EXPAND_BUILD_SETTINGS = YES;
-				INFOPLIST_FILE = Info.plist;
-				INSTALL_PATH = "$(HOME)/Applications";
-				LIBRARY_SEARCH_PATHS = (
-					"$(LIBRARY_SEARCH_PATHS)",
-					"$(SRCROOT)/../../liboggplay/.libs",
-					/usr/local/lib,
-				);
-				PREBINDING = NO;
-				PRODUCT_NAME = gplayer;
-				STRIP_INSTALLED_PRODUCT = YES;
-				WRAPPER_EXTENSION = app;
-				ZERO_LINK = NO;
-			};
-			name = Release;
-		};
-		C0E91ACA08A95435008D54AB /* Debug */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				GCC_CW_ASM_SYNTAX = NO;
-				GCC_ENABLE_CPP_EXCEPTIONS = YES;
-				GCC_ENABLE_CPP_RTTI = YES;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_MODEL_TUNING = G5;
-				GCC_OPTIMIZATION_LEVEL = 0;
-				GCC_WARN_ABOUT_POINTER_SIGNEDNESS = YES;
-				GCC_WARN_ABOUT_RETURN_TYPE = YES;
-				GCC_WARN_MISSING_PARENTHESES = YES;
-				GCC_WARN_SHADOW = YES;
-				GCC_WARN_SIGN_COMPARE = YES;
-				GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
-				GCC_WARN_UNINITIALIZED_AUTOS = YES;
-				GCC_WARN_UNKNOWN_PRAGMAS = YES;
-				GCC_WARN_UNUSED_FUNCTION = YES;
-				GCC_WARN_UNUSED_LABEL = YES;
-				GCC_WARN_UNUSED_PARAMETER = YES;
-				GCC_WARN_UNUSED_VALUE = YES;
-				GCC_WARN_UNUSED_VARIABLE = YES;
-				PREBINDING = NO;
-				SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
-				STRIP_INSTALLED_PRODUCT = NO;
-			};
-			name = Debug;
-		};
-		C0E91ACB08A95435008D54AB /* Release */ = {
-			isa = XCBuildConfiguration;
-			buildSettings = {
-				GCC_CW_ASM_SYNTAX = NO;
-				GCC_ENABLE_CPP_EXCEPTIONS = YES;
-				GCC_ENABLE_CPP_RTTI = YES;
-				GCC_ENABLE_PASCAL_STRINGS = NO;
-				GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
-				GCC_WARN_ABOUT_POINTER_SIGNEDNESS = YES;
-				GCC_WARN_ABOUT_RETURN_TYPE = YES;
-				GCC_WARN_MISSING_PARENTHESES = YES;
-				GCC_WARN_SHADOW = YES;
-				GCC_WARN_SIGN_COMPARE = YES;
-				GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
-				GCC_WARN_UNINITIALIZED_AUTOS = YES;
-				GCC_WARN_UNKNOWN_PRAGMAS = YES;
-				GCC_WARN_UNUSED_FUNCTION = YES;
-				GCC_WARN_UNUSED_LABEL = YES;
-				GCC_WARN_UNUSED_PARAMETER = YES;
-				GCC_WARN_UNUSED_VALUE = YES;
-				GCC_WARN_UNUSED_VARIABLE = YES;
-				PREBINDING = NO;
-				SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
-			};
-			name = Release;
-		};
-/* End XCBuildConfiguration section */
-
-/* Begin XCConfigurationList section */
-		C0E91AC508A95435008D54AB /* Build configuration list for PBXNativeTarget "gplayer" */ = {
-			isa = XCConfigurationList;
-			buildConfigurations = (
-				C0E91AC608A95435008D54AB /* Debug */,
-				C0E91AC708A95435008D54AB /* Release */,
-			);
-			defaultConfigurationIsVisible = 0;
-			defaultConfigurationName = Release;
-		};
-		C0E91AC908A95435008D54AB /* Build configuration list for PBXProject "gplayer" */ = {
-			isa = XCConfigurationList;
-			buildConfigurations = (
-				C0E91ACA08A95435008D54AB /* Debug */,
-				C0E91ACB08A95435008D54AB /* Release */,
-			);
-			defaultConfigurationIsVisible = 0;
-			defaultConfigurationName = Release;
-		};
-/* End XCConfigurationList section */
-	};
-	rootObject = 20286C28FDCF999611CA2CEA /* Project object */;
-}

Deleted: liboggplay/trunk/src/tools/mac-player.c
===================================================================
--- liboggplay/trunk/src/tools/mac-player.c	2008-05-01 09:40:13 UTC (rev 3578)
+++ liboggplay/trunk/src/tools/mac-player.c	2008-05-02 04:35:28 UTC (rev 3579)
@@ -1,461 +0,0 @@
-#include <AGL/agl.h>
-#include <pthread.h>
-#include <oggplay/oggplay.h>
-
-#define N_OGG_BUFS    20
-
-static OggPlayReader    *reader       = NULL;
-static OggPlay          *player       = NULL;
-static IBNibRef          nibRef       = NULL;
-static AGLContext        aglContext   = NULL;
-static MPSemaphoreID     sem          = NULL;
-static bool              run_display  = TRUE;
-static pthread_t         decode_thread;
-static pthread_t         display_thread;
-static WindowRef         window;
-static int               n_frames     = 0;
-static GLuint            texture      = 0;
-static unsigned char    *texture_bits = NULL;
-static int               texture_width;
-static int               texture_height;
-static float             texture_wscale;
-static float             texture_hscale;
-//static Rect              window_bounds;
-
-
-// All GL calls must be made in the same thread, so any initialisations that
-// have a corresponding shutdown must be performed by the display thread
-// (rather than at the end of the main function, where most other shutdowns
-// are being handled).
-bool
-init_gl() {
-  CGrafPtr        port;
-  AGLPixelFormat  aglPixelFormat;
-  GLint           pixelAttr[] = {
-    AGL_RGBA,
-    AGL_DOUBLEBUFFER,
-    AGL_PIXEL_SIZE, 32,
-    AGL_ACCELERATED,
-    AGL_NONE
-  };
-
-  // Initialise the AGL drawing context and attach it to the window's graphics port.
-  port = GetWindowPort(window);
-  if (port == NULL) {
-    printf("GetWindowPort failed\n");
-    return FALSE;
-  }
-
-  aglPixelFormat = aglChoosePixelFormat(NULL, 0, pixelAttr);
-  if (aglPixelFormat == NULL) {
-    printf("aglChoosePixelFormat failed\n");
-    return FALSE;
-  }
-
-  aglContext = aglCreateContext(aglPixelFormat, NULL);
-  aglDestroyPixelFormat(aglPixelFormat);
-  if (aglContext == NULL) {
-    printf("aglCreateContext failed\n");
-    return FALSE;
-  }
-
-  if (!aglSetDrawable(aglContext, port)) {
-    printf("aglSetDrawable failed\n");
-    return FALSE;
-  }
-
-  if (!aglSetCurrentContext(aglContext)) {
-    printf("aglSetCurrentContext failed\n");
-    return FALSE;
-  }
-
-  // Prepare GL for drawing a 2d texture (image).
-  glEnable(GL_TEXTURE_2D);
-  glDisable(GL_CULL_FACE);
-  glGenTextures(1, &texture);
-  glBindTexture(GL_TEXTURE_2D, texture);
-  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
-  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-  if (glGetError() != GL_NO_ERROR) {
-    printf("An OpenGL function call failed\n");
-    return FALSE;
-  }
-  return TRUE;
-}
-
-
-static void
-update_gl_texture()
-{
-  if (texture_bits != NULL) {
-    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture_width,
-        texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture_bits);
-  }
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-  glBegin(GL_QUADS);
-  glTexCoord2f(0.0, texture_hscale);
-  glVertex2f(-1,-1);
-  glTexCoord2f(texture_wscale, texture_hscale);
-  glVertex2f(1,-1);
-  glTexCoord2f(texture_wscale, 0.0);
-  glVertex2f(1,1);
-  glTexCoord2f(0.0, 0.0);
-  glVertex2f(-1,1);
-  glEnd();
-  aglSwapBuffers(aglContext);
-}
-
-
-static void
-shutdown_gl() {
-  if (texture != 0)
-    glDeleteTextures(1, &texture);
-  if (aglContext != NULL)
-    aglDestroyContext(aglContext);
-}
-
-
-static void
-handle_video_data(int track_num, OggPlayVideoData *video_data) {
-  int                 y_width;
-  int                 y_height;
-  int                 uv_width;
-  int                 uv_height;
-  int                 po2_width;
-  int                 po2_height;
-  OggPlayYUVChannels  yuv;
-  OggPlayRGBChannels  rgb;
-
-  oggplay_get_video_y_size(player, track_num, &y_width, &y_height);
-/*
-  if (y_width != window_bounds.right - window_bounds.left) {
-    window_bounds.right = window_bounds.left + y_width;
-    window_bounds.bottom = window_bounds.top + y_height;
-    SetWindowBounds(window, kWindowContentRgn, &window_bounds);
-  }
-*/
-
-  oggplay_get_video_uv_size(player, track_num, &uv_width, &uv_height);
-  assert(uv_width == y_width / 2);
-  assert(uv_height == y_height / 2);
-  
-  for (po2_width = 1; po2_width < y_width; po2_width <<= 1);
-  for (po2_height = 1; po2_height < y_height; po2_height <<= 1);
-  texture_wscale = (float)y_width / po2_width;
-  texture_hscale = (float)y_height / po2_height;
-
-  if (texture_bits == NULL) {
-    texture_bits = calloc(1, po2_width * po2_height * 4);
-    texture_width = po2_width;
-    texture_height = po2_height;    
-  } else if (texture_width != po2_width || texture_height != po2_height) {
-    free(texture_bits);
-    texture_bits = calloc(1, po2_width * po2_height * 4);
-    texture_width = po2_width;
-    texture_height = po2_height;
-  }
-  
-  yuv.ptry = video_data->y;
-  yuv.ptru = video_data->u;
-  yuv.ptrv = video_data->v;
-  yuv.uv_width = uv_width;
-  yuv.uv_height = uv_height;  
-  yuv.y_width = y_width;
-  yuv.y_height = y_height;  
-  
-  rgb.ptro = texture_bits;
-  rgb.rgb_width = texture_width;
-  rgb.rgb_height = texture_height;  
-  
-  oggplay_yuv2rgb(&yuv, &rgb);
-}
-
-
-static void *
-display_frame(void *arg) {
-#pragma unused(arg)
-  OggPlayDataHeader     **headers;
-  OggPlayVideoData       *video_data;
-  int                     required;
-  OggPlayDataType         type;
-  int                     num_tracks;
-  OggPlayCallbackInfo   **track_info;  
-  int                     i;
-  
-  if (!init_gl()) {
-    shutdown_gl();
-    return NULL;
-  }
-
-  num_tracks = oggplay_get_num_tracks(player);
-
-  // run_display will be set if the window is closed, so we can
-  // terminate this thread gracefully and perform appropriate shutdown.
-  while (run_display) {
-
-    track_info = oggplay_buffer_retrieve_next(player);
-    if (track_info == NULL) {
-      struct timespec ts;
-      ts.tv_nsec = 40000000;
-      nanosleep(&ts, NULL);
-      continue;
-    }
-
-    for (i = 0; i < num_tracks; i++) {
-      type = oggplay_callback_info_get_type(track_info[i]);
-      headers = oggplay_callback_info_get_headers(track_info[i]);
-      
-      switch (type) {
-        case OGGPLAY_INACTIVE:
-          break;
-
-        case OGGPLAY_YUV_VIDEO:
-          required = oggplay_callback_info_get_required(track_info[i]);
-          video_data = oggplay_callback_info_get_video_data(headers[0]);
-          handle_video_data(i, video_data);
-          break;
-
-        case OGGPLAY_FLOATS_AUDIO:
-          break;
-
-        case OGGPLAY_CMML:
-          if (oggplay_callback_info_get_required(track_info[i]) > 0)
-            printf("%s\n", oggplay_callback_info_get_text_data(headers[0]));
-          break;
-
-        case OGGPLAY_KATE:
-          required = oggplay_callback_info_get_required(track_info[i]);
-          for (j = 0; j < required; j++)
-            printf("[%d] %s\n", j, oggplay_callback_info_get_text_data(headers[j]));
-          break;
-
-        default:
-          break;
-      }
-    }
-    
-    update_gl_texture();
-    n_frames++;
-    //printf("%d\n", n_frames);
-
-    oggplay_buffer_release(player, track_info);
-    MPSignalSemaphore(sem);
-  }
-
-  shutdown_gl();
-  return NULL;
-}
-
-
-void *
-drive_decoding(void *arg) {
-#pragma unused(arg)
-  while (1) {
-    OggPlayErrorCode result;
-    MPWaitOnSemaphore(sem, kDurationForever);
-    result = oggplay_step_decoding(player);
-    if (result != E_OGGPLAY_CONTINUE && result != E_OGGPLAY_USER_INTERRUPT) {
-      printf("*** oggplay_step_decoding() failed in drive_decoding() ***\n");
-      return NULL;
-    }
-  }
-}
-
-
-// The window and app event handlers have been left as skeletons here in case
-// we ever want to add multiple windows or other application behaviours.
-static OSStatus
-WindowEventHandler(EventHandlerCallRef caller, EventRef event, void *arg) {
-#pragma unused(caller, arg)
-  OSStatus    result = eventNotHandledErr;
-  UInt32      class = GetEventClass(event);
-  UInt32      kind  = GetEventKind(event);
-
-  switch (class) {
-    case kEventClassWindow: {
-      WindowRef   winRef;
-      GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(winRef), NULL, &winRef);
-      switch (kind) {
-        case kEventWindowBoundsChanged:
-          //GetWindowBounds(window, kWindowContentRgn, &window_bounds);
-          break;
-        case kEventWindowClosed:
-          // Signal the display thread to shut down.
-          run_display = FALSE;
-          break;
-      } //switch (kind)
-      break;
-    } // case kEventClassWindow
-  } //switch (class)
-  return result;
-}
-
-static OSStatus
-AppEventHandler(EventHandlerCallRef caller, EventRef event, void *arg) {
-#pragma unused(caller, arg)
-  OSStatus    result = eventNotHandledErr;
-  UInt32      class = GetEventClass(event);
-  UInt32      kind  = GetEventKind(event);
-
-  switch (class) {
-    case kEventClassApplication: {
-      switch (kind) {
-        case kEventAppQuit:
-          // Signal the display thread to shut down.
-          run_display = FALSE;
-          break;
-      } // switch (kind)
-    } // case kEventClassApplication
-
-    case kEventClassCommand: {
-      HICommandExtended   cmd;
-      GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, sizeof(cmd), NULL, &cmd);
-      switch (kind) {
-        case kEventCommandProcess: {
-          switch (cmd.commandID) {
-            case kHICommandOpen:
-              //-- file open handling would go here --
-              break;
-          } //switch (cmd.commandID)
-          break;
-        } // case kEventCommandProcess
-      } //switch (kind)
-      break;
-    } // case kEventClassCommand
-
-  } //switch (class)
-  return result;
-}
-
-
-static bool
-InitApp() {
-  EventTypeSpec     appEvents[] = {
-    { kEventClassApplication, kEventAppQuit        },
-    { kEventClassCommand,     kEventCommandProcess }
-  };
-  EventTypeSpec     winEvents[] = {
-    { kEventClassWindow, kEventWindowBoundsChanged },
-    { kEventClassWindow, kEventWindowClosed        }
-  };
-
-  // Create a Nib reference, passing the name of the nib file (without the .nib extension).
-  // CreateNibReference only searches in the application bundle.
-  if (CreateNibReference(CFSTR("gplayer"), &nibRef) != noErr) {
-    printf("CreateNibReference failed\n");
-    return FALSE;
-  }
-  
-  // Once the nib reference is created, set the menu bar.
-  if (SetMenuBarFromNib(nibRef, CFSTR("MenuBar")) != noErr) {
-    printf("SetMenuBarFromNib failed\n");
-    return FALSE;
-  }
-  
-  // Create a window, using the settings from the nib file. The default close event
-  // handler apparently releases the resources for this, so we don't need any calls
-  // to ReleaseWindow()... I hope.
-  if (CreateWindowFromNib(nibRef, CFSTR("ViewWindow"), &window) != noErr) {
-    printf("CreateWindowFromNib failed\n");
-    return FALSE;
-  }
-  //GetWindowBounds(window, kWindowContentRgn, &window_bounds);
-
-  // Install the window and application event handlers.
-  if (InstallApplicationEventHandler(NewEventHandlerUPP(AppEventHandler),
-              GetEventTypeCount(appEvents), appEvents, NULL, NULL) != noErr) {
-    printf("InstallApplicationEventHandler failed\n");
-    return FALSE;
-  }
-
-  if (InstallWindowEventHandler(window, NewEventHandlerUPP(WindowEventHandler),
-              GetEventTypeCount(winEvents), winEvents, NULL, NULL) != noErr) {
-    printf("InstallWindowEventHandler failed\n");
-    return FALSE;
-  }
-
-  // The window is hidden on creation, so show it.
-  ShowWindow(window);
-  return TRUE;
-}
-
-
-int
-main(int argc, char *argv[]) {
-  char *media;
-  int   i;
-
-  // Open the requested AXV file (use a default if not provided).
-  if (argc > 1) {
-    media = argv[1];
-  } else {
-    media = "http://media.annodex.net/cmmlwiki/SFD2005-Trailer.axv";
-    printf("No source provided; using default\n");
-  }
-  if (strncmp(media, "http://", 7) == 0) {
-    reader = oggplay_tcp_reader_new(media);
-  } else {
-    reader = oggplay_file_reader_new(media);
-  }
-  if (reader == NULL) {
-    printf("oggplay_file_reader_new failed\n");
-    return 1;
-  }
-  player = oggplay_open_with_reader(reader);
-  if (player == NULL) {
-    printf("Could not initialise oggplay with this file\n");
-    goto done;
-  }
-  
-  printf("There are %d tracks\n", oggplay_get_num_tracks(player));
-  for (i = 0; i < oggplay_get_num_tracks(player); i++) {
-    printf("Track %d is of type %s\n", i, oggplay_get_track_typename(player, i));
-    switch (oggplay_get_track_type(player, i)) {
-      case OGGZ_CONTENT_THEORA:
-        oggplay_set_callback_num_frames(player, i, 1);
-        break;
-      case OGGZ_CONTENT_VORBIS:
-        oggplay_set_offset(player, i, 250L);
-        break;
-    }
-    if (oggplay_set_track_active(player, i) < 0)
-      printf("\tNote: could not set this track active!\n");
-  }
-  oggplay_use_buffer(player, N_OGG_BUFS);
-  
-  // Create the display window.
-  if (!InitApp())
-    goto done;
-
-  // Set up the semaphore used to coordinate decoding and displaying.
-  if (MPCreateSemaphore(N_OGG_BUFS, N_OGG_BUFS, &sem) != noErr) {
-    printf("Failed to create decoding semaphore\n");
-    goto done;
-  }
-
-  // Kick off one thread to continually decode the AXV file, and another
-  // to display when frames become available.
-  if (pthread_create(&decode_thread, NULL, drive_decoding, NULL) != 0) {
-    printf("pthread_create failed\n");
-    goto done;
-  }
-  if (pthread_create(&display_thread, NULL, display_frame, NULL) != 0) {
-    printf("pthread_create failed\n");
-    goto done;
-  }
-
-  RunApplicationEventLoop();
-
-done:
-  if (sem != NULL)
-    MPDeleteSemaphore(sem);
-  if (nibRef != NULL)
-    DisposeNibReference(nibRef);
-  //-- should destroy player here (currently there is no function to do this) --
-  if (reader != NULL)
-    reader->destroy(reader);
-  return 0;
-}

Deleted: liboggplay/trunk/src/tools/win32-player.c
===================================================================
--- liboggplay/trunk/src/tools/win32-player.c	2008-05-01 09:40:13 UTC (rev 3578)
+++ liboggplay/trunk/src/tools/win32-player.c	2008-05-02 04:35:28 UTC (rev 3579)
@@ -1,898 +0,0 @@
-#include "config_win32.h"
-
-#include <oggplay/oggplay.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <windows.h>
-
-#define OPENGL 0
-
-#if OPENGL
-#include <glut.h> // requires OpenGL for Win32
-#endif /* !OPENGL */
-
-#define USE_AUDIO 1
-
-#if USE_AUDIO
-#include <mmreg.h>
-#include <math.h>
-#endif
-
-#include <assert.h>
-
-static int            n_frames = 0;
-static DWORD			    position = 0;
-static UINT				    target = 0;
-static DWORD          rate = 0;
-static UINT				    channels = 2;
-static BOOL				    buffering = TRUE;
-static BOOL				    audio_opened = FALSE;
-
-static UINT          total_bytes = 0;
-
-#if OPENGL
-static GLuint texture;
-#endif
-
-#define OGGPLAY_BUFFER_SIZE 20
-#define BLOCK_SIZE  2560
-#define BLOCK_COUNT 4
-
-static unsigned char  *texture_bits = NULL;
-static int            texture_width;
-static int            texture_height;
-static float          texture_wscale;
-static float          texture_hscale;
-static int            window_width;
-static int            window_height;
-static int            window_style;
-
-static OggPlay*       player = NULL;
-
-static CRITICAL_SECTION waveCriticalSection;
-static HWAVEOUT			    hWaveOut;
-static WAVEHDR*         waveBlocks = NULL;
-static volatile int     waveFreeBlockCount;
-static int              waveCurrentBlock;
-
-static HANDLE			      audio_synch;
-typedef struct {
-  HANDLE           decode_thread;
-  HANDLE           display_thread;
-} Player_Info;
-
-
-// oggplay buffer underrun semaphore
-static HANDLE           sem;
-static HWAVEOUT         audio_dev;
-
-static int video_track;
-static int audio_track;
-
-
-#define APPLICATIONNAME TEXT("OggPlay Media Player\0")
-#define CLASSNAME       TEXT("OggPlayMediaPlayer\0")
-
-#if OPENGL
-static int        window;
-#else
-static HWND        window;
-#endif /*OPENGL*/
-
-#define DISPLAY_FRAMES 1
-
-#define CLAMP(v) (v > 255 ? 255 : v < 0 ? 0 : v)
-
-
-void
-handle_video_data (OggPlay * player, int track_num, 
-                    OggPlayVideoData * video_data, int frame) {
-
-  int               i;      
-  int               y_width;
-  int               y_height;
-  int               uv_width;
-  int               uv_height;
-  int               po2_width;
-  int               po2_height;  
-  int				style;
-  OggPlayYUVChannels      yuv;
-  OggPlayRGBChannels      rgb;  
-  RECT				r;
-
-#if 0  
-  unsigned char*     ptry;
-  unsigned char*     ptru;
-  unsigned char*     ptrv;
-  unsigned char*     ptro;
-  unsigned char*     ptro2;
-#endif
-
-  oggplay_get_video_y_size(player, track_num, &y_width, &y_height);
-  if (y_width != window_width)
-  {
-#if DISPLAY_FRAMES
-#if OPENGL
-	glutReshapeWindow(y_width, y_height);
-#else    
-    style = window_style & ~ WS_OVERLAPPED;
-    GetClientRect(window, &r);
-	r.right = r.left + y_width + 5;
-	r.bottom = r.top + y_height + 5;
-	// allow for the border, title size, etc.
-	AdjustWindowRect(&r, style, FALSE);
-	SetWindowPos(window, HWND_TOP, 0, 0, 
-        r.right - r.left, r.bottom - r.top,
-		SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | SWP_NOMOVE | 
-		SWP_NOOWNERZORDER | SWP_NOSENDCHANGING | SWP_NOZORDER | SWP_SHOWWINDOW);
-	UpdateWindow(window);
-#endif /* !OPENGL */
-#endif;
-    window_width = y_width;
-    window_height = y_height;
-  }
-    
-  oggplay_get_video_uv_size(player, track_num, &uv_width, &uv_height);
-  assert(uv_width == y_width / 2);
-  assert(uv_height == y_height / 2);
-  
-  for (po2_width = 1; po2_width < y_width; po2_width <<= 1);
-  for (po2_height = 1; po2_height < y_height; po2_height <<= 1);
-  texture_wscale = (float) y_width / po2_width;
-  texture_hscale = (float) y_height / po2_height;
-
-  if (texture_bits == NULL) {
-
-    texture_bits = (unsigned char*)calloc(1, po2_width * po2_height * 4);
-    texture_width = po2_width;
-    texture_height = po2_height;    
-    
-  } else if (texture_width != po2_width || texture_height != po2_height) {
-
-    free(texture_bits);
-    
-    texture_bits = (unsigned char*)calloc(1, po2_width * po2_height * 4);
-    texture_width = po2_width;
-    texture_height = po2_height;
-  }
-
-  /*
-   *  R = Y + 1.140V
-   *  G = Y - 0.395U - 0.581V
-   *  B = Y + 2.032U
-   */
-    
-#if 1
-  
-  yuv.ptry = video_data->y;
-  yuv.ptru = video_data->u;
-  yuv.ptrv = video_data->v;
-  yuv.uv_width = uv_width;
-  yuv.uv_height = uv_height;  
-  yuv.y_width = y_width;
-  yuv.y_height = y_height;  
-  
-  rgb.ptro = texture_bits;
-  rgb.rgb_width = texture_width;
-  rgb.rgb_height = texture_height;  
-
-#if OPENGL
-  oggplay_yuv2rgb(&yuv, &rgb);
-#else
-  oggplay_yuv2bgr(&yuv, &rgb);
-#endif 
-
-#else
-  ptry = video_data->y;
-  ptru = video_data->u;
-  ptrv = video_data->v;
-  ptro = texture_bits;
-
-  for (i = 0; i < y_height; i++) {
-    int j;
-    ptro2 = ptro;
-    for (j = 0; j < y_width; j += 2) {
-
-      short pr, pg, pb;
-      short r, g, b;
-      
-    //pr = ((128 + (ptrv[j/2] - 128) * 292) >> 8) - 16; /* 1.14 * 256 */
-      pr = (-41344 + ptrv[j/2] * 292) >> 8;
-    //pg = ((128 - (ptru[j/2] - 128) * 101 - (ptrv[j/2] - 128) * 149) >> 8)-16; 
-    //                                /* 0.395 & 0.581 */
-      pg = (28032 - ptru[j/2] * 101 - ptrv[j/2] * 149) >> 8;
-    //pb = ((128 + (ptru[j/2] - 128) * 520) >> 8) - 16; /* 2.032 */
-      pb = (-70528 + ptru[j/2] * 520) >> 8;
-
-      r = ptry[j] + pr;
-      g = ptry[j] + pg;
-      b = ptry[j] + pb;
-
-      *ptro2++ = CLAMP(r);
-      *ptro2++ = CLAMP(g);
-      *ptro2++ = CLAMP(b);
-      
-      r = ptry[j + 1] + pr;
-      g = ptry[j + 1] + pg;
-      b = ptry[j + 1] + pb;
-      
-      *ptro2++ = CLAMP(b);
-      *ptro2++ = CLAMP(g);
-      *ptro2++ = CLAMP(r);
-    }
-    ptry += y_width;
-    if (i & 1) {
-      ptru += uv_width;
-      ptrv += uv_width;
-    }
-    ptro += po2_width * 3;
-  }
-  
-  
-#endif
- 
-}
-
-#if USE_AUDIO
-
-void
-float_to_short_array(const float* in, short* out, int len) {
-        int i = 0;
-        float scaled_value = 0;		
-        for(i = 0; i < len; i++) {				
-                scaled_value = floorf(0.5 + 32768 * in[i]);
-                if (in[i] < 0) {
-                   out[i] = (scaled_value < -32768.0) ? -32768 : (short)scaled_value;
-                } else {
-                   out[i] = (scaled_value > 32767.0) ? 32767 : (short)scaled_value;
-                }
-        }
-}
-
-WAVEHDR* allocateBlocks(int size, int count)
-{
-    unsigned char* buffer;    
-    int i;
-    WAVEHDR* blocks;
-    DWORD totalBufferSize = (size + sizeof(WAVEHDR)) * count;
-    
-    /*
-     * allocate memory for the entire set in one go     
-     */    
-    if((buffer = HeapAlloc(
-        GetProcessHeap(), 
-        HEAP_ZERO_MEMORY, 
-        totalBufferSize
-        )) == NULL) {
-        printf("Memory allocation error\n");
-        ExitProcess(1);
-    }
-
-    /*
-     * and set up the pointers to each bit
-     */
-    blocks = (WAVEHDR*)buffer;
-    buffer += sizeof(WAVEHDR) * count;
-    for(i = 0; i < count; i++) {
-        blocks[i].dwBufferLength = size;
-        blocks[i].lpData = buffer;
-        buffer += size;
-    }
-    
-    return blocks;
-}
-
-void freeBlocks(WAVEHDR* blockArray)
-{    
-	  /* 
-     * and this is why allocateBlocks works the way it does     
-     */     
-    HeapFree(GetProcessHeap(), 0, blockArray);
-}
-
-static void CALLBACK waveOutProc(
-    HWAVEOUT hWaveOut, 
-    UINT uMsg, 
-    DWORD dwInstance,  
-    DWORD dwParam1,    
-    DWORD dwParam2     
-)
-{
-    /*
-     * pointer to free block counter
-     */
-    int* freeBlockCounter = (int*)dwInstance;
-    /*
-     * ignore calls that occur due to openining and closing the
-     * device.
-     */
-    if(uMsg != WOM_DONE)
-        return;
-
-    EnterCriticalSection(&waveCriticalSection);
-    (*freeBlockCounter)++;
-    /*if ((*freeBlockCounter) == 1) 
-       SetEvent(audio_synch);*/
-    LeaveCriticalSection(&waveCriticalSection);	
-}
-
-void openAudio(OggPlay * player, int track) {
-	WAVEFORMATEX wfx;		
-	UINT fps = 25; // get from the stream information
-	UINT supported = FALSE;
-		
-	waveBlocks         = allocateBlocks(BLOCK_SIZE, BLOCK_COUNT);
-	waveFreeBlockCount = BLOCK_COUNT;
-  waveCurrentBlock   = 0;  
- 	wfx.nSamplesPerSec  = (DWORD)rate;  /* sample rate */
-  wfx.wBitsPerSample  = 16;     /* sample size */
-  wfx.nChannels       = channels;      /* channels    */
-  wfx.cbSize          = 0;      /* size of _extra_ info */
-  wfx.wFormatTag      = WAVE_FORMAT_PCM;
-  wfx.nBlockAlign     = (wfx.wBitsPerSample * wfx.nChannels) >> 3;
-  wfx.nAvgBytesPerSec = wfx.nBlockAlign * wfx.nSamplesPerSec;
-	// target sample size in bytes for each frame
-	target				= wfx.nAvgBytesPerSec / fps; 	
-
-	supported = waveOutOpen(NULL, WAVE_MAPPER, &wfx, (DWORD_PTR)0, (DWORD_PTR)0, 
-		WAVE_FORMAT_QUERY);
-	if (supported == MMSYSERR_NOERROR) { // audio device sucessfully opened
-		waveOutOpen((LPHWAVEOUT)&hWaveOut, WAVE_MAPPER, &wfx, 
-	      (DWORD_PTR)waveOutProc, (DWORD_PTR)&waveFreeBlockCount, CALLBACK_FUNCTION);
-		//printf("Audio device sucessfully opened\n");
-	} else if (supported == WAVERR_BADFORMAT) {
-       printf("Requested format not supported...\n");
-       ExitProcess(1);
-	} else {
-       printf("Error opening default audio device. Exiting...\n");
-       ExitProcess(1);
-	}	
-  return;
-}
-
-
-void writeAudio(LPSTR data, int samples)
-{    
-	WAVEHDR* current;	
-  int bytes;
-	int remain;
-
-  current = &waveBlocks[waveCurrentBlock];
-  
-  while(samples > 0) {
-      /* 
-       * first make sure the header we're going to use is unprepared
-       */
-      if(current->dwFlags & WHDR_PREPARED) 
-          waveOutUnprepareHeader(hWaveOut, current, sizeof(WAVEHDR));
-	
-	    bytes = sizeof(short) * samples;
-      total_bytes += bytes;
-      if(bytes < (int)(BLOCK_SIZE - current->dwUser)) {						
-	  	    float_to_short_array((float*)data, (short*)(current->lpData + current->dwUser), samples);						
-		      //memcpy(current->lpData + current->dwUser, data, size);
-          current->dwUser += bytes;
-          break;
-      }
-	
-      // bytes is even as BLOCK_SIZE and dwUser are even too
-      bytes = BLOCK_SIZE - current->dwUser;
-	    remain = bytes / sizeof(short); // samples left in the buffer		
-      float_to_short_array((float*)data, (short*)(current->lpData + current->dwUser), remain);
-  		//memcpy(current->lpData + current->dwUser, data, remain);
-      samples -= remain;
-      data += 2 * bytes;		
-	    current->dwBufferLength = BLOCK_SIZE;
-	    waveOutPrepareHeader(hWaveOut, current, sizeof(WAVEHDR));
-	    waveOutWrite(hWaveOut, current, sizeof(WAVEHDR));
-      if (buffering == TRUE) {
-        printf("Total bytes %d\n", total_bytes);
-      }
-      buffering = FALSE;		
-      
-      EnterCriticalSection(&waveCriticalSection);
-      waveFreeBlockCount--;
-      LeaveCriticalSection(&waveCriticalSection);
-      /*
-       * wait for a block to become free
-       */
-      while (!waveFreeBlockCount) {        
-        //printf("All audio buffer blocks empty\n");        
-        //WaitForSingleObject(audio_synch, INFINITE);
-        Sleep(10);
-      }		  
-		
-      /*
-       * point to the next block
-       */
-      waveCurrentBlock++;
-      waveCurrentBlock %= BLOCK_COUNT;		
-
-      current = &waveBlocks[waveCurrentBlock];
-      current->dwUser = 0;
-  }
-}
-
-void 
-closeAudio() {
-  int i;
-  /*
-   * wait for all blocks to complete
-   */
-  while(waveFreeBlockCount < BLOCK_COUNT)
-	  Sleep(10);
-
- /*
-  * unprepare any blocks that are still prepared
-  */
-  for(i = 0; i < waveFreeBlockCount; i++) 
-    if(waveBlocks[i].dwFlags & WHDR_PREPARED)
-	  waveOutUnprepareHeader(hWaveOut, &waveBlocks[i], sizeof(WAVEHDR));
-
-  freeBlocks(waveBlocks);
-  waveOutClose(hWaveOut);
-    
-}
-
-void
-handle_audio_data (OggPlay * player, int track, OggPlayAudioData * data, 
-                int size) {		
-	if (audio_opened == FALSE) {
-		openAudio(player, track);
-		audio_opened = TRUE;
-
-	}
-	writeAudio((LPSTR)data, size);  
-}
-#endif
-
-#if !OPENGL
-DWORD WINAPI display_frame(void *arg) {
-#else 
-void display_frame(void) {
-#endif
-  int                     i;
-  int                     j;
-  OggPlayDataHeader    ** headers;
-  OggPlayVideoData      * video_data;
-#if USE_AUDIO
-  OggPlayAudioData      * audio_data;
-#endif
-  int					  size;
-  int                     required;
-  OggPlayDataType         type;
-  int                     num_tracks;
-  OggPlayCallbackInfo  ** track_info;  
-  DWORD				            offset = 0;  
-  DWORD                   delay;
-  MMTIME                  mm;
-
-  delay = 40; // 40ms timeslots @ 25 fps
-
-  num_tracks = oggplay_get_num_tracks (player);
-
-  //nice(5);
-
-#if !OPENGL
-  while (1) { 
-#endif
-    track_info = oggplay_buffer_retrieve_next(player);
-    if (track_info == NULL) {
-#if DISPLAY_FRAMES
-      Sleep(delay);      
-
-#if OPENGL            
-      return;
-#else
-      continue;
-#endif
-    }
-#endif
-    // make sure the playback rate is correct
-	  if (buffering == FALSE) {		
-		  mm.wType = TIME_BYTES;		
-		  waveOutGetPosition(hWaveOut, &mm, sizeof(MMTIME));						  
-      if (target > (DWORD)mm.u.cb - position) {						  
-        offset = (target - (DWORD)mm.u.cb + position) * delay / target;												                               
-        Sleep(offset);
-		  }      
-		  position = (DWORD)mm.u.cb;
-	  }
-    for (i = 0; i < num_tracks; i++) {
-      type = oggplay_callback_info_get_type(track_info[i]);
-      headers = oggplay_callback_info_get_headers(track_info[i]);
-    
-      switch (type) {
-        case OGGPLAY_INACTIVE:
-          break;
-        case OGGPLAY_YUV_VIDEO:
-          /*
-           * there should only be one record
-           */
-          required = oggplay_callback_info_get_required(track_info[i]);
-          if (required == 0) {
-            oggplay_buffer_free_info(track_info);
-            oggplay_buffer_release_next(player);            
-            goto next_frame;
-            }
-          video_data = oggplay_callback_info_get_video_data(headers[0]);
-          //printf("video presentation time: %llx\n",
-          //        oggplay_callback_info_get_presentation_time(headers[0]));
-          handle_video_data(player, i, video_data, n_frames);
-          break;
-        case OGGPLAY_FLOATS_AUDIO:
-#if USE_AUDIO
-          required = oggplay_callback_info_get_required(track_info[i]);          
-          // fill in fist and second buffer          
-          for (j = 0; j < required; j++) {      
-              size = oggplay_callback_info_get_record_size(headers[j]);
-              audio_data = oggplay_callback_info_get_audio_data(headers[j]);  
-              handle_audio_data(player, i, audio_data, channels * size);            
-          }          
-          //printf("audio presentation time: %llx\n",
-          //        oggplay_callback_info_get_presentation_time(headers[j]));                    
-#endif    
-          break;
-        case OGGPLAY_CMML:
-          if (oggplay_callback_info_get_required(track_info[i]) > 0)
-            printf("%s\n", oggplay_callback_info_get_text_data(headers[0]));
-          break;
-
-        case OGGPLAY_KATE:
-          required = oggplay_callback_info_get_required(track_info[i]);
-          for (j = 0; j < required; j++)
-            printf("[%d] %s\n", j, oggplay_callback_info_get_text_data(headers[j]));
-          break;
-
-        default:
-          break;
-      }
-    }    
-    n_frames++;
-    
-#if DISPLAY_FRAMES
-#if USE_AUDIO
-#ifdef WIN32	
-	//QueryPerformanceCounter(&last_tick_count);
-#endif
-#endif
-#if OPENGL
-    glutPostRedisplay();	
-#else
-    // send WM_PAINT to the player window
-	InvalidateRect(window, NULL, TRUE);
-	UpdateWindow(window);
-#endif
-#endif /* DISPLAY_FRAMES */
- 
-    oggplay_buffer_free_info(track_info);
-    oggplay_buffer_release_next (player);
-
-next_frame:
-    ReleaseSemaphore(sem, 1, NULL);
-#if !OPENGL
-  }
-#endif  
-}
-
-#if DISPLAY_FRAMES
-void show_window(void) {
-
-#if OPENGL
-  if (texture_bits != NULL) 
-  {
-
-    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture_width, 
-                    texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 
-                    texture_bits);
-
-  }
-  
-  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-  glBegin(GL_QUADS);
-  glTexCoord2f(0.0, texture_hscale);
-  glVertex2f(-1,-1);
-  glTexCoord2f(texture_wscale, texture_hscale);
-  glVertex2f(1,-1);  
-  glTexCoord2f(texture_wscale, 0.0);
-  glVertex2f(1,1);
-  glTexCoord2f(0.0, 0.0);
-  glVertex2f(-1,1);
-  glEnd();
-  glutSwapBuffers();
-#endif
-}
-#endif
-
-
-DWORD WINAPI drive_decoding(void *arg) {
-
-  while (1) { 
-    OggPlayErrorCode r;
-    WaitForSingleObject(sem, INFINITE);   
-
-	r = oggplay_step_decoding(player);
-
-    if (r != E_OGGPLAY_CONTINUE && r != E_OGGPLAY_USER_INTERRUPT) {
-#if DISPLAY_FRAMES
-#if OPENGL
-	  glutDestroyWindow(window);
-#endif
-#endif
-      // stop all treads and close the window 
-      SendMessage(window, WM_CLOSE, (WPARAM)0, (LPARAM)0);
-      Sleep(10);
-    }
-  }
-}
-
-
-#if !OPENGL
-void CreateDDBitmap(HDC hdc, HBITMAP* hBitmap) {
-
-	BITMAPINFOHEADER bih;
-	BITMAPINFO bmi;
-
-	// fill in BITMAPINFOHEADER
-	ZeroMemory(&bih, sizeof(BITMAPINFOHEADER));
-	bih.biClrImportant = 0;
-	bih.biClrUsed = 0;
-	bih.biXPelsPerMeter = 0;
-	bih.biYPelsPerMeter = 0;
-	bih.biSize = 40;
-	bih.biWidth = texture_width;
-	bih.biHeight = -texture_height;
-	bih.biPlanes = 1;
-	bih.biBitCount = 32;
-	bih.biCompression = BI_RGB;				
-	bih.biSizeImage = ((bih.biWidth * 32 + 31) & ~31) /8 * (-bih.biHeight);
-        //(((bih.biWidth * bih.biBitCount / 8) + 3) & ~3) * bih.biHeight;
-	
-	// fill in BITMAPINFO
-	ZeroMemory(&bmi, sizeof(BITMAPINFO));
-	bmi.bmiHeader = bih;	
-		
-	// create bitmap from raw rgb bits
-	SetDIBits(hdc, (*hBitmap), 0, texture_height, texture_bits, 
-						&bmi, DIB_RGB_COLORS);
-	/*SetDIBitsToDevice(hdc, 0, 0, texture_width, texture_height, 
-						0, 0, 0, texture_height, texture_bits, &bmi, DIB_RGB_COLORS);*/
-	return;
-}
-
-LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
-{
-	PAINTSTRUCT ps;	
-	RECT r;
-	HDC hdc, hdcMem;
-	HBITMAP hbmOld, hbm;
-
-	BITMAP bm;
-	Player_Info* info = NULL;	
-
-    switch(message)
-    {
-		case WM_PAINT : {							
-		    hdc = BeginPaint(window, &ps);
-        GetClientRect(window, &r);
-				/* FIXME: very performance costly operations, use global context? */
-				hdcMem = CreateCompatibleDC(hdc);
-				hbm = CreateCompatibleBitmap(hdc, texture_width, texture_height);
-				CreateDDBitmap(hdc, &hbm);
-				hbmOld = SelectObject(hdcMem, hbm);
-				
-				if ((r.right - r.left != window_width) ||
-					(r.bottom - r.top != window_height)) {
-					StretchBlt(hdc, r.left, r.top, r.right - r.left, r.bottom - r.top, 
-						hdcMem, r.left, r.top, r.left + window_width, r.top + window_height,
-						SRCCOPY);
-				} else  {				
-					BitBlt(hdc, 0, 0, window_width, window_height, hdcMem, 
-						    0, 0, SRCCOPY);
-				}
-				//restore the initial state
-				SelectObject(hdcMem, hbmOld);
-				DeleteObject(hbm);
-                DeleteDC(hdcMem);                
-				EndPaint(window, &ps);
-			}
-			break;
-		case WM_CLOSE: {
-				info = (Player_Info*)GetWindowLong(window, GWL_USERDATA);
-				TerminateThread(info->decode_thread, (DWORD)0);
-        TerminateThread(info->display_thread, (DWORD)0);
-        CloseHandle(info->decode_thread);
-				CloseHandle(info->display_thread);
-        ExitProcess(0);
-        /*SuspendThread(info->decode_thread);
-				SuspendThread(info->display_thread);*/
-			}
-            break;
-        
-		case WM_DESTROY: {				
-				PostQuitMessage(0);
-			}
-            break;		
-		default:
-            return DefWindowProc(hWnd, message, wParam, lParam);
-
-	}
-	return 0;
-}
-
-int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int 
-				   nCmdShow) {
-#else
-int
-main (int argc, char * argv[]) {
-#endif
-	
-  OggPlayReader * reader;
-  int             i;  
-
-  MSG			  msg = {0};
-  WNDCLASSEX	  wc;
-  Player_Info	  info;
-  DWORD			  dec_id;
-  DWORD			  disp_id;  
-  LONG        offset = 0L;
-  BOOL fGotMessage;
-
-#if OPENGL
-  if (argc < 2) {
-    printf ("please provide a filename\n");
-    exit (1);
-  }
- 
-  if (strncmp(argv[1], "http://", 7) == 0) {
-    reader = oggplay_tcp_reader_new();
-  } else {
-    reader = oggplay_file_reader_new();
-  }
-
-  player = oggplay_open_with_reader(reader, argv[1]);
-#else
-  reader = oggplay_file_reader_new();
-  //reader = oggplay_tcp_reader_new();
-  //player = oggplay_open_with_reader(reader, "http://media.annodex.net/cmmlwiki/SFD2005-Trailer.axv");
-  player = oggplay_open_with_reader(reader, "E:\\_marcin\\_devel\\ogg_play\\index.anx");
-#endif
-
-  if (player == NULL) {
-    printf ("could not initialise oggplay with this file\n");
-    return 1;
-  }
-
-  printf ("there are %d tracks\n", oggplay_get_num_tracks (player));
-  
-  for (i = 0; i < oggplay_get_num_tracks (player); i++) {
-    printf("Track %d is of type %s\n", i, 
-                    oggplay_get_track_typename (player, i));
-    if (oggplay_get_track_type (player, i) == OGGZ_CONTENT_THEORA) {
-      oggplay_set_callback_num_frames (player, i, 1);
-      video_track = i;
-    }
-    else if (oggplay_get_track_type (player, i) == OGGZ_CONTENT_VORBIS) {
-      audio_track = i;
-      channels = 2;//oggplay_get_audio_channels(player, audio_track);
-  	  if (!channels)
-	  	  printf("Problems reading channel information\n");				
-	    rate = 16000;//oggplay_get_audio_samplerate(player, audio_track);
-  	  if (!rate)
-	  	  printf("Problems retreiving sample rate information\n");    
-      // calculate audio offset in [ms]
-      offset = (LONG)(1000 * BLOCK_SIZE * BLOCK_COUNT / channels / sizeof(short) / rate);      
-      printf("Calculated offset: %d\n", offset);
-      oggplay_set_offset(player, i, offset); 
-    }
-
-    if (oggplay_set_track_active(player, i) < 0) {
-      printf("\tNote: Could not set this track active!\n");
-    }
-  }
-
-#if DISPLAY_FRAMES
-#if OPENGL
-  glutInit(&argc, argv);
-  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
-  glutInitWindowPosition(100, 100);
-  glutInitWindowSize(400, 400);
-#endif /* !OPENGL */
-#endif /* !DISPLAY_FRAMES */
-  window_width = 400;
-  window_height = 400;
-#if DISPLAY_FRAMES
-#if OPENGL
-  window = glutCreateWindow("glut player");
-#else
-  // InitApplication
-  ZeroMemory(&wc, sizeof(WNDCLASSEX));
-  wc.cbSize = sizeof(WNDCLASSEX);
-  wc.style = 0; // thick frame?
-  wc.lpfnWndProc = WndProc;
-  wc.cbClsExtra = 0;
-  wc.cbWndExtra = 0;
-  wc.hInstance = hInstance;
-  wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
-  wc.hCursor = LoadCursor(NULL, IDC_ARROW);
-  wc.lpszMenuName = NULL;
-  wc.lpszClassName = CLASSNAME;	
-  
-  if (!RegisterClassEx(&wc)) {
-  // end of InitApplication
- 	  printf("Window registration failed\n");
-	  return 1;
-  }
-  window_style = WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
-  // InitInstance
-  window = CreateWindowEx(WS_EX_CLIENTEDGE, CLASSNAME, APPLICATIONNAME, window_style, 
-						CW_USEDEFAULT, CW_USEDEFAULT, window_width, window_height,
-						NULL, NULL, hInstance, NULL);
-  // InitInstance
-  if (window == NULL) {
-	  printf("Window creation failed\n");		  
-	  return 1;  
-  }
-  // display and update window
-
-#endif
-#endif // DISPLAY_FRAMES
-
-  oggplay_use_buffer(player, OGGPLAY_BUFFER_SIZE);
-
-  audio_synch = CreateEvent(0, FALSE, FALSE, 0);
-  sem = CreateSemaphore(NULL, (long)OGGPLAY_BUFFER_SIZE, (long)OGGPLAY_BUFFER_SIZE, NULL);
-  
-  InitializeCriticalSection(&waveCriticalSection);
-  info.decode_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)drive_decoding, NULL, 0, &dec_id);  
-#if !OPENGL
-  info.display_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)display_frame, NULL, 0, &disp_id);    
-  SetWindowLong(window, GWL_USERDATA, (long)&info); 
-#endif
-
-#if DISPLAY_FRAMES
-#if OPENGL
-  glutIdleFunc(&display_frame);  
-  glutDisplayFunc(&show_window);
-  //glutDisplayFunc(&empty);
-
-  glEnable(GL_TEXTURE_2D);
-  glDisable(GL_CULL_FACE);
-  glBindTexture(GL_TEXTURE_2D, texture);
-  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
-  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
-  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-  glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
-  glGenTextures(1, &texture);
-
-  //nice(5);
-  
-  glutMainLoop();
-#else
-
-  // process window messages  
-  while ((fGotMessage = GetMessage(&msg, (HWND) NULL, 0, 0)) != 0 && fGotMessage != -1) 
-  { 
-	  TranslateMessage(&msg); 
-	  DispatchMessage(&msg); 
-  }
-  DeleteCriticalSection(&waveCriticalSection);  
-#endif  
-
-
-#else
-  while (1) {
-    display_frame(NULL);
-  }
-#endif /* !DISPLAY_FRAMES */
- 
-  printf("there were %d frames\n", n_frames);
-
-#if !OPENGL
-	return msg.wParam; 
-	UNREFERENCED_PARAMETER(lpCmdLine); 
-#endif
-}



More information about the commits mailing list