Commit 7bdf5e36 authored by jpbl's avatar jpbl

*** empty log message ***

parent de904074
......@@ -44,6 +44,7 @@ namespace SFLAudio
* on the system.
*/
virtual std::list< std::string > getDevicesNames() = 0;
virtual std::list< std::string > getCaptureDevicesNames() = 0;
/**
* Will return the name of the audio system. OpenAL or
......
......@@ -19,9 +19,9 @@
*/
#include "AudioManagerImpl.hpp"
#include "NullLayer.hpp"
#include "OpenALLayer.hpp"
#include "PortAudioLayer.hpp"
#include "Null/NullLayer.hpp"
#include "OpenAL/OpenALLayer.hpp"
#include "PortAudio/PortAudioLayer.hpp"
SFLAudio::AudioManagerImpl::AudioManagerImpl()
{
......
if MAINTENER_CODE
noinst_PROGRAMS = example01 example02 example03 example04 example05
noinst_PROGRAMS = example01 example02 example03 example04 example05 example06
noinst_LTLIBRARIES = libsflaudio.la
libsflaudio_la_SOURCES = \
......@@ -8,12 +9,12 @@ libsflaudio_la_SOURCES = \
Context.cpp Context.hpp \
Device.cpp Device.hpp \
Emitter.cpp Emitter.hpp \
MicEmitter.cpp MicEmitter.hpp \
NullLayer.cpp NullLayer.hpp \
NullContext.cpp NullContext.hpp \
NullDevice.cpp NullDevice.hpp \
NullEmitter.hpp \
NullSource.cpp NullSource.hpp \
./Null/NullLayer.cpp ./Null/NullLayer.hpp \
Null/NullContext.cpp Null/NullContext.hpp \
Null/NullDevice.cpp Null/NullDevice.hpp \
Null/NullEmitter.hpp \
Null/NullSource.cpp Null/NullSource.hpp \
OpenAL/MicEmitter.cpp OpenAL/MicEmitter.hpp \
OpenALLayer.cpp OpenALLayer.hpp \
OpenALDevice.cpp OpenALDevice.hpp \
OpenALContext.cpp OpenALContext.hpp \
......@@ -30,11 +31,12 @@ AM_LDFLAGS = -L$(top_srcdir)/libs/portaudio/
LIBADD = $(PORTAUDIO_LIBS) -lportaudio -lopenal -lalut
LDADD = libsflaudio.la $(PORTAUDIO_LIBS) -lopenal -lportaudio -lalut $(libccgnu2_LIBS)
example01_SOURCES = example01.cpp
example02_SOURCES = example02.cpp
example03_SOURCES = example03.cpp
example04_SOURCES = example04.cpp
example05_SOURCES = example05.cpp
example06_SOURCES = example06.cpp
endif
/*
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "Null/NullContext.hpp"
#include "Null/NullSource.hpp"
SFLAudio::Source *
SFLAudio::NullContext::createSource(int, int)
{
return new NullSource();
}
/*
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __SFLAUDIO_NULL_CONTEXT_HPP__
#define __SFLAUDIO_NULL_CONTEXT_HPP__
#include "Context.hpp"
namespace SFLAudio
{
class NullContext : public Context
{
public:
virtual bool isNull() {return true;}
Source *createSource(int format, int freq);
};
}
#endif
/*
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <iostream>
#include "Null/NullDevice.hpp"
#include "Null/NullContext.hpp"
SFLAudio::NullDevice::NullDevice()
: Device("Null/NullDevice")
{
currentContext(createContext());
}
SFLAudio::Context *
SFLAudio::NullDevice::createContext()
{
return new NullContext();
}
bool
SFLAudio::NullDevice::load()
{
return true;
}
void
SFLAudio::NullDevice::unload()
{}
bool
SFLAudio::NullDevice::isNull()
{
return true;
}
/*
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __SFLAUDIO_NULL_DEVICE_HPP__
#define __SFLAUDIO_NULL_DEVICE_HPP__
#include "Device.hpp"
namespace SFLAudio
{
class NullDevice : public Device
{
public:
NullDevice();
Context *createContext();
virtual bool load();
virtual void unload();
bool isNull();
};
}
#endif
/*
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __SFLAUDIO_NULL_EMITTER_HPP__
#define __SFLAUDIO_NULL_EMITTER_HPP__
#include "Emitter.hpp"
namespace SFLAudio
{
class Context;
class Source;
class NullEmitter : public Emitter
{
public:
virtual bool isNull() {return true;}
virtual void play() {}
};
}
#endif
/*
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "Null/NullLayer.hpp"
#include "Null/NullDevice.hpp"
#include "Null/NullEmitter.hpp"
SFLAudio::NullLayer::NullLayer()
: AudioLayer("Null/NullLayer")
{}
std::list< std::string >
SFLAudio::NullLayer::getDevicesNames()
{return std::list< std::string >();}
std::list< std::string >
SFLAudio::NullLayer::getCaptureDevicesNames()
{return std::list< std::string >();}
SFLAudio::Device *
SFLAudio::NullLayer::openDevice()
{
return new NullDevice();
}
SFLAudio::Emitter *
SFLAudio::NullLayer::openCaptureDevice()
{
return new NullEmitter();
}
SFLAudio::Device *
SFLAudio::NullLayer::openDevice(const std::string &)
{
return new NullDevice();
}
/*
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __SFLAUDIO_NULL_LAYER_HPP__
#define __SFLAUDIO_NULL_LAYER_HPP__
#include "AudioLayer.hpp"
namespace SFLAudio
{
class NullLayer : public AudioLayer
{
public:
NullLayer();
std::list< std::string > getDevicesNames();
std::list< std::string > getCaptureDevicesNames();
virtual Device *openDevice();
virtual Emitter *openCaptureDevice();
virtual Device *openDevice(const std::string &name);
};
}
#endif
/*
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "Null/NullSource.hpp"
SFLAudio::NullSource::NullSource()
: Source(0, 0)
{}
bool
SFLAudio::NullSource::isPlaying()
{return true;}
void
SFLAudio::NullSource::play(void *, int)
{}
void
SFLAudio::NullSource::stream(void *, int)
{}
void
SFLAudio::NullSource::stop()
{}
/*
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __SFLAUDIO_NULL_SOURCE_HPP__
#define __SFLAUDIO_NULL_SOURCE_HPP__
#include "Source.hpp"
namespace SFLAudio
{
class NullSource : public Source
{
public:
NullSource();
virtual bool isNull() {return true;};
virtual bool isPlaying();
virtual void stream(void *data, int size);
virtual void play(void *data, int size);
virtual void stop();
};
}
#endif
/*
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <AL/alut.h>
#include <AL/alut.h>
#include <iostream>
#include "OpenAL/OpenALLayer.hpp"
#include "MicEmitter.hpp"
#include "Source.hpp"
SFLAudio::MicEmitter::MicEmitter(int format, int freq, int size,
PFNALCAPTURESTARTPROC palCaptureStart,
PFNALCAPTURESTOPPROC palCaptureStop,
PFNALCAPTUREGETDATAPROC palCaptureGetData)
: Emitter(format, freq)
, mSize(size)
, mAlCaptureStart(palCaptureStart)
, mAlCaptureStop(palCaptureStop)
, mAlCaptureGetData(palCaptureGetData)
, mThread(0)
{}
void
SFLAudio::MicEmitter::play()
{
if(mThread == 0) {
mAlCaptureStart();
mThread = new MicEmitterThread(getFormat(), getFrequency(), mSize, mAlCaptureGetData);
mThread->setSource(getSource());
mThread->start();
}
}
void
SFLAudio::MicEmitter::stop()
{
if(mThread != 0) {
delete mThread;
mThread = 0;
}
}
SFLAudio::MicEmitterThread::MicEmitterThread(int format,
int freq,
int size,
PFNALCAPTUREGETDATAPROC palCaptureGetData)
: mSource(0)
, mFormat(format)
, mFreq(freq)
, mSize(size)
, mAlCaptureGetData(palCaptureGetData)
{
setCancel(cancelDeferred);
mData = (ALchar *)malloc(mSize);
}
SFLAudio::MicEmitterThread::~MicEmitterThread()
{
terminate();
free(mData);
}
void
SFLAudio::MicEmitterThread::setSource(SFLAudio::Source *source) {
mSource = source;
}
void
SFLAudio::MicEmitterThread::fill() {
ALsizei retval = 0;
std::cout << "filling capture buffer...\n";
while(retval < mSize) {
int size = mAlCaptureGetData(&mData[retval],
mSize - retval,
mFormat,
mFreq);
retval += size;
if(size != 0)
std::cout << "read " << size <<
" bytes from capture, for a total of " << retval << std::endl;
}
std::cout << "capture buffer filled!\n";
}
void
SFLAudio::MicEmitterThread::run()
{
while (!testCancel()) {
if(mData) {
fill();
}
if(mSource && mData) {
mSource->stream(mData, mSize);
}
else {
std::cerr << "source or buffer invalid.\n";
}
std::cout << "done." << std::endl;
}
}
/*
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __SFLAUDIO_MIC_EMITTER_HPP__
#define __SFLAUDIO_MIC_EMITTER_HPP__
#include <AL/al.h>
#include <cc++/thread.h>
#include "Emitter.hpp"
namespace SFLAudio
{
class Source;
class MicEmitterThread : public ost::Thread
{
public:
MicEmitterThread(int format, int freq, int size, PFNALCAPTUREGETDATAPROC palCaptureGetData);
~MicEmitterThread();
void setSource(SFLAudio::Source *source);
virtual void run();
void fill();
private:
SFLAudio::Source *mSource;
ALchar *mData;
ALsizei mFormat;
ALsizei mFreq;
ALsizei mSize;
PFNALCAPTUREGETDATAPROC mAlCaptureGetData;
};
class MicEmitter : public Emitter
{
private:
MicEmitter();
public:
MicEmitter(int format, int freq, int size,
PFNALCAPTURESTARTPROC palCaptureStart,
PFNALCAPTURESTOPPROC palCaptureStop,
PFNALCAPTUREGETDATAPROC palCaptureGetData);
virtual void play();
virtual void stop();
private:
ALsizei mSize;
PFNALCAPTURESTARTPROC mAlCaptureStart;
PFNALCAPTURESTOPPROC mAlCaptureStop;
PFNALCAPTUREGETDATAPROC mAlCaptureGetData;
MicEmitterThread* mThread;
};
}
#endif
/*
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <iostream>
#include "OpenAL/OpenALContext.hpp"
#include "OpenAL/OpenALSource.hpp"
#include "Null/NullSource.hpp"
SFLAudio::OpenALContext::OpenALContext(ALCcontext *context)
: mContext(context)
{}
SFLAudio::Source *
SFLAudio::OpenALContext::createSource(int format, int freq)
{
Source *source = 0;
if(mContext == 0) {
source = new NullSource();
}
else {
source = OpenALSource::create(this, format, freq);
}
return source;
}
/*
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Jean-Philippe Barrette-LaPierre
* <jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __SFLAUDIO_OPENAL_CONTEXT_HPP__
#define __SFLAUDIO_OPENAL_CONTEXT_HPP__
#include "Context.hpp"
#include "AL/alc.h"
namespace SFLAudio
{
class OpenALContext : public Context
{
private:
OpenALContext();
public:
OpenALContext(ALCcontext *context);
Source *createSource(int format, int freq);
private:
ALCcontext *mContext;
};
}