mirror of
https://github.com/radio95-rnt/fm95.git
synced 2026-02-26 19:23:51 +01:00
fix access denied errors
This commit is contained in:
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@@ -38,7 +38,10 @@
|
|||||||
"time.h": "c",
|
"time.h": "c",
|
||||||
"vban.h": "c",
|
"vban.h": "c",
|
||||||
"chimer.h": "c",
|
"chimer.h": "c",
|
||||||
"liquid.h": "c"
|
"liquid.h": "c",
|
||||||
|
"queue": "c",
|
||||||
|
"thread": "c",
|
||||||
|
"vector": "c"
|
||||||
},
|
},
|
||||||
"C_Cpp.errorSquiggles": "disabled"
|
"C_Cpp.errorSquiggles": "disabled"
|
||||||
}
|
}
|
||||||
26
io/audio.c
26
io/audio.c
@@ -5,7 +5,7 @@ int init_PulseInputDevice(PulseInputDevice* dev, int sample_rate, int channels,
|
|||||||
debug_printf("Initializing PulseInputDevice format with app_name: %s, stream_name: %s, device: %s, sample_rate: %d, channels: %d, format: %d\n", app_name, stream_name, device, sample_rate, channels, format);
|
debug_printf("Initializing PulseInputDevice format with app_name: %s, stream_name: %s, device: %s, sample_rate: %d, channels: %d, format: %d\n", app_name, stream_name, device, sample_rate, channels, format);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (dev->initialized) return -1;
|
if (dev->initialized) return PA_ERR_BADSTATE;
|
||||||
pa_sample_spec sample_spec = {.format = format, .channels = channels, .rate = sample_rate};
|
pa_sample_spec sample_spec = {.format = format, .channels = channels, .rate = sample_rate};
|
||||||
pa_buffer_attr new_buffer_attr = *buffer_attr;
|
pa_buffer_attr new_buffer_attr = *buffer_attr;
|
||||||
dev->sample_spec = sample_spec;
|
dev->sample_spec = sample_spec;
|
||||||
@@ -23,7 +23,7 @@ int init_PulseInputDevice(PulseInputDevice* dev, int sample_rate, int channels,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int read_PulseInputDevice(PulseInputDevice* dev, void* buffer, size_t size) {
|
int read_PulseInputDevice(PulseInputDevice* dev, void* buffer, size_t size) {
|
||||||
if (!dev->initialized) return -1;
|
if (!dev->initialized) return PA_ERR_BADSTATE;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
pa_simple_read(dev->dev, buffer, size, &error);
|
pa_simple_read(dev->dev, buffer, size, &error);
|
||||||
return error;
|
return error;
|
||||||
@@ -46,12 +46,8 @@ int init_PulseOutputDevice(PulseOutputDevice* dev, int sample_rate, int channels
|
|||||||
debug_printf("Initializing PulseOutputDevice format with app_name: %s, stream_name: %s, device: %s, sample_rate: %d, channels: %d, format: %d\n", app_name, stream_name, device, sample_rate, channels, format);
|
debug_printf("Initializing PulseOutputDevice format with app_name: %s, stream_name: %s, device: %s, sample_rate: %d, channels: %d, format: %d\n", app_name, stream_name, device, sample_rate, channels, format);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (dev->initialized) return -1;
|
if (dev->initialized) return PA_ERR_BADSTATE;
|
||||||
pa_sample_spec sample_spec = {
|
pa_sample_spec sample_spec = {.format = format, .channels = channels, .rate = sample_rate};
|
||||||
.format = format,
|
|
||||||
.channels = channels,
|
|
||||||
.rate = sample_rate
|
|
||||||
};
|
|
||||||
pa_buffer_attr new_buffer_attr = *buffer_attr;
|
pa_buffer_attr new_buffer_attr = *buffer_attr;
|
||||||
dev->sample_spec = sample_spec;
|
dev->sample_spec = sample_spec;
|
||||||
dev->buffer_attr = new_buffer_attr;
|
dev->buffer_attr = new_buffer_attr;
|
||||||
@@ -61,24 +57,14 @@ int init_PulseOutputDevice(PulseOutputDevice* dev, int sample_rate, int channels
|
|||||||
dev->device = strdup(device);
|
dev->device = strdup(device);
|
||||||
|
|
||||||
int error;
|
int error;
|
||||||
dev->dev = pa_simple_new(
|
dev->dev = pa_simple_new(NULL, app_name, PA_STREAM_PLAYBACK, device, stream_name, &sample_spec, NULL, &new_buffer_attr, &error);
|
||||||
NULL,
|
|
||||||
app_name,
|
|
||||||
PA_STREAM_PLAYBACK,
|
|
||||||
device,
|
|
||||||
stream_name,
|
|
||||||
&sample_spec,
|
|
||||||
NULL,
|
|
||||||
&new_buffer_attr,
|
|
||||||
&error
|
|
||||||
);
|
|
||||||
if (!dev->dev) return error;
|
if (!dev->dev) return error;
|
||||||
dev->initialized = 1;
|
dev->initialized = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_PulseOutputDevice(PulseOutputDevice* dev, void* buffer, size_t size) {
|
int write_PulseOutputDevice(PulseOutputDevice* dev, void* buffer, size_t size) {
|
||||||
if (!dev->initialized) return -1;
|
if (!dev->initialized) return PA_ERR_BADSTATE;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
if(pa_simple_write(dev->dev, buffer, size, &error) == 0) return 0;
|
if(pa_simple_write(dev->dev, buffer, size, &error) == 0) return 0;
|
||||||
return error;
|
return error;
|
||||||
|
|||||||
@@ -372,6 +372,7 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FM95_Runtime runtime;
|
FM95_Runtime runtime;
|
||||||
|
memset(&runtime, 0, sizeof(runtime));
|
||||||
|
|
||||||
int mpx_on = (strlen(mpx_device_name) != 0);
|
int mpx_on = (strlen(mpx_device_name) != 0);
|
||||||
int rds_on = (strlen(rds_device_name) != 0 && config.rds_streams != 0);
|
int rds_on = (strlen(rds_device_name) != 0 && config.rds_streams != 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user