2004-11-07 19:04:02 +01:00
|
|
|
/*
|
|
|
|
* QEMU Audio subsystem header
|
2005-10-30 19:58:22 +01:00
|
|
|
*
|
|
|
|
* Copyright (c) 2003-2005 Vassili Karpov (malc)
|
|
|
|
*
|
2004-11-07 19:04:02 +01: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.
|
|
|
|
*/
|
|
|
|
#ifndef QEMU_AUDIO_H
|
|
|
|
#define QEMU_AUDIO_H
|
|
|
|
|
2005-11-05 19:55:28 +01:00
|
|
|
#include "sys-queue.h"
|
|
|
|
|
2005-10-30 19:58:22 +01:00
|
|
|
typedef void (*audio_callback_fn_t) (void *opaque, int avail);
|
2004-11-07 19:04:02 +01:00
|
|
|
|
|
|
|
typedef enum {
|
2005-11-05 19:55:28 +01:00
|
|
|
AUD_FMT_U8,
|
|
|
|
AUD_FMT_S8,
|
|
|
|
AUD_FMT_U16,
|
|
|
|
AUD_FMT_S16
|
2004-11-07 19:04:02 +01:00
|
|
|
} audfmt_e;
|
|
|
|
|
2005-11-05 19:55:28 +01:00
|
|
|
typedef struct {
|
|
|
|
int freq;
|
|
|
|
int nchannels;
|
|
|
|
audfmt_e fmt;
|
|
|
|
} audsettings_t;
|
|
|
|
|
|
|
|
typedef struct AudioState AudioState;
|
2005-10-30 19:58:22 +01:00
|
|
|
typedef struct SWVoiceOut SWVoiceOut;
|
|
|
|
typedef struct SWVoiceIn SWVoiceIn;
|
|
|
|
|
2005-11-05 19:55:28 +01:00
|
|
|
typedef struct QEMUSoundCard {
|
|
|
|
AudioState *audio;
|
|
|
|
char *name;
|
|
|
|
LIST_ENTRY (QEMUSoundCard) entries;
|
|
|
|
} QEMUSoundCard;
|
|
|
|
|
2005-10-30 19:58:22 +01:00
|
|
|
typedef struct QEMUAudioTimeStamp {
|
|
|
|
uint64_t old_ts;
|
|
|
|
} QEMUAudioTimeStamp;
|
|
|
|
|
|
|
|
void AUD_vlog (const char *cap, const char *fmt, va_list ap);
|
|
|
|
void AUD_log (const char *cap, const char *fmt, ...)
|
|
|
|
#ifdef __GNUC__
|
|
|
|
__attribute__ ((__format__ (__printf__, 2, 3)))
|
|
|
|
#endif
|
|
|
|
;
|
2004-11-07 19:04:02 +01:00
|
|
|
|
2005-11-05 19:55:28 +01:00
|
|
|
AudioState *AUD_init (void);
|
2005-10-30 19:58:22 +01:00
|
|
|
void AUD_help (void);
|
2005-11-05 19:55:28 +01:00
|
|
|
void AUD_register_card (AudioState *s, const char *name, QEMUSoundCard *card);
|
|
|
|
void AUD_remove_card (QEMUSoundCard *card);
|
2005-10-30 19:58:22 +01:00
|
|
|
|
2005-11-05 19:55:28 +01:00
|
|
|
SWVoiceOut *AUD_open_out (
|
|
|
|
QEMUSoundCard *card,
|
2005-10-30 19:58:22 +01:00
|
|
|
SWVoiceOut *sw,
|
|
|
|
const char *name,
|
|
|
|
void *callback_opaque,
|
|
|
|
audio_callback_fn_t callback_fn,
|
2005-11-05 19:55:28 +01:00
|
|
|
audsettings_t *settings
|
2005-10-30 19:58:22 +01:00
|
|
|
);
|
2005-11-05 19:55:28 +01: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);
|
|
|
|
|
|
|
|
SWVoiceIn *AUD_open_in (
|
|
|
|
QEMUSoundCard *card,
|
2005-10-30 19:58:22 +01:00
|
|
|
SWVoiceIn *sw,
|
|
|
|
const char *name,
|
|
|
|
void *callback_opaque,
|
|
|
|
audio_callback_fn_t callback_fn,
|
2005-11-05 19:55:28 +01:00
|
|
|
audsettings_t *settings
|
2005-10-30 19:58:22 +01:00
|
|
|
);
|
2005-11-05 19:55:28 +01: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 19:04:02 +01:00
|
|
|
|
|
|
|
static inline void *advance (void *p, int incr)
|
|
|
|
{
|
|
|
|
uint8_t *d = p;
|
|
|
|
return (d + incr);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t popcount (uint32_t u);
|
|
|
|
inline uint32_t lsbindex (uint32_t u);
|
|
|
|
|
2005-10-30 19:58:22 +01: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 19:04:02 +01:00
|
|
|
#define audio_MIN(a, b) ((a)>(b)?(b):(a))
|
|
|
|
#define audio_MAX(a, b) ((a)<(b)?(b):(a))
|
2005-10-30 19:58:22 +01:00
|
|
|
#endif
|
2004-11-07 19:04:02 +01:00
|
|
|
|
|
|
|
#endif /* audio.h */
|