1 /*****************************************************************************
2 * mmdevice.h : Windows Multimedia Device API audio output plugin for VLC
3 *****************************************************************************
4 * Copyright (C) 2012 RĂ©mi Denis-Courmont
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.
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.
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 *****************************************************************************/
21 #ifndef VLC_AOUT_MMDEVICE_H
22 # define VLC_AOUT_MMDEVICE_H 1
24 typedef struct aout_stream aout_stream_t
;
27 * Audio output simplified API for Windows
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
*);
42 HRESULT (*activate
)(void *device
, REFIID
, PROPVARIANT
*, void **);
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]
52 typedef HRESULT (*aout_stream_start_t
)(aout_stream_t
*s
,
53 audio_sample_format_t
*fmt
, const GUID
*sid
);
56 * Destroys an audio output stream.
58 typedef HRESULT (*aout_stream_stop_t
)(aout_stream_t
*);
60 static inline HRESULT
aout_stream_TimeGet(aout_stream_t
*s
, mtime_t
*delay
)
62 return (s
->time_get
)(s
, delay
);
65 static inline HRESULT
aout_stream_Play(aout_stream_t
*s
, block_t
*block
)
67 return (s
->play
)(s
, block
);
70 static inline HRESULT
aout_stream_Pause(aout_stream_t
*s
, bool paused
)
72 return (s
->pause
)(s
, paused
);
75 static inline HRESULT
aout_stream_Flush(aout_stream_t
*s
, bool wait
)
78 { /* Loosy drain emulation */
81 if (SUCCEEDED(aout_stream_TimeGet(s
, &delay
))
82 && delay
<= INT64_C(5000000))
83 Sleep((delay
/ (CLOCK_FREQ
/ 1000)) + 1);
91 HRESULT
aout_stream_Activate(aout_stream_t
*s
, REFIID iid
,
92 PROPVARIANT
*actparms
, void **pv
)
94 return s
->owner
.activate(s
->owner
.device
, iid
, actparms
, pv
);