From ad350a207efbead3cfecdf15eeafe49422311145 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 24 Mar 2016 23:55:21 +0100 Subject: [PATCH 1/3] Replace use of deprecated base.loadSfx/loadMusic with loader.loadSfx/Music --- samples/music-box/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/music-box/main.py b/samples/music-box/main.py index 774168f782..dd8ecf0299 100755 --- a/samples/music-box/main.py +++ b/samples/music-box/main.py @@ -41,7 +41,7 @@ class MusicBox(DirectObject): # Loading sounds is done in a similar way to loading other things # Loading the main music box song - self.musicBoxSound = base.loadMusic('music/musicbox.ogg') + self.musicBoxSound = loader.loadMusic('music/musicbox.ogg') self.musicBoxSound.setVolume(.5) # Volume is a percentage from 0 to 1 # 0 means loop forever, 1 (default) means # play once. 2 or higher means play that many times @@ -69,7 +69,7 @@ class MusicBox(DirectObject): # Loading the open/close effect # loadSFX and loadMusic are identical. They are often used for organization #(loadMusic is used for background music, loadSfx is used for other effects) - self.lidSfx = base.loadSfx('music/openclose.ogg') + self.lidSfx = loader.loadSfx('music/openclose.ogg') # The open/close file has both effects in it. Fortunatly we can use intervals # to easily define parts of a sound file to play self.lidOpenSfx = SoundInterval(self.lidSfx, duration=2, startTime=0) From ce947adf8f33a28c50c3f9083859a3f64c035601 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 24 Mar 2016 23:56:12 +0100 Subject: [PATCH 2/3] Replace uses of "delete" with "delete[]" where appropriate --- dtool/src/dtoolutil/executionEnvironment.cxx | 3 +-- dtool/src/dtoolutil/pfstreamBuf.cxx | 2 +- panda/src/downloader/download_utils.cxx | 4 ++-- panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dtool/src/dtoolutil/executionEnvironment.cxx b/dtool/src/dtoolutil/executionEnvironment.cxx index a51fb7741c..b6ae2c7f71 100644 --- a/dtool/src/dtoolutil/executionEnvironment.cxx +++ b/dtool/src/dtoolutil/executionEnvironment.cxx @@ -283,7 +283,7 @@ ns_get_environment_variable(const string &var) const { if (item != NULL) { if (PyUnicode_Check(item)) { Py_ssize_t size = PyUnicode_GetSize(item); - wchar_t *data = new wchar_t[size + 1]; + wchar_t *data = (wchar_t *)alloca(sizeof(wchar_t) * (size + 1)); #if PY_MAJOR_VERSION >= 3 if (PyUnicode_AsWideChar(item, data, size) != -1) { #else @@ -292,7 +292,6 @@ ns_get_environment_variable(const string &var) const { wstring wstr (data, size); main_dir = Filename::from_os_specific_w(wstr); } - delete data; } #if PY_MAJOR_VERSION < 3 else if (PyString_Check(item)) { diff --git a/dtool/src/dtoolutil/pfstreamBuf.cxx b/dtool/src/dtoolutil/pfstreamBuf.cxx index fc0de36048..1fd59207ca 100644 --- a/dtool/src/dtoolutil/pfstreamBuf.cxx +++ b/dtool/src/dtoolutil/pfstreamBuf.cxx @@ -122,7 +122,7 @@ int PipeStreamBuf::underflow(void) { #endif /* PHAVE_IOSTREAM */ gbump(-((int)n)); } - delete buf; + delete[] buf; return ret; } diff --git a/panda/src/downloader/download_utils.cxx b/panda/src/downloader/download_utils.cxx index d1aba78fd6..be31c81cd8 100644 --- a/panda/src/downloader/download_utils.cxx +++ b/panda/src/downloader/download_utils.cxx @@ -41,7 +41,7 @@ check_crc(Filename name) { unsigned long crc = crc32(0L, Z_NULL, 0); crc = crc32(crc, (unsigned char *)buffer, buffer_length); - delete buffer; + delete[] buffer; return crc; } @@ -67,7 +67,7 @@ check_adler(Filename name) { unsigned long adler = adler32(0L, Z_NULL, 0); adler = adler32(adler, (unsigned char *)buffer, buffer_length); - delete buffer; + delete[] buffer; return adler; } diff --git a/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx b/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx index a73d1c415c..97964714fa 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeJPGWriter.cxx @@ -333,7 +333,7 @@ write_data(xel *array, xelval *) { row_pointer[0] = row; (void) jpeg_write_scanlines(&cinfo, row_pointer, 1); } - delete row; + delete[] row; /* Step 6: Finish compression */ From 2b034506fad5a64efdd3f8c6a390e061c11dda0b Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 24 Mar 2016 23:57:00 +0100 Subject: [PATCH 3/3] Backport fixes for Arch compile issues to 1.9 --- direct/src/dcparser/dcPython.h | 1 - panda/src/ffmpeg/ffmpegAudioCursor.cxx | 16 ++++++++++++++++ panda/src/ffmpeg/ffmpegVideoCursor.cxx | 22 +++++++++++++++++++--- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/direct/src/dcparser/dcPython.h b/direct/src/dcparser/dcPython.h index d5a50baa2f..6236f8f0b6 100644 --- a/direct/src/dcparser/dcPython.h +++ b/direct/src/dcparser/dcPython.h @@ -20,7 +20,6 @@ #ifdef HAVE_PYTHON -#undef HAVE_LONG_LONG // NSPR and Python both define this. #undef _POSIX_C_SOURCE #include diff --git a/panda/src/ffmpeg/ffmpegAudioCursor.cxx b/panda/src/ffmpeg/ffmpegAudioCursor.cxx index a33db26b6f..38c3057c6f 100644 --- a/panda/src/ffmpeg/ffmpegAudioCursor.cxx +++ b/panda/src/ffmpeg/ffmpegAudioCursor.cxx @@ -210,7 +210,11 @@ cleanup() { if (_packet) { if (_packet->data) { +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) + av_packet_unref(_packet); +#else av_free_packet(_packet); +#endif } delete _packet; _packet = NULL; @@ -251,7 +255,11 @@ cleanup() { void FfmpegAudioCursor:: fetch_packet() { if (_packet->data) { +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) + av_packet_unref(_packet); +#else av_free_packet(_packet); +#endif } while (av_read_frame(_format_ctx, _packet) >= 0) { if (_packet->stream_index == _audio_index) { @@ -259,7 +267,11 @@ fetch_packet() { _packet_data = _packet->data; return; } +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) + av_packet_unref(_packet); +#else av_free_packet(_packet); +#endif } _packet->data = 0; _packet_size = 0; @@ -312,7 +324,11 @@ reload_buffer() { pkt.size = _packet_size; int len = avcodec_decode_audio4(_audio_ctx, _frame, &got_frame, &pkt); movies_debug("avcodec_decode_audio4 returned " << len); +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) + av_packet_unref(&pkt); +#else av_free_packet(&pkt); +#endif bufsize = 0; if (got_frame) { diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index 87b3b48395..45e72026c8 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -89,9 +89,13 @@ init_from(FfmpegVideo *source) { #ifdef HAVE_SWSCALE nassertv(_convert_ctx == NULL); - _convert_ctx = sws_getContext(_size_x, _size_y, - _video_ctx->pix_fmt, _size_x, _size_y, - PIX_FMT_BGR24, SWS_BILINEAR | SWS_PRINT_INFO, NULL, NULL, NULL); + _convert_ctx = sws_getContext(_size_x, _size_y, _video_ctx->pix_fmt, +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51, 74, 100) + _size_x, _size_y, AV_PIX_FMT_BGR24, +#else + _size_x, _size_y, PIX_FMT_BGR24, +#endif + SWS_BILINEAR | SWS_PRINT_INFO, NULL, NULL, NULL); #endif // HAVE_SWSCALE #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 59, 100) @@ -622,7 +626,11 @@ cleanup() { if (_packet) { if (_packet->data) { +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) + av_packet_unref(_packet); +#else av_free_packet(_packet); +#endif } delete _packet; _packet = NULL; @@ -812,14 +820,22 @@ fetch_packet(int default_frame) { bool FfmpegVideoCursor:: do_fetch_packet(int default_frame) { if (_packet->data) { +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) + av_packet_unref(_packet); +#else av_free_packet(_packet); +#endif } while (av_read_frame(_format_ctx, _packet) >= 0) { if (_packet->stream_index == _video_index) { _packet_frame = _packet->dts; return false; } +#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 12, 100) + av_packet_unref(_packet); +#else av_free_packet(_packet); +#endif } _packet->data = 0;