Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8242530: [macos] Some audio files miss spectrum data when another audio file plays first #184

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -270,6 +270,7 @@ gst_spectrum_init (GstSpectrum * spectrum)
spectrum->bps_user = 0;
spectrum->bpf_user = 0;
spectrum->user_data = NULL;
spectrum->post_message_callback = NULL;
#endif // GSTREAMER_LITE and OSX

g_mutex_init (&spectrum->lock);
Expand Down Expand Up @@ -1060,7 +1061,15 @@ gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * buffer)
m = gst_spectrum_message_new (spectrum, spectrum->message_ts,
spectrum->interval);

#if defined (GSTREAMER_LITE) && defined (OSX)
if (spectrum->post_message_callback != NULL) {
spectrum->post_message_callback(GST_ELEMENT (spectrum), m);
} else {
gst_element_post_message (GST_ELEMENT (spectrum), m);
}
#else // GSTREAMER_LITE && OSX
gst_element_post_message (GST_ELEMENT (spectrum), m);
#endif // GSTREAMER_LITE && OSX
#ifndef GSTREAMER_LITE
}
#endif // GSTREAMER_LITE
Expand Down
Expand Up @@ -40,6 +40,15 @@ typedef struct _GstSpectrumChannel GstSpectrumChannel;
typedef void (*GstSpectrumInputData)(const guint8 * in, gfloat * out,
guint len, guint channels, gfloat max_value, guint op, guint nfft);

#if defined (GSTREAMER_LITE) && defined (OSX)
// Used to overwrite post_message callback to get spectrum messages in OSXPlatform.
// We cannot use GST_ELEMENT_GET_CLASS(spectrum)->post_message, since it will
// change callback for all instances of spectrum elements and it will conflict
// with GStreamer platform.
typedef gboolean (*PostMessageCallbackProc)(GstElement * element,
GstMessage * message);
#endif // GSTREAMER_LITE and OSX

struct _GstSpectrumChannel
{
gfloat *input;
Expand Down Expand Up @@ -86,6 +95,7 @@ struct _GstSpectrum
guint bps_user; // User provided values to avoid more complex spectrum initialization
guint bpf_user;
void *user_data;
PostMessageCallbackProc post_message_callback;
#endif // GSTREAMER_LITE and OSX
};

Expand Down
Expand Up @@ -272,10 +272,10 @@ void AVFAudioSpectrumUnit::SetupSpectralProcessor() {
mSpectrum = GST_SPECTRUM(mSpectrumElement);
mSpectrum->user_data = (void*)this;

// Set our own callback for post message
GstElementClass *klass;
klass = GST_ELEMENT_GET_CLASS(mSpectrumElement);
klass->post_message = PostMessageCallback;
// Set our own callback for post message, do not use
// GST_ELEMENT_GET_CLASS(mSpectrumElement)->post_message, since it will change
// callback for all instances of spectrum element.
mSpectrum->post_message_callback = PostMessageCallback;

// Configure spectrum element
// Do send magnitude and phase information, off by default
Expand Down