1 |
/*************************************************************************** |
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 __AUDIO_H__ |
24 |
#define __AUDIO_H__ |
25 |
|
26 |
// We only support Alsa at the moment |
27 |
|
28 |
#include <string> |
29 |
#include <stdio.h> |
30 |
#include <stdlib.h> |
31 |
#include <string.h> |
32 |
#include <unistd.h> |
33 |
#include <alsa/asoundlib.h> |
34 |
#include <sched.h> |
35 |
#include <sys/mman.h> |
36 |
|
37 |
#include "global.h" |
38 |
|
39 |
class AudioIO { |
40 |
public: |
41 |
bool Initialized; |
42 |
int16_t* pOutputBuffer; ///< This is the buffer where the final mix will be copied to and send to the sound card |
43 |
uint Channels; |
44 |
uint Samplerate; |
45 |
uint Fragments; |
46 |
uint FragmentSize; ///< in sample points |
47 |
|
48 |
AudioIO(); |
49 |
~AudioIO(); |
50 |
int Initialize(uint channels, uint samplerate, uint numfragments, uint fragmentsize); |
51 |
int Output(); |
52 |
void Close(); |
53 |
private: |
54 |
typedef std::string String; |
55 |
|
56 |
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. |
57 |
snd_pcm_t* pcm_handle; ///< Handle for the PCM device |
58 |
snd_pcm_stream_t stream; |
59 |
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. |
60 |
snd_pcm_sw_params_t* swparams; |
61 |
|
62 |
bool HardwareParametersSupported(uint channels, int samplerate, uint numfragments, uint fragmentsize); |
63 |
}; |
64 |
|
65 |
#endif // __AUDIO_H__ |