#include <string.h>
#include <string>
-#include <parser.hh>
+#include "parser.hh"
#define DEVICE_FILE_OBJECT "device-files"
#define DEVICE_TYPE_PROP_PLAYBACK_DEVICES "playback-devices"
using namespace std;
CDeviceMapParser::CDeviceMapParser()
+ : m_json_obj(nullptr), m_json_device_files_obj(nullptr)
{
open_json("/etc/pulse/device-map.json");
}
CDeviceMapParser::CDeviceMapParser(const char* map_file)
+ : m_json_obj(nullptr), m_json_device_files_obj(nullptr)
{
open_json(map_file);
}
if (!json_object_is_type(m_json_device_files_obj, json_type_object)) {
cout << "json object type failed" << endl;
json_object_put(m_json_obj);
- m_json_obj = NULL;
+ m_json_obj = nullptr;
return;
}
void CDeviceMapParser::parse_playback()
{
- json_object *playback_devices_o = NULL;
+ json_object *playback_devices_o = nullptr;
if (!json_object_object_get_ex(m_json_device_files_obj, DEVICE_TYPE_PROP_PLAYBACK_DEVICES, &playback_devices_o)) {
cout << "failed to get playback" << endl;
void CDeviceMapParser::parse_capture()
{
- json_object *capture_devices_o = NULL;
+ json_object *capture_devices_o = nullptr;
if (!json_object_object_get_ex(m_json_device_files_obj, DEVICE_TYPE_PROP_CAPTURE_DEVICES, &capture_devices_o)) {
cout << "failed to get capture" << endl;
void CDeviceMapParser::parse_device_file_object(json_object *device_file_o, pair<string, string>& device)
{
- json_object *device_file_prop_o = NULL;
+ json_object *device_file_prop_o = nullptr;
string device_string, device_param;
assert(device_file_o);
void CDeviceMapParser::parse_device_file_array_object(json_object *device_file_array_o, pair<string, string>& device)
{
int num, idx;
- json_object *device_file_o = NULL;
+ json_object *device_file_o = nullptr;
assert(device_file_array_o);
assert(json_object_is_type(device_file_array_o, json_type_array));
{
public:
CDeviceMapParser();
- CDeviceMapParser(const char* map_file);
+ explicit CDeviceMapParser(const char* map_file);
virtual ~CDeviceMapParser();
void dump_devices();
void get_params(string& s, int& rate, int& channels);
void get_single_param(string& s, int& rate, int& channels);
- // FixMe, pair doens't define what is paired clearly....
+ // FixMe, pair doesn't define what is paired clearly....
pair<string, string> m_playback; // device_string, device_params
pair<string, string> m_capture; // device_string, device_params