0
0

Hi.

First of all I have to apologize to you about my bad English. I’m trying to improve it.

I’ve to code an application in VC++ 2005 which uses the MFC. Among other things it has to play MP3s. Therefor I decided to use a reusable class. Under specific circumstances the application has to react when stream playing has ended. I thought using “Channel::setCallback()” with “FMOD_CHANNEL_CALLBACKTYPE_END” could be the right way, but it doesn’t work right. At the beginning of the stream the callback is fired, but I want it to be fired at the end of stream.

Please look at the relevant parts:

[i:1p0j6php]Player.h:[/i:1p0j6php]
[code:1p0j6php]#pragma once

include "fmod.hpp"

include "fmod.h"

define WM_PLAYER_CALLBACK WM_USER + 9427

class CPlayer
{
public:
CPlayer(void);
~CPlayer(void);
void Play(CString Datei);
...
private:

FMOD::System *fmodSYSTEM;
FMOD::Sound *fmodSOUND;
FMOD::Channel *fmodCHANNEL;
FMOD::DSP *fmodDSP;
FMOD_RESULT F_CALLBACK endCallBackFunc(void);
};[/code:1p0j6php]

[i:1p0j6php]Player.cpp[/i:1p0j6php]
[code:1p0j6php]#include "StdAfx.h"

include ".\player.h"

CPlayer::CPlayer(void)
: used_driver(0)
, fmodSYSTEM(NULL)
, fmodSOUND(NULL)
, fmodCHANNEL(NULL)
, useNormalize(false)
, fmodDSP(NULL)
, m_playerID(0)
, m_ParentName(_T(""))
{
useNormalize = true;
used_driver = -1;
FMOD::System_Create(&fmodSYSTEM);
fmodSYSTEM->setDriver(used_driver);
fmodSYSTEM->init(1, FMOD_INIT_NORMAL, NULL);
fmodSYSTEM->createDSPByType(FMOD_DSP_TYPE_NORMALIZE, &fmodDSP);
fmodSYSTEM->addDSP(fmodDSP);
fmodDSP->setActive(true);
setNormalize(useNormalize);
}

CPlayer::~CPlayer(void)
{
// if (fmodSOUND) fmodSOUND->release();
fmodSYSTEM->close();
fmodSYSTEM->release();
}

void CPlayer::Play(CString Datei)
{
bool result;
fmodCHANNEL->getPaused(&result);
if (result) fmodCHANNEL->setPaused(false); else
{
fmodSYSTEM->createStream(Datei, FMOD_SOFTWARE, 0, &fmodSOUND);
fmodSYSTEM->playSound(FMOD_CHANNEL_FREE, fmodSOUND, 0, &fmodCHANNEL);
fmodCHANNEL->setCallback(FMOD_CHANNEL_CALLBACKTYPE_END, 0, endCallBackFunc());
fmodSYSTEM->update();
}
}

FMOD_RESULT F_CALLBACK CPlayer::endCallBackFunc(void)
{
WPARAM wParam = m_playerID;
LPARAM lParam = m_playerID;

HWND hWnd = ::FindWindow(NULL, _T(m_ParentName));
if (hWnd) PostMessage( hWnd, WM_PLAYER_CALLBACK, wParam , lParam);

return FMOD_OK;

}[/code:1p0j6php]

I’ve read the documentation many times, but that doesn’t have helped me. I would be very glad to have your explanation and corrections.

THX

Markus

  • You must to post comments
0
0

endCallBackFunc() should be static.

Also:
[code:2a5g7c73]fmodCHANNEL->setCallback(FMOD_CHANNEL_CALLBACKTYPE_END, 0, endCallBackFunc());[/code:2a5g7c73]

That should read:
[code:2a5g7c73]fmodCHANNEL->setCallback(FMOD_CHANNEL_CALLBACKTYPE_END, 0, endCallBackFunc);[/code:2a5g7c73]

(Difference is no parentheses after endCallBackFunc.)

Try that out.

  • G
  • You must to post comments
0
0

Hi,

that doesn’t work at all. VC++ 2005 stops compiling with an error message:

"[…] error C3867: "CPlayer::endCallBackFunc": Dem Funktionsaufruf fehlt die Argumentliste. Verwenden Sie "&CPlayer::endCallBackFunc", um einen Zeiger auf den Member zu erstellen."

Even when I try "&CPlayer::endCallBackFunc", as the copiler says, I get an error message.

Any other ideas?

THX

Markus

  • You must to post comments
0
0

[quote="Markus":2yx7wwjs]Hi,

that doesn’t work at all. VC++ 2005 stops compiling with an error message:

"[…] error C3867: "CPlayer::endCallBackFunc": Dem Funktionsaufruf fehlt die Argumentliste. Verwenden Sie "&CPlayer::endCallBackFunc", um einen Zeiger auf den Member zu erstellen."

Even when I try "&CPlayer::endCallBackFunc", as the copiler says, I get an error message.

Any other ideas?

THX

Markus[/quote:2yx7wwjs]Pointers to methods of classes don’t have the same signatures as pointers to functions. You’ll need to use a function. (You can use the userdata field to store a pointer to an object that you can use as a This, though.)

You could also make CPlayer::endCallBackFunc a static method, and then use the userdata field as this, so it acts like a method.

  • You must to post comments
0
0

Hi,

Probier mal:

[code:30g2af5m]
class CPlayer
{
public:
CPlayer(void);
~CPlayer(void);
void Play(CString Datei);
...
private:

FMOD::System *fmodSYSTEM;
FMOD::Sound *fmodSOUND;
FMOD::Channel *fmodCHANNEL;
FMOD::DSP *fmodDSP;
static FMOD_RESULT F_CALLBACK endCallBackFunc(void);
};
[/code:30g2af5m]

aber bei der Def. ohne static.

  • You must to post comments
0
0

Hi,

habe ich jetzt auch ohne Compilerfehler zum Laufen bekommen. Das Problem ist nur, dass sich das Verhalten des Callbacks sich nicht geändert hat.

Der Callback wird noch immer zu Beginn des Streams ausgelöst und nicht am Ende wie ich es eigentlich bräuchte.

Vielleicht noch ‘ne Idee?

LG

Markus

In English: I’ve tried all of your hints and at least I got the application running. But all for that the callback’s behavior doesn’t change. It is still fired at the begin of the stream and not at the end. Any other ideas?

THX

Markus

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.