transcoding: separate pause&stop on transcoder<->scheduler interface
Separate stop from pause, and use stop when a job is being cancelled.
This tells the transcoder to discard the job and all states for it.
Also send the original request to the transcoder start.
bug: 154734285
bug: 145233472
test: unit tests
Change-Id: I112c08b909f3432dfd4b4803c0786a1ea01deea6
diff --git a/media/libmediatranscoding/TranscodingJobScheduler.cpp b/media/libmediatranscoding/TranscodingJobScheduler.cpp
index 1b36d4c..ea07c5f 100644
--- a/media/libmediatranscoding/TranscodingJobScheduler.cpp
+++ b/media/libmediatranscoding/TranscodingJobScheduler.cpp
@@ -76,7 +76,7 @@
// the topJob now.
if (!mResourceLost) {
if (topJob->state == Job::NOT_STARTED) {
- mTranscoder->start(topJob->key.first, topJob->key.second);
+ mTranscoder->start(topJob->key.first, topJob->key.second, curJob->request);
} else if (topJob->state == Job::PAUSED) {
mTranscoder->resume(topJob->key.first, topJob->key.second);
}
@@ -257,9 +257,12 @@
}
for (auto it = jobsToRemove.begin(); it != jobsToRemove.end(); ++it) {
- // If the job is running, pause it first.
- if (mJobMap[*it].state == Job::RUNNING) {
- mTranscoder->pause(clientId, jobId);
+ // If the job has ever been started, stop it now.
+ // Note that stop() is needed even if the job is currently paused. This instructs
+ // the transcoder to discard any states for the job, otherwise the states may
+ // never be discarded.
+ if (mJobMap[*it].state != Job::NOT_STARTED) {
+ mTranscoder->stop(it->first, it->second);
}
// Remove the job.