Microsoft DirectX 9.0 |
It might happen that an application needs to manage object loading itselffor example, because all objects are stored in a special compressed content file. The application can create its own loader in the form of an object that supports the IDirectMusicLoader8 interface, with at least the GetObject method implemented. This implementation of the loader must also create its own stream object that has both the IStream and the IDirectMusicGetLoader8 interfaces.
When GetObject receives a request to load an object from a file or resource, it creates a stream and passes the IStream pointer to the object's IPersistStream::Load method. When it receives a request to load an object from an existing stream created by the application to manage reading from a custom file, it creates a copy of the IStream with the same seek pointer and passes this copy to Load.
The stream object's implementation of IDirectMusicGetLoader8::GetLoader is used by loadable objects to retrieve a pointer to the loader that created the IStream. Objects need this pointer in order to call GetObject recursively when they find references to other objects. For example, a segment object might contain references to WAV files, which must be loaded along with the segment.
To support container objects, the loader must also implement the IDirectMusicLoader8::SetObject method. The implementation retains all information in the supplied DMUS_OBJECTDESC structure, copying the stream pointer if necessary. It then creates the object and calls IDirectMusicObject8::ParseDescriptor to obtain the rest of the object's descriptive information. However, the loader should not actually load the object until GetObject is called. If only containers with embedded objects need to be handled, only the case where DMUS_OBJ_STREAM is set needs to be implemented.
For more information, see Custom Loading in DirectMusic at msdn.microsoft.com.