2015-07-07 09:55:32 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Andrew Kelley
|
|
|
|
*
|
|
|
|
* This file is part of libsoundio, which is MIT licensed.
|
|
|
|
* See http://opensource.org/licenses/MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SOUNDIO_ALSA_HPP
|
|
|
|
#define SOUNDIO_ALSA_HPP
|
|
|
|
|
2015-07-30 19:18:56 +00:00
|
|
|
#include "soundio/soundio.h"
|
|
|
|
#include "soundio/os.h"
|
2015-07-27 23:37:45 +00:00
|
|
|
#include "atomics.hpp"
|
|
|
|
|
2015-07-28 00:06:12 +00:00
|
|
|
#include <alsa/asoundlib.h>
|
|
|
|
|
2015-07-13 16:17:20 +00:00
|
|
|
int soundio_alsa_init(struct SoundIoPrivate *si);
|
2015-07-07 09:55:32 +00:00
|
|
|
|
2015-08-01 20:00:46 +00:00
|
|
|
struct SoundIoDeviceAlsa { };
|
2015-07-27 23:37:45 +00:00
|
|
|
|
|
|
|
struct SoundIoAlsa {
|
|
|
|
SoundIoOsMutex *mutex;
|
|
|
|
SoundIoOsCond *cond;
|
2015-07-07 09:55:32 +00:00
|
|
|
|
2015-07-27 23:37:45 +00:00
|
|
|
struct SoundIoOsThread *thread;
|
|
|
|
atomic_flag abort_flag;
|
|
|
|
int notify_fd;
|
|
|
|
int notify_wd;
|
|
|
|
atomic_bool have_devices_flag;
|
|
|
|
int notify_pipe_fd[2];
|
|
|
|
|
|
|
|
// this one is ready to be read with flush_events. protected by mutex
|
|
|
|
struct SoundIoDevicesInfo *ready_devices_info;
|
2015-07-30 07:46:13 +00:00
|
|
|
|
|
|
|
int shutdown_err;
|
|
|
|
bool emitted_shutdown_cb;
|
2015-07-27 23:37:45 +00:00
|
|
|
};
|
|
|
|
|
2015-07-28 00:06:12 +00:00
|
|
|
struct SoundIoOutStreamAlsa {
|
|
|
|
snd_pcm_t *handle;
|
|
|
|
snd_pcm_chmap_t *chmap;
|
|
|
|
int chmap_size;
|
|
|
|
snd_pcm_uframes_t offset;
|
|
|
|
snd_pcm_access_t access;
|
|
|
|
int sample_buffer_size;
|
|
|
|
char *sample_buffer;
|
|
|
|
int poll_fd_count;
|
|
|
|
struct pollfd *poll_fds;
|
|
|
|
SoundIoOsThread *thread;
|
|
|
|
atomic_flag thread_exit_flag;
|
|
|
|
int period_size;
|
2015-08-04 07:56:03 +00:00
|
|
|
int frames_left;
|
|
|
|
int frames_to_write;
|
2015-07-28 00:06:12 +00:00
|
|
|
SoundIoChannelArea areas[SOUNDIO_MAX_CHANNELS];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SoundIoInStreamAlsa {
|
|
|
|
snd_pcm_t *handle;
|
|
|
|
snd_pcm_chmap_t *chmap;
|
|
|
|
int chmap_size;
|
|
|
|
snd_pcm_uframes_t offset;
|
|
|
|
snd_pcm_access_t access;
|
|
|
|
int sample_buffer_size;
|
|
|
|
char *sample_buffer;
|
|
|
|
int poll_fd_count;
|
|
|
|
struct pollfd *poll_fds;
|
|
|
|
SoundIoOsThread *thread;
|
|
|
|
atomic_flag thread_exit_flag;
|
|
|
|
int period_size;
|
2015-08-04 07:56:03 +00:00
|
|
|
int frames_left;
|
2015-07-28 00:06:12 +00:00
|
|
|
int read_frame_count;
|
|
|
|
SoundIoChannelArea areas[SOUNDIO_MAX_CHANNELS];
|
|
|
|
};
|
|
|
|
|
2015-07-27 23:37:45 +00:00
|
|
|
#endif
|