annotate libao2/ao_dart.c @ 29234:6c47111fe28e

Do not use flag CWBackPixel when calling vo_x11_create_vo_window(): It leads to VDPAU errors after video aspect ratio changes. Patch by Stephen Warren.
author cehoyos
date Fri, 08 May 2009 15:43:54 +0000
parents 9a5b8c2ed6de
children c4fe7474709d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28740
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
1 /*
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
2 * OS/2 DART audio output driver
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
3 *
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
4 * Copyright (c) 2007-2009 by KO Myung-Hun (komh@chollian.net)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
5 *
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
6 * This file is part of MPlayer.
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
7 *
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
8 * MPlayer is free software; you can redistribute it and/or modify
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
11 * (at your option) any later version.
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
12 *
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
13 * MPlayer is distributed in the hope that it will be useful,
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
16 * GNU General Public License for more details.
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
17 *
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License along
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
21 */
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
22
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
23 #define INCL_DOS
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
24 #define INCL_DOSERRORS
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
25 #include <os2.h>
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
26
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
27 #include <stdio.h>
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
28 #include <stdlib.h>
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
29 #include <sys/time.h>
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
30 #include <float.h>
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
31
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
32 #include <dart.h>
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
33
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
34 #include "config.h"
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
35 #include "libaf/af_format.h"
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
36 #include "audio_out.h"
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
37 #include "audio_out_internal.h"
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
38 #include "mp_msg.h"
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
39 #include "libvo/fastmemcpy.h"
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
40 #include "subopt-helper.h"
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
41
28823
9a5b8c2ed6de Make ao_info_t structs const.
reimar
parents: 28740
diff changeset
42 static const ao_info_t info = {
28740
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
43 "DART audio output",
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
44 "dart",
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
45 "KO Myung-Hun <komh@chollian.net>",
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
46 ""
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
47 };
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
48
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
49 LIBAO_EXTERN(dart)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
50
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
51 #define OUTBURST_SAMPLES 512
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
52 #define DEFAULT_DART_SAMPLES (OUTBURST_SAMPLES << 2)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
53
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
54 #define CHUNK_SIZE ao_data.outburst
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
55
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
56 static uint8_t *m_audioBuf = NULL;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
57
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
58 static int m_nBufSize = 0;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
59
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
60 static volatile int m_fQuit = FALSE;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
61 // may only be modified by DART's playback thread or while it is stopped
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
62 static volatile int m_iBufReadPos = 0;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
63 // may only be modified by MPlayer's thread
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
64 static volatile int m_iBufWritePos = 0;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
65
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
66 // may only be called by MPlayer's thread
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
67 // return value may change between immediately following two calls,
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
68 // and the real number of free bytes might be larger!
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
69 static int buf_free(void)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
70 {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
71 int nFree = m_iBufReadPos - m_iBufWritePos - CHUNK_SIZE;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
72
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
73 if (nFree < 0)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
74 nFree += m_nBufSize;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
75
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
76 return nFree;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
77 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
78
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
79 // may only be called by DART's playback thread
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
80 // return value may change between immediately following two calls,
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
81 // and the real number of buffered bytes might be larger!
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
82 static int buf_used(void)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
83 {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
84 int nUsed = m_iBufWritePos - m_iBufReadPos;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
85
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
86 if (nUsed < 0)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
87 nUsed += m_nBufSize;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
88
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
89 return nUsed;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
90 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
91
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
92 static int write_buffer(unsigned char *data, int len)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
93 {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
94 int nFirstLen = m_nBufSize - m_iBufWritePos;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
95 int nFree = buf_free();
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
96
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
97 if (len > nFree)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
98 len = nFree;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
99
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
100 if (nFirstLen > len)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
101 nFirstLen = len;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
102
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
103 // till end of buffer
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
104 fast_memcpy(m_audioBuf + m_iBufWritePos, data, nFirstLen);
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
105 if (len > nFirstLen) { // we have to wrap around
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
106 // remaining part from beginning of buffer
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
107 fast_memcpy(m_audioBuf, data + nFirstLen, len - nFirstLen);
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
108 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
109
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
110 m_iBufWritePos = (m_iBufWritePos + len) % m_nBufSize;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
111
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
112 return len;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
113 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
114
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
115 static int read_buffer(unsigned char *data, int len)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
116 {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
117 int nFirstLen = m_nBufSize - m_iBufReadPos;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
118 int nBuffered = buf_used();
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
119
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
120 if (len > nBuffered)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
121 len = nBuffered;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
122
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
123 if (nFirstLen > len)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
124 nFirstLen = len;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
125
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
126 // till end of buffer
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
127 fast_memcpy(data, m_audioBuf + m_iBufReadPos, nFirstLen);
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
128 if (len > nFirstLen) { // we have to wrap around
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
129 // remaining part from beginning of buffer
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
130 fast_memcpy(data + nFirstLen, m_audioBuf, len - nFirstLen);
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
131 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
132
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
133 m_iBufReadPos = (m_iBufReadPos + len) % m_nBufSize;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
134
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
135 return len;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
136 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
137
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
138 // end ring buffer stuff
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
139
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
140 static ULONG APIENTRY dart_audio_callback(PVOID pCBData, PVOID pBuffer,
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
141 ULONG ulSize)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
142 {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
143 int nReadLen;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
144
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
145 nReadLen = read_buffer(pBuffer, ulSize);
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
146 if (nReadLen < ulSize && !m_fQuit) {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
147 memset((uint8_t *)pBuffer + nReadLen, DART.bSilence, ulSize - nReadLen);
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
148 nReadLen = ulSize;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
149 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
150
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
151 return nReadLen;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
152 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
153
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
154 // to set/get/query special features/parameters
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
155 static int control(int cmd, void *arg)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
156 {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
157 switch (cmd) {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
158 case AOCONTROL_GET_VOLUME:
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
159 {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
160 ao_control_vol_t *vol = arg;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
161
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
162 vol->left = vol->right = LOUSHORT(dartGetVolume());
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
163
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
164 return CONTROL_OK;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
165 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
166
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
167 case AOCONTROL_SET_VOLUME:
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
168 {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
169 int mid;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
170 ao_control_vol_t *vol = arg;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
171
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
172 mid = (vol->left + vol->right) / 2;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
173 dartSetVolume(MCI_SET_AUDIO_ALL, mid);
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
174
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
175 return CONTROL_OK;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
176 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
177 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
178
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
179 return CONTROL_UNKNOWN;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
180 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
181
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
182 static void print_help(void)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
183 {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
184 mp_msg(MSGT_AO, MSGL_FATAL,
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
185 "\n-ao dart commandline help:\n"
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
186 "Example: mplayer -ao dart:noshare\n"
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
187 " open DART in exclusive mode\n"
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
188 "\nOptions:\n"
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
189 " (no)share\n"
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
190 " Open DART in shareable or exclusive mode\n"
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
191 " bufsize=<size>\n"
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
192 " Set buffer size to <size> in samples(default: 2048)\n");
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
193 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
194
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
195 // open & set up audio device
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
196 // return: 1=success 0=fail
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
197 static int init(int rate, int channels, int format, int flags)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
198 {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
199 int fShare = 1;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
200 int nDartSamples = DEFAULT_DART_SAMPLES;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
201 int nBytesPerSample;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
202
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
203 opt_t subopts[] = {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
204 {"share", OPT_ARG_BOOL, &fShare, NULL},
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
205 {"bufsize", OPT_ARG_INT, &nDartSamples, (opt_test_f)int_non_neg},
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
206 {NULL}
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
207 };
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
208
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
209 if (subopt_parse(ao_subdevice, subopts) != 0) {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
210 print_help();
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
211 return 0;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
212 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
213
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
214 if (!nDartSamples)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
215 nDartSamples = DEFAULT_DART_SAMPLES;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
216
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
217 mp_msg(MSGT_AO, MSGL_V, "DART: opened in %s mode, buffer size = %d sample(s)\n",
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
218 fShare ? "shareable" : "exclusive", nDartSamples);
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
219
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
220 switch (format) {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
221 case AF_FORMAT_S16_LE:
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
222 case AF_FORMAT_S8:
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
223 break;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
224
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
225 default:
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
226 format = AF_FORMAT_S16_LE;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
227 mp_msg(MSGT_AO, MSGL_V, "DART: format %s not supported defaulting to Signed 16-bit Little-Endian\n",
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
228 af_fmt2str_short(format));
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
229 break;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
230 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
231
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
232 nBytesPerSample = (af_fmt2bits(format) >> 3) * channels;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
233
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
234 if (dartInit(0, af_fmt2bits(format), rate, MCI_WAVE_FORMAT_PCM, channels,
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
235 2, nBytesPerSample * nDartSamples, fShare,
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
236 dart_audio_callback, NULL))
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
237 return 0;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
238
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
239 mp_msg(MSGT_AO, MSGL_V, "DART: obtained buffer size = %lu bytes\n",
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
240 DART.ulBufferSize);
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
241
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
242 m_fQuit = FALSE;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
243
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
244 ao_data.channels = channels;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
245 ao_data.samplerate = rate;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
246 ao_data.format = format;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
247 ao_data.bps = nBytesPerSample * rate;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
248 ao_data.outburst = nBytesPerSample * OUTBURST_SAMPLES;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
249 ao_data.buffersize = DART.ulBufferSize;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
250
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
251 // multiple of CHUNK_SIZE
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
252 m_nBufSize = ((DART.ulBufferSize << 2) / CHUNK_SIZE) * CHUNK_SIZE;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
253 // and one more chunk plus round up
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
254 m_nBufSize += 2 * CHUNK_SIZE;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
255
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
256 m_audioBuf = malloc(m_nBufSize);
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
257
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
258 m_iBufReadPos = 0;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
259 m_iBufWritePos = 0;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
260
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
261 dartPlay();
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
262
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
263 // might cause PM DLLs to be loaded which incorrectly enable SIG_FPE,
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
264 // which AAC decoding might trigger.
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
265 // so, mask off all floating-point exceptions.
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
266 _control87(MCW_EM, MCW_EM);
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
267
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
268 return 1;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
269 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
270
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
271 // close audio device
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
272 static void uninit(int immed)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
273 {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
274 m_fQuit = TRUE;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
275
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
276 if (!immed) {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
277 while (DART.fPlaying)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
278 DosSleep(1);
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
279 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
280
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
281 dartClose();
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
282
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
283 free(m_audioBuf);
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
284 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
285
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
286 // stop playing and empty buffers (for seeking/pause)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
287 static void reset(void)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
288 {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
289 dartPause();
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
290
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
291 // Reset ring-buffer state
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
292 m_iBufReadPos = 0;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
293 m_iBufWritePos = 0;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
294
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
295 dartResume();
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
296 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
297
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
298 // stop playing, keep buffers (for pause)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
299 static void audio_pause(void)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
300 {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
301 dartPause();
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
302 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
303
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
304 // resume playing, after audio_pause()
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
305 static void audio_resume(void)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
306 {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
307 dartResume();
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
308 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
309
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
310 // return: how many bytes can be played without blocking
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
311 static int get_space(void)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
312 {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
313 return buf_free();
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
314 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
315
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
316 // plays 'len' bytes of 'data'
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
317 // it should round it down to outburst*n
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
318 // return: number of bytes played
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
319 static int play(void *data, int len, int flags)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
320 {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
321
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
322 if (!(flags & AOPLAY_FINAL_CHUNK))
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
323 len = (len / ao_data.outburst) * ao_data.outburst;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
324
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
325 return write_buffer(data, len);
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
326 }
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
327
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
328 // return: delay in seconds between first and last sample in buffer
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
329 static float get_delay(void)
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
330 {
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
331 int nBuffered = m_nBufSize - CHUNK_SIZE - buf_free(); // could be less
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
332
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
333 return (float)nBuffered / (float)ao_data.bps;
1f76d86e49ae DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
diff changeset
334 }