From 5ecc8ad8636847c149f27e6386fab01e391d6eef Mon Sep 17 00:00:00 2001
From: chris <chris@ rudorff com>
Date: Sun, 27 Jun 2010 01:52:22 +0200
Subject: [PATCH 5/5] Well, increasing kDecoderProbeBufferSize to 1MB for whatever reason
 results in a stack overflow on osx.

This patch allocates that test buffer on the heap ... and if I
understood it right, the testbuf is a tmp_buf, right?
---
 mythtv/libs/libmythtv/NuppelVideoPlayer.cpp |   21 ++++++++++++++-------
 mythtv/libs/libmythtv/decoderbase.h         |    2 +-
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/mythtv/libs/libmythtv/NuppelVideoPlayer.cpp b/mythtv/libs/libmythtv/NuppelVideoPlayer.cpp
index 2fa8641..c176e35 100644
--- a/mythtv/libs/libmythtv/NuppelVideoPlayer.cpp
+++ b/mythtv/libs/libmythtv/NuppelVideoPlayer.cpp
@@ -1182,7 +1182,7 @@ int NuppelVideoPlayer::OpenFile(bool skipDsp, uint retries,
     }
 
     player_ctx->buffer->Start();
-    char testbuf[kDecoderProbeBufferSize];
+    char *testbuf = new char[kDecoderProbeBufferSize];
     player_ctx->buffer->Unpause(); // so we can read testbuf if we were paused
 
     // delete any pre-existing recorder
@@ -1196,7 +1196,7 @@ int NuppelVideoPlayer::OpenFile(bool skipDsp, uint retries,
             VERBOSE(VB_IMPORTANT,
                     QString("NVP::OpenFile(): Error, couldn't read file: %1")
                     .arg(player_ctx->buffer->GetFilename()));
-            return -1;
+            goto error;
         }
 
         player_ctx->LockPlayingInfo(__FILE__, __LINE__);
@@ -1223,13 +1223,13 @@ int NuppelVideoPlayer::OpenFile(bool skipDsp, uint retries,
                 QString("Couldn't find an A/V decoder for: '%1'")
                 .arg(player_ctx->buffer->GetFilename()));
 
-        return -1;
+        goto error;
     }
     else if (GetDecoder()->IsErrored())
     {
         VERBOSE(VB_IMPORTANT, LOC_ERR + "Could not initialize A/V decoder.");
         SetDecoder(NULL);
-        return -1;
+        goto error;
     }
 
     GetDecoder()->setExactSeeks(exactseeks);
@@ -1241,18 +1241,18 @@ int NuppelVideoPlayer::OpenFile(bool skipDsp, uint retries,
     eof = false;
 
     // Set 'no_video_decode' to true for audio only decodeing
-    bool no_video_decode = false;
+    // bool no_video_decode = false;
 
     // We want to locate decoder for video even if using_null_videoout
     // is true, only disable if no_video_decode is true.
     int ret = GetDecoder()->OpenFile(
-        player_ctx->buffer, no_video_decode, testbuf, testreadsize);
+        player_ctx->buffer, false, testbuf, testreadsize);
 
     if (ret < 0)
     {
         VERBOSE(VB_IMPORTANT, QString("Couldn't open decoder for: %1")
                 .arg(player_ctx->buffer->GetFilename()));
-        return -1;
+        goto error;
     }
 
     if (audio_bits == -1)
@@ -1276,7 +1276,14 @@ int NuppelVideoPlayer::OpenFile(bool skipDsp, uint retries,
 
     bookmarkseek = GetBookmark();
 
+    delete [] testbuf;
+
     return IsErrored() ? -1 : 0;
+
+error:
+
+    delete [] testbuf;
+    return -1;
 }
 
 void NuppelVideoPlayer::SetVideoFilters(const QString &override)
diff --git a/mythtv/libs/libmythtv/decoderbase.h b/mythtv/libs/libmythtv/decoderbase.h
index 693066a..8748e75 100644
--- a/mythtv/libs/libmythtv/decoderbase.h
+++ b/mythtv/libs/libmythtv/decoderbase.h
@@ -17,7 +17,7 @@ class RingBuffer;
 class TeletextViewer;
 class NuppelVideoPlayer;
 
-const int kDecoderProbeBufferSize = 128 * 1024;
+const int kDecoderProbeBufferSize = 1024 * 1024;
 
 /// Track types
 typedef enum TrackTypes
-- 
1.6.5.1

