~ubuntu-branches/ubuntu/trusty/portmidi/trusty

« back to all changes in this revision

Viewing changes to pm_mac/finddefault.c

  • Committer: Bazaar Package Importer
  • Author(s): Paul Brossier
  • Date: 2009-09-16 06:50:57 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090916065057-lz24lbrrygyev85b
Tags: 1:131-1
* New upstream version, uses epoch (closes: #501132)
* debian/watch: update to match new download location and version
  numbering (closes: #450055), but still fails due to zip format
* Add depends on quilt, move patches to debian/patches
* Add Homepage to debian/control
* debian/control: use ${binary:Version}, bump to S-V 3.8.3
* debian/compat: bump to 5
* debian/copyright: update to match license.txt and add missing copyrights
* debian/patches/02_pmlinuxalsa.diff: remove merged hunks
* debian/patches/04_ptlinux.diff: remove merged hunks
* debian/patches/05_makefile.diff: merge and link portmidi to porttime,
  thanks to Willem van Engen (closes: #515712)
* debian/rules: use pm_linux/Makefile, ship CHANGELOG.txt and make sure
  source and header files are not executable
* debian/README.source: refer to quilt documentation
* debian/libportmidi-dev.install: do not try to install unexisting files
* debian/patches/{06_pm_test_mm,07_pm_test_sysex,08_pm_test_qtest}.diff:
  get rid of missing include and parenthesis, fix long int formatting
* debian/rules: do not compress header files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* finddefault.c -- find_default_device() implementation
 
2
   Roger Dannenberg, June 2008
 
3
*/
 
4
 
 
5
#include <stdlib.h>
 
6
#include <string.h>
 
7
#include "portmidi.h"
 
8
#include "pmmacosxcm.h"
 
9
#include "readbinaryplist.h"
 
10
 
 
11
/* Parse preference files, find default device, search devices --
 
12
   This parses the preference file(s) once for input and once for
 
13
   output, which is inefficient but much simpler to manage. Note
 
14
   that using the readbinaryplist.c module, you cannot keep two
 
15
   plist files (user and system) open at once (due to a simple
 
16
   memory management scheme).
 
17
*/
 
18
PmDeviceID find_default_device(char *path, int input, PmDeviceID id)
 
19
/* path -- the name of the preference we are searching for
 
20
   input -- true iff this is an input device
 
21
   id -- current default device id
 
22
   returns matching device id if found, otherwise id
 
23
*/
 
24
{
 
25
    static char *pref_file = "com.apple.java.util.prefs.plist";
 
26
    char *pref_str = NULL;
 
27
    // read device preferences
 
28
    value_ptr prefs = bplist_read_user_pref(pref_file);
 
29
    if (prefs) {
 
30
        value_ptr pref_val = value_dict_lookup_using_path(prefs, path);
 
31
        if (pref_val) {
 
32
            pref_str = value_get_asciistring(pref_val);
 
33
        }
 
34
    }
 
35
    if (!pref_str) {
 
36
        bplist_free_data(); /* look elsewhere */
 
37
        prefs = bplist_read_system_pref(pref_file);
 
38
        if (prefs) {
 
39
            value_ptr pref_val = value_dict_lookup_using_path(prefs, path);
 
40
            if (pref_val) {
 
41
                pref_str = value_get_asciistring(pref_val);
 
42
            }
 
43
        }
 
44
    }
 
45
    if (pref_str) { /* search devices for match */
 
46
        int i = pm_find_default_device(pref_str, input);
 
47
        if (i != pmNoDevice) {
 
48
            id = i;
 
49
        }
 
50
    }
 
51
    if (prefs) {
 
52
        bplist_free_data();
 
53
    }
 
54
    return id;
 
55
}