ListenerList and parameters


#1

Hi everyone,

in a ListenerList I try to call a callback with complex parameters, one is

class FFmpegVideoListener {
public:
    virtual void presentationTimestampChanged (const double) {}
    virtual void displayNewFrame (const AVFrame*) {}
    virtual void displayNewFrame (const juce::Image&) {}
};

// and calling it; no problem with double
double pts = 123.4;
videoListeners.call (&FFmpegVideoListener::presentationTimestampChanged, pts);

// but doesn't compile with pointer or reference
AVFrame* nextFrame;
videoListeners.call (&FFmpegVideoListener::displayNewFrame, nextFrame);
Image outputImage;
videoListeners.call (&FFmpegVideoListener::displayNewFrame, outputImage);

Is this a restriction of the ListenerList template or is there something I did the wrong way?

Thanks for any insight…


#2

Uhm, I’m not an expert with method pointers, but couldn’t it be that the compiler is finding it difficult to understand which of the two methods with the same name (displayNewFrame) you are getting the address of?

Try temporarily commenting one of them and see if that resolves the issue. If that’s it, I guess there must be a syntactic way (which I don’t know) to explicitly tell the compiler which method you are getting the pointer of, based on its prototype…


#3

Indeed, that solves the problem. Thanks @yfede.

Or I simply name them slightly different…