Skip to content

Commit

Permalink
screens4: Shut down Media Foundation on device reset
Browse files Browse the repository at this point in the history
  • Loading branch information
kebby committed Apr 14, 2014
1 parent 46160a6 commit e211a0f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
42 changes: 36 additions & 6 deletions altona_wz4/wz4/screens4/movieplayer_win7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ template<class Interface> class sFakeCOMObject : public Interface
unsigned long __stdcall Release(void) { return 1; }
};

static void InitMF();


class sMPSoundOutput
{
public:
Expand Down Expand Up @@ -919,28 +922,55 @@ class sMoviePlayerMF : public sMoviePlayer

sMoviePlayer * sCreateMoviePlayer(const sChar *filename, sInt flags, sTextureBase *alphatexture)
{
InitMF();
sMoviePlayerMF *mp = new sMoviePlayerMF;
if (mp && !mp->Init(filename,flags,alphatexture)) sDelete(mp);
return mp;
}

static HANDLE AvTaskHandle=INVALID_HANDLE_VALUE;
static bool MFActive = 0;

static void InitMF()
{
if (!MFActive)
{
MFStartup(MF_VERSION);
MFActive = sTRUE;
}
}

static void ExitMF()
{
if (MFActive)
{
MFShutdown();
MFActive = sFALSE;
}
}

static void DeviceLostHook(void*)
{
ExitMF();
}

static void InitMFSys()
{
// while we're at it, let the scheduler know we're doing something important :)
DWORD taskindex=0;
AvTaskHandle=AvSetMmThreadCharacteristics(L"Playback",&taskindex);
DWORD taskindex = 0;
AvTaskHandle = AvSetMmThreadCharacteristics(L"Playback", &taskindex);

MFStartup(MF_VERSION);
sGraphicsLostHook->Add(DeviceLostHook);
InitMF();
}

static void ExitMF()
static void ExitMFSys()
{
sGraphicsLostHook->Rem(DeviceLostHook);
ExitMF();

if (AvTaskHandle != INVALID_HANDLE_VALUE)
AvRevertMmThreadCharacteristics(AvTaskHandle);

MFShutdown();
}

sADDSUBSYSTEM(MediaFoundation,0xe0,InitMF,ExitMF);
Expand Down
Binary file modified altona_wz4/wz4/screens4/test.wz4
Binary file not shown.

0 comments on commit e211a0f

Please sign in to comment.