同步相关 --及音量

复制代码
#include <windows.h>
#include <mutex>
#include "SDL.h"

#define REFRESH_EVENT  (SDL_USEREVENT + 1)

static SDL_Thread* refresh_thread;
static SDL_Event event;

static int thread_exit = 0;
static int refresh_video(void* opaque) {
    while (thread_exit == 0) {
        SDL_Event event;
        event.type = REFRESH_EVENT;
        SDL_PushEvent(&event);
        SDL_Delay(4000);
    }
    return 0;
}



int main(int argc, char** argv)
{

    refresh_thread = SDL_CreateThread(refresh_video, NULL, NULL);

    while (1) {
        SDL_WaitEvent(&event);
        if (event.type == REFRESH_EVENT) {
            printf("REFRESH_EVENT \n");
        }else if (event.type == SDL_QUIT) {
            printf("SDL_QUIT \n");
            break;
        }
        printf("while\n");
    }
    return 0;
}
复制代码

 

复制代码
    SDL_Event event;
    double remaining_time = 0.0;
    SDL_PumpEvents();
    //while (!SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT)) 
    SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT);
    {

        sdlRender->Display((uint8_t**)frame->data, frame->linesize);

#define DelayTime 5
        if (lastDts >= 0)
        {
            auto diff = frame->pkt_pts - lastDts;
            int duration = diff * 1000 / (video_stream->time_base.den
                / video_stream->time_base.num);
            if (duration > DelayTime && duration < 1000)
            {
                Sleep(duration - DelayTime);
                printf("Sleep %d ----------\n", duration - DelayTime);
            }
        }
        lastDts = frame->pkt_pts;


        SDL_PumpEvents();
    }
复制代码

 

音量

 

 

https://blog.csdn.net/weixinhum/article/details/34864625

posted @   cnchengv  阅读(31)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 通过 API 将Deepseek响应流式内容输出到前端
· 因为Apifox不支持离线,我果断选择了Apipost!
历史上的今天:
2020-12-31 1231
点击右上角即可分享
微信分享提示