DirectMusic PlaySegmentEx stops working after running for 18 - 20 days
I ran into an interesting issue with DirectMusic yesterday. When you use PlaySegmentEx to repeatedly play MIDI content, after about 18 - 20 days of constant playback the API stops playing the content as expected.
DirectMusic builds a DirectShow graph internally. This issue appears to be due to the fact that after 20 days the underlying DShow graph has been constantly playing back. This makes the graph clock time extremely close to the 64bit int maximum. DMusic attempts to convert the graph time into "music time". When the graph time is close to int 64 max the calculation from graph to music time causes the variable that is calculating the music time (a long32) to roll over. The long become negative but this actually has the effect of scheduling playback substantially in the future. No sound is generated since the start time of the sequence is so far in the future.
To get around this you can restart the process after about 16 days. You could also try shutting down the DMusic subsystem after 16 days, tearing down the internal graph.