12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #ifndef JNI_AUDIO_PCMPLAYER_H_
- #define JNI_AUDIO_PCMPLAYER_H_
- #include <stdio.h>
- #include <system/Thread.h>
- #include "audio_parameter.h"
- namespace base {
- class PCMPlayer {
- public:
- PCMPlayer(const AudioParameter& parameter);
- virtual ~PCMPlayer();
- enum class Status {
- Disabled,
- Normal,
- Paused,
- };
- int AddSamples(const char* data, ::size_t size);
- int Pause();
- int Resume();
- void Wait();
- void Reset();
- void Disable();
- int Enable();
- /**
- * vol 0.0 ~ 1.0
- */
- void SetVolume(float vol);
- void SetVolume2(int vol);
- bool GetMute();
- void SetMute(bool mute);
- private:
- void ResetWithoutLock();
- void SetMuteWithoutLock(bool mute);
- int DeviceEnable();
- int DevicePlaySamples(const char* data, size_t size);
- int DeviceWaitForPlayToEnd();
- int DeviceDisable();
- private:
- Mutex mutex_;
- int volume_;
- bool mute_;
- Status status_;
- AudioParameter* parameter_;
- };
- } /* namespace voip */
- #endif /* JNI_AUDIO_PCMPLAYER_H_ */
|