25 |
|
|
26 |
// We only support Alsa at the moment |
// We only support Alsa at the moment |
27 |
|
|
28 |
|
#include <string> |
29 |
#include <stdio.h> |
#include <stdio.h> |
30 |
#include <stdlib.h> |
#include <stdlib.h> |
31 |
#include <string.h> |
#include <string.h> |
34 |
#include <sched.h> |
#include <sched.h> |
35 |
#include <sys/mman.h> |
#include <sys/mman.h> |
36 |
|
|
37 |
|
#include "global.h" |
38 |
|
|
39 |
class AudioIO { |
class AudioIO { |
40 |
public: |
public: |
41 |
int16_t* pOutputBuffer; ///< This is the buffer where the final mix will be copied to and send to the sound card |
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; |
uint Channels; |
44 |
uint Samplerate; |
uint Samplerate; |
45 |
uint Fragments; |
uint Fragments; |
46 |
uint FragmentSize; ///< in sample points |
uint FragmentSize; ///< in sample points |
47 |
|
|
48 |
AudioIO(); |
AudioIO(); |
49 |
~AudioIO(); |
~AudioIO(); |
51 |
int Output(); |
int Output(); |
52 |
void Close(); |
void Close(); |
53 |
private: |
private: |
54 |
snd_pcm_t* pcm_handle; ///< Handle for the PCM device |
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__ |
#endif // __AUDIO_H__ |