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.