2004-11-07 21:04:02 +03:00
|
|
|
/*
|
|
|
|
* QEMU Audio subsystem header
|
2005-10-30 21:58:22 +03:00
|
|
|
*
|
|
|
|
* Copyright (c) 2003-2005 Vassili Karpov (malc)
|
|
|
|
*
|
2004-11-07 21:04:02 +03:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
2016-06-29 16:29:06 +03:00
|
|
|
|
2004-11-07 21:04:02 +03:00
|
|
|
#ifndef QEMU_AUDIO_H
|
|
|
|
#define QEMU_AUDIO_H
|
|
|
|
|
2012-12-17 21:20:00 +04:00
|
|
|
#include "qemu/queue.h"
|
2005-11-05 21:55:28 +03:00
|
|
|
|
2009-10-15 02:40:17 +04:00
|
|
|
typedef void (*audio_callback_fn) (void *opaque, int avail);
|
2004-11-07 21:04:02 +03:00
|
|
|
|
|
|
|
typedef enum {
|
2005-11-05 21:55:28 +03:00
|
|
|
AUD_FMT_U8,
|
|
|
|
AUD_FMT_S8,
|
|
|
|
AUD_FMT_U16,
|
2007-02-18 01:19:29 +03:00
|
|
|
AUD_FMT_S16,
|
|
|
|
AUD_FMT_U32,
|
|
|
|
AUD_FMT_S32
|
2004-11-07 21:04:02 +03:00
|
|
|
} audfmt_e;
|
|
|
|
|
2009-07-27 18:13:06 +04:00
|
|
|
#ifdef HOST_WORDS_BIGENDIAN
|
2006-07-05 01:47:22 +04:00
|
|
|
#define AUDIO_HOST_ENDIANNESS 1
|
|
|
|
#else
|
|
|
|
#define AUDIO_HOST_ENDIANNESS 0
|
|
|
|
#endif
|
|
|
|
|
2008-12-04 01:48:44 +03:00
|
|
|
struct audsettings {
|
2005-11-05 21:55:28 +03:00
|
|
|
int freq;
|
|
|
|
int nchannels;
|
|
|
|
audfmt_e fmt;
|
2006-07-05 01:47:22 +04:00
|
|
|
int endianness;
|
2008-12-04 01:48:44 +03:00
|
|
|
};
|
2005-11-05 21:55:28 +03:00
|
|
|
|
2006-07-16 22:57:03 +04:00
|
|
|
typedef enum {
|
|
|
|
AUD_CNOTIFY_ENABLE,
|
|
|
|
AUD_CNOTIFY_DISABLE
|
|
|
|
} audcnotification_e;
|
|
|
|
|
2006-07-04 20:51:32 +04:00
|
|
|
struct audio_capture_ops {
|
2006-07-16 22:57:03 +04:00
|
|
|
void (*notify) (void *opaque, audcnotification_e cmd);
|
2006-07-04 20:51:32 +04:00
|
|
|
void (*capture) (void *opaque, void *buf, int size);
|
2006-07-16 22:57:03 +04:00
|
|
|
void (*destroy) (void *opaque);
|
2006-07-04 20:51:32 +04:00
|
|
|
};
|
|
|
|
|
2006-07-16 22:57:03 +04:00
|
|
|
struct capture_ops {
|
|
|
|
void (*info) (void *opaque);
|
|
|
|
void (*destroy) (void *opaque);
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct CaptureState {
|
|
|
|
void *opaque;
|
|
|
|
struct capture_ops ops;
|
2009-09-12 11:36:22 +04:00
|
|
|
QLIST_ENTRY (CaptureState) entries;
|
2006-07-16 22:57:03 +04:00
|
|
|
} CaptureState;
|
|
|
|
|
2005-10-30 21:58:22 +03:00
|
|
|
typedef struct SWVoiceOut SWVoiceOut;
|
2006-07-16 22:57:03 +04:00
|
|
|
typedef struct CaptureVoiceOut CaptureVoiceOut;
|
2005-10-30 21:58:22 +03:00
|
|
|
typedef struct SWVoiceIn SWVoiceIn;
|
|
|
|
|
2005-11-05 21:55:28 +03:00
|
|
|
typedef struct QEMUSoundCard {
|
|
|
|
char *name;
|
2009-09-12 11:36:22 +04:00
|
|
|
QLIST_ENTRY (QEMUSoundCard) entries;
|
2005-11-05 21:55:28 +03:00
|
|
|
} QEMUSoundCard;
|
|
|
|
|
2005-10-30 21:58:22 +03:00
|
|
|
typedef struct QEMUAudioTimeStamp {
|
|
|
|
uint64_t old_ts;
|
|
|
|
} QEMUAudioTimeStamp;
|
|
|
|
|
2010-09-23 23:28:05 +04:00
|
|
|
void AUD_vlog (const char *cap, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
|
2010-09-23 23:28:03 +04:00
|
|
|
void AUD_log (const char *cap, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
|
2004-11-07 21:04:02 +03:00
|
|
|
|
2005-10-30 21:58:22 +03:00
|
|
|
void AUD_help (void);
|
2009-05-14 03:11:35 +04:00
|
|
|
void AUD_register_card (const char *name, QEMUSoundCard *card);
|
2005-11-05 21:55:28 +03:00
|
|
|
void AUD_remove_card (QEMUSoundCard *card);
|
2006-07-16 22:57:03 +04:00
|
|
|
CaptureVoiceOut *AUD_add_capture (
|
2008-12-04 01:48:44 +03:00
|
|
|
struct audsettings *as,
|
2006-07-04 20:51:32 +04:00
|
|
|
struct audio_capture_ops *ops,
|
|
|
|
void *opaque
|
|
|
|
);
|
2006-07-16 22:57:03 +04:00
|
|
|
void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque);
|
2005-10-30 21:58:22 +03:00
|
|
|
|
2005-11-05 21:55:28 +03:00
|
|
|
SWVoiceOut *AUD_open_out (
|
|
|
|
QEMUSoundCard *card,
|
2005-10-30 21:58:22 +03:00
|
|
|
SWVoiceOut *sw,
|
|
|
|
const char *name,
|
|
|
|
void *callback_opaque,
|
2009-10-15 02:40:17 +04:00
|
|
|
audio_callback_fn callback_fn,
|
2008-12-04 01:48:44 +03:00
|
|
|
struct audsettings *settings
|
2005-10-30 21:58:22 +03:00
|
|
|
);
|
2005-11-05 21:55:28 +03:00
|
|
|
|
|
|
|
void AUD_close_out (QEMUSoundCard *card, SWVoiceOut *sw);
|
|
|
|
int AUD_write (SWVoiceOut *sw, void *pcm_buf, int size);
|
|
|
|
int AUD_get_buffer_size_out (SWVoiceOut *sw);
|
|
|
|
void AUD_set_active_out (SWVoiceOut *sw, int on);
|
|
|
|
int AUD_is_active_out (SWVoiceOut *sw);
|
|
|
|
|
|
|
|
void AUD_init_time_stamp_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts);
|
|
|
|
uint64_t AUD_get_elapsed_usec_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts);
|
|
|
|
|
2008-05-04 14:21:03 +04:00
|
|
|
void AUD_set_volume_out (SWVoiceOut *sw, int mute, uint8_t lvol, uint8_t rvol);
|
|
|
|
void AUD_set_volume_in (SWVoiceIn *sw, int mute, uint8_t lvol, uint8_t rvol);
|
|
|
|
|
2005-11-05 21:55:28 +03:00
|
|
|
SWVoiceIn *AUD_open_in (
|
|
|
|
QEMUSoundCard *card,
|
2005-10-30 21:58:22 +03:00
|
|
|
SWVoiceIn *sw,
|
|
|
|
const char *name,
|
|
|
|
void *callback_opaque,
|
2009-10-15 02:40:17 +04:00
|
|
|
audio_callback_fn callback_fn,
|
2008-12-04 01:48:44 +03:00
|
|
|
struct audsettings *settings
|
2005-10-30 21:58:22 +03:00
|
|
|
);
|
2005-11-05 21:55:28 +03:00
|
|
|
|
|
|
|
void AUD_close_in (QEMUSoundCard *card, SWVoiceIn *sw);
|
|
|
|
int AUD_read (SWVoiceIn *sw, void *pcm_buf, int size);
|
|
|
|
void AUD_set_active_in (SWVoiceIn *sw, int on);
|
|
|
|
int AUD_is_active_in (SWVoiceIn *sw);
|
|
|
|
|
|
|
|
void AUD_init_time_stamp_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts);
|
|
|
|
uint64_t AUD_get_elapsed_usec_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts);
|
2004-11-07 21:04:02 +03:00
|
|
|
|
|
|
|
static inline void *advance (void *p, int incr)
|
|
|
|
{
|
|
|
|
uint8_t *d = p;
|
|
|
|
return (d + incr);
|
|
|
|
}
|
|
|
|
|
2005-10-30 21:58:22 +03:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#define audio_MIN(a, b) ( __extension__ ({ \
|
|
|
|
__typeof (a) ta = a; \
|
|
|
|
__typeof (b) tb = b; \
|
|
|
|
((ta)>(tb)?(tb):(ta)); \
|
|
|
|
}))
|
|
|
|
|
|
|
|
#define audio_MAX(a, b) ( __extension__ ({ \
|
|
|
|
__typeof (a) ta = a; \
|
|
|
|
__typeof (b) tb = b; \
|
|
|
|
((ta)<(tb)?(tb):(ta)); \
|
|
|
|
}))
|
|
|
|
#else
|
2004-11-07 21:04:02 +03:00
|
|
|
#define audio_MIN(a, b) ((a)>(b)?(b):(a))
|
|
|
|
#define audio_MAX(a, b) ((a)<(b)?(b):(a))
|
2005-10-30 21:58:22 +03:00
|
|
|
#endif
|
2004-11-07 21:04:02 +03:00
|
|
|
|
2008-10-05 14:30:43 +04:00
|
|
|
int wav_start_capture (CaptureState *s, const char *path, int freq,
|
|
|
|
int bits, int nchannels);
|
|
|
|
|
2016-06-29 16:29:06 +03:00
|
|
|
#endif /* QEMU_AUDIO_H */
|