mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Automated formatting fix
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) 2006-2011 LOVE Development Team
|
||||
*
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any damages
|
||||
* arising from the use of this software.
|
||||
*
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any purpose,
|
||||
* including commercial applications, and to alter it and redistribute it
|
||||
* freely, subject to the following restrictions:
|
||||
*
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you must not
|
||||
* claim that you wrote the original software. If you use this software
|
||||
* in a product, an acknowledgment in the product documentation would be
|
||||
@@ -30,16 +30,18 @@ namespace audio
|
||||
namespace openal
|
||||
{
|
||||
Audio::PoolThread::PoolThread(Pool* pool)
|
||||
: pool(pool), finish(false) {
|
||||
|
||||
: pool(pool), finish(false)
|
||||
{
|
||||
}
|
||||
|
||||
void Audio::PoolThread::main()
|
||||
{
|
||||
while(true) {
|
||||
while (true)
|
||||
{
|
||||
{
|
||||
thread::Lock lock(mutex);
|
||||
if (finish) {
|
||||
if (finish)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -61,32 +63,35 @@ namespace openal
|
||||
// Passing zero for default device.
|
||||
device = alcOpenDevice(0);
|
||||
|
||||
if(device == 0)
|
||||
if (device == 0)
|
||||
throw love::Exception("Could not open device.");
|
||||
|
||||
context = alcCreateContext(device, 0);
|
||||
|
||||
if(context == 0)
|
||||
if (context == 0)
|
||||
throw love::Exception("Could not create context.");
|
||||
|
||||
alcMakeContextCurrent(context);
|
||||
|
||||
if(alcGetError(device) != ALC_NO_ERROR)
|
||||
if (alcGetError(device) != ALC_NO_ERROR)
|
||||
throw love::Exception("Could not make context current.");
|
||||
|
||||
|
||||
/*std::string captureName(alcGetString(NULL, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER));
|
||||
const ALCchar * devices = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER);
|
||||
while (*devices) {
|
||||
while (*devices)
|
||||
{
|
||||
std::string device(devices);
|
||||
devices += device.size() + 1;
|
||||
if (device.find("Mic") != std::string::npos || device.find("mic") != std::string::npos) {
|
||||
if (device.find("Mic") != std::string::npos || device.find("mic") != std::string::npos)
|
||||
{
|
||||
captureName = device;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
capture = alcCaptureOpenDevice(captureName.c_str(), 8000, AL_FORMAT_MONO16, 262144); // about 32 seconds
|
||||
|
||||
if (!capture) {
|
||||
|
||||
if (!capture)
|
||||
{
|
||||
// We're not going to prevent LOVE from running without a microphone, but we should warn, at least
|
||||
std::cerr << "Warning, couldn't open capture device! No audio input!" << std::endl;
|
||||
}*/
|
||||
@@ -105,7 +110,7 @@ namespace openal
|
||||
|
||||
delete poolThread;
|
||||
delete pool;
|
||||
|
||||
|
||||
alcMakeContextCurrent(0);
|
||||
alcDestroyContext(context);
|
||||
//if (capture) alcCaptureCloseDevice(capture);
|
||||
@@ -167,7 +172,7 @@ namespace openal
|
||||
{
|
||||
source->resume();
|
||||
}
|
||||
|
||||
|
||||
void Audio::resume()
|
||||
{
|
||||
pool->resume();
|
||||
@@ -224,16 +229,17 @@ namespace openal
|
||||
{
|
||||
alListenerfv(AL_VELOCITY, v);
|
||||
}
|
||||
|
||||
|
||||
void Audio::record()
|
||||
{
|
||||
if (!canRecord()) return;
|
||||
alcCaptureStart(capture);
|
||||
}
|
||||
|
||||
|
||||
love::sound::SoundData * Audio::getRecordedData()
|
||||
{
|
||||
if (!canRecord()) return NULL;
|
||||
if (!canRecord())
|
||||
return NULL;
|
||||
int samplerate = 8000;
|
||||
ALCint samples;
|
||||
alcGetIntegerv(capture, ALC_CAPTURE_SAMPLES, 4, &samples);
|
||||
@@ -243,18 +249,20 @@ namespace openal
|
||||
free(data);
|
||||
return sd;
|
||||
}
|
||||
|
||||
|
||||
love::sound::SoundData * Audio::stopRecording(bool returnData)
|
||||
{
|
||||
if (!canRecord()) return NULL;
|
||||
if (!canRecord())
|
||||
return NULL;
|
||||
love::sound::SoundData * sd = NULL;
|
||||
if (returnData) {
|
||||
if (returnData)
|
||||
{
|
||||
sd = getRecordedData();
|
||||
}
|
||||
alcCaptureStop(capture);
|
||||
return sd;
|
||||
}
|
||||
|
||||
|
||||
bool Audio::canRecord()
|
||||
{
|
||||
return (capture != NULL);
|
||||
|
||||
Reference in New Issue
Block a user