From 52b1bbadfce33c88f5651b913257e41fade77a8f Mon Sep 17 00:00:00 2001 From: Cary Sandvig Date: Fri, 10 Nov 2000 20:50:01 +0000 Subject: [PATCH] buffer error found --- panda/src/audiotraits/audio_load_mp3.cxx | 47 ++++++++++++++++-------- panda/src/gui/guiLabel.cxx | 4 +- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/panda/src/audiotraits/audio_load_mp3.cxx b/panda/src/audiotraits/audio_load_mp3.cxx index 8956c5711e..38441bab0f 100644 --- a/panda/src/audiotraits/audio_load_mp3.cxx +++ b/panda/src/audiotraits/audio_load_mp3.cxx @@ -131,7 +131,6 @@ static void initialize(void) { initialized = true; } -/* class BufferStuff { private: typedef vector Buffer; @@ -158,7 +157,6 @@ public: }; static BufferStuff* my_buf; -*/ /* class BufferPart { @@ -200,7 +198,9 @@ static BufferPart* my_buf_head; static BufferPart* my_buf_curr; */ +/* string my_buf; +*/ extern "C" { int audio_open(struct audio_info_struct* ai) { @@ -256,15 +256,18 @@ int audio_play_samples(struct audio_info_struct* ai, unsigned char* buf, my_buf_curr = my_buf_curr->add(buf, len); } */ - /* + if (my_buf == (BufferStuff*)0L) my_buf = new BufferStuff; my_buf->add(buf, len); - */ + + /* string tmp; for (int i=0; ifatal() << "cannot allocate sample buffer" << endl; exit(1); } + // pcm_sample = &(real_sample_buf[1024]); switch (param.outmode) { case DECODE_AUDIO: if (audio_open(&ai) < 0) { @@ -420,8 +427,8 @@ static void read_file(Filename filename, unsigned char** buf, initialize(); // my_buf_head = my_buf_curr = (BufferPart*)0L; - // my_buf = (BufferStuff*)0L; - my_buf = ""; + my_buf = (BufferStuff*)0L; + // my_buf = ""; if (open_stream((char*)(filename.to_os_specific().c_str()), -1)) { long leftFrames, newFrame; @@ -455,8 +462,6 @@ static void read_file(Filename filename, unsigned char** buf, if (audio_cat->is_debug()) audio_cat->debug(false) << endl; audio_flush(param.outmode, &ai); - if (pcm_sample != (unsigned char*)0L) - free(pcm_sample); switch (param.outmode) { case DECODE_AUDIO: audio_close(&ai); @@ -471,6 +476,16 @@ static void read_file(Filename filename, unsigned char** buf, cdr_close(); break; } + /* + if (real_sample_buf != (unsigned char*)0L) { + free(real_sample_buf); + pcm_sample = (unsigned char*)0L; + } + */ + if (pcm_sample != (unsigned char*)0L) { + free(pcm_sample); + pcm_sample = (unsigned char*)0L; + } // generate output /* slen = my_buf_head->length(); @@ -478,16 +493,18 @@ static void read_file(Filename filename, unsigned char** buf, my_buf_head->output(*buf); delete my_buf_head; */ - /* + slen = my_buf->length(); *buf = new byte[slen]; my_buf->output(*buf); delete my_buf; my_buf = (BufferStuff*)0L; - */ + + /* slen = my_buf.size(); *buf = new byte[slen]; memcpy(*buf, my_buf.data(), slen); + */ } #ifdef AUDIO_USE_MIKMOD diff --git a/panda/src/gui/guiLabel.cxx b/panda/src/gui/guiLabel.cxx index b126097e11..5bde75b8e5 100644 --- a/panda/src/gui/guiLabel.cxx +++ b/panda/src/gui/guiLabel.cxx @@ -28,7 +28,7 @@ void GuiLabel::recompute_transform(void) { break; default: gui_cat->warning() << "recompute_transform on invalid label type (" - << _type << ")" << endl; + << (int)_type << ")" << endl; } set_properties(); } @@ -61,7 +61,7 @@ void GuiLabel::set_properties(void) { break; default: gui_cat->warning() << "recompute_transform on invalid label type (" - << _type << ")" << endl; + << (int)_type << ")" << endl; } }