0
1
mirror of https://github.com/radio95-rnt/fm95.git synced 2026-02-26 19:23:51 +01:00

a good vban receiver!!!???? impossible!!!!

This commit is contained in:
2025-05-17 17:28:08 +02:00
parent 0104dcbc20
commit 120f9a2467
4 changed files with 361 additions and 1 deletions

View File

@@ -79,6 +79,38 @@ int init_PulseOutputDevice(PulseOutputDevice* dev, int sample_rate, int channels
return 0;
}
int init_PulseOutputDevicef(PulseOutputDevice* dev, int sample_rate, int channels, char* app_name, char *stream_name, char* device, pa_buffer_attr* buffer_attr, enum pa_sample_format format) {
if (dev->initialized) return -1;
pa_sample_spec sample_spec = {
.format = format,
.channels = channels,
.rate = sample_rate
};
pa_buffer_attr new_buffer_attr = *buffer_attr;
dev->sample_spec = sample_spec;
dev->buffer_attr = new_buffer_attr;
dev->app_name = strdup(app_name);
dev->stream_name = strdup(stream_name);
dev->device = strdup(device);
int error;
dev->dev = pa_simple_new(
NULL,
app_name,
PA_STREAM_PLAYBACK,
device,
stream_name,
&sample_spec,
NULL,
&new_buffer_attr,
&error
);
if (!dev->dev) return error;
dev->initialized = 1;
return 0;
}
int write_PulseOutputDevice(PulseOutputDevice* dev, float* buffer, size_t size) {
if (!dev->initialized) return -1;
int error;
@@ -86,6 +118,13 @@ int write_PulseOutputDevice(PulseOutputDevice* dev, float* buffer, size_t size)
return 0;
}
int write_PulseOutputDevicef(PulseOutputDevice* dev, void* buffer, size_t size) {
if (!dev->initialized) return -1;
int error;
if (pa_simple_write(dev->dev, buffer, size, &error) < 0) return error;
return 0;
}
void free_PulseOutputDevice(PulseOutputDevice* dev) {
if (dev->dev && dev->initialized) pa_simple_free(dev->dev);
free(dev->app_name);

View File

@@ -22,5 +22,7 @@ void free_PulseInputDevice(PulseInputDevice *dev);
typedef PulseInputDevice PulseOutputDevice;
int init_PulseOutputDevice(PulseOutputDevice *dev, int sample_rate, int channels, char *app_name, char *stream_name, char *device, pa_buffer_attr *buffer_attr);
int init_PulseOutputDevicef(PulseOutputDevice *dev, int sample_rate, int channels, char *app_name, char *stream_name, char *device, pa_buffer_attr *buffer_attr, pa_sample_format_t format);
int write_PulseOutputDevice(PulseOutputDevice *dev, float *buffer, size_t size);
int write_PulseOutputDevicef(PulseOutputDevice *dev, void *buffer, size_t size);
void free_PulseOutputDevice(PulseOutputDevice *dev);