forked from ahlstromcj/seq66
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpmwin.c
136 lines (115 loc) · 3.13 KB
/
pmwin.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* This file is part of seq66, adapted from the PortMIDI project.
*
* seq66 is free software; you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* seq66 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 General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along
* with seq66; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
* \file pmwin.c
*
* PortMidi os-dependent code for Windows.
*
* \library seq66 application
* \author PortMIDI team; modifications by Chris Ahlstrom
* \date 2017-08-21
* \updates 2021-12-09
* \license GNU GPLv2 or above
* This file needs to implement pm_init(), which calls various routines to
* register the available MIDI devices.
*
* This file must be separate from the main portmidi.c file because it is
* system dependent, and it is separate from, say, pmwinmm.c, because it
* might need to register devices for WinMM, DirectX, and others.
*/
#include <windows.h>
#include <stdlib.h>
#include "util/basic_macros.h" /* not_nullptr() macro, etc. */
#include "portmidi.h" /* Pm_set_initialized(), etc. */
#include "pmutil.h"
#include "pmwinmm.h"
#include "portmidi.h"
/**
* This macro is part of Microsoft's tchar.h, but we want to use it only as
* a marker for now.
*
* #include <tchar.h>
*/
#define _T(x) ((char *)(x))
/**
* The maximum length of the name of a device.
*/
#define PATTERN_MAX 256
/**
* pm_exit() is called when the program exits. It calls pm_term() to make
* sure PortMidi is properly closed.
*/
static void
pm_exit (void)
{
pm_term();
}
/*
* pm_init() provides the windows-dependent initialization. It also sets the
* atexit() callback to pm_exit().
*/
void
pm_init (void)
{
atexit(pm_exit);
pm_winmm_init();
/*
* Initialize other APIs (DirectX?) here. Don't we need to set
* pm_initialized = TRUE here? And call find_default_device()?
* No.
*/
}
/**
* Calls pm_winmm_term() to end the PortMidi session.
*/
void
pm_term (void)
{
pm_winmm_term();
}
/**
* A simple wrapper for malloc().
*
* \param s
* Provides the desired size of the allocation.
*
* \return
* Returns a void pointer to the allocated buffer.
*/
void *
pm_alloc (size_t s)
{
return malloc(s);
}
/**
* The inverse of pm_alloc(), a wrapper for the free(3) function.
*
* \param ptr
* Provides the pointer to be freed, if it is not null.
*/
void
pm_free (void * ptr)
{
if (not_nullptr(ptr))
free(ptr);
}
/*
* pmwin.c
*
* vim: sw=4 ts=4 wm=4 et ft=c
*/