Skip to content

Instantly share code, notes, and snippets.

@z4none
z4none / simplest_player.c
Created June 17, 2022 01:36 — forked from mashingan/simplest_player.c
Simplest example of creating player using FFMpeg and SDL2. Currently with choppy audio playing.
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#include <windows.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
//#include <libavutil/frame.h>
#include <SDL2/SDL.h>
#include <Windows.h>
#include <iostream>
#include <thread>
struct pipe
{
pipe()
{
SECURITY_ATTRIBUTES sa = { sizeof(sa), nullptr,true};
CreatePipe(&read, &write, &sa, 0);
@z4none
z4none / microtime.c
Created June 11, 2019 14:41
Get the current time in microseconds in C.
#include <sys/time.h>
/**
* Returns the current time in microseconds.
*/
long getMicrotime(){
struct timeval currentTime;
gettimeofday(&currentTime, NULL);
return currentTime.tv_sec * (int)1e6 + currentTime.tv_usec;
}
@z4none
z4none / SharedMemorySample_read_main.cpp
Created November 14, 2017 04:07 — forked from yoggy/SharedMemorySample_read_main.cpp
SharedMemory Sample for WIN32
#include <SDKDDKVer.h>
#include <Windows.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
int shmem_size = 16; // 16byte
HANDLE shmem = INVALID_HANDLE_VALUE;
HANDLE mutex = INVALID_HANDLE_VALUE;