< prev index next >
modules/javafx.media/src/main/native/jfxmedia/platform/osx/avf/AVFAudioSpectrumUnit.h
Print this page
rev 10028 : 8156563: JavaFX Ensemble8 media sample hang and crash
Reviewed-by: almatvee, kcr
*** 1,7 ****
/*
! * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 25,40 ****
--- 25,45 ----
#ifndef __JFXMedia__AVFAudioSpectrumUnit__
#define __JFXMedia__AVFAudioSpectrumUnit__
#include <AudioUnit/AudioUnit.h>
+
+ #include <pthread.h>
+ #include <memory>
+
#include "PipelineManagement/AudioSpectrum.h"
#include "AVFKernelProcessor.h"
#include "CASpectralProcessor.h"
#include "CAStreamBasicDescription.h"
#include "CAAutoDisposer.h"
+
// Defaults, these match the current defaults in JavaFX which get set anyways
// but we can optimize things a bit here...
#define kDefaultAudioSpectrumUpdateInterval 0.1 // every 1/10 second
#define kDefaultAudioSpectrumThreshold -60.0 // -60 dB
*** 91,100 ****
--- 96,107 ----
private:
AVFSpectrumUnitCallbackProc mSpectrumCallbackProc;
void *mSpectrumCallbackContext;
bool mEnabled;
+
+ pthread_mutex_t mBandLock; // prevent bands from disappearing while we're processing
int mBandCount;
CBandsHolder *mBands;
double mUpdateInterval;
Float32 mThreshold;
CASpectralProcessor *mProcessor;
*** 109,120 ****
CAAutoFree<Float32> mWorkBuffer; // temp vectors for calculations
CAAutoFree<Float32> mMagnitudes; // magnitude accumulator
CAAutoFree<Float32> mPhases; // phase accumulator
! bool mRebuildCrunch; // atomic lock avoidance...
CASpectralProcessor *mSpectralCrunch;
void SetupSpectralProcessor();
};
#endif /* defined(__JFXMedia__AVFAudioSpectrumUnit__) */
--- 116,138 ----
CAAutoFree<Float32> mWorkBuffer; // temp vectors for calculations
CAAutoFree<Float32> mMagnitudes; // magnitude accumulator
CAAutoFree<Float32> mPhases; // phase accumulator
!
! bool mRebuildCrunch;
CASpectralProcessor *mSpectralCrunch;
+ void lockBands() {
+ pthread_mutex_lock(&mBandLock);
+ }
+
+ void unlockBands() {
+ pthread_mutex_unlock(&mBandLock);
+ }
+
void SetupSpectralProcessor();
};
+ typedef std::shared_ptr<AVFAudioSpectrumUnit> AVFAudioSpectrumUnitPtr;
+
#endif /* defined(__JFXMedia__AVFAudioSpectrumUnit__) */
< prev index next >