Update logging to also print to stdout + replace printf to logging.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#include "audio.h"
|
||||
#include "log.h"
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
static SDL_AudioSpec recording_spec;
|
||||
static SDL_AudioSpec playback_spec;
|
||||
static SDL_AudioSpec received_recording_spec;
|
||||
@@ -37,9 +39,9 @@ int audio_init(audio_state* state)
|
||||
int audio_recording_init(audio_state* state, int index)
|
||||
{
|
||||
SDL_AudioDeviceID device_id = SDL_OpenAudioDevice(SDL_GetAudioDeviceName(index, 1), 1, &recording_spec, &received_recording_spec, SDL_AUDIO_ALLOW_FORMAT_CHANGE);
|
||||
printf("Recording Device: %s\n", SDL_GetAudioDeviceName(index, 1));
|
||||
log_message(LOG_INFO, "Recording Device: %s", SDL_GetAudioDeviceName(index, 1));
|
||||
if (!device_id) {
|
||||
printf("Failed to open recording device! SDL Error: %s", SDL_GetError());
|
||||
log_message(LOG_INFO, "Failed to open recording device! SDL Error: %s", SDL_GetError());
|
||||
return 0;
|
||||
}
|
||||
state->recording_device_id = device_id;
|
||||
@@ -65,13 +67,13 @@ void audio_destroy(audio_state* state)
|
||||
int audio_playback_init(audio_state* state)
|
||||
{
|
||||
if (!state->recording_buffer) {
|
||||
printf("Audio buffer not initialized");
|
||||
log_message(LOG_INFO, "Audio buffer not initialized");
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_AudioDeviceID device_id = SDL_OpenAudioDevice(NULL, 0, &playback_spec, &received_playback_spec, SDL_AUDIO_ALLOW_FORMAT_CHANGE);
|
||||
if (!device_id) {
|
||||
printf("Failed to open playback device! SDL Error: %s", SDL_GetError());
|
||||
log_message(LOG_INFO, "Failed to open playback device! SDL Error: %s", SDL_GetError());
|
||||
return 0;
|
||||
}
|
||||
state->playback_device_id = device_id;
|
||||
@@ -79,7 +81,7 @@ int audio_playback_init(audio_state* state)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void audio_recording_callback(void* userdata, Uint8* stream, int len)
|
||||
void audio_recording_callback(void* userdata, uint8_t* stream, int len)
|
||||
{
|
||||
char string[64];
|
||||
audio_state* state = userdata;
|
||||
@@ -103,7 +105,7 @@ void audio_recording_callback(void* userdata, Uint8* stream, int len)
|
||||
log_message(LOG_INFO, string);
|
||||
}
|
||||
|
||||
void audio_playback_callback(void* userdata, Uint8* stream, int len)
|
||||
void audio_playback_callback(void* userdata, uint8_t* stream, int len)
|
||||
{
|
||||
char string[64];
|
||||
audio_state* state = userdata;
|
||||
|
||||
Reference in New Issue
Block a user