summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS2
-rw-r--r--COPYING510
-rw-r--r--ChangeLog0
-rw-r--r--INSTALL370
-rw-r--r--Makefile.am28
-rw-r--r--NEWS0
-rw-r--r--README0
-rwxr-xr-xautogen.sh23
-rw-r--r--backends/Makefile.am7
-rw-r--r--backends/null/Makefile.am24
-rw-r--r--backends/null/null.c95
-rw-r--r--backends/null/null.h54
-rw-r--r--backends/pulse/Makefile.am30
-rw-r--r--backends/pulse/pulse-device.c308
-rw-r--r--backends/pulse/pulse-device.h78
-rw-r--r--backends/pulse/pulse-track.c0
-rw-r--r--backends/pulse/pulse-track.h0
-rw-r--r--backends/pulse/pulse.c371
-rw-r--r--backends/pulse/pulse.h61
-rw-r--r--configure.ac159
-rw-r--r--data/Makefile.am6
-rw-r--r--data/libmatemixer.pc.in11
-rw-r--r--doc/Makefile.am2
-rw-r--r--git.mk318
-rw-r--r--libmatemixer/Makefile.am60
-rw-r--r--libmatemixer/matemixer-backend-module.c161
-rw-r--r--libmatemixer/matemixer-backend-module.h75
-rw-r--r--libmatemixer/matemixer-backend.c60
-rw-r--r--libmatemixer/matemixer-backend.h59
-rw-r--r--libmatemixer/matemixer-control.c210
-rw-r--r--libmatemixer/matemixer-control.h66
-rw-r--r--libmatemixer/matemixer-device-port.c220
-rw-r--r--libmatemixer/matemixer-device-port.h69
-rw-r--r--libmatemixer/matemixer-device-profile.c165
-rw-r--r--libmatemixer/matemixer-device-profile.h63
-rw-r--r--libmatemixer/matemixer-device.c68
-rw-r--r--libmatemixer/matemixer-device.h51
-rw-r--r--libmatemixer/matemixer-enum-types.c.template36
-rw-r--r--libmatemixer/matemixer-enum-types.h.template26
-rw-r--r--libmatemixer/matemixer-enums.h35
-rw-r--r--libmatemixer/matemixer-private.h30
-rw-r--r--libmatemixer/matemixer-track.c29
-rw-r--r--libmatemixer/matemixer-track.h47
-rw-r--r--libmatemixer/matemixer.c158
-rw-r--r--libmatemixer/matemixer.h34
45 files changed, 4179 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..99318be
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+Michal Ratajsky <[email protected]>
+
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..2d2d780
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,510 @@
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations
+below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it
+becomes a de-facto standard. To achieve this, non-free programs must
+be allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control
+compilation and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at least
+ three years, to give the same user the materials specified in
+ Subsection 6a, above, for a charge no more than the cost of
+ performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply, and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License
+may add an explicit geographical distribution limitation excluding those
+countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms
+of the ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library.
+It is safest to attach them to the start of each source file to most
+effectively convey the exclusion of warranty; and each file should
+have at least the "copyright" line and a pointer to where the full
+notice is found.
+
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or
+your school, if any, to sign a "copyright disclaimer" for the library,
+if necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James
+ Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/ChangeLog
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..2099840
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,370 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
+Inc.
+
+ Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved. This file is offered as-is,
+without warranty of any kind.
+
+Basic Installation
+==================
+
+ Briefly, the shell command `./configure && make && make install'
+should configure, build, and install this package. The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package. Some packages provide this
+`INSTALL' file but do not implement all of the features documented
+below. The lack of an optional feature in a given package is not
+necessarily a bug. More recommendations for GNU packages can be found
+in *note Makefile Conventions: (standards)Makefile Conventions.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+ It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring. Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+ The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'. You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+ The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system.
+
+ Running `configure' might take a while. While running, it prints
+ some messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package, generally using the just-built uninstalled binaries.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation. When installing into a prefix owned by root, it is
+ recommended that the package be configured and built as a regular
+ user, and only the `make install' phase executed with root
+ privileges.
+
+ 5. Optionally, type `make installcheck' to repeat any self-tests, but
+ this time using the binaries in their final installed location.
+ This target does not install anything. Running this target as a
+ regular user, particularly if the prior `make install' required
+ root privileges, verifies that the installation completed
+ correctly.
+
+ 6. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+ 7. Often, you can also type `make uninstall' to remove the installed
+ files again. In practice, not all packages have tested that
+ uninstallation works correctly, even though it is required by the
+ GNU Coding Standards.
+
+ 8. Some packages, particularly those that use Automake, provide `make
+ distcheck', which can by used by developers to test that all other
+ targets like `make install' and `make uninstall' work correctly.
+ This target is generally not run by end users.
+
+Compilers and Options
+=====================
+
+ Some systems require unusual options for compilation or linking that
+the `configure' script does not know about. Run `./configure --help'
+for details on some of the pertinent environment variables.
+
+ You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment. Here
+is an example:
+
+ ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+ *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+ You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you can use GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'. This
+is known as a "VPATH" build.
+
+ With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory. After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+ On MacOS X 10.5 and later systems, you can create libraries and
+executables that work on multiple system types--known as "fat" or
+"universal" binaries--by specifying multiple `-arch' options to the
+compiler but only a single `-arch' option to the preprocessor. Like
+this:
+
+ ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
+ CPP="gcc -E" CXXCPP="g++ -E"
+
+ This is not guaranteed to produce working output in all cases, you
+may have to build one architecture at a time and combine the results
+using the `lipo' tool if you have problems.
+
+Installation Names
+==================
+
+ By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc. You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX', where PREFIX must be an
+absolute file name.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them. In general, the
+default for these options is expressed in terms of `${prefix}', so that
+specifying just `--prefix' will affect all of the other directory
+specifications that were not explicitly provided.
+
+ The most portable way to affect installation locations is to pass the
+correct locations to `configure'; however, many packages provide one or
+both of the following shortcuts of passing variable assignments to the
+`make install' command line to change installation locations without
+having to reconfigure or recompile.
+
+ The first method involves providing an override variable for each
+affected directory. For example, `make install
+prefix=/alternate/directory' will choose an alternate location for all
+directory configuration variables that were expressed in terms of
+`${prefix}'. Any directories that were specified during `configure',
+but not in terms of `${prefix}', must each be overridden at install
+time for the entire installation to be relocated. The approach of
+makefile variable overrides for each directory variable is required by
+the GNU Coding Standards, and ideally causes no recompilation.
+However, some platforms have known limitations with the semantics of
+shared libraries that end up requiring recompilation when using this
+method, particularly noticeable in packages that use GNU Libtool.
+
+ The second method involves providing the `DESTDIR' variable. For
+example, `make install DESTDIR=/alternate/directory' will prepend
+`/alternate/directory' before all installation names. The approach of
+`DESTDIR' overrides is not required by the GNU Coding Standards, and
+does not work on platforms that have drive letters. On the other hand,
+it does better at avoiding recompilation issues, and works well even
+when some directory options were not specified in terms of `${prefix}'
+at `configure' time.
+
+Optional Features
+=================
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+ Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+ Some packages offer the ability to configure how verbose the
+execution of `make' will be. For these packages, running `./configure
+--enable-silent-rules' sets the default to minimal output, which can be
+overridden with `make V=1'; while running `./configure
+--disable-silent-rules' sets the default to verbose, which can be
+overridden with `make V=0'.
+
+Particular systems
+==================
+
+ On HP-UX, the default C compiler is not ANSI C compatible. If GNU
+CC is not installed, it is recommended to use the following options in
+order to use an ANSI C compiler:
+
+ ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
+
+and if that doesn't work, install pre-built binaries of GCC for HP-UX.
+
+ HP-UX `make' updates targets which have the same time stamps as
+their prerequisites, which makes it generally unusable when shipped
+generated files such as `configure' are involved. Use GNU `make'
+instead.
+
+ On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
+parse its `<wchar.h>' header file. The option `-nodtk' can be used as
+a workaround. If GNU CC is not installed, it is therefore recommended
+to try
+
+ ./configure CC="cc"
+
+and if that doesn't work, try
+
+ ./configure CC="cc -nodtk"
+
+ On Solaris, don't put `/usr/ucb' early in your `PATH'. This
+directory contains several dysfunctional programs; working variants of
+these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
+in your `PATH', put it _after_ `/usr/bin'.
+
+ On Haiku, software installed for all users goes in `/boot/common',
+not `/usr/local'. It is recommended to use the following options:
+
+ ./configure --prefix=/boot/common
+
+Specifying the System Type
+==========================
+
+ There may be some features `configure' cannot figure out
+automatically, but needs to determine by the type of machine the package
+will run on. Usually, assuming the package is built to be run on the
+_same_ architectures, `configure' can figure that out, but if it prints
+a message saying it cannot guess the machine type, give it the
+`--build=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+ CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+ OS
+ KERNEL-OS
+
+ See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+ If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+ If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+ If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+ Variables not defined in a site shell script can be set in the
+environment passed to `configure'. However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost. In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'. For example:
+
+ ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf limitation. Until the limitation is lifted, you can use
+this workaround:
+
+ CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+ `configure' recognizes the following options to control how it
+operates.
+
+`--help'
+`-h'
+ Print a summary of all of the options to `configure', and exit.
+
+`--help=short'
+`--help=recursive'
+ Print a summary of the options unique to this package's
+ `configure', and exit. The `short' variant lists options used
+ only in the top level, while the `recursive' variant lists options
+ also present in any nested packages.
+
+`--version'
+`-V'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`--cache-file=FILE'
+ Enable the cache: use and save the results of the tests in FILE,
+ traditionally `config.cache'. FILE defaults to `/dev/null' to
+ disable caching.
+
+`--config-cache'
+`-C'
+ Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made. To
+ suppress all normal output, redirect it to `/dev/null' (any error
+ messages will still be shown).
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`--prefix=DIR'
+ Use DIR as the installation prefix. *note Installation Names::
+ for more details, including other options available for fine-tuning
+ the installation locations.
+
+`--no-create'
+`-n'
+ Run the configure checks, but stop before creating any output
+ files.
+
+`configure' also accepts some other, not widely useful, options. Run
+`configure --help' for more details.
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..57aa03e
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,28 @@
+ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
+
+SUBDIRS = \
+ libmatemixer \
+ backends \
+ data \
+ doc
+
+EXTRA_DIR = autogen.sh
+
+MAINTAINERCLEANFILES = \
+ $(srcdir)/aclocal.m4 \
+ $(srcdir)/config.h.in \
+ $(srcdir)/build-aux/compile \
+ $(srcdir)/build-aux/config.guess \
+ $(srcdir)/build-aux/config.sub \
+ $(srcdir)/build-aux/depcomp \
+ $(srcdir)/build-aux/install-sh \
+ $(srcdir)/build-aux/ltmain.sh \
+ $(srcdir)/build-aux/missing \
+ $(srcdir)/build-aux/mkinstalldirs \
+ $(srcdir)/m4/libtool.m4 \
+ $(srcdir)/m4/lt~obsolete.m4 \
+ $(srcdir)/m4/ltoptions.m4 \
+ $(srcdir)/m4/ltsugar.m4 \
+ $(srcdir)/m4/ltversion.m4
+
+-include $(top_srcdir)/git.mk
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/NEWS
diff --git a/README b/README
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/README
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..cfa4c75
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+# Run this to generate all the initial makefiles, etc.
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+PKG_NAME="libmatemixer"
+
+(test -f $srcdir/configure.ac) || {
+ echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
+ echo " top-level $PKG_NAME directory"
+ exit 1
+}
+
+which mate-autogen || {
+ echo "You need to install mate-common from the MATE Git"
+ exit 1
+}
+
+REQUIRED_AUTOMAKE_VERSION=1.9
+# USE_COMMON_DOC_BUILD=yes
+
+. mate-autogen
diff --git a/backends/Makefile.am b/backends/Makefile.am
new file mode 100644
index 0000000..d2f0e96
--- /dev/null
+++ b/backends/Makefile.am
@@ -0,0 +1,7 @@
+SUBDIRS = null
+
+if HAVE_PULSEAUDIO
+SUBDIRS += pulse
+endif
+
+-include $(top_srcdir)/git.mk
diff --git a/backends/null/Makefile.am b/backends/null/Makefile.am
new file mode 100644
index 0000000..b6d92c7
--- /dev/null
+++ b/backends/null/Makefile.am
@@ -0,0 +1,24 @@
+backenddir = $(libdir)/libmatemixer
+
+backend_LTLIBRARIES = libmatemixer-null.la
+
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ -DG_LOG_DOMAIN=\"libmatemixer-null\"
+
+libmatemixer_null_la_CFLAGS = \
+ $(GLIB_CFLAGS)
+
+libmatemixer_null_la_SOURCES = \
+ null.c \
+ null.h
+
+libmatemixer_null_la_LIBADD = \
+ $(GLIB_LIBS)
+
+libmatemixer_null_la_LDFLAGS = \
+ -avoid-version \
+ -export-dynamic \
+ -module
+
+-include $(top_srcdir)/git.mk
diff --git a/backends/null/null.c b/backends/null/null.c
new file mode 100644
index 0000000..c049dcb
--- /dev/null
+++ b/backends/null/null.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <libmatemixer/matemixer-backend.h>
+#include <libmatemixer/matemixer-backend-module.h>
+
+#include "null.h"
+
+#define BACKEND_NAME "Null"
+#define BACKEND_PRIORITY 999
+
+/* Support function for dynamic loading of the backend module */
+void backend_module_init (GTypeModule *module);
+void backend_module_free (void);
+
+const MateMixerBackendModuleInfo *backend_module_get_info (void);
+
+static void mate_mixer_backend_interface_init (MateMixerBackendInterface *iface);
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (MateMixerNull, mate_mixer_null,
+ G_TYPE_OBJECT, 0,
+ G_IMPLEMENT_INTERFACE_DYNAMIC (MATE_MIXER_TYPE_BACKEND,
+ mate_mixer_backend_interface_init))
+
+static MateMixerBackendModuleInfo info;
+
+void
+backend_module_init (GTypeModule *module)
+{
+ mate_mixer_null_register_type (module);
+
+ info.name = BACKEND_NAME;
+ info.priority = BACKEND_PRIORITY;
+ info.g_type = MATE_MIXER_TYPE_NULL;
+ info.backend_type = MATE_MIXER_BACKEND_TYPE_NULL;
+}
+
+void
+backend_module_free (void)
+{
+}
+
+const MateMixerBackendModuleInfo *
+backend_module_get_info (void)
+{
+ return &info;
+}
+
+static void
+mate_mixer_backend_interface_init (MateMixerBackendInterface *iface)
+{
+}
+
+static void
+mate_mixer_null_init (MateMixerNull *null)
+{
+}
+
+static void
+mate_mixer_null_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (mate_mixer_null_parent_class)->finalize (object);
+}
+
+static void
+mate_mixer_null_class_init (MateMixerNullClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = mate_mixer_null_finalize;
+}
+
+/* Called in the code generated by G_DEFINE_DYNAMIC_TYPE_EXTENDED() */
+static void
+mate_mixer_null_class_finalize (MateMixerNullClass *klass)
+{
+}
diff --git a/backends/null/null.h b/backends/null/null.h
new file mode 100644
index 0000000..ef5b779
--- /dev/null
+++ b/backends/null/null.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_NULL_H
+#define MATEMIXER_NULL_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <libmatemixer/matemixer-backend.h>
+
+#define MATE_MIXER_TYPE_NULL \
+ (mate_mixer_null_get_type ())
+#define MATE_MIXER_NULL(o) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_NULL, MateMixerNull))
+#define MATE_MIXER_IS_NULL(o) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_NULL))
+#define MATE_MIXER_NULL_CLASS(k) \
+ (G_TYPE_CHECK_CLASS_CAST ((k), MATE_MIXER_TYPE_NULL, MateMixerNullClass))
+#define MATE_MIXER_IS_NULL_CLASS(k) \
+ (G_TYPE_CLASS_CHECK_CLASS_TYPE ((k), MATE_MIXER_TYPE_NULL))
+#define MATE_MIXER_NULL_GET_CLASS(o) \
+ (G_TYPE_INSTANCE_GET_CLASS ((o), MATE_MIXER_TYPE_NULL, MateMixerNullClass))
+
+typedef struct _MateMixerNull MateMixerNull;
+typedef struct _MateMixerNullClass MateMixerNullClass;
+
+struct _MateMixerNull
+{
+ GObject parent;
+};
+
+struct _MateMixerNullClass
+{
+ GObjectClass parent;
+};
+
+GType mate_mixer_null_get_type (void) G_GNUC_CONST;
+
+#endif /* MATEMIXER_NULL_H */
diff --git a/backends/pulse/Makefile.am b/backends/pulse/Makefile.am
new file mode 100644
index 0000000..2f7cd6f
--- /dev/null
+++ b/backends/pulse/Makefile.am
@@ -0,0 +1,30 @@
+backenddir = $(libdir)/libmatemixer
+
+backend_LTLIBRARIES = libmatemixer-pulse.la
+
+AM_CPPFLAGS = \
+ -I$(top_srcdir) \
+ -DG_LOG_DOMAIN=\"libmatemixer-pulse\"
+
+libmatemixer_pulse_la_CFLAGS = \
+ $(GLIB_CFLAGS) \
+ $(PULSEAUDIO_CFLAGS)
+
+libmatemixer_pulse_la_SOURCES = \
+ pulse.c \
+ pulse.h \
+ pulse-device.c \
+ pulse-device.h \
+ pulse-track.c \
+ pulse-track.h
+
+libmatemixer_pulse_la_LIBADD = \
+ $(GLIB_LIBS) \
+ $(PULSEAUDIO_LIBS)
+
+libmatemixer_pulse_la_LDFLAGS = \
+ -avoid-version \
+ -export-dynamic \
+ -module
+
+-include $(top_srcdir)/git.mk
diff --git a/backends/pulse/pulse-device.c b/backends/pulse/pulse-device.c
new file mode 100644
index 0000000..75c5a32
--- /dev/null
+++ b/backends/pulse/pulse-device.c
@@ -0,0 +1,308 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <libmatemixer/matemixer-device.h>
+#include <libmatemixer/matemixer-device-port.h>
+#include <libmatemixer/matemixer-device-profile.h>
+
+#include <pulse/pulseaudio.h>
+
+#include "pulse-device.h"
+
+struct _MateMixerPulseDevicePrivate
+{
+ guint32 index;
+ GList *profiles;
+ GList *ports;
+ gchar *identifier;
+ gchar *name;
+ gchar *icon;
+
+ MateMixerDeviceProfile *active_profile;
+};
+
+enum
+{
+ PROP_0,
+ PROP_IDENTIFIER,
+ PROP_NAME,
+ PROP_ICON,
+ PROP_ACTIVE_PROFILE,
+ N_PROPERTIES
+};
+
+static void mate_mixer_device_interface_init (MateMixerDeviceInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (MateMixerPulseDevice, mate_mixer_pulse_device, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (MATE_MIXER_TYPE_DEVICE,
+ mate_mixer_device_interface_init))
+
+static void
+mate_mixer_device_interface_init (MateMixerDeviceInterface *iface)
+{
+
+}
+
+static void
+mate_mixer_pulse_device_init (MateMixerPulseDevice *device)
+{
+ device->priv = G_TYPE_INSTANCE_GET_PRIVATE (
+ device,
+ MATE_MIXER_TYPE_PULSE_DEVICE,
+ MateMixerPulseDevicePrivate);
+}
+
+static void
+mate_mixer_pulse_device_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ MateMixerPulseDevice *device;
+
+ device = MATE_MIXER_PULSE_DEVICE (object);
+
+ switch (param_id) {
+ case PROP_IDENTIFIER:
+ g_value_set_string (value, device->priv->identifier);
+ break;
+ case PROP_NAME:
+ g_value_set_string (value, device->priv->name);
+ break;
+ case PROP_ICON:
+ g_value_set_string (value, device->priv->icon);
+ break;
+ case PROP_ACTIVE_PROFILE:
+ g_value_set_object (value, device->priv->active_profile);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+mate_mixer_pulse_device_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ MateMixerPulseDevice *device;
+
+ device = MATE_MIXER_PULSE_DEVICE (object);
+
+ switch (param_id) {
+ case PROP_IDENTIFIER:
+ device->priv->identifier = g_strdup (g_value_get_string (value));
+ break;
+ case PROP_NAME:
+ device->priv->name = g_strdup (g_value_get_string (value));
+ break;
+ case PROP_ICON:
+ device->priv->icon = g_strdup (g_value_get_string (value));
+ break;
+ case PROP_ACTIVE_PROFILE:
+ // TODO
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+mate_mixer_pulse_device_finalize (GObject *object)
+{
+ MateMixerPulseDevice *device;
+
+ device = MATE_MIXER_PULSE_DEVICE (object);
+
+ g_free (device->priv->identifier);
+ g_free (device->priv->name);
+ g_free (device->priv->icon);
+
+ if (device->priv->profiles != NULL)
+ g_list_free_full (device->priv->profiles, g_object_unref);
+
+ if (device->priv->ports != NULL)
+ g_list_free_full (device->priv->ports, g_object_unref);
+
+ if (device->priv->active_profile != NULL)
+ g_object_unref (device->priv->active_profile);
+
+ G_OBJECT_CLASS (mate_mixer_pulse_device_parent_class)->finalize (object);
+}
+
+static void
+mate_mixer_pulse_device_class_init (MateMixerPulseDeviceClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = mate_mixer_pulse_device_finalize;
+ object_class->get_property = mate_mixer_pulse_device_get_property;
+ object_class->set_property = mate_mixer_pulse_device_set_property;
+
+ g_object_class_override_property (object_class, PROP_IDENTIFIER, "identifier");
+ g_object_class_override_property (object_class, PROP_NAME, "name");
+ g_object_class_override_property (object_class, PROP_ICON, "icon");
+ g_object_class_override_property (object_class, PROP_ACTIVE_PROFILE, "active-profile");
+
+ g_type_class_add_private (object_class, sizeof (MateMixerPulseDevicePrivate));
+}
+
+MateMixerPulseDevice *
+mate_mixer_pulse_device_new (const pa_card_info *info)
+{
+ MateMixerPulseDevice *device;
+ MateMixerDeviceProfile *active_profile = NULL;
+ GList *profiles = NULL;
+ GList *ports = NULL;
+ guint32 i;
+
+ g_return_val_if_fail (info != NULL, NULL);
+
+ /* Create a list of card profiles */
+ for (i = 0; i < info->n_profiles; i++) {
+ MateMixerDeviceProfile *profile;
+
+#if PA_CHECK_VERSION(5, 0, 0)
+ pa_card_profile_info2 *p_info = info->profiles2[i];
+
+ /* PulseAudio 5.0 includes a new pa_card_profile_info2 which
+ * only differs in the new available flag, we use it not to include
+ * profiles which are unavailable */
+ if (p_info->available == 0)
+ continue;
+#else
+ /* The old profile list is an array of structs, not pointers */
+ pa_card_profile_info *p_info = &info->profiles[i];
+#endif
+ profile = mate_mixer_device_profile_new (
+ p_info->name,
+ p_info->description,
+ p_info->priority);
+
+#if PA_CHECK_VERSION(5, 0, 0)
+ if (!g_strcmp0 (p_info->name, info->active_profile2->name))
+ active_profile = g_object_ref (profile);
+#else
+ if (!g_strcmp0 (p_info->name, info->active_profile->name))
+ active_profile = g_object_ref (profile);
+#endif
+ profiles = g_list_prepend (profiles, profile);
+ }
+
+ /* Keep the profiles in the same order as in PulseAudio */
+ if (profiles)
+ profiles = g_list_reverse (profiles);
+
+ /* Create a list of card ports */
+ for (i = 0; i < info->n_ports; i++) {
+ MateMixerDevicePort *port;
+ MateMixerDevicePortDirection direction = 0;
+ MateMixerDevicePortStatus status = 0;
+ pa_card_port_info *p_info = info->ports[i];
+
+ if (p_info->direction & PA_DIRECTION_INPUT)
+ direction |= MATE_MIXER_DEVICE_PORT_DIRECTION_INPUT;
+
+ if (p_info->direction & PA_DIRECTION_OUTPUT)
+ direction |= MATE_MIXER_DEVICE_PORT_DIRECTION_OUTPUT;
+
+#if PA_CHECK_VERSION(2, 0, 0)
+ if (p_info->available == PA_PORT_AVAILABLE_YES)
+ status |= MATE_MIXER_DEVICE_PORT_STATUS_AVAILABLE;
+#endif
+ port = mate_mixer_device_port_new (
+ p_info->name,
+ p_info->description,
+ pa_proplist_gets (p_info->proplist, "device.icon_name"),
+ p_info->priority,
+ direction,
+ status,
+ p_info->latency_offset);
+
+ ports = g_list_prepend (ports, port);
+ }
+
+ /* Keep the ports in the same order as in PulseAudio */
+ if (ports)
+ ports = g_list_reverse (ports);
+
+ device = g_object_new (MATE_MIXER_TYPE_PULSE_DEVICE,
+ "identifier", info->name,
+ "name", pa_proplist_gets (info->proplist, "device.description"),
+ "icon", pa_proplist_gets (info->proplist, "device.icon_name"),
+ "active-profile", active_profile,
+ NULL);
+
+ device->priv->index = info->index;
+ device->priv->profiles = profiles;
+ device->priv->ports = ports;
+
+ return device;
+}
+
+const GList *
+mate_mixer_pulse_device_get_ports (MateMixerPulseDevice *device)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_PULSE_DEVICE (device), NULL);
+
+ return device->priv->ports;
+}
+
+const GList *
+mate_mixer_pulse_device_get_profiles (MateMixerPulseDevice *device)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_PULSE_DEVICE (device), NULL);
+
+ return device->priv->profiles;
+}
+
+MateMixerDeviceProfile *
+mate_mixer_pulse_device_get_active_profile (MateMixerPulseDevice *device)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_PULSE_DEVICE (device), NULL);
+
+ return device->priv->active_profile;
+}
+
+gboolean
+mate_mixer_pulse_device_set_active_profile (MateMixerPulseDevice *device,
+ MateMixerDeviceProfile *profile)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_PULSE_DEVICE (device), FALSE);
+ g_return_val_if_fail (MATE_MIXER_IS_DEVICE_PROFILE (profile), FALSE);
+
+ // TODO
+ // pa_context_set_card_profile_by_index ()
+ return TRUE;
+}
+
+gboolean
+mate_mixer_pulse_device_update (MateMixerPulseDevice *device, const pa_card_info *info)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_PULSE_DEVICE (device), FALSE);
+ g_return_val_if_fail (info != NULL, FALSE);
+
+ // TODO: update status, active_profile, maybe others?
+ return TRUE;
+}
diff --git a/backends/pulse/pulse-device.h b/backends/pulse/pulse-device.h
new file mode 100644
index 0000000..f8b5a07
--- /dev/null
+++ b/backends/pulse/pulse-device.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_PULSE_DEVICE_H
+#define MATEMIXER_PULSE_DEVICE_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <libmatemixer/matemixer-device.h>
+#include <libmatemixer/matemixer-device-profile.h>
+
+#include <pulse/pulseaudio.h>
+
+G_BEGIN_DECLS
+
+#define MATE_MIXER_TYPE_PULSE_DEVICE \
+ (mate_mixer_pulse_device_get_type ())
+#define MATE_MIXER_PULSE_DEVICE(o) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_PULSE_DEVICE, MateMixerPulseDevice))
+#define MATE_MIXER_IS_PULSE_DEVICE(o) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_PULSE_DEVICE))
+#define MATE_MIXER_PULSE_DEVICE_CLASS(k) \
+ (G_TYPE_CHECK_CLASS_CAST ((k), MATE_MIXER_TYPE_PULSE_DEVICE, MateMixerPulseDeviceClass))
+#define MATE_MIXER_IS_PULSE_DEVICE_CLASS(k) \
+ (G_TYPE_CLASS_CHECK_CLASS_TYPE ((k), MATE_MIXER_TYPE_PULSE_DEVICE))
+#define MATE_MIXER_PULSE_DEVICE_GET_CLASS(o) \
+ (G_TYPE_INSTANCE_GET_CLASS ((o), MATE_MIXER_TYPE_PULSE_DEVICE, MateMixerPulseDeviceClass))
+
+typedef struct _MateMixerPulseDevice MateMixerPulseDevice;
+typedef struct _MateMixerPulseDeviceClass MateMixerPulseDeviceClass;
+typedef struct _MateMixerPulseDevicePrivate MateMixerPulseDevicePrivate;
+
+struct _MateMixerPulseDevice
+{
+ GObject parent;
+
+ MateMixerPulseDevicePrivate *priv;
+};
+
+struct _MateMixerPulseDeviceClass
+{
+ GObjectClass parent;
+};
+
+GType mate_mixer_pulse_device_get_type (void) G_GNUC_CONST;
+
+MateMixerPulseDevice *mate_mixer_pulse_device_new (const pa_card_info *info);
+GList *mate_mixer_pulse_device_list_tracks (MateMixerPulseDevice *device);
+
+const GList *mate_mixer_pulse_device_get_ports (MateMixerPulseDevice *device);
+const GList *mate_mixer_pulse_device_get_profiles (MateMixerPulseDevice *device);
+
+MateMixerDeviceProfile *mate_mixer_pulse_device_get_active_profile (MateMixerPulseDevice *device);
+
+gboolean mate_mixer_pulse_device_set_active_profile (MateMixerPulseDevice *device,
+ MateMixerDeviceProfile *profile);
+
+gboolean mate_mixer_pulse_device_update (MateMixerPulseDevice *device,
+ const pa_card_info *info);
+
+G_END_DECLS
+
+#endif /* MATEMIXER_PULSE_DEVICE_H */
diff --git a/backends/pulse/pulse-track.c b/backends/pulse/pulse-track.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/backends/pulse/pulse-track.c
diff --git a/backends/pulse/pulse-track.h b/backends/pulse/pulse-track.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/backends/pulse/pulse-track.h
diff --git a/backends/pulse/pulse.c b/backends/pulse/pulse.c
new file mode 100644
index 0000000..e969dcf
--- /dev/null
+++ b/backends/pulse/pulse.c
@@ -0,0 +1,371 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <libmatemixer/matemixer-backend.h>
+#include <libmatemixer/matemixer-backend-module.h>
+
+#include <pulse/pulseaudio.h>
+#include <pulse/thread-mainloop.h>
+
+#include "pulse.h"
+#include "pulse-device.h"
+
+#define BACKEND_NAME "PulseAudio"
+#define BACKEND_PRIORITY 0
+
+struct _MateMixerPulsePrivate
+{
+ pa_threaded_mainloop *mainloop;
+ pa_context *context;
+ GHashTable *devices;
+};
+
+/* Support function for dynamic loading of the backend module */
+void backend_module_init (GTypeModule *module);
+void backend_module_free (void);
+
+const MateMixerBackendModuleInfo *backend_module_get_info (void);
+
+static void mate_mixer_backend_interface_init (MateMixerBackendInterface *iface);
+
+static void pulse_card_info_cb (pa_context *c,
+ const pa_card_info *info,
+ int eol,
+ void *userdata);
+
+static void pulse_card_update (MateMixerPulse *pulse, const pa_card_info *i);
+
+static void pulse_state_cb (pa_context *c, void *userdata);
+
+static void pulse_subscribe_cb (pa_context *c,
+ pa_subscription_event_type_t t,
+ uint32_t idx,
+ void *userdata);
+
+static gchar *pulse_get_app_name (void);
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (MateMixerPulse, mate_mixer_pulse,
+ G_TYPE_OBJECT, 0,
+ G_IMPLEMENT_INTERFACE_DYNAMIC (MATE_MIXER_TYPE_BACKEND,
+ mate_mixer_backend_interface_init))
+
+static MateMixerBackendModuleInfo info;
+
+void
+backend_module_init (GTypeModule *module)
+{
+ mate_mixer_pulse_register_type (module);
+
+ info.name = BACKEND_NAME;
+ info.priority = BACKEND_PRIORITY;
+ info.g_type = MATE_MIXER_TYPE_PULSE;
+ info.backend_type = MATE_MIXER_BACKEND_TYPE_PULSE;
+}
+
+void
+backend_module_free (void)
+{
+}
+
+const MateMixerBackendModuleInfo *
+backend_module_get_info (void)
+{
+ return &info;
+}
+
+static void
+mate_mixer_backend_interface_init (MateMixerBackendInterface *iface)
+{
+ iface->open = mate_mixer_pulse_open;
+ iface->close = mate_mixer_pulse_close;
+ iface->list_devices = mate_mixer_pulse_list_devices;
+}
+
+static void
+mate_mixer_pulse_init (MateMixerPulse *pulse)
+{
+ pulse->priv = G_TYPE_INSTANCE_GET_PRIVATE (
+ pulse,
+ MATE_MIXER_TYPE_PULSE,
+ MateMixerPulsePrivate);
+
+ pulse->priv->devices = g_hash_table_new_full (
+ g_direct_hash,
+ g_direct_equal,
+ NULL,
+ g_object_unref);
+}
+
+static void
+mate_mixer_pulse_finalize (GObject *object)
+{
+ MateMixerPulse *pulse;
+
+ pulse = MATE_MIXER_PULSE (object);
+
+ g_hash_table_destroy (pulse->priv->devices);
+
+ G_OBJECT_CLASS (mate_mixer_pulse_parent_class)->finalize (object);
+}
+
+static void
+mate_mixer_pulse_class_init (MateMixerPulseClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = mate_mixer_pulse_finalize;
+
+ g_type_class_add_private (object_class, sizeof (MateMixerPulsePrivate));
+}
+
+/* Called in the code generated by G_DEFINE_DYNAMIC_TYPE_EXTENDED() */
+static void
+mate_mixer_pulse_class_finalize (MateMixerPulseClass *klass)
+{
+}
+
+gboolean
+mate_mixer_pulse_open (MateMixerBackend *backend)
+{
+ int ret;
+ gchar *app_name;
+ MateMixerPulse *pulse;
+
+ g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), FALSE);
+
+ pulse = MATE_MIXER_PULSE (backend);
+
+ g_return_val_if_fail (pulse->priv->mainloop == NULL, FALSE);
+
+ pulse->priv->mainloop = pa_threaded_mainloop_new ();
+ if (G_UNLIKELY (pulse->priv->mainloop == NULL)) {
+ g_warning ("Failed to created PulseAudio main loop");
+ return FALSE;
+ }
+
+ app_name = pulse_get_app_name ();
+
+ pulse->priv->context = pa_context_new (
+ pa_threaded_mainloop_get_api (pulse->priv->mainloop),
+ app_name);
+
+ g_free (app_name);
+
+ if (G_UNLIKELY (pulse->priv->context == NULL)) {
+ g_warning ("Failed to created PulseAudio context");
+
+ pa_threaded_mainloop_free (pulse->priv->mainloop);
+ pulse->priv->mainloop = NULL;
+ return FALSE;
+ }
+
+ // XXX: investigate PA_CONTEXT_NOFAIL
+ ret = pa_context_connect (pulse->priv->context, NULL, PA_CONTEXT_NOFLAGS, NULL);
+ if (ret < 0) {
+ g_warning ("Failed to connect to PulseAudio server: %s", pa_strerror (ret));
+
+ pa_context_unref (pulse->priv->context);
+ pa_threaded_mainloop_free (pulse->priv->mainloop);
+
+ pulse->priv->context = NULL;
+ pulse->priv->mainloop = NULL;
+ return FALSE;
+ }
+
+ g_debug ("Connected to PulseAudio server");
+
+ pa_threaded_mainloop_lock (pulse->priv->mainloop);
+
+ pa_context_set_state_callback (pulse->priv->context,
+ pulse_state_cb,
+ backend);
+ pa_context_set_subscribe_callback (pulse->priv->context,
+ pulse_subscribe_cb,
+ backend);
+
+ ret = pa_threaded_mainloop_start (pulse->priv->mainloop);
+ if (ret < 0) {
+ g_warning ("Failed to start PulseAudio main loop: %s", pa_strerror (ret));
+
+ pa_threaded_mainloop_unlock (pulse->priv->mainloop);
+
+ pa_context_unref (pulse->priv->context);
+ pa_threaded_mainloop_free (pulse->priv->mainloop);
+
+ pulse->priv->context = NULL;
+ pulse->priv->mainloop = NULL;
+ return FALSE;
+ }
+
+ while (pa_context_get_state (pulse->priv->context) != PA_CONTEXT_READY) {
+ // XXX this will get stuck if connection fails
+ pa_threaded_mainloop_wait (pulse->priv->mainloop);
+ }
+
+ pa_threaded_mainloop_unlock (pulse->priv->mainloop);
+
+ return TRUE;
+}
+
+void
+mate_mixer_pulse_close (MateMixerBackend *backend)
+{
+ MateMixerPulse *pulse;
+
+ g_return_if_fail (MATE_MIXER_IS_BACKEND (backend));
+
+ pulse = MATE_MIXER_PULSE (backend);
+
+ g_return_if_fail (pulse->priv->mainloop != NULL);
+
+ pa_threaded_mainloop_stop (pulse->priv->mainloop);
+
+ pa_context_unref (pulse->priv->context);
+ pa_threaded_mainloop_free (pulse->priv->mainloop);
+
+ pulse->priv->context = NULL;
+ pulse->priv->mainloop = NULL;
+}
+
+GList *
+mate_mixer_pulse_list_devices (MateMixerBackend *backend)
+{
+ MateMixerPulse *pulse;
+ pa_operation *o;
+
+ g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), NULL);
+
+ pulse = MATE_MIXER_PULSE (backend);
+
+ pa_threaded_mainloop_lock (pulse->priv->mainloop);
+
+ o = pa_context_get_card_info_list (pulse->priv->context, pulse_card_info_cb, pulse);
+ if (o == NULL) {
+ g_warning ("Failed to read card list: %s",
+ pa_strerror (pa_context_errno (pulse->priv->context)));
+
+ pa_threaded_mainloop_unlock (pulse->priv->mainloop);
+ return NULL;
+ }
+
+ while (pa_operation_get_state (o) == PA_OPERATION_RUNNING)
+ pa_threaded_mainloop_wait (pulse->priv->mainloop);
+
+ pa_operation_unref (o);
+ pa_threaded_mainloop_unlock (pulse->priv->mainloop);
+
+ return g_hash_table_get_values (pulse->priv->devices);
+}
+
+static void
+pulse_card_info_cb (pa_context *c, const pa_card_info *info, int eol, void *userdata)
+{
+ MateMixerPulse *pulse;
+
+ pulse = MATE_MIXER_PULSE (userdata);
+
+ if (!eol)
+ pulse_card_update (pulse, info);
+
+ pa_threaded_mainloop_signal (pulse->priv->mainloop, 0);
+}
+
+static void
+pulse_card_update (MateMixerPulse *pulse, const pa_card_info *info)
+{
+ gpointer item;
+
+ item = g_hash_table_lookup (pulse->priv->devices, GINT_TO_POINTER (info->index));
+ if (item) {
+ /* The card is already known, just update the fields that may
+ * have changed */
+ mate_mixer_pulse_device_update (MATE_MIXER_PULSE_DEVICE (item), info);
+ } else {
+ MateMixerPulseDevice *device = mate_mixer_pulse_device_new (info);
+
+ if (G_UNLIKELY (device == NULL))
+ g_warning ("Failed to process PulseAudio sound device");
+ else
+ g_hash_table_insert (
+ pulse->priv->devices,
+ GINT_TO_POINTER (info->index),
+ device);
+ }
+}
+
+static void
+pulse_state_cb (pa_context *c, void *userdata)
+{
+ MateMixerPulse *pulse;
+
+ pulse = MATE_MIXER_PULSE (userdata);
+
+ // TODO: handle errors
+
+ switch (pa_context_get_state (c)) {
+ case PA_CONTEXT_UNCONNECTED:
+ break;
+ case PA_CONTEXT_CONNECTING:
+ break;
+ case PA_CONTEXT_AUTHORIZING:
+ break;
+ case PA_CONTEXT_SETTING_NAME:
+ break;
+ case PA_CONTEXT_READY:
+ break;
+ case PA_CONTEXT_FAILED:
+ break;
+ case PA_CONTEXT_TERMINATED:
+ break;
+ default:
+ break;
+ }
+
+ pa_threaded_mainloop_signal (pulse->priv->mainloop, FALSE);
+}
+
+static void
+pulse_subscribe_cb (pa_context *c,
+ pa_subscription_event_type_t t,
+ uint32_t idx,
+ void *userdata)
+{
+ // TODO
+}
+
+static gchar *
+pulse_get_app_name (void)
+{
+ const char *name_app;
+ char name_buf[256];
+
+ /* Inspired by GStreamer's pulse plugin */
+ name_app = g_get_application_name ();
+ if (name_app != NULL)
+ return g_strdup (name_app);
+
+ if (pa_get_binary_name (name_buf, sizeof (name_buf)) != NULL)
+ return g_strdup (name_buf);
+
+ return g_strdup_printf ("libmatemixer-%lu", (gulong) getpid ());
+}
diff --git a/backends/pulse/pulse.h b/backends/pulse/pulse.h
new file mode 100644
index 0000000..2f8414f
--- /dev/null
+++ b/backends/pulse/pulse.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_PULSE_H
+#define MATEMIXER_PULSE_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <libmatemixer/matemixer-backend.h>
+
+#define MATE_MIXER_TYPE_PULSE \
+ (mate_mixer_pulse_get_type ())
+#define MATE_MIXER_PULSE(o) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_PULSE, MateMixerPulse))
+#define MATE_MIXER_IS_PULSE(o) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_PULSE))
+#define MATE_MIXER_PULSE_CLASS(k) \
+ (G_TYPE_CHECK_CLASS_CAST ((k), MATE_MIXER_TYPE_PULSE, MateMixerPulseClass))
+#define MATE_MIXER_IS_PULSE_CLASS(k) \
+ (G_TYPE_CLASS_CHECK_CLASS_TYPE ((k), MATE_MIXER_TYPE_PULSE))
+#define MATE_MIXER_PULSE_GET_CLASS(o) \
+ (G_TYPE_INSTANCE_GET_CLASS ((o), MATE_MIXER_TYPE_PULSE, MateMixerPulseClass))
+
+typedef struct _MateMixerPulse MateMixerPulse;
+typedef struct _MateMixerPulseClass MateMixerPulseClass;
+typedef struct _MateMixerPulsePrivate MateMixerPulsePrivate;
+
+struct _MateMixerPulse
+{
+ GObject parent;
+
+ MateMixerPulsePrivate *priv;
+};
+
+struct _MateMixerPulseClass
+{
+ GObjectClass parent;
+};
+
+GType mate_mixer_pulse_get_type (void) G_GNUC_CONST;
+
+gboolean mate_mixer_pulse_open (MateMixerBackend *backend);
+void mate_mixer_pulse_close (MateMixerBackend *backend);
+GList *mate_mixer_pulse_list_devices (MateMixerBackend *backend);
+
+#endif /* MATEMIXER_PULSE_H */
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..fdd632b
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,159 @@
+AC_PREREQ([2.60])
+
+AC_INIT([libmatemixer],
+ [1.9.0],
+ [http://www.mate-desktop.org])
+
+AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_SRCDIR([libmatemixer/matemixer.c])
+
+AM_INIT_AUTOMAKE
+
+# Use pretty build output with automake >= 1.11
+m4_ifdef([AM_SILENT_RULES],
+ [AM_SILENT_RULES([yes])],
+ [AM_DEFAULT_VERBOSITY=1 AC_SUBST(AM_DEFAULT_VERBOSITY)])
+
+# Checks for required programs.
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_INSTALL
+
+# Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS([sys/types.h unistd.h])
+
+# =======================================================================
+# Libtool
+# =======================================================================
+LT_CURRENT=0
+LT_REVISION=0
+LT_AGE=0
+AC_SUBST(LT_CURRENT)
+AC_SUBST(LT_REVISION)
+AC_SUBST(LT_AGE)
+
+LT_PREREQ([2.2])
+LT_INIT
+
+# =======================================================================
+# Check for required packages
+# =======================================================================
+PKG_PROG_PKG_CONFIG
+
+GLIB_REQUIRED_VERSION=2.36.0
+
+PKG_CHECK_MODULES(GLIB, [
+ glib-2.0 >= $GLIB_REQUIRED_VERSION
+ gobject-2.0 >= $GLIB_REQUIRED_VERSION
+ gmodule-2.0 >= $GLIB_REQUIRED_VERSION
+])
+AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal)
+AC_PATH_PROG(GLIB_MKENUMS, glib-mkenums)
+
+# =======================================================================
+# Check for backend module support
+# =======================================================================
+PA_REQUIRED_VERSION=0.9.16
+
+AC_ARG_ENABLE([pulseaudio],
+ AS_HELP_STRING([--enable-pulseaudio],
+ [Enable PulseAudio support @<:@default=auto@:>@]),
+ enable_pulseaudio=$enableval, enable_pulseaudio=auto)
+
+if test "x$enable_pulseaudio" != "xno"; then
+ PKG_CHECK_MODULES(PULSEAUDIO,
+ libpulse >= $PA_REQUIRED_VERSION,
+ have_pulseaudio=yes,
+ have_pulseaudio=no)
+
+ if test "x$enable_pulseaudio" = "xyes" -a "x$have_pulseaudio" = "xno"; then
+ AC_MSG_ERROR([PulseAudio support explicitly requested but dependencies not found])
+ fi
+
+ if test "x$have_pulseaudio" = "xyes" ; then
+ AC_DEFINE(HAVE_PULSEAUDIO, [], [Define if we have pulseaudio])
+ fi
+fi
+
+AM_CONDITIONAL(HAVE_PULSEAUDIO, test "x$have_pulseaudio" = "xyes")
+
+AC_SUBST(HAVE_PULSEAUDIO)
+AC_SUBST(PULSEAUDIO_CFLAGS)
+AC_SUBST(PULSEAUDIO_LIBS)
+
+# =======================================================================
+# Compiler warnings
+# =======================================================================
+MATE_COMPILE_WARNINGS([maximum])
+MATE_CXX_WARNINGS
+
+# Turn on the additional warnings last, so warnings don't affect other tests.
+AC_ARG_ENABLE(more-warnings,
+ [AC_HELP_STRING([--enable-more-warnings],
+ [Maximum compiler warnings])],
+ set_more_warnings="$enableval",[
+ if test -d $srcdir/.git; then
+ set_more_warnings=yes
+ else
+ set_more_warnings=no
+ fi
+ ])
+
+AC_MSG_CHECKING(for more warnings)
+if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
+ AC_MSG_RESULT(yes)
+ CFLAGS="-Wall -Wchar-subscripts -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wcast-align -Wsign-compare $CFLAGS"
+
+ for option in -Wno-unused-parameter -Wno-strict-aliasing -Wno-sign-compare; do
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $option"
+ AC_MSG_CHECKING([whether gcc understands $option])
+ AC_TRY_COMPILE([], [],
+ has_option=yes,
+ has_option=no,)
+ if test $has_option = no; then
+ CFLAGS="$SAVE_CFLAGS"
+ fi
+ AC_MSG_RESULT($has_option)
+ unset has_option
+ unset SAVE_CFLAGS
+ done
+ unset option
+else
+ AC_MSG_RESULT(no)
+fi
+AC_SUBST(CFLAGS)
+
+# =======================================================================
+# Finish
+# =======================================================================
+AC_CONFIG_FILES([
+Makefile
+libmatemixer/Makefile
+backends/Makefile
+backends/null/Makefile
+backends/pulse/Makefile
+data/Makefile
+data/libmatemixer.pc
+doc/Makefile
+])
+
+AC_OUTPUT
+
+echo "
+
+ ${PACKAGE} ${VERSION}
+ ============
+
+
+ Prefix: ${prefix}
+ Source code location: ${srcdir}
+ Compiler: ${CC}
+ CFLAGS: ${CFLAGS}
+
+ PulseAudio backend support: $have_pulseaudio
+
+"
diff --git a/data/Makefile.am b/data/Makefile.am
new file mode 100644
index 0000000..448abd8
--- /dev/null
+++ b/data/Makefile.am
@@ -0,0 +1,6 @@
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libmatemixer.pc
+
+EXTRA_DIST = libmatemixer.pc.in
+
+-include $(top_srcdir)/git.mk
diff --git a/data/libmatemixer.pc.in b/data/libmatemixer.pc.in
new file mode 100644
index 0000000..d56bfdb
--- /dev/null
+++ b/data/libmatemixer.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: libmatemixer
+Description:
+Version: @VERSION@
+Requires: glib-2.0 gobject-2.0
+Libs: -L${libdir} -lmatemixer
+Cflags: -I${includedir}/libmatemixer
diff --git a/doc/Makefile.am b/doc/Makefile.am
new file mode 100644
index 0000000..9b582ee
--- /dev/null
+++ b/doc/Makefile.am
@@ -0,0 +1,2 @@
+
+-include $(top_srcdir)/git.mk
diff --git a/git.mk b/git.mk
new file mode 100644
index 0000000..5638488
--- /dev/null
+++ b/git.mk
@@ -0,0 +1,318 @@
+# git.mk
+#
+# Copyright 2009, Red Hat, Inc.
+# Copyright 2010,2011,2012,2013 Behdad Esfahbod
+# Written by Behdad Esfahbod
+#
+# Copying and distribution of this file, with or without modification,
+# is permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+#
+# The latest version of this file can be downloaded from:
+# https://raw.github.com/behdad/git.mk/master/git.mk
+# Bugs, etc, should be reported upstream at:
+# https://github.com/behdad/git.mk
+#
+# To use in your project, import this file in your git repo's toplevel,
+# then do "make -f git.mk". This modifies all Makefile.am files in
+# your project to -include git.mk. Remember to add that line to new
+# Makefile.am files you create in your project, or just rerun the
+# "make -f git.mk".
+#
+# This enables automatic .gitignore generation. If you need to ignore
+# more files, add them to the GITIGNOREFILES variable in your Makefile.am.
+# But think twice before doing that. If a file has to be in .gitignore,
+# chances are very high that it's a generated file and should be in one
+# of MOSTLYCLEANFILES, CLEANFILES, DISTCLEANFILES, or MAINTAINERCLEANFILES.
+#
+# The only case that you need to manually add a file to GITIGNOREFILES is
+# when remove files in one of mostlyclean-local, clean-local, distclean-local,
+# or maintainer-clean-local make targets.
+#
+# Note that for files like editor backup, etc, there are better places to
+# ignore them. See "man gitignore".
+#
+# If "make maintainer-clean" removes the files but they are not recognized
+# by this script (that is, if "git status" shows untracked files still), send
+# me the output of "git status" as well as your Makefile.am and Makefile for
+# the directories involved and I'll diagnose.
+#
+# For a list of toplevel files that should be in MAINTAINERCLEANFILES, see
+# Makefile.am.sample in the git.mk git repo.
+#
+# Don't EXTRA_DIST this file. It is supposed to only live in git clones,
+# not tarballs. It serves no useful purpose in tarballs and clutters the
+# build dir.
+#
+# This file knows how to handle autoconf, automake, libtool, gtk-doc,
+# gnome-doc-utils, yelp.m4, mallard, intltool, gsettings, dejagnu, appdata.
+#
+# This makefile provides the following targets:
+#
+# - all: "make all" will build all gitignore files.
+# - gitignore: makes all gitignore files in the current dir and subdirs.
+# - .gitignore: make gitignore file for the current dir.
+# - gitignore-recurse: makes all gitignore files in the subdirs.
+#
+# KNOWN ISSUES:
+#
+# - Recursive configure doesn't work as $(top_srcdir)/git.mk inside the
+# submodule doesn't find us. If you have configure.{in,ac} files in
+# subdirs, add a proxy git.mk file in those dirs that simply does:
+# "include $(top_srcdir)/../git.mk". Add more ..'s to your taste.
+# And add those files to git. See vte/gnome-pty-helper/git.mk for
+# example.
+#
+
+
+
+###############################################################################
+# Variables user modules may want to add to toplevel MAINTAINERCLEANFILES:
+###############################################################################
+
+#
+# Most autotools-using modules should be fine including this variable in their
+# toplevel MAINTAINERCLEANFILES:
+GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL = \
+ $(srcdir)/aclocal.m4 \
+ $(srcdir)/autoscan.log \
+ $(srcdir)/configure.scan \
+ `AUX_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_AUX_DIR:$$1' ./configure.ac); \
+ test "x$$AUX_DIR" = "x$(srcdir)/" && AUX_DIR=$(srcdir); \
+ for x in \
+ ar-lib \
+ compile \
+ config.guess \
+ config.sub \
+ depcomp \
+ install-sh \
+ ltmain.sh \
+ missing \
+ mkinstalldirs \
+ test-driver \
+ ; do echo "$$AUX_DIR/$$x"; done` \
+ `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_HEADERS:$$1' ./configure.ac | \
+ head -n 1 | while read f; do echo "$(srcdir)/$$f.in"; done`
+#
+# All modules should also be fine including the following variable, which
+# removes automake-generated Makefile.in files:
+GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN = \
+ `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_FILES:$$1' ./configure.ac | \
+ while read f; do \
+ case $$f in Makefile|*/Makefile) \
+ test -f "$(srcdir)/$$f.am" && echo "$(srcdir)/$$f.in";; esac; \
+ done`
+#
+# Modules that use libtool and use AC_CONFIG_MACRO_DIR() may also include this,
+# though it's harmless to include regardless.
+GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL = \
+ `MACRO_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_MACRO_DIR:$$1' ./configure.ac); \
+ if test "x$$MACRO_DIR" != "x$(srcdir)/"; then \
+ for x in \
+ libtool.m4 \
+ ltoptions.m4 \
+ ltsugar.m4 \
+ ltversion.m4 \
+ lt~obsolete.m4 \
+ ; do echo "$$MACRO_DIR/$$x"; done; \
+ fi`
+
+
+
+###############################################################################
+# Default rule is to install ourselves in all Makefile.am files:
+###############################################################################
+
+git-all: git-mk-install
+
+git-mk-install:
+ @echo "Installing git makefile"
+ @any_failed=; \
+ find "`test -z "$(top_srcdir)" && echo . || echo "$(top_srcdir)"`" -name Makefile.am | while read x; do \
+ if grep 'include .*/git.mk' $$x >/dev/null; then \
+ echo "$$x already includes git.mk"; \
+ else \
+ failed=; \
+ echo "Updating $$x"; \
+ { cat $$x; \
+ echo ''; \
+ echo '-include $$(top_srcdir)/git.mk'; \
+ } > $$x.tmp || failed=1; \
+ if test x$$failed = x; then \
+ mv $$x.tmp $$x || failed=1; \
+ fi; \
+ if test x$$failed = x; then : else \
+ echo "Failed updating $$x"; >&2 \
+ any_failed=1; \
+ fi; \
+ fi; done; test -z "$$any_failed"
+
+.PHONY: git-all git-mk-install
+
+
+
+###############################################################################
+# Actual .gitignore generation:
+###############################################################################
+
+$(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk
+ @echo "git.mk: Generating $@"
+ @{ \
+ if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \
+ for x in \
+ $(DOC_MODULE)-decl-list.txt \
+ $(DOC_MODULE)-decl.txt \
+ tmpl/$(DOC_MODULE)-unused.sgml \
+ "tmpl/*.bak" \
+ xml html \
+ ; do echo "/$$x"; done; \
+ FLAVOR=$$(cd $(top_srcdir); $(AUTOCONF) --trace 'GTK_DOC_CHECK:$$2' ./configure.ac); \
+ case $$FLAVOR in *no-tmpl*) echo /tmpl;; esac; \
+ fi; \
+ if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \
+ for lc in $(DOC_LINGUAS); do \
+ for x in \
+ $(if $(DOC_MODULE),$(DOC_MODULE).xml) \
+ $(DOC_PAGES) \
+ $(DOC_INCLUDES) \
+ ; do echo "/$$lc/$$x"; done; \
+ done; \
+ for x in \
+ $(_DOC_OMF_ALL) \
+ $(_DOC_DSK_ALL) \
+ $(_DOC_HTML_ALL) \
+ $(_DOC_MOFILES) \
+ $(DOC_H_FILE) \
+ "*/.xml2po.mo" \
+ "*/*.omf.out" \
+ ; do echo /$$x; done; \
+ fi; \
+ if test "x$(HELP_ID)" = x -o "x$(HELP_LINGUAS)" = x; then :; else \
+ for lc in $(HELP_LINGUAS); do \
+ for x in \
+ $(HELP_FILES) \
+ "$$lc.stamp" \
+ "$$lc.mo" \
+ ; do echo "/$$lc/$$x"; done; \
+ done; \
+ fi; \
+ if test "x$(gsettings_SCHEMAS)" = x; then :; else \
+ for x in \
+ $(gsettings_SCHEMAS:.xml=.valid) \
+ $(gsettings__enum_file) \
+ ; do echo "/$$x"; done; \
+ fi; \
+ if test "x$(appdata_XML)" = x; then :; else \
+ for x in \
+ $(appdata_XML:.xml=.valid) \
+ ; do echo "/$$x"; done; \
+ fi; \
+ if test -f $(srcdir)/po/Makefile.in.in; then \
+ for x in \
+ po/Makefile.in.in \
+ po/Makefile.in.in~ \
+ po/Makefile.in \
+ po/Makefile \
+ po/Makevars.template \
+ po/POTFILES \
+ po/Rules-quot \
+ po/stamp-it \
+ po/.intltool-merge-cache \
+ "po/*.gmo" \
+ "po/*.header" \
+ "po/*.mo" \
+ "po/*.sed" \
+ "po/*.sin" \
+ po/$(GETTEXT_PACKAGE).pot \
+ intltool-extract.in \
+ intltool-merge.in \
+ intltool-update.in \
+ ; do echo "/$$x"; done; \
+ fi; \
+ if test -f $(srcdir)/configure; then \
+ for x in \
+ autom4te.cache \
+ configure \
+ config.h \
+ stamp-h1 \
+ libtool \
+ config.lt \
+ ; do echo "/$$x"; done; \
+ fi; \
+ if test "x$(DEJATOOL)" = x; then :; else \
+ for x in \
+ $(DEJATOOL) \
+ ; do echo "/$$x.sum"; echo "/$$x.log"; done; \
+ echo /site.exp; \
+ fi; \
+ if test "x$(am__dirstamp)" = x; then :; else \
+ echo "$(am__dirstamp)"; \
+ fi; \
+ if test "x$(LTCOMPILE)" = x -a "x$(GTKDOC_RUN)" = x; then :; else \
+ for x in \
+ "*.lo" \
+ ".libs" "_libs" \
+ ; do echo "$$x"; done; \
+ fi; \
+ for x in \
+ .gitignore \
+ $(GITIGNOREFILES) \
+ $(CLEANFILES) \
+ $(PROGRAMS) $(check_PROGRAMS) $(EXTRA_PROGRAMS) \
+ $(LIBRARIES) $(check_LIBRARIES) $(EXTRA_LIBRARIES) \
+ $(LTLIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LTLIBRARIES) \
+ so_locations \
+ $(MOSTLYCLEANFILES) \
+ $(TEST_LOGS) \
+ $(TEST_LOGS:.log=.trs) \
+ $(TEST_SUITE_LOG) \
+ "*.$(OBJEXT)" \
+ "*.gcda" \
+ "*.gcno" \
+ $(DISTCLEANFILES) \
+ $(am__CONFIG_DISTCLEAN_FILES) \
+ $(CONFIG_CLEAN_FILES) \
+ TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
+ "*.tab.c" \
+ $(MAINTAINERCLEANFILES) \
+ $(BUILT_SOURCES) \
+ $(DEPDIR) \
+ $(patsubst %.vala,%.c,$(filter %.vala,$(SOURCES))) \
+ $(filter %_vala.stamp,$(DIST_COMMON)) \
+ $(filter %.vapi,$(DIST_COMMON)) \
+ $(filter $(addprefix %,$(notdir $(patsubst %.vapi,%.h,$(filter %.vapi,$(DIST_COMMON))))),$(DIST_COMMON)) \
+ Makefile \
+ Makefile.in \
+ "*.orig" \
+ "*.rej" \
+ "*.bak" \
+ "*~" \
+ ".*.sw[nop]" \
+ ".dirstamp" \
+ ; do echo "/$$x"; done; \
+ } | \
+ sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
+ sed 's@/[.]/@/@g' | \
+ LC_ALL=C sort | uniq > [email protected] && \
+
+all: $(srcdir)/.gitignore gitignore-recurse-maybe
+gitignore: $(srcdir)/.gitignore gitignore-recurse
+
+gitignore-recurse-maybe:
+ @for subdir in $(DIST_SUBDIRS); do \
+ case " $(SUBDIRS) " in \
+ *" $$subdir "*) :;; \
+ *) test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir");; \
+ esac; \
+ done
+gitignore-recurse:
+ @for subdir in $(DIST_SUBDIRS); do \
+ test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir"); \
+ done
+
+maintainer-clean: gitignore-clean
+gitignore-clean:
+ -rm -f $(srcdir)/.gitignore
+
+.PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe
diff --git a/libmatemixer/Makefile.am b/libmatemixer/Makefile.am
new file mode 100644
index 0000000..a986a98
--- /dev/null
+++ b/libmatemixer/Makefile.am
@@ -0,0 +1,60 @@
+lib_LTLIBRARIES = libmatemixer.la
+
+AM_CPPFLAGS = \
+ $(GLIB_CFLAGS) \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/libmatemixer \
+ -DG_LOG_DOMAIN=\"libmatemixer\" \
+ -DLIBMATEMIXER_BACKEND_DIR=\"$(libdir)/libmatemixer\"
+
+BUILT_SOURCES = \
+ matemixer-enum-types.c \
+ matemixer-enum-types.h
+
+libmatemixer_includedir = $(includedir)/libmatemixer
+
+libmatemixer_include_HEADERS = \
+ matemixer.h \
+ matemixer-control.h \
+ matemixer-device.h \
+ matemixer-device-port.h \
+ matemixer-device-profile.h \
+ matemixer-enums.h \
+ matemixer-track.h
+
+libmatemixer_la_SOURCES = \
+ matemixer.c \
+ matemixer-private.h \
+ matemixer-backend.c \
+ matemixer-backend.h \
+ matemixer-backend-module.c \
+ matemixer-control.c \
+ matemixer-device.c \
+ matemixer-device-port.c \
+ matemixer-device-profile.c \
+ matemixer-track.c \
+ $(BUILD_SOURCES)
+
+libmatemixer_la_LIBADD = $(GLIB_LIBS)
+
+libmatemixer_la_LDFLAGS = \
+ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
+ -export-dynamic
+
+libmatemixer_ENUM_TYPES = matemixer-enums.h
+
+matemixer-enum-types.h: $(libmatemixer_ENUM_TYPES)
+ $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template matemixer-enum-types.h.template \
+ $(libmatemixer_ENUM_TYPES) ) > matemixer-enum-types.h.tmp \
+ && mv matemixer-enum-types.h.tmp matemixer-enum-types.h \
+ || rm -f matemixer-enum-type.h.tmp
+
+matemixer-enum-types.c: $(libmatemixer_ENUM_TYPES)
+ $(AM_V_GEN) (cd $(srcdir) && $(GLIB_MKENUMS) --template matemixer-enum-types.c.template \
+ $(libmatemixer_ENUM_TYPES) ) > matemixer-enum-types.c.tmp \
+ && mv matemixer-enum-types.c.tmp matemixer-enum-types.c \
+ || rm -f matemixer-enum-type.c.tmp
+
+CLEANFILES = $(BUILT_SOURCES)
+
+-include $(top_srcdir)/git.mk
diff --git a/libmatemixer/matemixer-backend-module.c b/libmatemixer/matemixer-backend-module.c
new file mode 100644
index 0000000..0acd786
--- /dev/null
+++ b/libmatemixer/matemixer-backend-module.c
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gmodule.h>
+
+#include "matemixer-backend.h"
+#include "matemixer-backend-module.h"
+
+G_DEFINE_TYPE (MateMixerBackendModule, mate_mixer_backend_module, G_TYPE_TYPE_MODULE);
+
+struct _MateMixerBackendModulePrivate
+{
+ GModule *gmodule;
+ gchar *path;
+
+ void (*init) (GTypeModule *type_module);
+ void (*free) (void);
+
+ const MateMixerBackendModuleInfo *(*get_info) (void);
+};
+
+static gboolean mate_mixer_backend_module_load (GTypeModule *gmodule);
+static void mate_mixer_backend_module_unload (GTypeModule *gmodule);
+
+static void
+mate_mixer_backend_module_init (MateMixerBackendModule *module)
+{
+ module->priv = G_TYPE_INSTANCE_GET_PRIVATE (
+ module,
+ MATE_MIXER_TYPE_BACKEND_MODULE,
+ MateMixerBackendModulePrivate);
+}
+
+static void
+mate_mixer_backend_module_finalize (GObject *object)
+{
+ MateMixerBackendModule *module;
+
+ module = MATE_MIXER_BACKEND_MODULE (object);
+
+ g_free (module->priv->path);
+
+ G_OBJECT_CLASS (mate_mixer_backend_module_parent_class)->finalize (object);
+}
+
+static void
+mate_mixer_backend_module_class_init (MateMixerBackendModuleClass *klass)
+{
+ GObjectClass *object_class;
+ GTypeModuleClass *gtype_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = mate_mixer_backend_module_finalize;
+
+ gtype_class = G_TYPE_MODULE_CLASS (klass);
+ gtype_class->load = mate_mixer_backend_module_load;
+ gtype_class->unload = mate_mixer_backend_module_unload;
+
+ g_type_class_add_private (object_class, sizeof (MateMixerBackendModulePrivate));
+}
+
+static gboolean
+mate_mixer_backend_module_load (GTypeModule *type_module)
+{
+ MateMixerBackendModule *module;
+
+ module = MATE_MIXER_BACKEND_MODULE (type_module);
+
+ module->priv->gmodule = g_module_open (
+ module->priv->path,
+ G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
+
+ if (module->priv->gmodule == NULL) {
+ g_warning ("Failed to load backend module %s: %s",
+ module->priv->path,
+ g_module_error ());
+
+ return FALSE;
+ }
+
+ /* Validate library symbols that each backend module must provide */
+ if (!g_module_symbol (module->priv->gmodule,
+ "backend_module_init",
+ (gpointer *) &module->priv->init) ||
+ !g_module_symbol (module->priv->gmodule,
+ "backend_module_free",
+ (gpointer *) &module->priv->free) ||
+ !g_module_symbol (module->priv->gmodule,
+ "backend_module_get_info",
+ (gpointer *) &module->priv->get_info)) {
+ g_warning ("Failed to load backend module %s: %s",
+ module->priv->path,
+ g_module_error ());
+
+ g_module_close (module->priv->gmodule);
+ return FALSE;
+ }
+
+ g_debug ("Loaded backend module %s", module->priv->path);
+
+ module->priv->init (type_module);
+ return TRUE;
+}
+
+static void
+mate_mixer_backend_module_unload (GTypeModule *type_module)
+{
+ MateMixerBackendModule *module;
+
+ module = MATE_MIXER_BACKEND_MODULE (type_module);
+ module->priv->free ();
+
+ g_module_close (module->priv->gmodule);
+}
+
+MateMixerBackendModule *
+mate_mixer_backend_module_new (const gchar *path)
+{
+ MateMixerBackendModule *module;
+
+ g_return_val_if_fail (path != NULL, NULL);
+
+ module = g_object_newv (MATE_MIXER_TYPE_BACKEND_MODULE, 0, NULL);
+ module->priv->path = g_strdup (path);
+
+ g_type_module_set_name (G_TYPE_MODULE (module), path);
+
+ return module;
+}
+
+const MateMixerBackendModuleInfo *
+mate_mixer_backend_module_get_info (MateMixerBackendModule *module)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_BACKEND_MODULE (module), NULL);
+
+ return module->priv->get_info ();
+}
+
+const gchar *
+mate_mixer_backend_module_get_path (MateMixerBackendModule *module)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_BACKEND_MODULE (module), NULL);
+
+ return module->priv->path;
+}
diff --git a/libmatemixer/matemixer-backend-module.h b/libmatemixer/matemixer-backend-module.h
new file mode 100644
index 0000000..4cba866
--- /dev/null
+++ b/libmatemixer/matemixer-backend-module.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_BACKEND_MODULE_H
+#define MATEMIXER_BACKEND_MODULE_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "matemixer-enums.h"
+
+G_BEGIN_DECLS
+
+#define MATE_MIXER_TYPE_BACKEND_MODULE \
+ (mate_mixer_backend_module_get_type ())
+#define MATE_MIXER_BACKEND_MODULE(o) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_BACKEND_MODULE, MateMixerBackendModule))
+#define MATE_MIXER_IS_BACKEND_MODULE(o) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_BACKEND_MODULE))
+#define MATE_MIXER_BACKEND_MODULE_CLASS(k) \
+ (G_TYPE_CHECK_CLASS_CAST ((k), MATE_MIXER_TYPE_BACKEND_MODULE, MateMixerBackendModuleClass))
+#define MATE_MIXER_IS_BACKEND_MODULE_CLASS(k) \
+ (G_TYPE_CLASS_CHECK_CLASS_TYPE ((k), MATE_MIXER_TYPE_BACKEND_MODULE))
+#define MATE_MIXER_BACKEND_MODULE_GET_CLASS(o) \
+ (G_TYPE_INSTANCE_GET_CLASS ((o), MATE_MIXER_TYPE_BACKEND_MODULE, MateMixerBackendModuleClass))
+
+typedef struct _MateMixerBackendModule MateMixerBackendModule;
+typedef struct _MateMixerBackendModuleClass MateMixerBackendModuleClass;
+typedef struct _MateMixerBackendModuleInfo MateMixerBackendModuleInfo;
+typedef struct _MateMixerBackendModulePrivate MateMixerBackendModulePrivate;
+
+struct _MateMixerBackendModuleInfo
+{
+ gchar *name;
+ guint priority;
+ GType g_type;
+
+ MateMixerBackendType backend_type;
+};
+
+struct _MateMixerBackendModule
+{
+ GTypeModule parent;
+
+ MateMixerBackendModulePrivate *priv;
+};
+
+struct _MateMixerBackendModuleClass
+{
+ GTypeModuleClass parent;
+};
+
+GType mate_mixer_backend_module_get_type (void) G_GNUC_CONST;
+
+MateMixerBackendModule *mate_mixer_backend_module_new (const gchar *path);
+const MateMixerBackendModuleInfo *mate_mixer_backend_module_get_info (MateMixerBackendModule *module);
+const gchar *mate_mixer_backend_module_get_path (MateMixerBackendModule *module);
+
+G_END_DECLS
+
+#endif /* MATEMIXER_BACKEND_MODULE_H */
diff --git a/libmatemixer/matemixer-backend.c b/libmatemixer/matemixer-backend.c
new file mode 100644
index 0000000..9533e0f
--- /dev/null
+++ b/libmatemixer/matemixer-backend.c
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "matemixer-backend.h"
+
+G_DEFINE_INTERFACE (MateMixerBackend, mate_mixer_backend, G_TYPE_OBJECT)
+
+static void
+mate_mixer_backend_default_init (MateMixerBackendInterface *iface)
+{
+}
+
+gboolean
+mate_mixer_backend_open (MateMixerBackend *backend)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), NULL);
+
+ return MATE_MIXER_BACKEND_GET_INTERFACE (backend)->open (backend);
+}
+
+void
+mate_mixer_backend_close (MateMixerBackend *backend)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), NULL);
+
+ MATE_MIXER_BACKEND_GET_INTERFACE (backend)->close (backend);
+}
+
+const GList *
+mate_mixer_backend_list_devices (MateMixerBackend *backend)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), NULL);
+
+ return MATE_MIXER_BACKEND_GET_INTERFACE (backend)->list_devices (backend);
+}
+
+const GList *
+mate_mixer_backend_list_tracks (MateMixerBackend *backend)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_BACKEND (backend), NULL);
+
+ return MATE_MIXER_BACKEND_GET_INTERFACE (backend)->list_tracks (backend);
+}
diff --git a/libmatemixer/matemixer-backend.h b/libmatemixer/matemixer-backend.h
new file mode 100644
index 0000000..6b0c318
--- /dev/null
+++ b/libmatemixer/matemixer-backend.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_BACKEND_H
+#define MATEMIXER_BACKEND_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <libmatemixer/matemixer-enums.h>
+
+G_BEGIN_DECLS
+
+#define MATE_MIXER_TYPE_BACKEND \
+ (mate_mixer_backend_get_type ())
+#define MATE_MIXER_BACKEND(o) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_BACKEND, MateMixerBackend))
+#define MATE_MIXER_IS_BACKEND(o) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_BACKEND))
+#define MATE_MIXER_BACKEND_GET_INTERFACE(o) \
+ (G_TYPE_INSTANCE_GET_INTERFACE ((o), MATE_MIXER_TYPE_BACKEND, MateMixerBackendInterface))
+
+typedef struct _MateMixerBackend MateMixerBackend; /* dummy object */
+typedef struct _MateMixerBackendInterface MateMixerBackendInterface;
+
+struct _MateMixerBackendInterface
+{
+ GTypeInterface parent;
+
+ gboolean (*open) (MateMixerBackend *backend);
+ void (*close) (MateMixerBackend *backend);
+ const GList *(*list_devices) (MateMixerBackend *backend);
+ const GList *(*list_tracks) (MateMixerBackend *backend);
+};
+
+GType mate_mixer_backend_get_type (void) G_GNUC_CONST;
+
+gboolean mate_mixer_backend_open (MateMixerBackend *backend);
+void mate_mixer_backend_close (MateMixerBackend *backend);
+const GList *mate_mixer_backend_list_devices (MateMixerBackend *backend);
+const GList *mate_mixer_backend_list_tracks (MateMixerBackend *backend);
+
+G_END_DECLS
+
+#endif /* MATEMIXER_BACKEND_H */
diff --git a/libmatemixer/matemixer-control.c b/libmatemixer/matemixer-control.c
new file mode 100644
index 0000000..c3489e6
--- /dev/null
+++ b/libmatemixer/matemixer-control.c
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "matemixer-backend.h"
+#include "matemixer-backend-module.h"
+#include "matemixer-control.h"
+#include "matemixer-enums.h"
+#include "matemixer-private.h"
+#include "matemixer-track.h"
+
+struct _MateMixerControlPrivate
+{
+ MateMixerBackend *backend;
+ GHashTable *devices;
+ GHashTable *tracks;
+};
+
+G_DEFINE_TYPE (MateMixerControl, mate_mixer_control, G_TYPE_OBJECT);
+
+G_LOCK_DEFINE_STATIC (mixer_control_get_modules_lock);
+
+static MateMixerBackend *mixer_control_init_module (MateMixerBackendModule *module);
+
+static void
+mate_mixer_control_init (MateMixerControl *control)
+{
+ control->priv = G_TYPE_INSTANCE_GET_PRIVATE (
+ control,
+ MATE_MIXER_TYPE_CONTROL,
+ MateMixerControlPrivate);
+
+ control->priv->devices = g_hash_table_new_full (
+ g_direct_hash,
+ g_direct_equal,
+ NULL,
+ g_object_unref);
+
+ control->priv->tracks = g_hash_table_new_full (
+ g_direct_hash,
+ g_direct_equal,
+ NULL,
+ g_object_unref);
+}
+
+static void
+mate_mixer_control_finalize (GObject *object)
+{
+ MateMixerControl *control;
+
+ control = MATE_MIXER_CONTROL (object);
+
+ g_object_unref (control->priv->backend);
+ g_hash_table_destroy (control->priv->devices);
+ g_hash_table_destroy (control->priv->tracks);
+
+ G_OBJECT_CLASS (mate_mixer_control_parent_class)->finalize (object);
+}
+
+static void
+mate_mixer_control_class_init (MateMixerControlClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = mate_mixer_control_finalize;
+
+ g_type_class_add_private (object_class, sizeof (MateMixerControlPrivate));
+}
+
+MateMixerControl *
+mate_mixer_control_new (void)
+{
+ GList *modules;
+ MateMixerControl *control;
+ MateMixerBackend *backend = NULL;
+
+ if (!mate_mixer_is_initialized ()) {
+ g_critical ("The library has not been initialized");
+ return NULL;
+ }
+
+ G_LOCK (mixer_control_get_modules_lock);
+
+ modules = mate_mixer_get_modules ();
+ while (modules) {
+ MateMixerBackendModule *module;
+
+ module = MATE_MIXER_BACKEND_MODULE (modules->data);
+ backend = mixer_control_init_module (module);
+ if (backend != NULL)
+ break;
+
+ modules = modules->next;
+ }
+
+ G_UNLOCK (mixer_control_get_modules_lock);
+
+ /* The last module in the priority list is the "null" module which
+ * should always be initialized correctly, but in case "null" is absent
+ * all the other modules might fail their initializations */
+ if (backend == NULL)
+ return NULL;
+
+ control = g_object_new (MATE_MIXER_TYPE_CONTROL, NULL);
+ control->priv->backend = backend;
+
+ return control;
+}
+
+MateMixerControl *
+mate_mixer_control_new_backend (MateMixerBackendType backend_type)
+{
+ GList *modules;
+ MateMixerControl *control;
+ MateMixerBackend *backend = NULL;
+
+ if (!mate_mixer_is_initialized ()) {
+ g_critical ("The library has not been initialized");
+ return NULL;
+ }
+
+ G_LOCK (mixer_control_get_modules_lock);
+
+ modules = mate_mixer_get_modules ();
+
+ while (modules) {
+ MateMixerBackendModule *module;
+ const MateMixerBackendModuleInfo *info;
+
+ module = MATE_MIXER_BACKEND_MODULE (modules->data);
+ info = mate_mixer_backend_module_get_info (module);
+
+ if (info->backend_type == backend_type) {
+ backend = mixer_control_init_module (module);
+ break;
+ }
+ modules = modules->next;
+ }
+
+ G_UNLOCK (mixer_control_get_modules_lock);
+
+ /* The initialization might fail or the selected module might be absent */
+ if (backend == NULL)
+ return NULL;
+
+ control = g_object_new (MATE_MIXER_TYPE_CONTROL, NULL);
+ control->priv->backend = backend;
+
+ return control;
+}
+
+const GList *
+mate_mixer_control_list_devices (MateMixerControl *control)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_CONTROL (control), NULL);
+
+ // XXX
+ // this is the midpoint between MateMixerDevice implementation and
+ // the application, probably the list could be cached here but the
+ // implementation uses a hash table, figure out how to do this properly
+
+ return mate_mixer_backend_list_devices (MATE_MIXER_BACKEND (control->priv->backend));
+}
+
+const GList *
+mate_mixer_control_list_tracks (MateMixerControl *control)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_CONTROL (control), NULL);
+
+ return mate_mixer_backend_list_tracks (MATE_MIXER_BACKEND (control->priv->backend));
+}
+
+static MateMixerBackend *
+mixer_control_init_module (MateMixerBackendModule *module)
+{
+ MateMixerBackend *backend;
+ const MateMixerBackendModuleInfo *info;
+
+ info = mate_mixer_backend_module_get_info (module);
+ if (G_UNLIKELY (info == NULL)) {
+ g_warning ("Backend module %s does not provide module information",
+ mate_mixer_backend_module_get_path (module));
+ return NULL;
+ }
+
+ backend = g_object_newv (info->g_type, 0, NULL);
+
+ if (!mate_mixer_backend_open (backend)) {
+ g_object_unref (backend);
+ return NULL;
+ }
+ return backend;
+}
diff --git a/libmatemixer/matemixer-control.h b/libmatemixer/matemixer-control.h
new file mode 100644
index 0000000..010cbfa
--- /dev/null
+++ b/libmatemixer/matemixer-control.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_CONTROL_H
+#define MATEMIXER_CONTROL_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "matemixer-enums.h"
+
+G_BEGIN_DECLS
+
+#define MATE_MIXER_TYPE_CONTROL \
+ (mate_mixer_control_get_type ())
+#define MATE_MIXER_CONTROL(o) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_CONTROL, MateMixerControl))
+#define MATE_MIXER_IS_CONTROL(o) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_CONTROL))
+#define MATE_MIXER_CONTROL_CLASS(k) \
+ (G_TYPE_CHECK_CLASS_CAST ((k), MATE_MIXER_TYPE_CONTROL, MateMixerControlClass))
+#define MATE_MIXER_IS_CONTROL_CLASS(k) \
+ (G_TYPE_CLASS_CHECK_CLASS_TYPE ((k), MATE_MIXER_TYPE_CONTROL))
+#define MATE_MIXER_CONTROL_GET_CLASS(o) \
+ (G_TYPE_INSTANCE_GET_CLASS ((o), MATE_MIXER_TYPE_CONTROL, MateMixerControlClass))
+
+typedef struct _MateMixerControl MateMixerControl;
+typedef struct _MateMixerControlClass MateMixerControlClass;
+typedef struct _MateMixerControlPrivate MateMixerControlPrivate;
+
+struct _MateMixerControl
+{
+ GObject parent;
+
+ MateMixerControlPrivate *priv;
+};
+
+struct _MateMixerControlClass
+{
+ GObjectClass parent;
+};
+
+GType mate_mixer_control_get_type (void) G_GNUC_CONST;
+
+MateMixerControl *mate_mixer_control_new (void);
+MateMixerControl *mate_mixer_control_new_backend (MateMixerBackendType backend_type);
+const GList *mate_mixer_control_list_devices (MateMixerControl *control);
+const GList *mate_mixer_control_list_tracks (MateMixerControl *control);
+
+G_END_DECLS
+
+#endif /* MATEMIXER_CONTROL_H */
diff --git a/libmatemixer/matemixer-device-port.c b/libmatemixer/matemixer-device-port.c
new file mode 100644
index 0000000..9443879
--- /dev/null
+++ b/libmatemixer/matemixer-device-port.c
@@ -0,0 +1,220 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "matemixer-device-port.h"
+#include "matemixer-enums.h"
+
+struct _MateMixerDevicePortPrivate
+{
+ gchar *identifier;
+ gchar *name;
+ gchar *icon;
+ guint32 priority;
+ gint64 latency_offset;
+
+ MateMixerDevicePortDirection direction;
+ MateMixerDevicePortStatus status;
+};
+
+enum
+{
+ PROP_0,
+ PROP_IDENTIFIER,
+ PROP_NAME,
+ PROP_ICON,
+ PROP_PRIORITY,
+ // PROP_DIRECTION,
+ // PROP_STATUS,
+ PROP_LATENCY_OFFSET,
+ N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
+
+G_DEFINE_TYPE (MateMixerDevicePort, mate_mixer_device_port, G_TYPE_OBJECT);
+
+static void
+mate_mixer_device_port_init (MateMixerDevicePort *port)
+{
+ port->priv = G_TYPE_INSTANCE_GET_PRIVATE (
+ port,
+ MATE_MIXER_TYPE_DEVICE_PORT,
+ MateMixerDevicePortPrivate);
+}
+
+static void
+mate_mixer_device_port_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ MateMixerDevicePort *port;
+
+ port = MATE_MIXER_DEVICE_PORT (object);
+
+ switch (param_id) {
+ case PROP_IDENTIFIER:
+ g_value_set_string (value, port->priv->identifier);
+ break;
+ case PROP_NAME:
+ g_value_set_string (value, port->priv->name);
+ break;
+ case PROP_ICON:
+ g_value_set_string (value, port->priv->icon);
+ break;
+ case PROP_PRIORITY:
+ g_value_set_uint (value, port->priv->priority);
+ break;
+ // case PROP_DIRECTION:
+ // break;
+ // case PROP_STATUS:
+ // break;
+ case PROP_LATENCY_OFFSET:
+ g_value_set_int64 (value, port->priv->latency_offset);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+mate_mixer_device_port_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ MateMixerDevicePort *port;
+
+ port = MATE_MIXER_DEVICE_PORT (object);
+
+ switch (param_id) {
+ case PROP_IDENTIFIER:
+ port->priv->identifier = g_strdup (g_value_get_string (value));
+ break;
+ case PROP_NAME:
+ port->priv->name = g_strdup (g_value_get_string (value));
+ break;
+ case PROP_ICON:
+ port->priv->icon = g_strdup (g_value_get_string (value));
+ break;
+ case PROP_PRIORITY:
+ port->priv->priority = g_value_get_uint (value);
+ break;
+ // case PROP_DIRECTION:
+ // break;
+ // case PROP_STATUS:
+ // break;
+ case PROP_LATENCY_OFFSET:
+ port->priv->latency_offset = g_value_get_int64 (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+mate_mixer_device_port_finalize (GObject *object)
+{
+ MateMixerDevicePort *port;
+
+ port = MATE_MIXER_DEVICE_PORT (object);
+
+ g_free (port->priv->identifier);
+ g_free (port->priv->name);
+ g_free (port->priv->icon);
+
+ G_OBJECT_CLASS (mate_mixer_device_port_parent_class)->finalize (object);
+}
+
+static void
+mate_mixer_device_port_class_init (MateMixerDevicePortClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = mate_mixer_device_port_finalize;
+ object_class->get_property = mate_mixer_device_port_get_property;
+ object_class->set_property = mate_mixer_device_port_set_property;
+
+ properties[PROP_IDENTIFIER] = g_param_spec_string(
+ "identifier",
+ "Identifier",
+ "Identifier of the device port",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
+
+ properties[PROP_NAME] = g_param_spec_string(
+ "name",
+ "Name",
+ "Name of the device port",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
+
+ properties[PROP_ICON] = g_param_spec_string(
+ "icon",
+ "Icon",
+ "Icon name for the device port",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
+
+ properties[PROP_PRIORITY] = g_param_spec_uint(
+ "priority",
+ "Priority",
+ "Priority of the device port",
+ 0,
+ G_MAXUINT32,
+ 0,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
+
+ properties[PROP_LATENCY_OFFSET] = g_param_spec_int64(
+ "latency-offset",
+ "Latency offset",
+ "Latency offset of the device port",
+ G_MININT64,
+ G_MAXINT64,
+ 0,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
+
+ g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+
+ g_type_class_add_private (object_class, sizeof (MateMixerDevicePortPrivate));
+}
+
+MateMixerDevicePort *
+mate_mixer_device_port_new (const gchar *identifier,
+ const gchar *name,
+ const gchar *icon,
+ guint32 priority,
+ MateMixerDevicePortDirection direction,
+ MateMixerDevicePortStatus status,
+ gint64 latency_offset)
+{
+ return g_object_new (MATE_MIXER_TYPE_DEVICE_PORT,
+ "identifier", identifier,
+ "name", name,
+ "icon", icon,
+ "priority", priority,
+ //"direction", direction,
+ //"status", status,
+ "latency-offset", latency_offset,
+ NULL);
+}
diff --git a/libmatemixer/matemixer-device-port.h b/libmatemixer/matemixer-device-port.h
new file mode 100644
index 0000000..d411c89
--- /dev/null
+++ b/libmatemixer/matemixer-device-port.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_DEVICE_PORT_H
+#define MATEMIXER_DEVICE_PORT_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <libmatemixer/matemixer-enums.h>
+
+G_BEGIN_DECLS
+
+#define MATE_MIXER_TYPE_DEVICE_PORT \
+ (mate_mixer_device_port_get_type ())
+#define MATE_MIXER_DEVICE_PORT(o) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_DEVICE_PORT, MateMixerDevicePort))
+#define MATE_MIXER_IS_DEVICE_PORT(o) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_DEVICE_PORT))
+#define MATE_MIXER_DEVICE_PORT_CLASS(k) \
+ (G_TYPE_CHECK_CLASS_CAST ((k), MATE_MIXER_TYPE_DEVICE_PORT, MateMixerDevicePortClass))
+#define MATE_MIXER_IS_DEVICE_PORT_CLASS(k) \
+ (G_TYPE_CLASS_CHECK_CLASS_TYPE ((k), MATE_MIXER_TYPE_DEVICE_PORT))
+#define MATE_MIXER_DEVICE_PORT_GET_CLASS(o) \
+ (G_TYPE_INSTANCE_GET_CLASS ((o), MATE_MIXER_TYPE_DEVICE_PORT, MateMixerDevicePortClass))
+
+typedef struct _MateMixerDevicePort MateMixerDevicePort;
+typedef struct _MateMixerDevicePortClass MateMixerDevicePortClass;
+typedef struct _MateMixerDevicePortPrivate MateMixerDevicePortPrivate;
+
+struct _MateMixerDevicePort
+{
+ GObject parent;
+
+ MateMixerDevicePortPrivate *priv;
+};
+
+struct _MateMixerDevicePortClass
+{
+ GObjectClass parent;
+};
+
+GType mate_mixer_device_port_get_type (void) G_GNUC_CONST;
+
+MateMixerDevicePort *mate_mixer_device_port_new (const gchar *identifier,
+ const gchar *name,
+ const gchar *icon,
+ guint32 priority,
+ MateMixerDevicePortDirection direction,
+ MateMixerDevicePortStatus status,
+ gint64 latency_offset);
+
+G_END_DECLS
+
+#endif /* MATEMIXER_PORT_H */
diff --git a/libmatemixer/matemixer-device-profile.c b/libmatemixer/matemixer-device-profile.c
new file mode 100644
index 0000000..bfcbe6a
--- /dev/null
+++ b/libmatemixer/matemixer-device-profile.c
@@ -0,0 +1,165 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "matemixer-device-profile.h"
+
+struct _MateMixerDeviceProfilePrivate
+{
+ gchar *identifier;
+ gchar *name;
+ guint32 priority;
+};
+
+enum
+{
+ PROP_0,
+ PROP_IDENTIFIER,
+ PROP_NAME,
+ PROP_PRIORITY,
+ N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
+
+G_DEFINE_TYPE (MateMixerDeviceProfile, mate_mixer_device_profile, G_TYPE_OBJECT);
+
+static void
+mate_mixer_device_profile_init (MateMixerDeviceProfile *profile)
+{
+ profile->priv = G_TYPE_INSTANCE_GET_PRIVATE (
+ profile,
+ MATE_MIXER_TYPE_DEVICE_PROFILE,
+ MateMixerDeviceProfilePrivate);
+}
+
+static void
+mate_mixer_device_profile_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ MateMixerDeviceProfile *profile;
+
+ profile = MATE_MIXER_DEVICE_PROFILE (object);
+
+ switch (param_id) {
+ case PROP_IDENTIFIER:
+ g_value_set_string (value, profile->priv->identifier);
+ break;
+ case PROP_NAME:
+ g_value_set_string (value, profile->priv->name);
+ break;
+ case PROP_PRIORITY:
+ g_value_set_uint (value, profile->priv->priority);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+mate_mixer_device_profile_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ MateMixerDeviceProfile *profile;
+
+ profile = MATE_MIXER_DEVICE_PROFILE (object);
+
+ switch (param_id) {
+ case PROP_IDENTIFIER:
+ profile->priv->identifier = g_strdup (g_value_get_string (value));
+ break;
+ case PROP_NAME:
+ profile->priv->name = g_strdup (g_value_get_string (value));
+ break;
+ case PROP_PRIORITY:
+ profile->priv->priority = g_value_get_uint (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ }
+}
+
+static void
+mate_mixer_device_profile_finalize (GObject *object)
+{
+ MateMixerDeviceProfile *profile;
+
+ profile = MATE_MIXER_DEVICE_PROFILE (object);
+
+ g_free (profile->priv->identifier);
+ g_free (profile->priv->name);
+
+ G_OBJECT_CLASS (mate_mixer_device_profile_parent_class)->finalize (object);
+}
+
+static void
+mate_mixer_device_profile_class_init (MateMixerDeviceProfileClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = mate_mixer_device_profile_finalize;
+ object_class->get_property = mate_mixer_device_profile_get_property;
+ object_class->set_property = mate_mixer_device_profile_set_property;
+
+ properties[PROP_IDENTIFIER] = g_param_spec_string(
+ "identifier",
+ "Identifier",
+ "Identifier of the device profile",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
+
+ properties[PROP_NAME] = g_param_spec_string(
+ "name",
+ "Name",
+ "Name of the device profile",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
+
+ properties[PROP_PRIORITY] = g_param_spec_uint(
+ "priority",
+ "Priority",
+ "Priority of the device profile",
+ 0,
+ G_MAXUINT32,
+ 0,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
+
+ g_object_class_install_properties (object_class, N_PROPERTIES, properties);
+
+ g_type_class_add_private (object_class, sizeof (MateMixerDeviceProfilePrivate));
+}
+
+MateMixerDeviceProfile *
+mate_mixer_device_profile_new (const gchar *identifier,
+ const gchar *name,
+ guint32 priority)
+{
+ return g_object_new (MATE_MIXER_TYPE_DEVICE_PROFILE,
+ "identifier", identifier,
+ "name", name,
+ "priority", priority,
+ NULL);
+}
diff --git a/libmatemixer/matemixer-device-profile.h b/libmatemixer/matemixer-device-profile.h
new file mode 100644
index 0000000..fa750b8
--- /dev/null
+++ b/libmatemixer/matemixer-device-profile.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_DEVICE_PROFILE_H
+#define MATEMIXER_DEVICE_PROFILE_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define MATE_MIXER_TYPE_DEVICE_PROFILE \
+ (mate_mixer_device_profile_get_type ())
+#define MATE_MIXER_DEVICE_PROFILE(o) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_DEVICE_PROFILE, MateMixerDeviceProfile))
+#define MATE_MIXER_IS_DEVICE_PROFILE(o) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_DEVICE_PROFILE))
+#define MATE_MIXER_DEVICE_PROFILE_CLASS(k) \
+ (G_TYPE_CHECK_CLASS_CAST ((k), MATE_MIXER_TYPE_DEVICE_PROFILE, MateMixerDeviceProfileClass))
+#define MATE_MIXER_IS_DEVICE_PROFILE_CLASS(k) \
+ (G_TYPE_CLASS_CHECK_CLASS_TYPE ((k), MATE_MIXER_TYPE_DEVICE_PROFILE))
+#define MATE_MIXER_DEVICE_PROFILE_GET_CLASS(o) \
+ (G_TYPE_INSTANCE_GET_CLASS ((o), MATE_MIXER_TYPE_DEVICE_PROFILE, MateMixerDeviceProfileClass))
+
+typedef struct _MateMixerDeviceProfile MateMixerDeviceProfile;
+typedef struct _MateMixerDeviceProfileClass MateMixerDeviceProfileClass;
+typedef struct _MateMixerDeviceProfilePrivate MateMixerDeviceProfilePrivate;
+
+struct _MateMixerDeviceProfile
+{
+ GObject parent;
+
+ MateMixerDeviceProfilePrivate *priv;
+};
+
+struct _MateMixerDeviceProfileClass
+{
+ GObjectClass parent;
+};
+
+GType mate_mixer_device_profile_get_type (void) G_GNUC_CONST;
+
+MateMixerDeviceProfile *mate_mixer_device_profile_new (const gchar *identifier,
+ const gchar *name,
+ guint32 priority);
+
+G_END_DECLS
+
+#endif /* MATEMIXER_PROFILE_H */
diff --git a/libmatemixer/matemixer-device.c b/libmatemixer/matemixer-device.c
new file mode 100644
index 0000000..0c36b0b
--- /dev/null
+++ b/libmatemixer/matemixer-device.c
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "matemixer-device.h"
+#include "matemixer-device-profile.h"
+
+G_DEFINE_INTERFACE (MateMixerDevice, mate_mixer_device, G_TYPE_OBJECT)
+
+static void
+mate_mixer_device_default_init (MateMixerDeviceInterface *iface)
+{
+ g_object_interface_install_property (
+ iface,
+ g_param_spec_string ("identifier",
+ "Identifier",
+ "Identifier of the sound device",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+
+ g_object_interface_install_property (
+ iface,
+ g_param_spec_string ("name",
+ "Name",
+ "Name of the sound device",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+
+ g_object_interface_install_property (
+ iface,
+ g_param_spec_string ("icon",
+ "Icon",
+ "Name of the sound device icon",
+ NULL,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+
+ g_object_interface_install_property (
+ iface,
+ g_param_spec_object ("active-profile",
+ "Active profile",
+ "Identifier of the currently active profile",
+ MATE_MIXER_TYPE_DEVICE_PROFILE,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE));
+}
+
+const GList *
+mate_mixer_device_list_tracks (MateMixerDevice *device)
+{
+ g_return_val_if_fail (MATE_MIXER_IS_DEVICE (device), NULL);
+
+ return MATE_MIXER_DEVICE_GET_INTERFACE (device)->list_tracks (device);
+}
diff --git a/libmatemixer/matemixer-device.h b/libmatemixer/matemixer-device.h
new file mode 100644
index 0000000..af5a1ce
--- /dev/null
+++ b/libmatemixer/matemixer-device.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_DEVICE_H
+#define MATEMIXER_DEVICE_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define MATE_MIXER_TYPE_DEVICE \
+ (mate_mixer_device_get_type ())
+#define MATE_MIXER_DEVICE(o) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_DEVICE, MateMixerDevice))
+#define MATE_MIXER_IS_DEVICE(o) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_DEVICE))
+#define MATE_MIXER_DEVICE_GET_INTERFACE(o) \
+ (G_TYPE_INSTANCE_GET_INTERFACE ((o), MATE_MIXER_TYPE_DEVICE, MateMixerDeviceInterface))
+
+typedef struct _MateMixerDevice MateMixerDevice; /* dummy object */
+typedef struct _MateMixerDeviceInterface MateMixerDeviceInterface;
+
+struct _MateMixerDeviceInterface
+{
+ GTypeInterface parent;
+
+ const GList *(*list_tracks) (MateMixerDevice *device);
+};
+
+GType mate_mixer_device_get_type (void) G_GNUC_CONST;
+
+const GList *mate_mixer_device_list_tracks (MateMixerDevice *device);
+
+G_END_DECLS
+
+#endif /* MATEMIXER_DEVICE_H */
diff --git a/libmatemixer/matemixer-enum-types.c.template b/libmatemixer/matemixer-enum-types.c.template
new file mode 100644
index 0000000..475aed7
--- /dev/null
+++ b/libmatemixer/matemixer-enum-types.c.template
@@ -0,0 +1,36 @@
+/*** BEGIN file-header ***/
+#include "matemixer-enum-types.h"
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@filename@" */
+#include "@filename@"
+
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType
+@enum_name@_get_type (void)
+{
+ static GType etype = 0;
+
+ if (etype == 0) {
+ static const G@Type@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+ { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+ { 0, NULL, NULL }
+ };
+ etype = g_@type@_register_static (
+ g_intern_static_string ("@EnumName@"),
+ values);
+ }
+ return etype;
+}
+
+/*** END value-tail ***/
diff --git a/libmatemixer/matemixer-enum-types.h.template b/libmatemixer/matemixer-enum-types.h.template
new file mode 100644
index 0000000..55f405a
--- /dev/null
+++ b/libmatemixer/matemixer-enum-types.h.template
@@ -0,0 +1,26 @@
+/*** BEGIN file-header ***/
+#ifndef MATEMIXER_ENUM_TYPES_H
+#define MATEMIXER_ENUM_TYPES_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* Enumerations from "@filename@" */
+
+/*** END file-production ***/
+
+/*** BEGIN enumeration-production ***/
+#define MATE_MIXER_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
+GType @enum_name@_get_type (void) G_GNUC_CONST;
+
+/*** END enumeration-production ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* MATEMIXER_ENUM_TYPES_H */
+/*** END file-tail ***/
diff --git a/libmatemixer/matemixer-enums.h b/libmatemixer/matemixer-enums.h
new file mode 100644
index 0000000..445af7d
--- /dev/null
+++ b/libmatemixer/matemixer-enums.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_ENUMS_H
+#define MATEMIXER_ENUMS_H
+
+typedef enum {
+ MATE_MIXER_BACKEND_TYPE_PULSE,
+ MATE_MIXER_BACKEND_TYPE_NULL
+} MateMixerBackendType;
+
+typedef enum { /*< flags >*/
+ MATE_MIXER_DEVICE_PORT_DIRECTION_INPUT = 1 << 0,
+ MATE_MIXER_DEVICE_PORT_DIRECTION_OUTPUT = 1 << 1
+} MateMixerDevicePortDirection;
+
+typedef enum { /*< flags >*/
+ MATE_MIXER_DEVICE_PORT_STATUS_AVAILABLE = 1 << 0
+} MateMixerDevicePortStatus;
+
+#endif /* MATEMIXER_ENUMS_H */
diff --git a/libmatemixer/matemixer-private.h b/libmatemixer/matemixer-private.h
new file mode 100644
index 0000000..8f95664
--- /dev/null
+++ b/libmatemixer/matemixer-private.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_PRIVATE_H
+#define MATEMIXER_PRIVATE_H
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+GList *mate_mixer_get_modules (void);
+gboolean mate_mixer_is_initialized (void);
+
+G_END_DECLS
+
+#endif /* MATEMIXER_PRIVATE_H */
diff --git a/libmatemixer/matemixer-track.c b/libmatemixer/matemixer-track.c
new file mode 100644
index 0000000..f78c4f8
--- /dev/null
+++ b/libmatemixer/matemixer-track.c
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "matemixer-track.h"
+
+G_DEFINE_INTERFACE (MateMixerTrack, mate_mixer_track, G_TYPE_OBJECT)
+
+static void
+mate_mixer_track_default_init (MateMixerTrackInterface *iface)
+{
+ // TODO: properties
+}
diff --git a/libmatemixer/matemixer-track.h b/libmatemixer/matemixer-track.h
new file mode 100644
index 0000000..a535b59
--- /dev/null
+++ b/libmatemixer/matemixer-track.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_TRACK_H
+#define MATEMIXER_TRACK_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define MATE_MIXER_TYPE_TRACK \
+ (mate_mixer_track_get_type ())
+#define MATE_MIXER_TRACK(o) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((o), MATE_MIXER_TYPE_TRACK, MateMixerTrack))
+#define MATE_MIXER_IS_TRACK(o) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((o), MATE_MIXER_TYPE_TRACK))
+#define MATE_MIXER_TRACK_GET_INTERFACE(o) \
+ (G_TYPE_INSTANCE_GET_INTERFACE ((o), MATE_MIXER_TYPE_TRACK, MateMixerTrackInterface))
+
+typedef struct _MateMixerTrack MateMixerTrack; /* dummy object */
+typedef struct _MateMixerTrackInterface MateMixerTrackInterface;
+
+struct _MateMixerTrackInterface
+{
+ GTypeInterface parent;
+};
+
+GType mate_mixer_track_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* MATEMIXER_TRACK_H */
diff --git a/libmatemixer/matemixer.c b/libmatemixer/matemixer.c
new file mode 100644
index 0000000..6c25cc5
--- /dev/null
+++ b/libmatemixer/matemixer.c
@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gmodule.h>
+
+#include "matemixer.h"
+#include "matemixer-private.h"
+#include "matemixer-backend-module.h"
+
+static gboolean mixer_load_backends (void);
+static gint mixer_compare_modules (gconstpointer a, gconstpointer b);
+
+static GList *mixer_modules = NULL;
+static gboolean mixer_initialized = FALSE;
+
+gboolean
+mate_mixer_init (void)
+{
+ if (!mixer_initialized)
+ mixer_initialized = mixer_load_backends ();
+
+ return mixer_initialized;
+}
+
+void
+mate_mixer_deinit (void)
+{
+ GList *list;
+
+ if (!mixer_initialized)
+ return;
+
+ list = mixer_modules;
+ while (list) {
+ MateMixerBackendModule *module;
+
+ module = MATE_MIXER_BACKEND_MODULE (list->data);
+
+ g_type_module_unuse (G_TYPE_MODULE (module));
+
+ // XXX it is not possible to unref the module, figure out how
+ // to handle repeated initialization
+ // g_object_unref (module);
+
+ list = list->next;
+ }
+ g_list_free (mixer_modules);
+
+ mixer_initialized = FALSE;
+}
+
+/* Internal function: return a *shared* list of loaded backend modules */
+GList *
+mate_mixer_get_modules (void)
+{
+ return mixer_modules;
+}
+
+/* Internal function: return TRUE if the library has been initialized */
+gboolean
+mate_mixer_is_initialized (void)
+{
+ gboolean initialized;
+
+ G_LOCK_DEFINE_STATIC (mixer_initialized_lock);
+
+ G_LOCK (mixer_initialized_lock);
+ initialized = mixer_initialized;
+ G_UNLOCK (mixer_initialized_lock);
+
+ return initialized;
+}
+
+static gboolean
+mixer_load_backends (void)
+{
+ GDir *dir;
+ GError *error = NULL;
+
+ if (!g_module_supported ()) {
+ g_critical ("Unable to load backend modules: GModule not supported");
+ return FALSE;
+ }
+
+ /* Read the directory which contains module libraries and load them */
+ dir = g_dir_open (LIBMATEMIXER_BACKEND_DIR, 0, &error);
+ if (dir != NULL) {
+ const gchar *name;
+
+ while ((name = g_dir_read_name (dir)) != NULL) {
+ gchar *file;
+ MateMixerBackendModule *module;
+
+ if (!g_str_has_suffix (name, "." G_MODULE_SUFFIX))
+ continue;
+
+ file = g_build_filename (LIBMATEMIXER_BACKEND_DIR, name, NULL);
+ module = mate_mixer_backend_module_new (file);
+
+ /* Load the backend module and make sure it includes all the
+ * required symbols */
+ if (g_type_module_use (G_TYPE_MODULE (module)))
+ mixer_modules = g_list_prepend (mixer_modules, module);
+ else
+ g_object_unref (module);
+
+ g_free (file);
+ }
+
+ if (mixer_modules == NULL)
+ g_critical ("No usable backend modules have been found");
+
+ g_dir_close (dir);
+ } else {
+ g_critical ("%s", error->message);
+ g_error_free (error);
+ }
+
+ if (mixer_modules) {
+ mixer_modules = g_list_sort (mixer_modules, mixer_compare_modules);
+ return TRUE;
+ }
+
+ /* As we include a "null" backend module to provide no functionality,
+ * we fail the initialization in case no module could be loaded */
+ return FALSE;
+}
+
+/* GCompareFunc function to sort backend modules by the priority, lower
+ * number means higher priority */
+static gint
+mixer_compare_modules (gconstpointer a, gconstpointer b)
+{
+ const MateMixerBackendModuleInfo *info1, *info2;
+
+ info1 = mate_mixer_backend_module_get_info (MATE_MIXER_BACKEND_MODULE (a));
+ info2 = mate_mixer_backend_module_get_info (MATE_MIXER_BACKEND_MODULE (b));
+
+ return info1->priority - info2->priority;
+}
diff --git a/libmatemixer/matemixer.h b/libmatemixer/matemixer.h
new file mode 100644
index 0000000..8a62320
--- /dev/null
+++ b/libmatemixer/matemixer.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2014 Michal Ratajsky <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the licence, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MATEMIXER_H
+#define MATEMIXER_H
+
+#include <glib.h>
+#include <libmatemixer/matemixer-control.h>
+#include <libmatemixer/matemixer-device.h>
+#include <libmatemixer/matemixer-enums.h>
+#include <libmatemixer/matemixer-track.h>
+
+G_BEGIN_DECLS
+
+gboolean mate_mixer_init (void);
+void mate_mixer_deinit (void);
+
+G_END_DECLS
+
+#endif /* MATEMIXER_H */