ALSA9Helpers.h
Go to the documentation of this file.00001
#ifndef ALSA9_HELPERS_H
00002
#define ALSA9_HELPERS_H
00003
00004 #define ALSA_PCM_NEW_HW_PARAMS_API
00005 #define ALSA_PCM_NEW_SW_PARAMS_API
00006
#include <alsa/asoundlib.h>
00007
00008
#include "SDL_types.h"
00009
00010 class Alsa9Buf
00011 {
00012
private:
00013 int channels,
samplerate,
samplebits;
00014 int buffersize;
00015 int64_t
last_cursor_pos;
00016 bool samplerate_set_explicitly;
00017
00018 snd_pcm_uframes_t
preferred_writeahead,
preferred_chunksize;
00019 snd_pcm_uframes_t
writeahead,
chunksize;
00020
00021 snd_pcm_t *
pcm;
00022
00023
bool Recover(
int r );
00024
bool SetHWParams();
00025
bool SetSWParams();
00026
00027
static void ErrorHandler(
const char *file,
int line,
const char *function,
int err,
const char *fmt, ...);
00028
00029
public:
00030
static void InitializeErrorHandler();
00031
static void GetSoundCardDebugInfo();
00032
static CString GetHardwareID( CString name=
"" );
00033
00034 enum hw {
HW_HARDWARE,
HW_SOFTWARE,
HW_DONT_CARE };
00035
00036
00037
Alsa9Buf();
00038
CString Init( hw hardware,
int channels );
00039
~Alsa9Buf();
00040
00041
int GetNumFramesToFill();
00042
bool WaitUntilFramesCanBeFilled(
int timeout_ms );
00043
void Write(
const int16_t *buffer,
int frames );
00044
unsigned FindSampleRate(
unsigned rate );
00045
00046
void Play();
00047
void Stop();
00048
void SetVolume(
float vol);
00049
void SetSampleRate(
int hz);
00050 int GetSampleRate()
const {
return samplerate; }
00051
00052
void SetWriteahead( snd_pcm_sframes_t frames );
00053
void SetChunksize( snd_pcm_sframes_t frames );
00054
void LogParams();
00055
00056 int64_t
GetPosition() const;
00057 int64_t GetPlayPos()
const {
return last_cursor_pos; }
00058 };
00059
#endif
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
Generated on Thu Jan 27 20:57:17 2005 for StepMania by
1.3.7