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

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (1.1.11)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20140128182336-3xenud1kbnwmf3mz
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *  Author: Yan Morin <yan.morin@savoirfairelinux.com>
4
4
 *  Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com>
5
5
 *  Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
 
6
 *  Author: Adrien Beraud <adrien.beraud@gmail.com>
6
7
 *
7
8
 *  This program is free software; you can redistribute it and/or modify
8
9
 *  it under the terms of the GNU General Public License as published by
25
26
#include <fstream>
26
27
#include <vector>
27
28
#include <map>
 
29
 
28
30
#include "noncopyable.h"
 
31
#include "audiobuffer.h"
29
32
 
30
33
typedef std::map<std::string, size_t> ReadPointer;
31
34
 
 
35
/**
 
36
 * A ring buffer for mutichannel audio samples
 
37
 */
32
38
class RingBuffer {
33
39
    public:
34
40
        /**
92
98
         * @param buffer Data to copied
93
99
         * @param toCopy Number of bytes to copy
94
100
         */
95
 
        void put(void* buffer, size_t toCopy);
 
101
         void put(AudioBuffer& buf);
96
102
 
97
103
        /**
98
 
         * To get how much space is available in the buffer to read in
99
 
         * @return int The available size
 
104
         * To get how much samples are available in the buffer to read in
 
105
         * @return int The available (multichannel) samples number
100
106
         */
101
107
        size_t availableForGet(const std::string &call_id) const;
102
108
 
106
112
         * @param toCopy Number of bytes to copy
107
113
         * @return size_t Number of bytes copied
108
114
         */
109
 
        size_t get(void* buffer, size_t toCopy, const std::string &call_id);
 
115
         size_t get(AudioBuffer& buf, const std::string &call_id);
110
116
 
111
117
        /**
112
118
         * Discard data from the buffer
113
 
         * @param toDiscard Number of bytes to discard
114
 
         * @return size_t Number of bytes discarded
 
119
         * @param toDiscard Number of samples to discard
 
120
         * @return size_t Number of samples discarded
115
121
         */
116
122
        size_t discard(size_t toDiscard, const std::string &call_id);
117
123
 
129
135
        void debug();
130
136
 
131
137
    private:
 
138
        /* POULET! */
132
139
        NON_COPYABLE(RingBuffer);
133
140
 
134
141
        /** Pointer on the last data */
135
142
        size_t endPos_;
136
 
        /** Buffer size */
137
 
        size_t bufferSize_;
138
143
        /** Data */
139
 
        std::vector<unsigned char> buffer_;
 
144
        AudioBuffer buffer_;
140
145
 
141
146
        ReadPointer readpointers_;
142
147
        std::string buffer_id_;