diff --git a/.vscode/settings.json b/.vscode/settings.json index f64c144..ad69577 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -38,7 +38,10 @@ "time.h": "c", "vban.h": "c", "chimer.h": "c", - "liquid.h": "c" + "liquid.h": "c", + "queue": "c", + "thread": "c", + "vector": "c" }, "C_Cpp.errorSquiggles": "disabled" } \ No newline at end of file diff --git a/io/audio.c b/io/audio.c index a2b246c..6c68918 100644 --- a/io/audio.c +++ b/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); #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_buffer_attr new_buffer_attr = *buffer_attr; 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) { - if (!dev->initialized) return -1; + if (!dev->initialized) return PA_ERR_BADSTATE; int error = 0; pa_simple_read(dev->dev, buffer, size, &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); #endif - if (dev->initialized) return -1; - pa_sample_spec sample_spec = { - .format = format, - .channels = channels, - .rate = sample_rate - }; + if (dev->initialized) return PA_ERR_BADSTATE; + 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; @@ -61,24 +57,14 @@ int init_PulseOutputDevice(PulseOutputDevice* dev, int sample_rate, int channels 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 - ); + 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, void* buffer, size_t size) { - if (!dev->initialized) return -1; + if (!dev->initialized) return PA_ERR_BADSTATE; int error = 0; if(pa_simple_write(dev->dev, buffer, size, &error) == 0) return 0; return error; diff --git a/src/fm95.c b/src/fm95.c index 688183f..0d4ddc7 100644 --- a/src/fm95.c +++ b/src/fm95.c @@ -372,6 +372,7 @@ int main(int argc, char **argv) { } FM95_Runtime runtime; + memset(&runtime, 0, sizeof(runtime)); int mpx_on = (strlen(mpx_device_name) != 0); int rds_on = (strlen(rds_device_name) != 0 && config.rds_streams != 0);