Skip to content

Commit

Permalink
Buildfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Feb 19, 2017
1 parent a5035c7 commit b5a9768
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,7 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/HW/SimpleAudioDec.h
Core/HW/AsyncIOManager.cpp
Core/HW/AsyncIOManager.h
Core/HW/AsyncAudioQueue.h
Core/HW/MediaEngine.cpp
Core/HW/MediaEngine.h
Core/HW/MpegDemux.cpp
Expand All @@ -1480,6 +1481,8 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/HW/SasReverb.h
Core/HW/StereoResampler.cpp
Core/HW/StereoResampler.h
Core/HW/StereoStretcher.cpp
Core/HW/StereoStretcher.h
Core/Host.cpp
Core/Host.h
Core/Loaders.cpp
Expand Down Expand Up @@ -1552,6 +1555,8 @@ add_library(${CoreLibName} ${CoreLinkType}
Core/Util/PPGeDraw.h
Core/Util/ppge_atlas.cpp
Core/Util/ppge_atlas.h
Core/Util/TimeStretcher.cpp
Core/Util/TimeStretcher.h
${CORE_NEON}
${GPU_SOURCES}
Globals.h
Expand Down
8 changes: 2 additions & 6 deletions Core/HW/StereoResampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ StereoResampler::StereoResampler()
, sample_rate_(0.0f)
, lastBufSize_(0) {
// Need to have space for the worst case in case it changes.
m_buffer = new int16_t[MAX_SAMPLES_EXTRA * 2]();
m_buffer.reset(new int16_t[MAX_SAMPLES_EXTRA * 2]());

// Some Android devices are v-synced to non-60Hz framerates. We simply timestretch audio to fit.
// TODO: should only do this if auto frameskip is off?
Expand All @@ -73,10 +73,6 @@ StereoResampler::StereoResampler()
UpdateBufferSize();
}

StereoResampler::~StereoResampler() {
delete[] m_buffer;
}

void StereoResampler::UpdateBufferSize() {
if (g_Config.bExtraAudioBuffering) {
m_bufsize = MAX_SAMPLES_EXTRA;
Expand Down Expand Up @@ -121,7 +117,7 @@ inline void ClampBufferToS16WithVolume(s16 *out, const s32 *in, size_t size) {
}

void StereoResampler::Clear() {
memset(m_buffer, 0, m_bufsize * 2 * sizeof(int16_t));
memset(&m_buffer[0], 0, m_bufsize * 2 * sizeof(int16_t));
}

// Executed from sound stream thread
Expand Down
4 changes: 3 additions & 1 deletion Core/HW/StereoResampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#pragma once

#include <string>
#include <memory>

#include "base/mutex.h"

Expand All @@ -43,6 +44,7 @@ class StereoResampler : public AsyncAudioQueue {
void DoState(PointerWrap &p) override;

void GetAudioDebugStats(AudioDebugStats *stats) override;
void Clear() override;

protected:
void UpdateBufferSize();
Expand All @@ -51,7 +53,7 @@ class StereoResampler : public AsyncAudioQueue {
int m_bufsize;
int m_lowwatermark;
unsigned int m_input_sample_rate;
int16_t *m_buffer;
std::unique_ptr<int16_t[]> m_buffer;
volatile u32 m_indexW;
volatile u32 m_indexR;
float m_numLeftI;
Expand Down
7 changes: 4 additions & 3 deletions Core/HW/StereoStretcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ void StereoStretcher::PushSamples(const s32 * samples, unsigned int num_samples)

stats_.watermark = stretch_.GetSamplesQueued();
mutex_.lock();
size_t total_size = std::accumulate(queue.begin(), queue.end(), 0, [](size_t sum, const auto& buffer) {
return sum + buffer.size();
});
size_t total_size = 0;
for (auto iter = queue.begin(); iter != queue.end(); ++iter) {
total_size += iter->size();
}
double now = real_time_now();
stats_.duration = now - last_now_;
last_now_ = now;
Expand Down
3 changes: 2 additions & 1 deletion Core/Util/TimeStretcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ namespace AudioCore {

TimeStretcher::~TimeStretcher() {
impl->soundtouch.clear();
delete impl;
}

void TimeStretcher::SetOutputSampleRate(unsigned int sample_rate) {
Expand All @@ -102,7 +103,7 @@ namespace AudioCore {
}

int TimeStretcher::GetSamplesQueued() {
return impl->samples_queued;
return (int)impl->samples_queued;
}

void TimeStretcher::Flush() {
Expand Down
2 changes: 1 addition & 1 deletion Core/Util/TimeStretcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace AudioCore {

private:
struct Impl;
std::unique_ptr<Impl> impl;
Impl *impl;

/// INTERNAL: Clamp ratio within limits.
static double ClampRatio(double ratio);
Expand Down
2 changes: 2 additions & 0 deletions android/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ EXEC_AND_LIB_FILES := \
$(SRC)/Core/HW/SasAudio.cpp.arm \
$(SRC)/Core/HW/SasReverb.cpp.arm \
$(SRC)/Core/HW/StereoResampler.cpp.arm \
$(SRC)/Core/HW/StereoStretcher.cpp.arm \
$(SRC)/Core/Core.cpp \
$(SRC)/Core/Compatibility.cpp \
$(SRC)/Core/Config.cpp \
Expand Down Expand Up @@ -383,6 +384,7 @@ EXEC_AND_LIB_FILES := \
$(SRC)/Core/Util/AudioFormat.cpp \
$(SRC)/Core/Util/GameManager.cpp \
$(SRC)/Core/Util/BlockAllocator.cpp \
$(SRC)/Core/Util/TimeStretcher.cpp \
$(SRC)/Core/Util/ppge_atlas.cpp \
$(SRC)/Core/Util/PPGeDraw.cpp \
$(SRC)/git-version.cpp
Expand Down

0 comments on commit b5a9768

Please sign in to comment.