mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-09 18:40:14 +00:00
More cleanup of unused code
This commit is contained in:
parent
f7ff8b3374
commit
600494eed8
@ -59,15 +59,9 @@ namespace MWRender
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void packet_queue_init(PacketQueue *q)
|
||||||
|
{ memset(q, 0, sizeof(PacketQueue)); }
|
||||||
|
|
||||||
|
|
||||||
/* Since we only have one decoding thread, the Big Struct
|
|
||||||
can be global in case we need it. */
|
|
||||||
VideoState *global_video_state;
|
|
||||||
|
|
||||||
void packet_queue_init(PacketQueue *q) {
|
|
||||||
memset(q, 0, sizeof(PacketQueue));
|
|
||||||
}
|
|
||||||
int packet_queue_put(PacketQueue *q, AVPacket *pkt)
|
int packet_queue_put(PacketQueue *q, AVPacket *pkt)
|
||||||
{
|
{
|
||||||
AVPacketList *pkt1;
|
AVPacketList *pkt1;
|
||||||
@ -92,7 +86,8 @@ namespace MWRender
|
|||||||
q->mutex.unlock ();
|
q->mutex.unlock ();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static int packet_queue_get(PacketQueue *q, AVPacket *pkt, int block)
|
|
||||||
|
static int packet_queue_get(PacketQueue *q, AVPacket *pkt, VideoState *is, int block)
|
||||||
{
|
{
|
||||||
AVPacketList *pkt1;
|
AVPacketList *pkt1;
|
||||||
int ret;
|
int ret;
|
||||||
@ -101,7 +96,7 @@ namespace MWRender
|
|||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
if(global_video_state->quit)
|
if(is->quit)
|
||||||
{
|
{
|
||||||
ret = -1;
|
ret = -1;
|
||||||
break;
|
break;
|
||||||
@ -133,7 +128,8 @@ namespace MWRender
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PacketQueue::flush() {
|
void PacketQueue::flush()
|
||||||
|
{
|
||||||
AVPacketList *pkt, *pkt1;
|
AVPacketList *pkt, *pkt1;
|
||||||
|
|
||||||
this->mutex.lock();
|
this->mutex.lock();
|
||||||
@ -149,6 +145,7 @@ namespace MWRender
|
|||||||
this->mutex.unlock ();
|
this->mutex.unlock ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double get_audio_clock(VideoState *is)
|
double get_audio_clock(VideoState *is)
|
||||||
{
|
{
|
||||||
return is->AudioTrack->getTimeOffset();
|
return is->AudioTrack->getTimeOffset();
|
||||||
@ -161,18 +158,20 @@ namespace MWRender
|
|||||||
delta = (av_gettime() - is->video_current_pts_time) / 1000000.0;
|
delta = (av_gettime() - is->video_current_pts_time) / 1000000.0;
|
||||||
return is->video_current_pts + delta;
|
return is->video_current_pts + delta;
|
||||||
}
|
}
|
||||||
double get_external_clock(VideoState *is) {
|
|
||||||
|
double get_external_clock(VideoState *is)
|
||||||
|
{
|
||||||
return av_gettime() / 1000000.0;
|
return av_gettime() / 1000000.0;
|
||||||
}
|
}
|
||||||
double get_master_clock(VideoState *is) {
|
|
||||||
if(is->av_sync_type == AV_SYNC_VIDEO_MASTER) {
|
double get_master_clock(VideoState *is)
|
||||||
|
{
|
||||||
|
if(is->av_sync_type == AV_SYNC_VIDEO_MASTER)
|
||||||
return get_video_clock(is);
|
return get_video_clock(is);
|
||||||
} else if(is->av_sync_type == AV_SYNC_AUDIO_MASTER) {
|
if(is->av_sync_type == AV_SYNC_AUDIO_MASTER)
|
||||||
return get_audio_clock(is);
|
return get_audio_clock(is);
|
||||||
} else {
|
|
||||||
return get_external_clock(is);
|
return get_external_clock(is);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
class MovieAudioDecoder : public MWSound::Sound_Decoder
|
class MovieAudioDecoder : public MWSound::Sound_Decoder
|
||||||
{
|
{
|
||||||
@ -296,7 +295,7 @@ class MovieAudioDecoder : public MWSound::Sound_Decoder
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* next packet */
|
/* next packet */
|
||||||
if(packet_queue_get(&is->audioq, pkt, 1) < 0)
|
if(packet_queue_get(&is->audioq, pkt, is, 1) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
is->audio_pkt_data = pkt->data;
|
is->audio_pkt_data = pkt->data;
|
||||||
@ -382,7 +381,7 @@ public:
|
|||||||
is->audio_buf_index = 0;
|
is->audio_buf_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t len1 = std::min(is->audio_buf_size - is->audio_buf_index,
|
size_t len1 = std::min<size_t>(is->audio_buf_size - is->audio_buf_index,
|
||||||
len - total);
|
len - total);
|
||||||
memcpy(stream, (uint8_t*)is->audio_buf + is->audio_buf_index, len1);
|
memcpy(stream, (uint8_t*)is->audio_buf + is->audio_buf_index, len1);
|
||||||
|
|
||||||
@ -613,7 +612,7 @@ public:
|
|||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
if(packet_queue_get(&is->videoq, packet, 1) < 0)
|
if(packet_queue_get(&is->videoq, packet, is, 1) < 0)
|
||||||
{
|
{
|
||||||
// means we quit getting packets
|
// means we quit getting packets
|
||||||
break;
|
break;
|
||||||
@ -721,10 +720,6 @@ public:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int decode_interrupt_cb(void) {
|
|
||||||
return (global_video_state && global_video_state->quit);
|
|
||||||
}
|
|
||||||
|
|
||||||
int decode_thread(void *arg)
|
int decode_thread(void *arg)
|
||||||
{
|
{
|
||||||
VideoState *is = (VideoState *)arg;
|
VideoState *is = (VideoState *)arg;
|
||||||
@ -806,10 +801,6 @@ public:
|
|||||||
if(!is->format_ctx->pb)
|
if(!is->format_ctx->pb)
|
||||||
throw std::runtime_error("Failed to allocate ioContext ");
|
throw std::runtime_error("Failed to allocate ioContext ");
|
||||||
|
|
||||||
global_video_state = is;
|
|
||||||
// will interrupt blocking functions if we quit!
|
|
||||||
//url_set_interrupt_cb(decode_interrupt_cb);
|
|
||||||
|
|
||||||
// Open video file
|
// Open video file
|
||||||
/// \todo leak here, ffmpeg or valgrind bug ?
|
/// \todo leak here, ffmpeg or valgrind bug ?
|
||||||
if (avformat_open_input(&is->format_ctx, resourceName.c_str(), NULL, NULL))
|
if (avformat_open_input(&is->format_ctx, resourceName.c_str(), NULL, NULL))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user