2
* $Id: AUD_SDLDevice.cpp 25643 2010-01-01 05:09:30Z nexyon $
4
* ***** BEGIN LGPL LICENSE BLOCK *****
6
* Copyright 2009 Jörg Hermann Müller
2
* ***** BEGIN GPL LICENSE BLOCK *****
4
* Copyright 2009-2011 Jörg Hermann Müller
8
6
* This file is part of AudaSpace.
10
* AudaSpace is free software: you can redistribute it and/or modify
11
* it under the terms of the GNU Lesser General Public License as published by
12
* the Free Software Foundation, either version 3 of the License, or
8
* Audaspace is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
13
11
* (at your option) any later version.
15
13
* AudaSpace is distributed in the hope that it will be useful,
16
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Lesser General Public License for more details.
20
* You should have received a copy of the GNU Lesser General Public License
21
* along with AudaSpace. If not, see <http://www.gnu.org/licenses/>.
23
* ***** END LGPL LICENSE BLOCK *****
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with Audaspace; if not, write to the Free Software Foundation,
20
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
* ***** END GPL LICENSE BLOCK *****
25
/** \file audaspace/SDL/AUD_SDLDevice.cpp
26
30
#include "AUD_SDLDevice.h"
27
31
#include "AUD_IReader.h"
33
37
device->mix((data_t*)buffer,length/AUD_DEVICE_SAMPLE_SIZE(device->m_specs));
40
static const char* open_error = "AUD_SDLDevice: Device couldn't be opened.";
41
static const char* format_error = "AUD_SDLDevice: Obtained unsupported sample "
36
44
AUD_SDLDevice::AUD_SDLDevice(AUD_DeviceSpecs specs, int buffersize)
38
46
if(specs.channels == AUD_CHANNELS_INVALID)
57
65
format.userdata = this;
59
67
if(SDL_OpenAudio(&format, &obtained) != 0)
60
AUD_THROW(AUD_ERROR_SDL);
68
AUD_THROW(AUD_ERROR_SDL, open_error);
62
70
m_specs.rate = (AUD_SampleRate)obtained.freq;
63
71
m_specs.channels = (AUD_Channels)obtained.channels;
66
74
else if(obtained.format == AUDIO_S16LSB || obtained.format == AUDIO_S16MSB)
67
75
m_specs.format = AUD_FORMAT_S16;
69
AUD_THROW(AUD_ERROR_SDL);
79
AUD_THROW(AUD_ERROR_SDL, format_error);