MmDestroyGraph causes Segmentation fault

I am using the Multimedia2 library for playing audio files (ogg & mp3).
The playing is working fine, problem is, when I call MmDestroyGraph()
on the graph, it crashes with a segmentation fault:

Program received signal SIGSEGV, Segmentation fault.
0xb031c49e in _list_release () from /x86/lib/libc.so.2

I am calling MmStop() on the graph first (as per the “Using Graphs”/“Run
MP3s” example), though according to the docs, MmDestroyGraph will do
that anyway. Anything else I need to do before I destroy the graph?

This is 6.2.1 NC.

Thanks.

  • Joshua B. Helm
    Forefront Technologies, Inc.

Hi Joshua,

Joshua B. Helm wrote:

I am using the Multimedia2 library for playing audio files (ogg & mp3).
The playing is working fine, problem is, when I call MmDestroyGraph()
on the graph, it crashes with a segmentation fault:

Program received signal SIGSEGV, Segmentation fault.
0xb031c49e in _list_release () from /x86/lib/libc.so.2



I am calling MmStop() on the graph first (as per the “Using Graphs”/“Run
MP3s” example), though according to the docs, MmDestroyGraph will do
that anyway. Anything else I need to do before I destroy the graph?
No, MmDestroyGraph will stop the graph and free all allocated resources.

Could you post the code of your “CreateGraph()” function.
Thanks
Angelo.

This is 6.2.1 NC.

Thanks.

  • Joshua B. Helm
    Forefront Technologies, Inc.

angelo pennacchioli wrote:

Hi Joshua,


No, MmDestroyGraph will stop the graph and free all allocated resources.
Could you post the code of your “CreateGraph()” function.

Below is the code I’m using for playing the file, and cleaning up…

playfile_result Audio::PlayFile(const char *filepath)
{
MmFilter_t *filter ;
MmChannel_t *channelIn, *channelOut ;

//Close any open file
this->CloseFile() ;

//Open file streamer
if (!(this->mmFile = AoOpenFilespec(filepath, “rb”)))
return(NOT_FOUND) ;

//Create MM graph
this->mmGraph = MmCreateGraph(“ha audio”) ;

//Open the media reader filter
if (!(filter = MmFindMediaReader(this->mmGraph, this->mmFile)))
{
MmDestroyGraph(this->mmGraph) ;
return(UNKNOWN_ERROR) ;
}

//Find & connect all the filters we need to get from the source audio
to uncompressed output
while (!(channelOut = MmAcquireOutputChannel(filter, MEDIA_TYPE_AUDIO)))
{
if (!(channelOut = MmAcquireOutputChannel(filter, MEDIA_TYPE_AUDIO |
MEDIA_TYPE_COMPRESSED)))
{
if (!(channelOut = MmAcquireOutputChannel(filter,
MEDIA_TYPE_COMPRESSED)))
{
MmDestroyGraph(this->mmGraph) ;
return(UNSUPPORTED_TYPE) ;
}
}
filter = MmFindChannelsFilter(this->mmGraph, channelOut) ;
}

//Get the audio writer filter
if (!(filter = MmFindFilter(this->mmGraph, “audio_writer”)))
{
MmDestroyGraph(this->mmGraph) ;
return(UNKNOWN_ERROR) ;
}
//Get the audio writer’s input channel
if (!(channelIn = MmAcquireInputChannel(filter, MEDIA_TYPE_AUDIO)))
{
MmDestroyGraph(this->mmGraph) ;
return(UNKNOWN_ERROR) ;
}
//Connect the channels
if (MmAttachChannels(channelOut, channelIn) != 0)
{
MmDestroyGraph(this->mmGraph) ;
return(UNKNOWN_ERROR) ;
}

//Set the default clock
MmSetDefaultClock(this->mmGraph) ;

//Start playing
MmStart(this->mmGraph, 0) ;
MmResume(this->mmGraph) ;

//Return success
return(SUCCESS) ;
}



void Audio::CloseFile(void)
{
//Cleanup open/playing file
if (this->mmGraph)
{
MmStop(this->mmGraph) ;
MmDestroyGraph(this->mmGraph) ;
this->mmGraph = NULL ;
}
if (this->mmFile)
{
this->mmFile->streamer->Close(this->mmFile) ;
this->mmFile = NULL ;
}
}




Thank you for any insight.

Thanks
Angelo.

  • Joshua B. Helm
    Forefront Technologies, Inc.

Joshua B. Helm wrote:

angelo pennacchioli wrote:

Hi Joshua,


No, MmDestroyGraph will stop the graph and free all allocated
resources. Could you post the code of your “CreateGraph()” function.


