Bug 1176300 - Add soundtouch factory functions for DLL memory handling on windows; r=padenot

This commit is contained in:
Kyle Machulis 2015-07-06 12:08:56 -07:00
Родитель 793be989a7
Коммит 23445a5b80
7 изменённых файлов: 64 добавлений и 3 удалений

Просмотреть файл

@ -1257,6 +1257,7 @@ X11/Xos.h
X11/Xutil.h
zmouse.h
soundtouch/SoundTouch.h
soundtouch/SoundTouchFactory.h
#if MOZ_NATIVE_PNG==1
png.h
#endif

Просмотреть файл

@ -129,6 +129,7 @@ AudioStream::AudioStream()
, mOutChannels(0)
, mWritten(0)
, mAudioClock(this)
, mTimeStretcher(nullptr)
, mLatencyRequest(HighLatency)
, mReadPoint(0)
, mDumpFile(nullptr)
@ -151,6 +152,9 @@ AudioStream::~AudioStream()
if (mDumpFile) {
fclose(mDumpFile);
}
if (mTimeStretcher) {
soundtouch::destroySoundTouchObj(mTimeStretcher);
}
}
size_t
@ -173,7 +177,7 @@ nsresult AudioStream::EnsureTimeStretcherInitializedUnlocked()
{
mMonitor.AssertCurrentThreadOwns();
if (!mTimeStretcher) {
mTimeStretcher = new soundtouch::SoundTouch();
mTimeStretcher = soundtouch::createSoundTouchObj();
mTimeStretcher->setSampleRate(mInRate);
mTimeStretcher->setChannels(mOutChannels);
mTimeStretcher->setPitch(1.0);

Просмотреть файл

@ -15,7 +15,7 @@
#include "mozilla/RefPtr.h"
#include "mozilla/UniquePtr.h"
#include "CubebUtils.h"
#include "soundtouch/SoundTouch.h"
#include "soundtouch/SoundTouchFactory.h"
namespace mozilla {
@ -329,7 +329,7 @@ private:
// Number of frames written to the buffers.
int64_t mWritten;
AudioClock mAudioClock;
nsAutoPtr<soundtouch::SoundTouch> mTimeStretcher;
soundtouch::SoundTouch* mTimeStretcher;
nsRefPtr<AsyncLatencyLogger> mLatencyLog;
// copy of Latency logger's starting time for offset calculations

Просмотреть файл

@ -0,0 +1,31 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <soundtouch/SoundTouch.h>
namespace soundtouch
{
EXPORT
soundtouch::SoundTouch*
createSoundTouchObj()
{
return new soundtouch::SoundTouch();
}
EXPORT
void
destroySoundTouchObj(soundtouch::SoundTouch* aObj)
{
// SoundTouch runs deletes in its destructor, meaning they need to be run in
// the DLL context. Gecko should send its SoundTouch obj pointers here to be
// cleaned up.
if (aObj) {
delete aObj;
}
}
}

Просмотреть файл

@ -0,0 +1,22 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Code for dealing with creating/deleting SoundTouch objects across DLL
// boundaries.
#include <soundtouch/STTypes.h>
#include <soundtouch/SoundTouch.h>
namespace soundtouch
{
EXPORT
soundtouch::SoundTouch*
createSoundTouchObj();
EXPORT
void
destroySoundTouchObj(soundtouch::SoundTouch* aObj);
}

Просмотреть файл

@ -8,6 +8,7 @@ EXPORTS.soundtouch += [
'FIFOSamplePipe.h',
'SoundTouch.h',
'soundtouch_config.h',
'SoundTouchFactory.h',
'STTypes.h',
]
@ -21,6 +22,7 @@ UNIFIED_SOURCES += [
'InterpolateShannon.cpp',
'RateTransposer.cpp',
'SoundTouch.cpp',
'SoundTouchFactory.cpp',
'TDStretch.cpp',
]

Просмотреть файл

@ -12,6 +12,7 @@
#pragma GCC visibility push(default)
#include "SoundTouch.h"
#include "SoundTouchFactory.h"
#pragma GCC visibility pop
#endif // MOZILLA_SOUNDTOUCH_PERMS_H