|
a |
|
b/src/rcvqueue.h |
|
|
1 |
/* Copyright (C) 2014 J.F.Dockes
|
|
|
2 |
* This program is free software; you can redistribute it and/or modify
|
|
|
3 |
* it under the terms of the GNU General Public License as published by
|
|
|
4 |
* the Free Software Foundation; either version 2 of the License, or
|
|
|
5 |
* (at your option) any later version.
|
|
|
6 |
*
|
|
|
7 |
* This program is distributed in the hope that it will be useful,
|
|
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
10 |
* GNU General Public License for more details.
|
|
|
11 |
*
|
|
|
12 |
* You should have received a copy of the GNU General Public License
|
|
|
13 |
* along with this program; if not, write to the
|
|
|
14 |
* Free Software Foundation, Inc.,
|
|
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
16 |
*/
|
|
|
17 |
#ifndef _RCVQUEUE_H_INCLUDED_
|
|
|
18 |
#define _RCVQUEUE_H_INCLUDED_
|
|
|
19 |
|
|
|
20 |
#include "workqueue.h"
|
|
|
21 |
|
|
|
22 |
/** The audio messages which get passed between the songcast receiver
|
|
|
23 |
* and the http server part. We could probably use
|
|
|
24 |
* ohSongcast own audio messages, but I prefer to stop the custom type
|
|
|
25 |
* nonsense asap.
|
|
|
26 |
*/
|
|
|
27 |
class AudioMessage {
|
|
|
28 |
public:
|
|
|
29 |
// If buf is not 0, it is a malloced buffer, and we take
|
|
|
30 |
// ownership. The caller MUST NOT free it. Its size must be at
|
|
|
31 |
// least (bits/8) * chans * samples
|
|
|
32 |
AudioMessage(unsigned int bits, unsigned int channels, unsigned int samples,
|
|
|
33 |
unsigned int sampfreq, char *buf = 0)
|
|
|
34 |
: m_bits(bits), m_chans(channels), m_freq(sampfreq),
|
|
|
35 |
m_bytes(buf ? (bits/8) * channels * samples : 0), m_buf(buf),
|
|
|
36 |
m_curoffs(0) {
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
~AudioMessage() {
|
|
|
40 |
if (m_buf)
|
|
|
41 |
free(m_buf);
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
unsigned int m_bits;
|
|
|
45 |
unsigned int m_chans;
|
|
|
46 |
unsigned int m_freq;
|
|
|
47 |
unsigned int m_bytes;
|
|
|
48 |
char *m_buf;
|
|
|
49 |
unsigned int m_curoffs; /* Used by the http data emitter */
|
|
|
50 |
};
|
|
|
51 |
|
|
|
52 |
extern WorkQueue<AudioMessage*> audioqueue;
|
|
|
53 |
|
|
|
54 |
/** Worker routine for fetching bufs from the rcvqueue and making them
|
|
|
55 |
* available to HTTP. the param is actually an AudioEaterContext */
|
|
|
56 |
extern void *audioEater(void *);
|
|
|
57 |
|
|
|
58 |
struct AudioEaterContext {
|
|
|
59 |
AudioEaterContext(int p = 0) : port(p) {}
|
|
|
60 |
int port;
|
|
|
61 |
};
|
|
|
62 |
|
|
|
63 |
#endif /* _RCVQUEUE_H_INCLUDED_ */
|