#ifndef AudioSession_h
#define AudioSession_h
#include "PlatformExportMacros.h"
#if USE(AUDIO_SESSION)
#include <memory>
#include <wtf/HashSet.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/Noncopyable.h>
namespace WebCore {
class AudioSessionPrivate;
class AudioSession {
WTF_MAKE_NONCOPYABLE(AudioSession);
public:
WEBCORE_EXPORT static AudioSession& sharedSession();
enum CategoryType {
None,
AmbientSound,
SoloAmbientSound,
MediaPlayback,
RecordAudio,
PlayAndRecord,
AudioProcessing,
};
WEBCORE_EXPORT void setCategory(CategoryType);
WEBCORE_EXPORT CategoryType category() const;
void setCategoryOverride(CategoryType);
CategoryType categoryOverride() const;
float sampleRate() const;
size_t bufferSize() const;
size_t numberOfOutputChannels() const;
bool tryToSetActive(bool);
size_t preferredBufferSize() const;
void setPreferredBufferSize(size_t);
class MutedStateObserver {
public:
virtual ~MutedStateObserver() { }
virtual void hardwareMutedStateDidChange(AudioSession*) = 0;
};
void addMutedStateObserver(MutedStateObserver*);
void removeMutedStateObserver(MutedStateObserver*);
bool isMuted() const;
void handleMutedStateChange();
private:
friend class NeverDestroyed<AudioSession>;
AudioSession();
~AudioSession();
std::unique_ptr<AudioSessionPrivate> m_private;
HashSet<MutedStateObserver*> m_observers;
};
}
#endif // USE(AUDIO_SESSION)
#endif // AudioSession_h