2015-05-25 23:59:06 +02:00
|
|
|
/* audio_device.h
|
2014-06-24 23:45:14 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (C) 2014 Toxic All Rights Reserved.
|
|
|
|
*
|
|
|
|
* This file is part of Toxic.
|
|
|
|
*
|
|
|
|
* Toxic is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Toxic is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Toxic. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
2014-06-21 02:04:25 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* You can have multiple sources (Input devices) but only one output device.
|
2016-04-05 06:49:46 +02:00
|
|
|
* Pass buffers to output device via write();
|
2014-06-21 02:04:25 +02:00
|
|
|
* Read from running input device(s) via select()/callback combo.
|
|
|
|
*/
|
|
|
|
|
2015-05-25 23:59:06 +02:00
|
|
|
#ifndef AUDIO_DEVICE_H
|
|
|
|
#define AUDIO_DEVICE_H
|
2014-06-21 02:04:25 +02:00
|
|
|
|
2014-11-29 15:36:31 +01:00
|
|
|
#define OPENAL_BUFS 5
|
2020-04-04 02:00:00 +02:00
|
|
|
#define MAX_OPENAL_DEVICES 32
|
2014-06-21 02:04:25 +02:00
|
|
|
#define MAX_DEVICES 32
|
2019-03-27 06:38:15 +01:00
|
|
|
|
2014-06-22 02:18:23 +02:00
|
|
|
#include "windows.h"
|
2014-06-21 02:04:25 +02:00
|
|
|
|
|
|
|
typedef enum DeviceType {
|
|
|
|
input,
|
|
|
|
output,
|
|
|
|
} DeviceType;
|
|
|
|
|
|
|
|
typedef enum DeviceError {
|
|
|
|
de_None,
|
|
|
|
de_InternalError = -1,
|
|
|
|
de_InvalidSelection = -2,
|
|
|
|
de_FailedStart = -3,
|
|
|
|
de_Busy = -4,
|
|
|
|
de_AllDevicesBusy = -5,
|
|
|
|
de_DeviceNotActive = -6,
|
|
|
|
de_BufferError = -7,
|
2014-07-27 01:49:59 +02:00
|
|
|
de_UnsupportedMode = -8,
|
|
|
|
de_AlError = -9,
|
2014-06-21 02:04:25 +02:00
|
|
|
} DeviceError;
|
|
|
|
|
2018-07-18 17:33:16 +02:00
|
|
|
typedef void (*DataHandleCallback)(const int16_t *, uint32_t size, void *data);
|
2014-06-21 02:04:25 +02:00
|
|
|
|
|
|
|
|
2018-09-14 01:47:47 +02:00
|
|
|
DeviceError init_devices(void);
|
2014-07-21 03:25:21 +02:00
|
|
|
|
2020-04-04 02:00:00 +02:00
|
|
|
void get_al_device_names(void);
|
2018-09-14 01:47:47 +02:00
|
|
|
DeviceError terminate_devices(void);
|
2014-06-21 02:04:25 +02:00
|
|
|
|
2014-06-22 02:18:23 +02:00
|
|
|
/* toggle device mute */
|
|
|
|
DeviceError device_mute(DeviceType type, uint32_t device_idx);
|
|
|
|
|
2020-05-07 02:00:00 +02:00
|
|
|
bool device_is_muted(DeviceType type, uint32_t device_idx);
|
|
|
|
|
2020-05-07 02:00:00 +02:00
|
|
|
DeviceError device_set_VAD_threshold(uint32_t device_idx, float value);
|
|
|
|
|
|
|
|
float device_get_VAD_threshold(uint32_t device_idx);
|
2014-06-22 02:18:23 +02:00
|
|
|
|
2020-05-07 02:00:00 +02:00
|
|
|
DeviceError set_source_position(uint32_t device_idx, float x, float y, float z);
|
|
|
|
|
2020-04-04 02:00:00 +02:00
|
|
|
DeviceError set_al_device(DeviceType type, int32_t selection);
|
|
|
|
|
2014-06-21 02:04:25 +02:00
|
|
|
/* Start device */
|
2021-12-05 22:36:13 +01:00
|
|
|
DeviceError open_input_device(uint32_t *device_idx, DataHandleCallback cb, void *cb_data,
|
2020-04-04 02:00:00 +02:00
|
|
|
uint32_t sample_rate, uint32_t frame_duration, uint8_t channels);
|
2021-12-05 22:36:13 +01:00
|
|
|
DeviceError open_output_device(uint32_t *device_idx, uint32_t sample_rate, uint32_t frame_duration, uint8_t channels);
|
2020-04-04 02:00:00 +02:00
|
|
|
|
2014-06-21 02:04:25 +02:00
|
|
|
/* Stop device */
|
|
|
|
DeviceError close_device(DeviceType type, uint32_t device_idx);
|
|
|
|
|
2020-04-04 02:00:00 +02:00
|
|
|
/* Write data to output device */
|
2016-09-25 03:07:04 +02:00
|
|
|
DeviceError write_out(uint32_t device_idx, const int16_t *data, uint32_t length, uint8_t channels,
|
|
|
|
uint32_t sample_rate);
|
2014-06-21 02:04:25 +02:00
|
|
|
|
2020-05-07 02:00:00 +02:00
|
|
|
/* return current input volume as float in range 0.0-100.0 */
|
|
|
|
float get_input_volume(void);
|
|
|
|
|
2020-04-04 02:00:00 +02:00
|
|
|
void print_al_devices(ToxWindow *self, DeviceType type);
|
2014-06-21 02:04:25 +02:00
|
|
|
|
|
|
|
DeviceError selection_valid(DeviceType type, int32_t selection);
|
2015-05-25 23:59:06 +02:00
|
|
|
#endif /* AUDIO_DEVICE_H */
|