Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

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 /* Call SetSampleRate before you use the sample. */ 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 * (c) 2002-2004 Glenn Maynard, Aaron VonderHaar 00063 * All rights reserved. 00064 * 00065 * Permission is hereby granted, free of charge, to any person obtaining a 00066 * copy of this software and associated documentation files (the 00067 * "Software"), to deal in the Software without restriction, including 00068 * without limitation the rights to use, copy, modify, merge, publish, 00069 * distribute, and/or sell copies of the Software, and to permit persons to 00070 * whom the Software is furnished to do so, provided that the above 00071 * copyright notice(s) and this permission notice appear in all copies of 00072 * the Software and that both the above copyright notice(s) and this 00073 * permission notice appear in supporting documentation. 00074 * 00075 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00076 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00077 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 00078 * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS 00079 * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT 00080 * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS 00081 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00082 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 00083 * PERFORMANCE OF THIS SOFTWARE. 00084 */

Generated on Thu Jan 27 20:57:17 2005 for StepMania by doxygen 1.3.7