alsa: fix the poll interval
[jack2.git] / common / JackMetadata.h
blob67b4cdcf42ae585974e07a1bad6572e6294ed571
1 /*
2 Copyright (C) 2011 David Robillard
3 Copyright (C) 2013 Paul Davis
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or (at
8 your option) any later version.
10 This program is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13 License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #ifndef __JackMetadata__
21 #define __JackMetadata__
23 #ifdef HAVE_CONFIG_H
24 #include "config.h"
25 #endif
27 // libdb does not work in 32bit mixed mode
28 #ifdef BUILD_WITH_32_64
29 #undef HAVE_DB
30 #define HAVE_DB 0
31 #endif
33 #include <stdint.h>
34 #include <limits.h>
36 #if HAVE_DB
37 #include <db.h>
38 #endif
40 #include <jack/uuid.h>
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
46 typedef struct {
47 const char* key;
48 const char* data;
49 const char* type;
50 } jack_property_t;
52 typedef struct {
53 jack_uuid_t subject;
54 uint32_t property_cnt;
55 jack_property_t* properties;
56 uint32_t property_size;
57 } jack_description_t;
59 typedef enum {
60 PropertyCreated,
61 PropertyChanged,
62 PropertyDeleted
63 } jack_property_change_t;
65 typedef void (*JackPropertyChangeCallback)(jack_uuid_t subject,
66 const char* key,
67 jack_property_change_t change,
68 void* arg);
70 #ifdef __cplusplus
72 #endif
75 namespace Jack
78 class JackClient;
80 /*!
81 \brief Metadata base.
84 class JackMetadata
86 private:
88 #if HAVE_DB
89 DB* fDB;
90 DB_ENV* fDBenv;
91 const bool fIsEngine;
92 char fDBFilesDir[PATH_MAX + 1];
93 #endif
95 int PropertyInit();
96 int PropertyChangeNotify(JackClient* client, jack_uuid_t subject, const char* key, jack_property_change_t change);
98 #if HAVE_DB
99 void MakeKeyDbt(DBT* dbt, jack_uuid_t subject, const char* key);
100 #endif
102 public:
104 JackMetadata(bool isEngine);
105 ~JackMetadata();
107 int GetProperty(jack_uuid_t subject, const char* key, char** value, char** type);
108 int GetProperties(jack_uuid_t subject, jack_description_t* desc);
109 int GetAllProperties(jack_description_t** descriptions);
111 int GetDescription(jack_uuid_t subject, jack_description_t* desc);
112 int GetAllDescriptions(jack_description_t** descs);
113 void FreeDescription(jack_description_t* desc, int free_actual_description_too);
115 int SetProperty(JackClient* client, jack_uuid_t subject, const char* key, const char* value, const char* type);
117 int RemoveProperty(JackClient* client, jack_uuid_t subject, const char* key);
118 int RemoveProperties(JackClient* client, jack_uuid_t subject);
119 int RemoveAllProperties(JackClient* client);
124 } // end of namespace
126 #endif