]> git.sesse.net Git - vlc/blob - modules/audio_output/mmdevice.h
direct3d11: catch texture mapping errors
[vlc] / modules / audio_output / mmdevice.h
1 /*****************************************************************************
2  * mmdevice.h : Windows Multimedia Device API audio output plugin for VLC
3  *****************************************************************************
4  * Copyright (C) 2012 RĂ©mi Denis-Courmont
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19  *****************************************************************************/
20
21 #ifndef VLC_AOUT_MMDEVICE_H
22 # define VLC_AOUT_MMDEVICE_H 1
23
24 typedef struct aout_stream aout_stream_t;
25
26 /**
27  * Audio output simplified API for Windows
28  */
29 struct aout_stream
30 {
31     VLC_COMMON_MEMBERS
32     void *sys;
33
34     HRESULT (*time_get)(aout_stream_t *, mtime_t *);
35     HRESULT (*play)(aout_stream_t *, block_t *);
36     HRESULT (*pause)(aout_stream_t *, bool);
37     HRESULT (*flush)(aout_stream_t *);
38
39     struct
40     {
41         void *device;
42         HRESULT (*activate)(void *device, REFIID, PROPVARIANT *, void **);
43     } owner;
44 };
45
46 /**
47  * Creates an audio output stream on a given Windows multimedia device.
48  * \param s audio output stream object to be initialized
49  * \param fmt audio output sample format [IN/OUT]
50  * \param sid audio output session GUID [IN]
51  */
52 typedef HRESULT (*aout_stream_start_t)(aout_stream_t *s,
53     audio_sample_format_t *fmt, const GUID *sid);
54
55 /**
56  * Destroys an audio output stream.
57  */
58 typedef HRESULT (*aout_stream_stop_t)(aout_stream_t *);
59
60 static inline HRESULT aout_stream_TimeGet(aout_stream_t *s, mtime_t *delay)
61 {
62     return (s->time_get)(s, delay);
63 }
64
65 static inline HRESULT aout_stream_Play(aout_stream_t *s, block_t *block)
66 {
67     return (s->play)(s, block);
68 }
69
70 static inline HRESULT aout_stream_Pause(aout_stream_t *s, bool paused)
71 {
72     return (s->pause)(s, paused);
73 }
74
75 static inline HRESULT aout_stream_Flush(aout_stream_t *s, bool wait)
76 {
77     if (wait)
78     {   /* Loosy drain emulation */
79         mtime_t delay;
80
81         if (SUCCEEDED(aout_stream_TimeGet(s, &delay)))
82             Sleep((delay / (CLOCK_FREQ / 1000)) + 1);
83         return S_OK;
84     }
85     else
86         return (s->flush)(s);
87 }
88
89 static inline
90 HRESULT aout_stream_Activate(aout_stream_t *s, REFIID iid,
91                              PROPVARIANT *actparms, void **pv)
92 {
93     return s->owner.activate(s->owner.device, iid, actparms, pv);
94 }
95 #endif