-
Notifications
You must be signed in to change notification settings - Fork 0
/
action_readformats.h
64 lines (54 loc) · 1.63 KB
/
action_readformats.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef _action_readformats_h
#define _action_readformats_h
#include "action.h"
#include "format.h"
#include <pulse/ext-device-restore.h>
class cPulseReadFormatsAction : public cPulseAction {
private:
uint32_t _index;
pa_device_type_t _type;
cList<cPulseFormat> _formats;
static void ext_device_restore_read_formats_callback(pa_context *c, const pa_ext_device_restore_info* info, int eol, void *userdata)
{
cPulseReadFormatsAction *action = (cPulseReadFormatsAction*)userdata;
if (eol) {
if (eol < 0)
esyslog("pulsecontrol: failed to initialize device-restore extension: %s", pa_strerror(pa_context_errno(c)));
action->SignalReady();
}
else {
action->_formats.Clear();
for (int i = 0; i < info->n_formats; i++)
action->_formats.Add(new cPulseFormat(info->formats[i]->encoding));
}
}
protected:
virtual pa_operation *Action(pa_context *context)
{
return pa_ext_device_restore_read_formats(context, _type, _index, ext_device_restore_read_formats_callback, this);
}
public:
cPulseReadFormatsAction(cPulseLoop &loop, uint32_t index, pa_device_type_t type)
:cPulseAction(loop, "ReadFormats")
,_index(index)
,_type(type)
{
}
virtual ~cPulseReadFormatsAction(void)
{
}
const cList<cPulseFormat> &Formats(void) const
{
return _formats;
}
cString Info(void) const
{
if (Formats().Count() == 0)
return "no formats found";
cString ret = "";
for (const cPulseFormat *f = Formats().First(); f; f = Formats().Next(f))
ret = cString::sprintf("%sformat: %s\r\n", *ret, f->Name());
return ret;
}
};
#endif