1

this is my first question here. I apologize in advance if I make some mistakes.

I'm writing a software that call a customer number (audio/voiced) when a button is pressed with as little delay as possible. It's for Windows, using C++ on MS Visual Studio 2017. The requirement are as follows:

  1. Load all the mp3 files onto memory
  2. Whenever signal is received/button is pressed, construct a playlist containing only relevant mp3 files to the customer number being called
  3. Play the playlist on certain designated audio output device (there are multiple soundcards installed)
  4. Destroy the playlist after the session ended

I have tried the Playlist sample from Microsoft Media Foundation sample and it worked. Unfortunately the sample does not preload all mp3 files onto the memory so there are couple hundred ms delay each time the playlist is played.

I also have tried using bytestream (IMFByteStream). I load all the mp3 files onto vector of IMFByteStream pointers, then everytime signal received/button pressed, I construct the media source (IMFMediaSource). Unfortunately it only ran once. After the media source is shutdown after the session ended, the bytestream became unusable (error "the provided bytestream expected to be seekable" or MF_E_BYTESTREAM_NOT_SEEKABLE when trying to create media source using CreateObjectFromByteStream).

hr = pSourceResolver->CreateObjectFromByteStream(m_pMediaStreams[media_source_index].pStream, NULL, MF_RESOLUTION_MEDIASOURCE, NULL, &ObjectType, &pSource);

Clearly I did something wrong. Any hints and pointers are greatly appreciated. If some portions of the code are needed then I will post it here. The code is big and I don't know which parts are relevant.

Many thanks

Bjorka
  • 11
  • 4
  • Maybe stream is shutdown as well, so you need to re-create it or, to reuse it, have a cloned or wrapped version used in first place. – Roman R. Aug 13 '21 at 12:23
  • 1
    I ended up creating byte array of all the files, then construct IStream object, wrapped it into IMFBytestream to create media source each time my program received a signal. – Bjorka Aug 20 '21 at 10:53

0 Answers0