Files
itgmania212121/stepmania/src/arch/Sound/ALSA9Helpers.h
T

53 lines
1.2 KiB
C++
Raw Normal View History

2003-10-21 22:51:25 +00:00
#ifndef ALSA9_HELPERS_H
#define ALSA9_HELPERS_H
#define ALSA_PCM_NEW_HW_PARAMS_API
#define ALSA_PCM_NEW_SW_PARAMS_API
2003-10-21 22:51:25 +00:00
#include <alsa/asoundlib.h>
#include "SDL_types.h"
class Alsa9Buf
{
private:
2003-10-22 02:34:44 +00:00
int channels, samplerate, samplebits;
2004-01-20 01:00:01 +00:00
int buffersize;
int64_t last_cursor_pos;
2004-01-03 02:49:19 +00:00
bool samplerate_set_explicitly;
2003-10-21 22:51:25 +00:00
snd_pcm_sframes_t total_frames;
snd_pcm_uframes_t xfer_align;
2003-10-21 22:51:25 +00:00
snd_pcm_t *pcm;
bool Recover( int r );
bool SetHWParams();
bool SetSWParams();
2003-10-21 22:51:25 +00:00
2003-10-22 06:50:08 +00:00
static void ErrorHandler(const char *file, int line, const char *function, int err, const char *fmt, ...);
2003-10-21 22:51:25 +00:00
public:
static void GetSoundCardDebugInfo();
2004-02-18 00:40:22 +00:00
static CString GetHardwareID( CString name="" );
2003-10-21 22:51:25 +00:00
enum hw { HW_HARDWARE, HW_SOFTWARE, HW_DONT_CARE };
/* Call SetSampleRate before you use the sample. */
Alsa9Buf( hw hardware, int channels );
2003-10-21 22:51:25 +00:00
~Alsa9Buf();
2004-02-05 21:03:03 +00:00
int GetNumFramesToFill( snd_pcm_sframes_t writeahead, snd_pcm_sframes_t chunksize );
2003-10-21 22:51:25 +00:00
void Write( const Sint16 *buffer, int frames );
unsigned FindSampleRate( unsigned rate );
2003-10-21 22:51:25 +00:00
void Play();
void Stop();
void SetVolume(float vol);
void SetSampleRate(int hz);
2004-01-12 03:53:16 +00:00
int GetSampleRate() const { return samplerate; }
2003-10-21 22:51:25 +00:00
2004-01-20 01:00:01 +00:00
int64_t GetPosition() const;
int64_t GetPlayPos() const { return last_cursor_pos; }
2003-10-21 22:51:25 +00:00
};
#endif