~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to daemon/src/audio/audiolayer.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2015-01-07 14:51:16 UTC
  • mfrom: (4.3.5 sid)
  • Revision ID: package-import@ubuntu.com-20150107145116-yxnafinf4lrdvrmx
Tags: 1.4.1-0.1ubuntu1
* Merge with Debian, remaining changes:
 - Drop soprano, nepomuk build-dep
* Drop ubuntu patches, now upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#ifndef AUDIO_LAYER_H_
35
35
#define AUDIO_LAYER_H_
36
36
 
37
 
#include <mutex>
38
 
#include <sys/time.h>
39
 
#include <vector>
 
37
 
40
38
#include "ringbuffer.h"
41
39
#include "dcblocker.h"
42
 
#include "samplerateconverter.h"
 
40
#include "resampler.h"
43
41
#include "noncopyable.h"
44
42
 
 
43
#include <sys/time.h>
 
44
#include <mutex>
 
45
#include <vector>
 
46
 
45
47
/**
46
48
 * @file  audiolayer.h
47
49
 * @brief Main sound class. Manages the data transfers between the application and the hardware.
54
56
class Time;
55
57
}
56
58
 
 
59
enum class DeviceType {
 
60
    PLAYBACK,      /** To open playback device only */
 
61
    CAPTURE,       /** To open capture device only */
 
62
    RINGTONE       /** To open the ringtone device only */
 
63
};
 
64
 
57
65
class AudioLayer {
58
66
 
59
67
    private:
60
68
        NON_COPYABLE(AudioLayer);
61
69
 
62
70
    public:
63
 
        enum PCMType {
64
 
            SFL_PCM_BOTH = 0x0021,          /** To open both playback and capture devices */
65
 
            SFL_PCM_PLAYBACK = 0x0022,      /** To open playback device only */
66
 
            SFL_PCM_CAPTURE = 0x0023,       /** To open capture device only */
67
 
            SFL_PCM_RINGTONE = 0x0024       /** To open the ringtone device only */
68
 
        };
69
71
 
70
72
        AudioLayer(const AudioPreference &);
71
73
        virtual ~AudioLayer();
73
75
        virtual std::vector<std::string> getCaptureDeviceList() const = 0;
74
76
        virtual std::vector<std::string> getPlaybackDeviceList() const = 0;
75
77
 
76
 
        virtual int getAudioDeviceIndex(const std::string& name) const = 0;
77
 
        virtual std::string getAudioDeviceName(int index, PCMType type) const = 0;
 
78
        virtual int getAudioDeviceIndex(const std::string& name, DeviceType type) const = 0;
 
79
        virtual std::string getAudioDeviceName(int index, DeviceType type) const = 0;
78
80
        virtual int getIndexCapture() const = 0;
79
81
        virtual int getIndexPlayback() const = 0;
80
82
        virtual int getIndexRingtone() const = 0;
175
177
         *                          default: 44100 HZ
176
178
         */
177
179
        unsigned int getSampleRate() const {
178
 
            return sampleRate_;
 
180
            return audioFormat_.sample_rate;
 
181
        }
 
182
 
 
183
        /**
 
184
         * Get the audio format of the layer (sample rate & channel number).
 
185
         */
 
186
        AudioFormat getFormat() const {
 
187
            return audioFormat_;
179
188
        }
180
189
 
181
190
        /**
183
192
         */
184
193
        void notifyIncomingCall();
185
194
 
186
 
        virtual void updatePreference(AudioPreference &pref, int index, PCMType type) = 0;
 
195
        virtual void updatePreference(AudioPreference &pref, int index, DeviceType type) = 0;
187
196
 
188
197
    protected:
 
198
        /**
 
199
         * Callback to be called by derived classes when the audio output is opened.
 
200
         */
 
201
        void hardwareFormatAvailable(AudioFormat playback);
189
202
 
190
203
        /**
191
204
         * True if capture is not to be used
213
226
        bool isStarted_;
214
227
 
215
228
        /**
 
229
         * Sample Rate SFLphone should send sound data to the sound card
 
230
         */
 
231
        AudioFormat audioFormat_;
 
232
 
 
233
        /**
216
234
         * Urgent ring buffer used for ringtones
217
235
         */
218
236
        RingBuffer urgentRingBuffer_;
219
237
 
220
238
        /**
221
 
         * Sample Rate SFLphone should send sound data to the sound card
222
 
         * The value can be set in the user config file- now: 44100HZ
223
 
         */
224
 
        unsigned int sampleRate_;
225
 
 
226
 
        /**
227
239
         * Lock for the entire audio layer
228
240
         */
229
241
        std::mutex mutex_;
236
248
        /**
237
249
         * Manage sampling rate conversion
238
250
         */
239
 
        SamplerateConverter converter_;
 
251
        Resampler resampler_;
240
252
 
241
253
    private:
242
254