<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -153,8 +153,10 @@ public:
       sa_stream_drain(mAudio);
       sa_stream_destroy(mAudio);
     }
-    if (mSurface)
+    if (mSurface) {
       SDL_FreeSurface(mSurface);
+      mSurface = 0;
+    }
   }
   void play(istream&amp; stream);
 };
@@ -327,7 +329,8 @@ void OggDecoder::play(istream&amp; is) {
     while ((samples = vorbis_synthesis_pcmout(&amp;audio-&gt;mVorbis.mDsp, &amp;pcm)) &gt; 0) {
       if (mAudio) {
 	if (samples &gt; 0) {
-	  short buffer[samples * audio-&gt;mVorbis.mInfo.channels];
+          size_t size = samples * audio-&gt;mVorbis.mInfo.channels;
+          short* buffer = new short[size];
 	  short* p = buffer;
 	  for (int i=0;i &lt; samples; ++i) {
 	    for(int j=0; j &lt; audio-&gt;mVorbis.mInfo.channels; ++j) {
@@ -338,8 +341,9 @@ void OggDecoder::play(istream&amp; is) {
 	    }
 	  }
 	  
-	  ret = sa_stream_write(mAudio, buffer, sizeof(buffer));
+          ret = sa_stream_write(mAudio, buffer, sizeof(*buffer)*size);
 	  assert(ret == SA_SUCCESS);
+          delete[] buffer;
 	}
 	
 	ret = vorbis_synthesis_read(&amp;audio-&gt;mVorbis.mDsp, samples);
@@ -363,7 +367,11 @@ void OggDecoder::play(istream&amp; is) {
       //
       if (video) {
 	ogg_int64_t position = 0;
-	int ret = sa_stream_get_position(mAudio, SA_POSITION_WRITE_SOFTWARE, &amp;position);
+        sa_position_t positionType = SA_POSITION_WRITE_SOFTWARE;
+#if defined(WIN32)
+        positionType = SA_POSITION_WRITE_HARDWARE;
+#endif	
+        int ret = sa_stream_get_position(mAudio, positionType, &amp;position);
 	assert(ret == SA_SUCCESS);
 	float audio_time = 
 	  float(position) /
@@ -399,8 +407,6 @@ void OggDecoder::play(istream&amp; is) {
   // Cleanup
   ret = ogg_sync_clear(&amp;state);
   assert(ret == 0);
-
-  SDL_Quit();
 }
 
 bool OggDecoder::handle_theora_header(OggStream* stream, ogg_packet* packet) {
@@ -515,9 +521,10 @@ void usage() {
   cout &lt;&lt; &quot;Usage: plogg &lt;filename&gt;&quot; &lt;&lt; endl;
 }
 
-int main(int argc, const char* argv[]) {
+int main(int argc, char* argv[]) {
   if (argc != 2) { 
     usage();
+    return 0;
   }
 
   ifstream file(argv[1], ios::in | ios::binary);
@@ -532,7 +539,7 @@ int main(int argc, const char* argv[]) {
       delete stream;
     }
   }
-  
+  SDL_Quit();
   return 0;
 }
 // Copyright (C) 2009 Chris Double. All Rights Reserved.</diff>
      <filename>plogg.cpp</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ca3b9220f70a2012a7d0b4c2daa5658aadab4050</id>
    </parent>
  </parents>
  <author>
    <name>Chris Pearch</name>
    <email>chris@pearce.org.nz</email>
  </author>
  <url>http://github.com/doublec/plogg/commit/a8e441019c63feb9f5e1ed869e4a3f0f76fd669c</url>
  <id>a8e441019c63feb9f5e1ed869e4a3f0f76fd669c</id>
  <committed-date>2009-11-01T19:46:27-08:00</committed-date>
  <authored-date>2009-11-01T19:46:27-08:00</authored-date>
  <message>Patch to compile on win32</message>
  <tree>03cddfc978fca7603729cd18922a8cf1ff6c7238</tree>
  <committer>
    <name>Chris Double</name>
    <email>chris.double@double.co.nz</email>
  </committer>
</commit>
