all repos — mgba @ 255242a66515aaef88e5b6c07cc866cdd32214c7

mGBA Game Boy Advance Emulator

src/platform/qt/AudioProcessorSDL.cpp (view raw)

 1/* Copyright (c) 2013-2015 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#include "AudioProcessorSDL.h"
 7
 8extern "C" {
 9#include "gba/supervisor/thread.h"
10}
11
12using namespace QGBA;
13
14AudioProcessorSDL::AudioProcessorSDL(QObject* parent)
15	: AudioProcessor(parent)
16	, m_audio()
17{
18}
19
20AudioProcessorSDL::~AudioProcessorSDL() {
21	GBASDLDeinitAudio(&m_audio);
22}
23
24void AudioProcessorSDL::start() {
25	if (!input()) {
26		return;
27	}
28
29	if (m_audio.thread) {
30		GBASDLResumeAudio(&m_audio);
31	} else {
32		if (!m_audio.samples) {
33			m_audio.samples = input()->audioBuffers;
34		}
35		GBASDLInitAudio(&m_audio, input());
36	}
37}
38
39void AudioProcessorSDL::pause() {
40	GBASDLPauseAudio(&m_audio);
41}
42
43void AudioProcessorSDL::setBufferSamples(int samples) {
44	AudioProcessor::setBufferSamples(samples);
45	m_audio.samples = samples;
46	if (m_audio.thread) {
47		GBASDLDeinitAudio(&m_audio);
48		GBASDLInitAudio(&m_audio, input());
49	}
50}
51
52void AudioProcessorSDL::inputParametersChanged() {
53}