add libcurl basic example
This commit is contained in:
@@ -2,7 +2,7 @@ CC = gcc
|
|||||||
CFLAGS = -Wall -g
|
CFLAGS = -Wall -g
|
||||||
TARGET = audio_capture
|
TARGET = audio_capture
|
||||||
SRC = audio_capture.c
|
SRC = audio_capture.c
|
||||||
LIBS = -lavdevice -lavformat -lavcodec -lavutil -lasound
|
LIBS = -lavdevice -lavformat -lavcodec -lavutil -lasound -lcurl
|
||||||
|
|
||||||
$(TARGET): $(SRC)
|
$(TARGET): $(SRC)
|
||||||
$(CC) $(CFLAGS) -o $(TARGET) $(SRC) $(LIBS)
|
$(CC) $(CFLAGS) -o $(TARGET) $(SRC) $(LIBS)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#include <alsa/asoundlib.h>
|
#include <alsa/asoundlib.h>
|
||||||
#include <alsa/control.h>
|
#include <alsa/control.h>
|
||||||
#include <alsa/pcm.h>
|
#include <alsa/pcm.h>
|
||||||
|
#include <curl/curl.h>
|
||||||
|
|
||||||
// NOTE: find this via `arecord -l`
|
// NOTE: find this via `arecord -l`
|
||||||
#define ALSA_MIC_HARDWARE_DEVICE "hw:3"
|
#define ALSA_MIC_HARDWARE_DEVICE "hw:3"
|
||||||
@@ -13,6 +14,32 @@ void print_pcm_state(snd_pcm_t *pcm_handle) {
|
|||||||
printf("State of pcm handle: %s\n", state_name);
|
printf("State of pcm handle: %s\n", state_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t write_callback(void *contents, size_t size, size_t nmemb, void *userp) {
|
||||||
|
size_t total_size = size * nmemb;
|
||||||
|
printf("%.*s", (int)total_size, (char*)contents);
|
||||||
|
return total_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_request() {
|
||||||
|
CURL *curl;
|
||||||
|
CURLcode res;
|
||||||
|
curl = curl_easy_init();
|
||||||
|
|
||||||
|
if (curl) {
|
||||||
|
curl_easy_setopt(curl, CURLOPT_URL, "https://www.google.com");
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
|
||||||
|
|
||||||
|
res = curl_easy_perform(curl);
|
||||||
|
if (res != CURLE_OK)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "curl failed: %s\n", curl_easy_strerror(res));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
snd_pcm_t *pcm_handle = NULL;
|
snd_pcm_t *pcm_handle = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"arguments": [
|
||||||
|
"/usr/bin/gcc",
|
||||||
|
"-c",
|
||||||
|
"-Wall",
|
||||||
|
"-g",
|
||||||
|
"-o",
|
||||||
|
"audio_capture",
|
||||||
|
"audio_capture.c"
|
||||||
|
],
|
||||||
|
"directory": "/home/talksik/Documents/research_and_development/ai-conversation",
|
||||||
|
"file": "/home/talksik/Documents/research_and_development/ai-conversation/audio_capture.c",
|
||||||
|
"output": "/home/talksik/Documents/research_and_development/ai-conversation/audio_capture"
|
||||||
|
}
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user