Commit 00768e6b authored by Ken Martin's avatar Ken Martin
Browse files

Cleanup audio callback to not use nested class

Since c++ still cannot forward declare nested classes
parent 6ec7ca86
......@@ -107,7 +107,7 @@ void setupAudioPlayback(vtkFFMPEGVideoSource *video)
// debugc.BreakMask = XAUDIO2_LOG_ERRORS;
// pXAudio2->SetDebugConfiguration(&debugc, nullptr);
auto cbfunc = [pXAudio2](vtkFFMPEGVideoSource::AudioCallbackData &acbd)
auto cbfunc = [pXAudio2](vtkFFMPEGVideoSourceAudioCallbackData &acbd)
{
HRESULT hr;
static IXAudio2SourceVoice* pSourceVoice = nullptr;
......
......@@ -497,8 +497,6 @@ void *vtkFFMPEGVideoSource::Drain(vtkMultiThreader::ThreadInfo *data)
}
else if (ret == AVERROR_EOF)
{
done = true;
cerr << "video drain thread exiting on EOF!\n";
return nullptr;
}
else if (ret < 0) // error code
......@@ -563,8 +561,6 @@ void *vtkFFMPEGVideoSource::DrainAudio(vtkMultiThreader::ThreadInfo *data)
}
else if (ret == AVERROR_EOF)
{
done = true;
cerr << "audio drain thread exiting on EOF!\n";
return nullptr;
}
else if (ret < 0) // error code
......@@ -625,7 +621,7 @@ void *vtkFFMPEGVideoSource::DrainAudio(vtkMultiThreader::ThreadInfo *data)
if (this->AudioCallback)
{
AudioCallbackData cbd;
vtkFFMPEGVideoSourceAudioCallbackData cbd;
cbd.NumberOfSamples = this->Internal->AudioFrame->nb_samples;
cbd.BytesPerSample =
av_get_bytes_per_sample(this->Internal->AudioDecodeContext->sample_fmt);
......
......@@ -37,6 +37,22 @@ class vtkFFMPEGVideoSourceInternal;
class vtkConditionVariable;
class vtkMutexLock;
class vtkFFMPEGVideoSource;
// audio callback struct, outside the class so that we
// can forward ref it
struct vtkFFMPEGVideoSourceAudioCallbackData
{
int NumberOfSamples;
int BytesPerSample;
int NumberOfChannels;
int SampleRate;
int DataType;
bool Packed;
unsigned char** Data;
vtkFFMPEGVideoSource *Caller;
void *ClientData;
};
class VTKIOFFMPEG_EXPORT vtkFFMPEGVideoSource : public vtkVideoSource
{
......@@ -114,20 +130,6 @@ public:
// Usefull for while loops
vtkGetMacro(EndOfFile,bool);
class AudioCallbackData
{
public:
int NumberOfSamples;
int BytesPerSample;
int NumberOfChannels;
int SampleRate;
int DataType;
bool Packed;
unsigned char** Data;
vtkFFMPEGVideoSource *Caller;
void *ClientData;
};
// we do not use Invoke Observers here because this callback
// will happen in a different thread that could conflict
// with events from other threads. In this function you should
......@@ -135,7 +137,7 @@ public:
// instead you should have enough buffering that you can consume
// the provided data and return. Typically even 1 second of
// buffer storage is enough to prevent blocking.
typedef std::function<void(AudioCallbackData &data)> AudioCallbackType;
typedef std::function<void(vtkFFMPEGVideoSourceAudioCallbackData &data)> AudioCallbackType;
void SetAudioCallback(AudioCallbackType cb, void *clientData)
{
this->AudioCallback = cb;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment