Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

The Limitations

Fixed number of attributes

As it stands there are currently a fixed number of 128 attributes per format. This consumes a bit of extra memory since most formats would never need this many.

Fixed type of attributes

All attributes are of type uint8_t. It is possible to overcome this by casting the format attribute structure to another structure, but if you exceed the size of the allocated format attribute structure... badness would occur.

Copying

Deep copying occurs frequently on formats.

The Possibilities

Reference counted format object

Instead of using a simple data structure that can be allocated as part of other structures which is then populated with data the creator of the media format could create an ao2 reference counted object which is then passed around using a pointer. No locking would need to occur because if the media format changes a new ao2 reference counted object is created. This would reduce memory consumption and time spent copying. The con is that use would have to be audited and the proper unreffing put into places.

Container of attributes

By making the media format structure an ao2 reference counted object a container of attributes could be used, allowing the format specific module to place any kind of attributes on the media format. Due to the reference counting no leaks would occur since they would be destroyed once the media format is no longer in use.

How to go about it

1. Change the media format structure to an ao2 reference counted object.
2. Audit usage to ensure new media format structure is created when changes occur.
3. Audit usage to add reference count incrementing and decrementing when needed.
4. Audit heap usage of media format structures.
5. Change format attributes to ao2 objects in container.

Changing to an ao2 reference counted object is straight forward. The hardest part would be auditing the code to ensure the reference count is incremented and decremented at the proper time.

Changing attributes to ao2 objects in a container is also straight forward and due to the isolated nature of attributes would not require much work.