mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
fix some deprecated function calls, partly based on patch from plaristotle
This commit is contained in:
parent
efe1285e88
commit
6f987a585d
@ -52,7 +52,11 @@ FfmpegAudioCursor(FfmpegAudio *src) :
|
|||||||
_format_ctx = _ffvfile.get_format_context();
|
_format_ctx = _ffvfile.get_format_context();
|
||||||
nassertv(_format_ctx != NULL);
|
nassertv(_format_ctx != NULL);
|
||||||
|
|
||||||
if (av_find_stream_info(_format_ctx)<0) {
|
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53, 6, 0)
|
||||||
|
if (avformat_find_stream_info(_format_ctx, NULL) < 0) {
|
||||||
|
#else
|
||||||
|
if (av_find_stream_info(_format_ctx) < 0) {
|
||||||
|
#endif
|
||||||
cleanup();
|
cleanup();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -73,12 +77,17 @@ FfmpegAudioCursor(FfmpegAudio *src) :
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AVCodec *pAudioCodec=avcodec_find_decoder(_audio_ctx->codec_id);
|
AVCodec *pAudioCodec = avcodec_find_decoder(_audio_ctx->codec_id);
|
||||||
if(pAudioCodec == 0) {
|
if (pAudioCodec == 0) {
|
||||||
cleanup();
|
cleanup();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(avcodec_open(_audio_ctx, pAudioCodec)<0) {
|
|
||||||
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53, 8, 0)
|
||||||
|
if (avcodec_open2(_audio_ctx, pAudioCodec, NULL) < 0) {
|
||||||
|
#else
|
||||||
|
if (avcodec_open(_audio_ctx, pAudioCodec) < 0) {
|
||||||
|
#endif
|
||||||
cleanup();
|
cleanup();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -200,16 +209,14 @@ reload_buffer() {
|
|||||||
return true;
|
return true;
|
||||||
} else if (_packet_size > 0) {
|
} else if (_packet_size > 0) {
|
||||||
int bufsize = _buffer_size * 2;
|
int bufsize = _buffer_size * 2;
|
||||||
#if LIBAVCODEC_VERSION_INT < 3414272
|
|
||||||
#if LIBAVCODEC_VERSION_INT < 3349504
|
#if LIBAVCODEC_VERSION_INT < 3349504
|
||||||
int len = avcodec_decode_audio(_audio_ctx, _buffer, &bufsize,
|
int len = avcodec_decode_audio(_audio_ctx, _buffer, &bufsize,
|
||||||
_packet_data, _packet_size);
|
_packet_data, _packet_size);
|
||||||
movies_debug("avcodec_decode_audio returned " << len);
|
movies_debug("avcodec_decode_audio returned " << len);
|
||||||
#else
|
#elif LIBAVCODEC_VERSION_INT < 3414272
|
||||||
int len = avcodec_decode_audio2(_audio_ctx, _buffer, &bufsize,
|
int len = avcodec_decode_audio2(_audio_ctx, _buffer, &bufsize,
|
||||||
_packet_data, _packet_size);
|
_packet_data, _packet_size);
|
||||||
movies_debug("avcodec_decode_audio2 returned " << len);
|
movies_debug("avcodec_decode_audio2 returned " << len);
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
AVPacket pkt;
|
AVPacket pkt;
|
||||||
av_init_packet(&pkt);
|
av_init_packet(&pkt);
|
||||||
@ -217,7 +224,7 @@ reload_buffer() {
|
|||||||
pkt.size = _packet_size;
|
pkt.size = _packet_size;
|
||||||
int len = avcodec_decode_audio3(_audio_ctx, _buffer, &bufsize, &pkt);
|
int len = avcodec_decode_audio3(_audio_ctx, _buffer, &bufsize, &pkt);
|
||||||
movies_debug("avcodec_decode_audio3 returned " << len);
|
movies_debug("avcodec_decode_audio3 returned " << len);
|
||||||
av_free_packet(&pkt); // Not sure about this
|
av_free_packet(&pkt);
|
||||||
#endif
|
#endif
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
return false;
|
return false;
|
||||||
@ -258,12 +265,16 @@ seek(double t) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
avcodec_close(_audio_ctx);
|
avcodec_close(_audio_ctx);
|
||||||
AVCodec *pAudioCodec=avcodec_find_decoder(_audio_ctx->codec_id);
|
AVCodec *pAudioCodec = avcodec_find_decoder(_audio_ctx->codec_id);
|
||||||
if(pAudioCodec == 0) {
|
if(pAudioCodec == 0) {
|
||||||
cleanup();
|
cleanup();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(avcodec_open(_audio_ctx, pAudioCodec)<0) {
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53, 8, 0)
|
||||||
|
if (avcodec_open2(_audio_ctx, pAudioCodec, NULL) < 0) {
|
||||||
|
#else
|
||||||
|
if (avcodec_open(_audio_ctx, pAudioCodec) < 0) {
|
||||||
|
#endif
|
||||||
cleanup();
|
cleanup();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -289,18 +300,14 @@ seek(double t) {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void FfmpegAudioCursor::
|
void FfmpegAudioCursor::
|
||||||
read_samples(int n, PN_int16 *data) {
|
read_samples(int n, PN_int16 *data) {
|
||||||
|
|
||||||
//movies_debug("here!!! FfmpegAudioCursor n="<<n);
|
|
||||||
|
|
||||||
int desired = n * _audio_channels;
|
int desired = n * _audio_channels;
|
||||||
|
|
||||||
while (desired > 0) {
|
while (desired > 0) {
|
||||||
|
|
||||||
if (_buffer_head == _buffer_tail) {
|
if (_buffer_head == _buffer_tail) {
|
||||||
if(!reload_buffer()){
|
if(!reload_buffer()){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
movies_debug("read_samples() Desired samples: " << desired << " N:" << n);
|
movies_debug("read_samples() desired samples: " << desired << " N:" << n);
|
||||||
}
|
}
|
||||||
int available = _buffer_tail - _buffer_head;
|
int available = _buffer_tail - _buffer_head;
|
||||||
int ncopy = (desired > available) ? available : desired;
|
int ncopy = (desired > available) ? available : desired;
|
||||||
|
@ -509,7 +509,11 @@ open_stream() {
|
|||||||
_format_ctx = _ffvfile.get_format_context();
|
_format_ctx = _ffvfile.get_format_context();
|
||||||
nassertr(_format_ctx != NULL, false);
|
nassertr(_format_ctx != NULL, false);
|
||||||
|
|
||||||
|
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53, 6, 0)
|
||||||
|
if (avformat_find_stream_info(_format_ctx, NULL) < 0) {
|
||||||
|
#else
|
||||||
if (av_find_stream_info(_format_ctx) < 0) {
|
if (av_find_stream_info(_format_ctx) < 0) {
|
||||||
|
#endif
|
||||||
ffmpeg_cat.info()
|
ffmpeg_cat.info()
|
||||||
<< "Couldn't find stream info\n";
|
<< "Couldn't find stream info\n";
|
||||||
close_stream();
|
close_stream();
|
||||||
@ -541,7 +545,11 @@ open_stream() {
|
|||||||
close_stream();
|
close_stream();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53, 8, 0)
|
||||||
|
if (avcodec_open2(_video_ctx, pVideoCodec, NULL) < 0) {
|
||||||
|
#else
|
||||||
if (avcodec_open(_video_ctx, pVideoCodec) < 0) {
|
if (avcodec_open(_video_ctx, pVideoCodec) < 0) {
|
||||||
|
#endif
|
||||||
ffmpeg_cat.info()
|
ffmpeg_cat.info()
|
||||||
<< "Couldn't open codec\n";
|
<< "Couldn't open codec\n";
|
||||||
close_stream();
|
close_stream();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user