summaryrefslogtreecommitdiff
path: root/stable_diffusion.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'stable_diffusion.cpp')
-rw-r--r--stable_diffusion.cpp103
1 files changed, 32 insertions, 71 deletions
diff --git a/stable_diffusion.cpp b/stable_diffusion.cpp
index dc12bbc..469a85a 100644
--- a/stable_diffusion.cpp
+++ b/stable_diffusion.cpp
@@ -163,43 +163,6 @@ struct curl_state
};
static void
-Curl_Main()
-{
- if (State->CurlActive == -1) {
- Curl_GET_Init(&MainHandle, State->Dump1, State->JSONPayload, State->SD.ServerAddress, State->SD.Mode);
- Curl_Prog_Init(&ProgHandle, State->Dump2);
- State->CurlActive = 1;
- } else {
- if (Curl_Check(&MainHandle) == 1) {
- SD_JSONToSource(File, State, &Memory, State->Dump1, State->SD.Height, State->SD.Width);
- Curl_StopAll(State, &ProgHandle, &MainHandle);
- }
- uint64 Time = ImGui::GetTime();
- if (Time - State->SDTimer > 0.3f) {
- int Test = Curl_Check(&ProgHandle);
- if (Test == 1) {
- SD_ParseProgress(State, (char *)State->Dump2);
- curl_multi_remove_handle(ProgHandle.curlm, ProgHandle.curl);
- curl_easy_reset(ProgHandle.curl);
- ProgHandle.CurlData.size = 0;
- curl_easy_setopt(ProgHandle.curl, CURLOPT_URL, "http://127.0.0.1:7860/sdapi/v1/progress");
- curl_easy_setopt(ProgHandle.curl, CURLOPT_WRITEFUNCTION, dumbcurlcallback);
- curl_easy_setopt(ProgHandle.curl, CURLOPT_WRITEDATA, (void *)&ProgHandle.CurlData);
- curl_multi_add_handle(ProgHandle.curlm, ProgHandle.curl);
- } else if (Test == -1) {
- PostMsg(State, "Active stable-diffusion-webui instance not found at URL.");
- Curl_StopAll(State, &ProgHandle, &MainHandle);
- } else if (Test == -2) {
- PostMsg(State, "CURL error; see command line.");
- Curl_StopAll(State, &ProgHandle, &MainHandle);
- }
- State->SDTimer = Time;
- }
- Inc++;
- }
-}
-
-static void
Curl_Free(curl_state *Handle)
{
curl_multi_remove_handle(Handle->curlm, Handle->curl);
@@ -287,40 +250,38 @@ Curl_Prog_Init(curl_state *C, void *OutputData)
curl_multi_add_handle(C->curlm, C->curl);
}
- /*
- int num;
- CURLMcode mc = curl_multi_perform(C->curlm, &num);
- Assert(!mc);
-
- int queue = 0;
- CURLMsg *msg = curl_multi_info_read(C->curlm, &queue);
- if (msg) {
- CURL *e = msg->easy_handle;
- if (msg->msg == CURLMSG_DONE) {
- if (msg->data.result == CURLE_COULDNT_CONNECT) {
- printf("Active stable-diffusion-webui instance not found at URL.\n");
- } else {
- printf("curl error: %s!\n", curl_easy_strerror(msg->data.result));
+static void
+Curl_Main(project_data *File, project_state *State, memory *Memory, curl_state *MainHandle, curl_state *ProgHandle)
+{
+ if (State->CurlActive == -1) {
+ Curl_GET_Init(MainHandle, State->Dump1, State->JSONPayload, State->SD.ServerAddress, State->SD.Mode);
+ Curl_Prog_Init(ProgHandle, State->Dump2);
+ State->CurlActive = 1;
+ } else {
+ if (Curl_Check(MainHandle) == 1) {
+ SD_JSONToSource(File, State, Memory, State->Dump1, State->SD.Height, State->SD.Width);
+ Curl_StopAll(State, ProgHandle, MainHandle);
+ }
+ uint64 Time = ImGui::GetTime();
+ if (Time - State->SDTimer > 0.3f) {
+ int Test = Curl_Check(ProgHandle);
+ if (Test == 1) {
+ SD_ParseProgress(State, (char *)State->Dump2);
+ curl_multi_remove_handle(ProgHandle->curlm, ProgHandle->curl);
+ curl_easy_reset(ProgHandle->curl);
+ ProgHandle->CurlData.size = 0;
+ curl_easy_setopt(ProgHandle->curl, CURLOPT_URL, "http://127.0.0.1:7860/sdapi/v1/progress");
+ curl_easy_setopt(ProgHandle->curl, CURLOPT_WRITEFUNCTION, dumbcurlcallback);
+ curl_easy_setopt(ProgHandle->curl, CURLOPT_WRITEDATA, (void *)&ProgHandle->CurlData);
+ curl_multi_add_handle(ProgHandle->curlm, ProgHandle->curl);
+ } else if (Test == -1) {
+ PostMsg(State, "Active stable-diffusion-webui instance not found at URL.");
+ Curl_StopAll(State, ProgHandle, MainHandle);
+ } else if (Test == -2) {
+ PostMsg(State, "CURL error; see command line.");
+ Curl_StopAll(State, ProgHandle, MainHandle);
}
- Assert(0);
+ State->SDTimer = Time;
}
}
- */
-
-
-#if 0
- res = curl_easy_perform(curl);
- /* Check for errors */
- if(res != CURLE_OK)
- fprintf(stderr, "curl_easy_perform() failed: %s\n",
- curl_easy_strerror(res));
-
- /* Perform the request, res will get the return code */
-
- /* always cleanup */
- curl_slist_free_all(list);
- curl_easy_cleanup(curl);
-
-
- curl_global_cleanup();
-#endif
+}