| 1 |
/* |
|---|
| 2 |
* Sweep, a sound wave editor. |
|---|
| 3 |
* |
|---|
| 4 |
* Copyright (C) 2000 Conrad Parker |
|---|
| 5 |
* |
|---|
| 6 |
* This program is free software; you can redistribute it and/or modify |
|---|
| 7 |
* it under the terms of the GNU General Public License as published by |
|---|
| 8 |
* the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 |
* (at your option) any later version. |
|---|
| 10 |
* |
|---|
| 11 |
* This program is distributed in the hope that it will be useful, |
|---|
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 |
* GNU General Public License for more details. |
|---|
| 15 |
* |
|---|
| 16 |
* You should have received a copy of the GNU General Public License |
|---|
| 17 |
* along with this program; if not, write to the Free Software |
|---|
| 18 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 19 |
*/ |
|---|
| 20 |
|
|---|
| 21 |
#ifndef __DRIVER_H__ |
|---|
| 22 |
#define __DRIVER_H__ |
|---|
| 23 |
|
|---|
| 24 |
#include <unistd.h> |
|---|
| 25 |
|
|---|
| 26 |
#include "sweep_app.h" |
|---|
| 27 |
|
|---|
| 28 |
#define PBUF_SIZE 256 |
|---|
| 29 |
|
|---|
| 30 |
typedef struct _sw_handle sw_handle; |
|---|
| 31 |
typedef struct _sw_driver sw_driver; |
|---|
| 32 |
|
|---|
| 33 |
struct _sw_handle { |
|---|
| 34 |
int driver_flags; |
|---|
| 35 |
int driver_fd; |
|---|
| 36 |
int driver_channels; |
|---|
| 37 |
int driver_rate; |
|---|
| 38 |
void * custom_data; |
|---|
| 39 |
}; |
|---|
| 40 |
|
|---|
| 41 |
struct _sw_driver { |
|---|
| 42 |
const char * name; |
|---|
| 43 |
GList * (*get_names) (void); |
|---|
| 44 |
sw_handle * (*open) (int cueing, int flags); |
|---|
| 45 |
void (*setup) (sw_handle * handle, sw_format * format); |
|---|
| 46 |
int (*wait) (sw_handle * handle); |
|---|
| 47 |
ssize_t (*read) (sw_handle * handle, sw_audio_t * buf, size_t count); |
|---|
| 48 |
ssize_t (*write) (sw_handle * handle, sw_audio_t * buf, size_t count); |
|---|
| 49 |
sw_framecount_t (*offset) (sw_handle * handle); |
|---|
| 50 |
void (*reset) (sw_handle * handle); |
|---|
| 51 |
void (*flush) (sw_handle * handle); |
|---|
| 52 |
void (*drain) (sw_handle * handle); |
|---|
| 53 |
void (*close) (sw_handle * handle); |
|---|
| 54 |
|
|---|
| 55 |
char * primary_device_key; |
|---|
| 56 |
char * monitor_device_key; |
|---|
| 57 |
char * log_frags_key; |
|---|
| 58 |
}; |
|---|
| 59 |
|
|---|
| 60 |
void |
|---|
| 61 |
device_config (void); |
|---|
| 62 |
|
|---|
| 63 |
sw_handle * |
|---|
| 64 |
device_open (int cueing, int flags); |
|---|
| 65 |
|
|---|
| 66 |
void |
|---|
| 67 |
device_setup (sw_handle * handle, sw_format * format); |
|---|
| 68 |
|
|---|
| 69 |
int |
|---|
| 70 |
device_wait (sw_handle * handle); |
|---|
| 71 |
|
|---|
| 72 |
/* |
|---|
| 73 |
* For recording, ie. reading pcm data from the device. |
|---|
| 74 |
*/ |
|---|
| 75 |
ssize_t |
|---|
| 76 |
device_read (sw_handle * handle, sw_audio_t * buf, size_t count); |
|---|
| 77 |
|
|---|
| 78 |
ssize_t |
|---|
| 79 |
device_write (sw_handle * handle, sw_audio_t * buf, size_t count); |
|---|
| 80 |
|
|---|
| 81 |
/* As far as I'm aware the method |
|---|
| 82 |
* used to monitor latency in OSS and Solaris etc. is different to that which |
|---|
| 83 |
* ALSA uses, and different again from JACK and PortAudio. |
|---|
| 84 |
* |
|---|
| 85 |
* Basically, when the device is written to, the driver is also told what the |
|---|
| 86 |
* offset into the file is for that bit of sound. |
|---|
| 87 |
* |
|---|
| 88 |
* Then, when the GUI thread goes to draw the cursor, it asks the driver |
|---|
| 89 |
* what the offset of the sound that's currently coming out of the speaker is |
|---|
| 90 |
* and draws it there (which may be a little behind or ahead of where the |
|---|
| 91 |
* user is scrubbing) -- hence the sound and the vision are kept in sync. |
|---|
| 92 |
* |
|---|
| 93 |
* However, this is all currently disabled, and going to change, as its not |
|---|
| 94 |
* properly monitoring the latency of multiple files being played |
|---|
| 95 |
* simultaneously; plus it may have to change with respect to ALSA and JACK and |
|---|
| 96 |
* PortAudio. So for now, just return -1. |
|---|
| 97 |
*/ |
|---|
| 98 |
sw_framecount_t |
|---|
| 99 |
device_offset (sw_handle * handle); |
|---|
| 100 |
|
|---|
| 101 |
/* |
|---|
| 102 |
* Reset should stop the device immediately (ie. not bother emptying the |
|---|
| 103 |
* buffers, simply stop making any sound). The other half of what the RESET |
|---|
| 104 |
* ioctl does in OSS is put the device back into an initialised state where |
|---|
| 105 |
* it can accept new parameters, but sweep's not actually making use of that. |
|---|
| 106 |
*/ |
|---|
| 107 |
void |
|---|
| 108 |
device_reset (sw_handle * handle); |
|---|
| 109 |
|
|---|
| 110 |
void |
|---|
| 111 |
device_flush (sw_handle * handle); |
|---|
| 112 |
|
|---|
| 113 |
/* |
|---|
| 114 |
* Drain empties the buffers out, ie. plays out any data that's been written |
|---|
| 115 |
* (otherwise you often lose the last bit of sound when closing the device). |
|---|
| 116 |
*/ |
|---|
| 117 |
void |
|---|
| 118 |
device_drain (sw_handle * handle); |
|---|
| 119 |
|
|---|
| 120 |
void |
|---|
| 121 |
device_close (sw_handle * handle); |
|---|
| 122 |
|
|---|
| 123 |
void |
|---|
| 124 |
init_devices (void); |
|---|
| 125 |
|
|---|
| 126 |
void |
|---|
| 127 |
stop_playback (sw_sample * s) ; |
|---|
| 128 |
|
|---|
| 129 |
#endif /* __DRIVER_H__ */ |
|---|