Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/MD_package/MDCommon.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 117 - (show annotations) (download) (as text)
Sun Oct 1 03:33:45 2017 UTC (6 years, 6 months ago) by toshinagata1964
File MIME type: text/x-chdr
File size: 3771 byte(s)
Sizes of the integer types are reconsidered.
1 /*
2 * MDCommon.h
3 *
4 * Created by Toshi Nagata on Sun Jun 17 2001.
5
6 Copyright (c) 2000-2011 Toshi Nagata. All rights reserved.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation version 2 of the License.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 */
18
19 #ifndef __MDCommon__
20 #define __MDCommon__
21
22 /* MDPackage は基本的に plain C で書かれているが、オブジェクト操作とストリーム
23 入出力を許すために2つの型を定義している。
24 OBJECT ... 一般的なオブジェクト。
25 STREAM ... ストリーム。
26 これらはポインタと互換性のある型であり、plain C ではそれぞれ void *, FILE *
27 型に typedef される。
28 OBJECT は MDEvent.c の MDReleaseObject() で、また STREAM は MDTrack.c の
29 一連のファイル入出力関数で使われる。これ以外ではポインタとしてのみ使われる。
30 */
31
32 #if MD_USE_OBJECTIVE_C
33
34 #define General_stream_type
35 typedef id OBJECT;
36 typedef General_stream_type * STREAM;
37
38 #elif MD_USE_CPLUSPLUS
39
40 #define General_object_type
41 #define General_stream_type
42 class General_object_type, General_stream_type;
43 typedef General_object_type * OBJECT;
44 typedef General_stream_type * STREAM;
45
46 #else /* plain C */
47
48 #include <stdio.h>
49 #include <stdlib.h>
50 #include <sys/types.h>
51
52 typedef void * OBJECT;
53
54 typedef struct stream_record *STREAM;
55
56 typedef struct stream_record {
57 int (*getc)(STREAM);
58 int (*putc)(STREAM, int);
59 size_t (*fread)(STREAM, void *, size_t);
60 size_t (*fwrite)(STREAM, const void *, size_t);
61 int (*fseek)(STREAM, off_t, int);
62 off_t (*ftell)(STREAM);
63 int (*fclose)(STREAM);
64 } stream_record;
65
66 typedef struct file_stream_record {
67 stream_record base;
68 FILE *file;
69 } file_stream_record;
70
71 #define MDDATASTREAM_PAGESIZE 256
72
73 typedef struct data_stream_record {
74 stream_record base;
75 unsigned char *ptr;
76 off_t offset;
77 size_t size;
78 size_t bufsize;
79 } data_stream_record;
80
81 #define GETC(stream) ((*((stream)->getc))(stream))
82 #define PUTC(c, stream) ((*((stream)->putc))((stream), (c)))
83 /* Added _ to avoid conflict with fcntl.h 20060205 */
84 #define FREAD_(ptr, size, stream) ((*((stream)->fread))((stream), (ptr), (size)))
85 #define FWRITE_(ptr, size, stream) ((*((stream)->fwrite))((stream), (ptr), (size)))
86 #define FSEEK(stream, offset, origin) ((*((stream)->fseek))((stream), (offset), (origin)))
87 #define FTELL(stream) ((*((stream)->ftell))(stream))
88 #define FCLOSE(stream) ((*((stream)->fclose))(stream))
89
90 #endif
91
92 /* Utility macro */
93 #define re_malloc(p, size) ((p) != NULL ? realloc(p, size) : malloc(size))
94
95 /* エラーコード */
96 typedef int32_t MDStatus;
97 enum {
98 kMDNoError = 0,
99 kMDErrorOutOfMemory,
100 kMDErrorOutOfRange,
101 kMDErrorBadArrayIndex,
102 kMDErrorHeaderChunkNotFound,
103 kMDErrorUnsupportedSMFFormat,
104 kMDErrorUnexpectedEOF,
105 kMDErrorWrongMetaEvent,
106 kMDErrorUnknownChannelEvent,
107 kMDErrorBadDeviceNumber,
108 kMDErrorBadParameter,
109 kMDErrorCannotOpenFile,
110 kMDErrorCannotCreateFile,
111 kMDErrorCannotWriteToStream,
112 kMDErrorCannotReadFromStream,
113 kMDErrorNoEvents,
114 kMDErrorCannotStartPlaying,
115 kMDErrorNoRecordingTrack,
116 kMDErrorAlreadyRecording,
117 kMDErrorTickDisorder,
118 kMDErrorOrphanedNoteOff,
119 kMDErrorUserInterrupt,
120 kMDErrorCannotSetupAudio,
121 kMDErrorCannotProcessAudio,
122 kMDErrorOnSequenceMutex,
123 kMDErrorInternalError = 9998,
124 kMDErrorUnknownError = 9999
125 };
126
127 extern void MyAppCallback_startupMessage(const char *message, ...);
128
129 #endif /* __MDCommon__ */
130

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26