INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: More info on current playlist crash  (Read 2033 times)

MahlerFreak

  • Recent member
  • *
  • Posts: 49
More info on current playlist crash
« on: October 20, 2006, 09:43:12 pm »

After very extensive experimentation, I have learned more about the crash reported below. Basically, any C++ automation - based method that removes all files from the current playlist will eventually cause a crash, sometimes immediately, sometimes when followed by subsequent calls to functions that use the current playlist - adding files, playing, etc.

Background: my code was attempting to replace the current "now playing" list with a different list of files. I coded this, logically, by calling IMJCurPlaylistAutomation::RemoveAllFiles(), then adding files in a loop using AddFileByKey or AddFile, followed by a MJPlaybackAutomation::Play() call. Intermittent crashes, referencing HEAP errors or Invalid Handles, followed.

I tried several different methods of clearing the current playlist. For instance:

pCurPlaylist->RemoveAllFiles();

or:

for ( long i = pCurrentPlaylist->GetNumberFiles() - 1; i >= 0; i-- ) {
pCurrentPlaylist->RemoveFile(i);
}

or:

while (pCurrentPlaylist->GetNumberFiles() > 0 )
       pCurrentPlaylist->RemoveFile(0);

All of these techniques eventually led to crashes - both of the above crashed after , at most, a few iterations including subsequent calls to Play or similar.

Here is what worked for me finally (at least, based on 2 hours of diligent testing):

// add the files we want to add FIRST:

long i;
for ( i = 0; i < filesToAdd.size(); i++) {
     pCurPlaylist->AddFile(filesToAdd,i);
}

// NOW remove all of the files that existed in the current playlist before:

long j;
for ( j = pCurPlaylist->GetNumberFiles() - 1; j >= i; j-- )
     pCurPlaylist->RemoveFile(j);


In other words, as long as you don't remove all of the files from the now playing list using automation - at least, C++ automation - you're fine. At least, my experimentation thus far seems to demonstrate.

This should be tested and filed as a bug by JR folks, and the workaround published somewhere.

And BTW - the workarounds described in the previous post, such as sleeping for a time after adding files, seem to be a red herring - simply delaying the crash. It's quite possible that I've only found another temporarily promising avenue - but I'm hoping for the sake of my project, that this is the final resolution.
Logged

SwellGuy

  • Guest
Re: More info on current playlist crash
« Reply #1 on: October 24, 2006, 10:09:48 am »

Thanks MahlerFreak, we'll look into it...
Logged
Pages: [1]   Go Up