01org/media-service-upnp — pull request #92 by rmerlino (2012-10-22 15:16:58+00:00)
Title: Fix issue #76 - Command Processing Re-Arch

Fix issue #76 - Command Processing Re-Arch.

N.B. This PR does not contain the Device::Cancel() method yet, which will be added to this PR once the command processing re-arch code is validated.

About the strategy used in this proposal:

* In this first iteration I did not try to go too generic, but implement what is actually needed and what we agreed during our architecture meeting.
* I did not try to merge the chain-task into this implementation (reuse the task queues I defined instead of the chain-task list). This could be done in a future enhancement.
* At the beginning I wanted to handle the task scheduling strategy in the "task_processor" object rather than in the "queue" objects themselves so that it can decide which task should be the next to be executed (and be able manage queue priorities, etc.). But we don't need that right now, and I don't think we'll ever need such a capability, so I went to the simple way and kept the scheduling in the queues.
* I Implemented all the task processing stuff into a separate file task-processor.[ch]. Every piece of existing code related to this from media-service-upnp.c was moved to this new file.
* I tried to implement the processing with loose coupling: little knowledge of the "task" objects and execution environment. This is easier to read, enhance and reuse (in the renderer for instance)

Basically, the implementation does:

* Moved task processing fields from msu_context_t to a dedicated msu_task_processor object.
* The task processor holds a dictonary composed of {(client id, server id), task queue}
* A msu_task_queue holds the list of requests coming from one client to one server
* Tasks in a queue are processed serially
* The task scheduling is done by the queue itself (as previously)
* Queues are processed in parallel (for async tasks)
* I moved the task deletion code from task.c to task-processor.c

I did some basic testing, also using the chain-task objects from Ludo with success.