Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DeviceManagerAudioSession.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2014, The Cinder Project
3 
4  This code is intended to be used with the Cinder C++ library, http://libcinder.org
5 
6  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
7  the following conditions are met:
8 
9  * Redistributions of source code must retain the above copyright notice, this list of conditions and
10  the following disclaimer.
11  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12  the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
15  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
16  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
17  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
18  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
21  POSSIBILITY OF SUCH DAMAGE.
22 */
23 
24 #pragma once
25 
26 
27 #include "cinder/audio/Device.h"
28 
29 #if defined( __OBJC__ )
30  @class AudioSessionInterruptionHandlerImpl;
31 #else
32  class AudioSessionInterruptionHandlerImpl;
33 #endif
34 
35 namespace cinder { namespace audio { namespace cocoa {
36 
37 class DeviceAudioUnit;
38 
40  public:
43 
44  DeviceRef getDefaultOutput() override;
45  DeviceRef getDefaultInput() override;
46  DeviceRef findDeviceByName( const std::string &name ) override;
47  DeviceRef findDeviceByKey( const std::string &key ) override;
48 
49  const std::vector<DeviceRef>& getDevices() override;
50 
51  std::string getName( const DeviceRef &device ) override;
52  size_t getNumInputChannels( const DeviceRef &device ) override;
53  size_t getNumOutputChannels( const DeviceRef &device ) override;
54  size_t getSampleRate( const DeviceRef &device ) override;
55  size_t getFramesPerBlock( const DeviceRef &device ) override;
56 
57  void setSampleRate( const DeviceRef &device, size_t sampleRate ) override;
58  void setFramesPerBlock( const DeviceRef &device, size_t framesPerBlock ) override;
59 
60  void setInputEnabled( bool enable = true );
61  bool isInputEnabled() const { return mInputEnabled; }
62 
63  private:
64 
65  const DeviceRef& getRemoteIODevice();
66  void activateSession();
67  std::string getSessionCategory();
68 
69  AudioSessionInterruptionHandlerImpl *getSessionInterruptionHandler();
70 
71 
72  DeviceRef mRemoteIODevice;
73  bool mSessionIsActive, mInputEnabled;
74 
75  AudioSessionInterruptionHandlerImpl *mSessionInterruptionHandler;
76 };
77 
78 } } } // namespace cinder::audio::cocoa
void setSampleRate(const DeviceRef &device, size_t sampleRate) override
Definition: DeviceManagerAudioSession.mm:181
void enable(GLenum state)
Enables the OpenGL State state. Equivalent to calling to glEnable( state );.
Definition: dx.h:198
DeviceManagerAudioSession()
Definition: DeviceManagerAudioSession.mm:71
void setInputEnabled(bool enable=true)
Definition: DeviceManagerAudioSession.mm:112
GLsizei const GLchar ** string
Definition: GLee.h:2427
void setFramesPerBlock(const DeviceRef &device, size_t framesPerBlock) override
Definition: DeviceManagerAudioSession.mm:195
size_t getNumInputChannels(const DeviceRef &device) override
Definition: DeviceManagerAudioSession.mm:131
DeviceRef getDefaultOutput() override
Definition: DeviceManagerAudioSession.mm:83
bool isInputEnabled() const
Definition: DeviceManagerAudioSession.h:61
DeviceRef findDeviceByKey(const std::string &key) override
Definition: DeviceManagerAudioSession.mm:99
virtual ~DeviceManagerAudioSession()
Definition: DeviceManagerAudioSession.mm:77
Definition: DeviceManagerAudioSession.h:39
Platform-specific Singleton for managing hardware devices. Applications normally should not need to u...
Definition: Device.h:110
size_t getSampleRate(const DeviceRef &device) override
Definition: DeviceManagerAudioSession.mm:156
std::shared_ptr< class Device > DeviceRef
Definition: Device.h:36
size_t getFramesPerBlock(const DeviceRef &device) override
Definition: DeviceManagerAudioSession.mm:167
GLuint const GLchar * name
Definition: GLee.h:2259
DeviceRef getDefaultInput() override
Definition: DeviceManagerAudioSession.mm:88
DeviceRef findDeviceByName(const std::string &name) override
Definition: DeviceManagerAudioSession.mm:94
std::string getName(const DeviceRef &device) override
Definition: DeviceManagerAudioSession.mm:126
const std::vector< DeviceRef > & getDevices() override
Definition: DeviceManagerAudioSession.mm:104
size_t getNumOutputChannels(const DeviceRef &device) override
Definition: DeviceManagerAudioSession.mm:145