MCPcopy Create free account
hub / github.com/alibaba/CicadaPlayer / decode_func

Method decode_func

framework/codec/ActiveDecoder.cpp:79–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79int ActiveDecoder::decode_func()
80{
81 if (bDecoderEOS) {
82 af_usleep(10000);
83 return 0;
84 }
85 int needWait = 0;
86 int ret;
87 int64_t pts = INT64_MIN;
88 while (!mInputQueue.empty() && mOutputQueue.size() < maxOutQueueSize && mRunning) {
89 needWait = 0;
90 ret = extract_decoder();
91 if (ret == 0) {
92 needWait++;
93 } else if (ret < 0) {
94 AF_LOGW("extract_decoder error %d\n", ret);
95 enqueueError(ret, pts);
96 }
97
98 IAFPacket *pPacket = mInputQueue.front();
99 if (!pPacket) {
100 AF_LOGW("get a null packet");
101 mInputQueue.pop();
102 continue;
103 }
104
105 pts = pPacket->getInfo().pts;
106 std::unique_ptr<IAFPacket> packet = std::unique_ptr<IAFPacket>(pPacket);
107 ret = enqueue_decoder(packet);
108
109 if (ret == -EAGAIN) {
110 needWait++;
111 packet.release();
112 } else {
113 mInputQueue.pop();
114 if (ret == STATUS_EOS) {
115 bDecoderEOS = true;
116 } else if (ret < 0) {
117 AF_LOGW("enqueue_decoder error %d\n", ret);
118 enqueueError(ret, pts);
119 }
120 }
121 if (needWait > 1) {
122 std::unique_lock<std::mutex> locker(mSleepMutex);
123 mSleepCondition.wait_for(locker, std::chrono::milliseconds(5 * needWait), [this]() { return !mRunning; });
124 }
125 }
126
127 if (bInputEOS && mInputQueue.empty()) {
128 // TODO: flush once only
129 if (!bSendEOS2Decoder) {
130 unique_ptr<IAFPacket> pPacket{};
131 ret = enqueue_decoder(pPacket);
132
133 if (ret != -EAGAIN) {
134 bSendEOS2Decoder = true;
135 }
136

Callers 1

openMethod · 0.95

Calls 6

af_usleepFunction · 0.85
frontMethod · 0.80
releaseMethod · 0.65
emptyMethod · 0.45
sizeMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected