1 |
schoenebeck |
31 |
/*************************************************************************** |
2 |
|
|
* * |
3 |
|
|
* LinuxSampler - modular, streaming capable sampler * |
4 |
|
|
* * |
5 |
|
|
* Copyright (C) 2003 by Benno Senoner and Christian Schoenebeck * |
6 |
|
|
* * |
7 |
|
|
* This program is free software; you can redistribute it and/or modify * |
8 |
|
|
* it under the terms of the GNU General Public License as published by * |
9 |
|
|
* the Free Software Foundation; either version 2 of the License, or * |
10 |
|
|
* (at your option) any later version. * |
11 |
|
|
* * |
12 |
|
|
* This program is distributed in the hope that it will be useful, * |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
15 |
|
|
* GNU General Public License for more details. * |
16 |
|
|
* * |
17 |
|
|
* You should have received a copy of the GNU General Public License * |
18 |
|
|
* along with this program; if not, write to the Free Software * |
19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
20 |
|
|
* MA 02111-1307 USA * |
21 |
|
|
***************************************************************************/ |
22 |
|
|
|
23 |
|
|
#ifndef __ALSAIO_H__ |
24 |
|
|
#define __ALSAIO_H__ |
25 |
|
|
|
26 |
|
|
#include <string.h> |
27 |
|
|
#include <alsa/asoundlib.h> |
28 |
|
|
|
29 |
|
|
#include "global.h" |
30 |
|
|
#include "audioio.h" |
31 |
|
|
#include "thread.h" |
32 |
|
|
#include "audiothread.h" |
33 |
|
|
|
34 |
|
|
class AlsaIO : public AudioIO, protected Thread { |
35 |
|
|
public: |
36 |
|
|
AlsaIO(); |
37 |
|
|
int Initialize(uint Channels, uint Samplerate, uint Fragments, uint FragmentSize); |
38 |
|
|
void Activate(); |
39 |
|
|
void Close(); |
40 |
|
|
void* GetInterleavedOutputBuffer(); |
41 |
|
|
void* GetChannelOutputBufer(uint Channel); |
42 |
|
|
protected: |
43 |
|
|
int Main(); ///< Implementation of virtual method from class Thread |
44 |
|
|
private: |
45 |
|
|
typedef std::string String; |
46 |
|
|
|
47 |
|
|
int16_t* pOutputBuffer; ///< This is the buffer where the final mix will be copied to and send to the sound card |
48 |
|
|
String pcm_name; ///< Name of the PCM device, like plughw:0,0 the first number is the number of the soundcard, the second number is the number of the device. |
49 |
|
|
snd_pcm_t* pcm_handle; ///< Handle for the PCM device |
50 |
|
|
snd_pcm_stream_t stream; |
51 |
|
|
snd_pcm_hw_params_t* hwparams; ///< This structure contains information about the hardware and can be used to specify the configuration to be used for the PCM stream. |
52 |
|
|
snd_pcm_sw_params_t* swparams; |
53 |
|
|
|
54 |
|
|
int Output(); |
55 |
|
|
bool HardwareParametersSupported(uint channels, int samplerate, uint numfragments, uint fragmentsize); |
56 |
|
|
}; |
57 |
|
|
|
58 |
|
|
#endif // __ALSAIO_H__ |