1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-23 01:43:01 +01:00
toxic/src/device.h

92 lines
2.8 KiB
C
Raw Normal View History

/* device.h
*
*
* 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.
* Pass buffers to output device via write();
* Read from running input device(s) via select()/callback combo.
*/
#ifndef DEVICE_H
#define DEVICE_H
2014-06-21 02:04:25 +02:00
2014-11-29 15:36:31 +01:00
#define OPENAL_BUFS 5
2014-06-21 02:04:25 +02:00
#define MAX_DEVICES 32
#include <inttypes.h>
#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,
de_UnsupportedMode = -8,
de_AlError = -9,
2014-06-21 02:04:25 +02:00
} DeviceError;
typedef void (*DataHandleCallback) (const int16_t*, uint32_t size, void* data);
#ifdef AUDIO
2014-06-21 02:04:25 +02:00
DeviceError init_devices(ToxAv* av);
#else
DeviceError init_devices();
#endif /* AUDIO */
2014-06-21 02:04:25 +02:00
DeviceError terminate_devices();
/* Callback handles ready data from INPUT device */
DeviceError register_device_callback(int32_t call_idx, uint32_t device_idx, DataHandleCallback callback, void* data, bool enable_VAD);
2014-06-21 02:04:25 +02:00
void* get_device_callback_data(uint32_t device_idx);
/* toggle device mute */
DeviceError device_mute(DeviceType type, uint32_t device_idx);
#ifdef AUDIO
DeviceError device_set_VAD_treshold(uint32_t device_idx, float value);
2014-07-21 23:48:39 +02:00
#endif
2014-06-21 02:04:25 +02:00
DeviceError set_primary_device(DeviceType type, int32_t selection);
DeviceError open_primary_device(DeviceType type, uint32_t* device_idx, uint32_t sample_rate, uint32_t frame_duration, uint8_t channels);
2014-06-21 02:04:25 +02:00
/* Start device */
DeviceError open_device(DeviceType type, int32_t selection, uint32_t* device_idx, uint32_t sample_rate, uint32_t frame_duration, uint8_t channels);
2014-06-21 02:04:25 +02:00
/* Stop device */
DeviceError close_device(DeviceType type, uint32_t device_idx);
/* Write data to device */
2014-11-26 06:48:58 +01:00
DeviceError write_out(uint32_t device_idx, const int16_t* data, uint32_t length, uint8_t channels);
2014-06-21 02:04:25 +02:00
void print_devices(ToxWindow* self, DeviceType type);
2014-11-29 15:36:31 +01:00
void get_primary_device_name(DeviceType type, char *buf, int size);
2014-06-21 02:04:25 +02:00
DeviceError selection_valid(DeviceType type, int32_t selection);
#endif /* DEVICE_H */