To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / JackDevice / DeviceManagerJack.h

History | View | Annotate | Download (3.88 KB)

1 1:b5bcad8e7803 f
/*
2

3 5:75b744078d66 f
 Copyright (C) 2016  Queen Mary University of London
4
 Author: Fiore Martin
5 1:b5bcad8e7803 f

6 5:75b744078d66 f
 This file is part of Collidoscope.
7

8
 Collidoscope is free software: you can redistribute it and/or modify
9
 it under the terms of the GNU General Public License as published by
10
 the Free Software Foundation, either version 3 of the License, or
11
 (at your option) any later version.
12

13
 This program is distributed in the hope that it will be useful,
14
 but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 GNU General Public License for more details.
17

18
 You should have received a copy of the GNU General Public License
19
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
20

21
 This file incorporates work covered by the following copyright and permission notice:
22

23
    Copyright (c) 2014, The Cinder Project
24

25
    This code is intended to be used with the Cinder C++ library, http://libcinder.org
26

27
    Redistribution and use in source and binary forms, with or without modification, are permitted provided that
28
    the following conditions are met:
29 1:b5bcad8e7803 f

30
    * Redistributions of source code must retain the above copyright notice, this list of conditions and
31 5:75b744078d66 f
    the following disclaimer.
32 1:b5bcad8e7803 f
    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
33 5:75b744078d66 f
    the following disclaimer in the documentation and/or other materials provided with the distribution.
34 1:b5bcad8e7803 f

35 5:75b744078d66 f
    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
36
    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
37
    PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
38
    ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
39
    TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40
    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41
    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42
    POSSIBILITY OF SUCH DAMAGE.
43

44 1:b5bcad8e7803 f
*/
45
46
#pragma once
47
48
#include "cinder/audio/Device.h"
49
50
namespace cinder { namespace audio { namespace linux {
51
52 4:ab6db404403a f
/**
53
 * DeviceManager ( as in cinder::audio::DeviceManager ) that handle the hardware device through the jack library.
54
 * Note that this is not suitable for general purpose use. Most of the functionalities are indeed hard coded
55
 * just to suit Collidoscope needs. In particular only two input and two output ports are assumed.
56
 *
57
 */
58 1:b5bcad8e7803 f
class DeviceManagerJack : public DeviceManager {
59
  public:
60
61 5:75b744078d66 f
    DeviceManagerJack();
62
    virtual ~DeviceManagerJack();
63 1:b5bcad8e7803 f
64 5:75b744078d66 f
    const std::vector<DeviceRef>& getDevices()      override;
65
    DeviceRef getDefaultOutput()                override;
66
    DeviceRef getDefaultInput()             override;
67 1:b5bcad8e7803 f
68 5:75b744078d66 f
    std::string getName( const DeviceRef &device )      override;
69
    size_t getNumInputChannels( const DeviceRef &device )   override;
70
    size_t getNumOutputChannels( const DeviceRef &device )  override;
71
    size_t getSampleRate( const DeviceRef &device )     override;
72
    size_t getFramesPerBlock( const DeviceRef &device ) override;
73 1:b5bcad8e7803 f
74 5:75b744078d66 f
    void setSampleRate( const DeviceRef &device, size_t sampleRate )        override;
75
    void setFramesPerBlock( const DeviceRef &device, size_t framesPerBlock )    override;
76 1:b5bcad8e7803 f
77 5:75b744078d66 f
    //! Returns the hardware's actual frames per block, which might not be a power of two.
78
    size_t getFramesPerBlockHardware( const DeviceRef &device );
79 1:b5bcad8e7803 f
80
private:
81
82 5:75b744078d66 f
    std::vector<DeviceRef> mDevices;
83
    DeviceRef   mDefaultOutDevice;
84
    DeviceRef   mDefaultInDevice;
85 1:b5bcad8e7803 f
    size_t mSampleRate;
86
    size_t mBufferSize;
87 5:75b744078d66 f
};
88 1:b5bcad8e7803 f
89 5:75b744078d66 f
} } } // namespace cinder::audio::linux