Skip to content

Commit

Permalink
Fix for crash when receiving audio
Browse files Browse the repository at this point in the history
Signed-off-by: pixsperdavid <[email protected]>
  • Loading branch information
pixsperdavid committed Nov 18, 2021
1 parent d22dc7c commit ee999dc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 17 deletions.
37 changes: 25 additions & 12 deletions source/jit.ndi/jit.ndi.receive~/jit.ndi.receive.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ t_jit_err jit_ndi_receive_matrix_calc(t_jit_ndi_receive* x, void* inputs, void*
convInfo.dstdimend[0] = info.dim[0];
convInfo.dstdimend[1] = info.dim[1];

err = jit_object_method(outputMatrix, _jit_sym_frommatrix, x->matrix, &convInfo);
err = (t_jit_err)jit_object_method(outputMatrix, _jit_sym_frommatrix, x->matrix, &convInfo);
}
else
{
Expand Down Expand Up @@ -703,17 +703,30 @@ void jit_ndi_receive_get_samples(t_jit_ndi_receive* x, double** outs, long sampl
NDIlib_audio_frame_v2_t audioFrame = { 0 };
ndiLib->framesync_capture_audio(x->ndiFrameSync, &audioFrame, x->samplerate, x->attrNumAudioChannels, sampleFrames);

assert(audioFrame.no_channels == x->attrNumAudioChannels);
assert(audioFrame.no_samples == sampleFrames);

for(int i = 0; i < x->attrNumAudioChannels; ++i)
{
double* dst = outs[i];
float* src = audioFrame.p_data + ((audioFrame.channel_stride_in_bytes / sizeof(float)) * i);

for(int j = 0; j < sampleFrames; ++j)
*dst++ = *src++;
}
if (audioFrame.p_data)
{
assert(audioFrame.no_channels == x->attrNumAudioChannels);
assert(audioFrame.no_samples == sampleFrames);

for(int i = 0; i < x->attrNumAudioChannels; ++i)
{
double* dst = outs[i];
float* src = audioFrame.p_data + ((audioFrame.channel_stride_in_bytes / sizeof(float)) * i);

for(int j = 0; j < sampleFrames; ++j)
*dst++ = *src++;
}
}
else
{
for(int i = 0; i < x->attrNumAudioChannels; ++i)
{
double* dst = outs[i];

for(int j = 0; j < sampleFrames; ++j)
*dst++ = 0;
}
}

ndiLib->framesync_free_audio(x->ndiFrameSync, &audioFrame);
}
Expand Down
4 changes: 2 additions & 2 deletions source/jit.ndi/jit.ndi.receive~/max.jit.ndi.receive~.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

#include <Processing.NDI.Lib.h>

#include "../ndi_runtime.h"
#include "../version.h"
#include "ndi_runtime.h"
#include "version.h"

#ifdef MAC_VERSION
#include <sys/param.h>
Expand Down
2 changes: 1 addition & 1 deletion source/jit.ndi/jit.ndi.send~/max.jit.ndi.send~.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <Processing.NDI.Lib.h>

#include "ndi_runtime.h"
#include "../version.h"
#include "version.h"



Expand Down
4 changes: 2 additions & 2 deletions source/jit.ndi/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#define H_JIT_NDI_VERSION

#define JIT_NDI_VERSION_MAJOR 0
#define JIT_NDI_VERSION_MINOR 2
#define JIT_NDI_VERSION_MINOR 3
#define JIT_NDI_VERSION_BUGFIX 0

#define JIT_NDI_COPYRIGHT "Copyright (C) 2020 David Butler / The Impersonal Stereo"
#define JIT_NDI_COPYRIGHT "Copyright (C) 2021 Pixsper Ltd."

#endif

0 comments on commit ee999dc

Please sign in to comment.