Files
itgmania212121/stepmania/src/arch/Sound/ALSA9Helpers.h
T
Glenn Maynard a27620a32d Handle hardware that only supports 48khz output (eg. Intel8x0, on
nForce boards).  Allow drivers to tell whether specific sample rates
are supported (instead of "all or nothing").

Warning: this will break the Windows (and possibly OS X) drivers for
a few minutes until I update them.
2004-01-03 02:35:47 +00:00

49 lines
1.0 KiB
C++

#ifndef ALSA9_HELPERS_H
#define ALSA9_HELPERS_H
#define ALSA_PCM_NEW_HW_PARAMS_API
#define ALSA_PCM_NEW_SW_PARAMS_API
#include <alsa/asoundlib.h>
#include "SDL_types.h"
class Alsa9Buf
{
private:
int channels, samplerate, samplebits;
int buffersize, last_cursor_pos;
snd_pcm_sframes_t total_frames;
snd_pcm_uframes_t xfer_align;
snd_pcm_t *pcm;
bool Recover( int r );
bool SetHWParams();
static void ErrorHandler(const char *file, int line, const char *function, int err, const char *fmt, ...);
public:
static void GetSoundCardDebugInfo();
enum hw { HW_HARDWARE, HW_SOFTWARE, HW_DONT_CARE };
/* Call SetSampleRate before you use the sample. */
Alsa9Buf( hw hardware, int channels );
~Alsa9Buf();
int GetNumFramesToFill( int writeahead );
void Write( const Sint16 *buffer, int frames );
unsigned FindSampleRate( unsigned rate );
void Reset();
void Play();
void Stop();
void SetVolume(float vol);
void SetSampleRate(int hz);
int GetPosition() const;
int GetPlayPos() const { return last_cursor_pos; }
};
#endif