SDL and SMPEG audio issue

I am making a program that uses SDL and SMPEG to play an MPEG. I am running
into a problem where on the second or sometimes third iteration of the while
loop, I receive an error. Debug shows that the error is occuring in the
SMPEG_new line. The example is below and I suspect it is to do with the Audio
initialization. However, if I try to initialize the audio with SDL_INIT_AUDIO
and then switch the third argument of SMPEG_new to 0, the video moves very
slowly and without sound, eventually crashing with a Passed NULL mutex error.

The simple structure of the program:

EXAMPLE #1:

(SDL_Init(SDL_INIT_VIDEO))

while(1){

mpeg = SMPEG_new(moviebuf, &info, 1); /* moviebuf is movie file */
SMPEG_setdisplay (mpeg, screen, NULL, update_frames);
SMPEG_play(mpeg);

SMPEG_delete(mpeg);
}

SDL_FreeSurface(screen);
SDL_Quit();

ERROR FOR THIS EXAMPLE IS: Fatal signal: Segmentation Fault (SDL Parachute
Deployed)

Any ideas? Very appreciative for any help!
Best,
Shu

@Sue_H

while(1){

mpeg = SMPEG_new(moviebuf, &info, 1); /* moviebuf is movie file */
SMPEG_setdisplay (mpeg, screen, NULL, update_frames);
SMPEG_play(mpeg);

SMPEG_play returns immediately; it doesn’t block until the movie
finishes playing. So do this:

 SMPEG_play(mpeg);
 while (SMPEG_status(mpeg) == SMPEG_PLAYING)
 {
     SDL_Event event;
     while (SDL_PollEvent(&event)) {/* handle event if you want. */}
     SDL_Delay(100); /* sleep; smpeg runs in another thread. */
 }
 SMPEG_delete(mpeg);

Also…

SDL_FreeSurface(screen);

…don’t free the screen surface; SDL_FreeSurface is just for offscreen
surfaces. SDL_Quit() will take care of the window.

–ryan.