[directmusic] Re: Creating, downloading and unloading segments with DirectMusic

  • From: "Vytautas Leonavicius" <vytas@xxxxxxxxxxxxx>
  • To: <directmusic@xxxxxxxxxxxxx>
  • Date: Tue, 6 Jul 2004 12:05:09 +0200

I continued my tests with loading and downloading.  I did two things -
tested loading of all files and runtime test.

If I just load all files at startup, I noticed that I always get same number
of successfully loaded files - 509. The good thing about that is that this
number does not depends on size of loaded wave files, I tryied different
sizes (up to 30Mb) and got same results. Note that I do not download
segments onto performance, I just create them from files.

Later I implemented simple runtime test. I load segment when it is played
first time. And I  just play them all in a row. I do not download them. With
GUID_PerfAutoDownload flag disabled, I get error code
DMUS_E_LOADER_FAILEDOPEN on loading 509th segment. Because I don't download
segments onto performance, they're not playing - just silence.

But if I enable GUID_PerfAutoDownload flag things go different. Sounds are
playing, but loader returns DMUS_E_LOADER_FAILEDOPEN on 470 - 475th sound.
For same sequence of sounds, this value differs. I inserted Sleep() call
between sequental play calls, this led to growth of this number to 490-500.
Some segments are looped ( ~9) so, it looks like they're not unloaded until
stopped. So autodownloading works in some smart way? But that is more 
important - segment loading is somehow affected by downloading!

With all these tests I am trying to udnerstand relationship between loading
and downloading of segments. I am also interested in how autodownloading
works, because if it is managed somehow by DM I will do unneccessary work by
implementing some unload/download managment. I am going to pick magic
number, say 64 and release least used segments... but I think this number
should be safe, not just taken from nowhere. So if anyone has any ideas I'll
be really thankful!

Vytautas

----- Original Message ----- 
From: "Todor Fay" <todor@xxxxxxxxxxxxx>
To: <directmusic@xxxxxxxxxxxxx>
Sent: Saturday, July 03, 2004 5:52 PM
Subject: [directmusic] Re: Creating, downloading and unloading segments with
DirectMusic


> This may be an issue with file handles. If the waves are over a certain
> length, dmusic opens them in streamed mode and keeps the file handles
> open so it can read from disk while playing them. Unfortunately, Windows
> has a limit of how many file handles it can allow open at one time. The
> solution would be to change these files into non-streaming (and I know
> that can be done in Producer as well as possibly via the api - but I
> forget how.) Or, don't open so many files at once, since you can't
> possibly plan to play them all at the same time!
>
> But, you say "crash" as opposed to "error". Is the program actually
> crashing or failing to load the file?
>
> Hope this helps,
>
> Todor
>
> -----Original Message-----
> From: directmusic-bounce@xxxxxxxxxxxxx
> [mailto:directmusic-bounce@xxxxxxxxxxxxx] On Behalf Of Vytautas
> Leonavicius
> Sent: Sunday, July 04, 2004 8:10 AM
> To: directmusic@xxxxxxxxxxxxx
> Subject: [directmusic] Re: Creating, downloading and unloading segments
> with DirectMusic
>
> My problem get narrowed to IDirectMuscicLoader only.
>
> I created big list of files, and try to load them at startup just for
> test.
> No audiopaths, no performances are created, just
> IDirectMusicLoader::LoadObjectFromFile. After loading approximately ~400
>
> small (90kb) sounds loader crashes with MUS_E_LOADER_FAILEDOPEN return
> value.
>
> Here are words from directX audio exposed:
>
> "Segment
> A Segment represents any playable audio. It might be a MIDI or wave
> file, or
> it might be a DirectMusic Segment file authored in DirectMusic Producer.
> You
> can load any number of Segments from disk, and you can play any number
> of
> them at the same time. You can even play the same Segment multiple times
>
> overlapping itself."
>
> But for me this is not true - even more, loader's crashes are somehow
> related to manual downloading of segments.
>
> I could manage segments and throw out least used to load other, the
> problem
> is HOW MANY OF THEM IT IS SAFE TO HAVE AT ONCE? Return value is saying
> nothing about some resource exhaustion.
>
> BTW - I had same error when I tried to do everything with DMP scripts.
> When
> scripts get large enough - they crashed at load. Sometimes they crashed
> with
> same return value.
>
> I also tried to disable Loader's cache - this don't solved the problem.
>
> Do wave files have some GUIDs?
>
> Vytautas
>
> ----- Original Message ----- 
> From: "Vytautas Leonavicius" <vytas@xxxxxxxxxxxxx>
> To: <directmusic@xxxxxxxxxxxxx>
> Sent: Saturday, July 03, 2004 3:15 PM
> Subject: [directmusic] Creating, downloading and unloading segments with
>
> DirectMusic
>
>
>> Hello Group,
>> I'll be very thankful for any help, cause I really need it.
>>
>> I am developing sound subsystem in our game. It uses DirectMusic API.
> I
>> got lots of troubles with DirectMusic, so I begin to suspect that the
> main
>> problem is in my wrong model of using DirectMusic. I addition to lack
> of
>> information on that's going on inside DM, I got stuck finally.
>>
>> I started this way - I loaded all segments from files based on list of
>
>> filenames. Later, I downloaded them all onto performance. The problem
> was
>> with download - it failed if too many sounds were downloaded.  Then I
>> introduced some kind of cache, that managed all segments, and unloaded
>
>> least useful, while downloading new ones. That worked. For some time.
>> Later, I faced another problem. Instead of creating all segment files
> at
>> startup, I created them on first use. After this modfication, I found
> that
>> now I am able to download much more segments than prior to that! So,
> looks
>> like IDirectMusicLoader and IDirectMusicSegment::Download, affect each
>
>> other - the less segments you load from file, the more segments
> downloaded
>> onto performance successfully and vice versa.
>> Another weird thing, is that both loader and segment downloading fail
> with
>> same return value. : DMUS_E_LOADER_FAILEDOPEN File open failed because
> the
>> file does not exist or is locked. From above, looks like
>> CreateSegmentFromFile and Download affect some shared memory or
> resource,
>> however, return value is saying nothing about memory etc.
>>
>> So it looks like I am doing something wrong, cause while searching
> forums,
>> I found no topics with similar problems.
>>
>> When should I create segments from wave files? Should I destroy/create
>
>> them again during runtime, and that's more important, how many of them
>
>> could be created at once, without being afraid of crash?  When should
> I
>> download and unload them? Is DMUS_E_LOADER_FAILEDOPEN saying: "too
> many
>> segments created, release some then retry"?
>>
>> Another problem is with audiopaths. I am using separate audiopath per
> each
>> sound with separate volume. And I noticed, that even if I don't use
>> audiopaths, just create them, they slow down application. I suppose
> I'll
>> going to implement some audiopath sharing between sounds, however,
> what is
>> 'too many audiopaths"? How many audiopaths are allowed without
> noticeable
>> perfromance penalty?
>>
>> Weird thing, I don't know how many segments are allowed to be created
> from
>> file at once, I don't know how many of them could be downloaded at
> once,
>> and same thing with audiopaths. In DM documentation no single word
> about
>> all these things...
>>
>> Vytautas
>>
>
>
>
>
>
>



Other related posts: