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

66 lines
1.3 KiB
C++
Raw Normal View History

2002-12-13 08:33:25 +00:00
#ifndef DSOUND_HELPERS
#define DSOUND_HELPERS 1
#include "SDL.h"
struct IDirectSound;
struct IDirectSoundBuffer;
2002-12-21 07:21:49 +00:00
class DSound
{
IDirectSound *ds;
2003-02-17 02:37:38 +00:00
static BOOL CALLBACK EnumCallback( LPGUID lpGuid, LPCSTR lpcstrDescription, LPCSTR lpcstrModule, LPVOID lpContext);
2002-12-21 07:21:49 +00:00
public:
IDirectSound *GetDS() const { return ds; }
2002-12-21 07:21:49 +00:00
bool IsEmulated() const;
DSound();
~DSound();
};
class DSoundBuf
{
IDirectSoundBuffer *buf;
2002-12-21 07:21:49 +00:00
2002-12-31 01:08:35 +00:00
int channels, samplerate, samplebits, writeahead;
2002-12-21 07:21:49 +00:00
2002-12-31 01:08:35 +00:00
int buffersize;
2002-12-21 07:21:49 +00:00
int buffersize_frames() const { return buffersize / samplesize(); }
2002-12-29 00:19:05 +00:00
int samplesize() const { return channels*samplebits/8; }
2002-12-21 07:21:49 +00:00
int write_cursor, buffer_bytes_filled; /* bytes */
int last_cursor_pos; /* frames */
2002-12-21 07:21:49 +00:00
mutable int LastPosition;
bool buffer_locked;
char *locked_buf;
int locked_len;
public:
enum hw { HW_HARDWARE, HW_SOFTWARE, HW_DONT_CARE };
DSoundBuf(DSound &ds, hw hardware,
int channels, int samplerate, int samplebits, int writeahead);
2002-12-21 07:21:49 +00:00
bool get_output_buf(char **buffer, unsigned *bufsiz, int *play_pos, int chunksize);
void release_output_buf(char *buffer, unsigned bufsiz);
void Reset();
void Play();
void Stop();
void SetVolume(float vol);
2002-12-21 07:21:49 +00:00
~DSoundBuf();
int GetPosition() const;
int GetMaxPosition() const { return last_cursor_pos; }
};
2002-12-13 08:33:25 +00:00
#endif
/*
* Copyright (c) 2002 by the person(s) listed below. All rights reserved.
*
* Glenn Maynard
*/