Below is the code I’m using for playing the file, and cleaning up…

playfile_result Audio::PlayFile(const char *filepath)
{
MmFilter_t *filter ;
MmChannel_t *channelIn, *channelOut ;

//Close any open file
this->CloseFile() ;

//Open file streamer
if (!(this->mmFile = AoOpenFilespec(filepath, “rb”)))
return(NOT_FOUND) ;

//Create MM graph
this->mmGraph = MmCreateGraph(“ha audio”) ;

//Open the media reader filter
if (!(filter = MmFindMediaReader(this->mmGraph, this->mmFile)))
{
MmDestroyGraph(this->mmGraph) ;
return(UNKNOWN_ERROR) ;
}

//Find & connect all the filters we need to get from the source
audio to uncompressed output
while (!(channelOut = MmAcquireOutputChannel(filter,
MEDIA_TYPE_AUDIO)))
{
if (!(channelOut = MmAcquireOutputChannel(filter,
MEDIA_TYPE_AUDIO | MEDIA_TYPE_COMPRESSED)))
{
if (!(channelOut = MmAcquireOutputChannel(filter,
MEDIA_TYPE_COMPRESSED)))
{
MmDestroyGraph(this->mmGraph) ;
return(UNSUPPORTED_TYPE) ;
}
}
filter = MmFindChannelsFilter(this->mmGraph, channelOut) ;
}

//Get the audio writer filter
if (!(filter = MmFindFilter(this->mmGraph, “audio_writer”)))
{
MmDestroyGraph(this->mmGraph) ;
return(UNKNOWN_ERROR) ;
}
//Get the audio writer’s input channel
if (!(channelIn = MmAcquireInputChannel(filter, MEDIA_TYPE_AUDIO)))
{
MmDestroyGraph(this->mmGraph) ;
return(UNKNOWN_ERROR) ;
}
//Connect the channels
if (MmAttachChannels(channelOut, channelIn) != 0)
{
MmDestroyGraph(this->mmGraph) ;
return(UNKNOWN_ERROR) ;
}

//Set the default clock
MmSetDefaultClock(this->mmGraph) ;

//Start playing
MmStart(this->mmGraph, 0) ;
MmResume(this->mmGraph) ;

//Return success
return(SUCCESS) ;
}



void Audio::CloseFile(void)
{
//Cleanup open/playing file
if (this->mmGraph)
{
MmStop(this->mmGraph) ;
MmDestroyGraph(this->mmGraph) ;
this->mmGraph = NULL ;
}
if (this->mmFile)
{
this->mmFile->streamer->Close(this->mmFile) ;
this->mmFile = NULL ;
}
}




Thank you for any insight.

Thanks
Angelo.


\

  • Joshua B. Helm
    Forefront Technologies, Inc.

Hi Joshua,
I don’t see any thing wrong in the code snippet you provided.
I have added a main and made little changes to have the code compiled.
I have tried it on a x86 release 6.2.1 box:
CPU:X86 Processors:1 FreeMem:90Mb/127Mb
BootTime:Oct 21 15:34:21 EDT 2004
Processor1: 686 Pentium III Stepping 3 550MHz FPU

and was able to play successfully a mp3 and a ogg file.
You will find attached the modified code.
You can compile it:
cc -o mmtest main.c -Bstatic -lmmedia -Bdynamic -l aoi
Please try it and let me know if you are still experiencing problems.
Regards,
Angelo.

angelo pennacchioli wrote:

Hi Joshua,
I don’t see any thing wrong in the code snippet you provided.
I have added a main and made little changes to have the code compiled.
I have tried it on a x86 release 6.2.1 box:
CPU:X86 Processors:1 FreeMem:90Mb/127Mb
BootTime:Oct 21 15:34:21 EDT 2004
Processor1: 686 Pentium III Stepping 3 550MHz FPU

and was able to play successfully a mp3 and a ogg file.
You will find attached the modified code.
You can compile it:
cc -o mmtest main.c -Bstatic -lmmedia -Bdynamic -l aoi
Please try it and let me know if you are still experiencing problems.

Yes, it seems to work fine like this. For some reason MmDestroyGraph()
crashes in my larger program though. I’ll have to do some digging.

Thanks.

Regards,
Angelo.

Hi Joshua and Angelo

I was working on and O&M application on my embedded target and
received the signal SIGBUS in the same location _list_release().

It seems to me that this is relates somehow with memory and has
nothing to do with code implementation. I am suspecting a possible
memory corruption in my application. Any suggestion to debug the same
?

BR
Akash