1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
//macros compatibilité linux
#ifdef WIN32
# include <windows.h>
# define SLEEP(A) Sleep((A))
# define thread_hdl HANDLE
# define CREATE_THREAD(hdl, attr, fct, param) hdl = CreateThread (0, 0, (LPTHREAD_START_ROUTINE)fct, param, 0, 0)
# define JOIN_THREAD(hdl, ret) WaitForSingleObject(hdl, INFINITE)
# define mutex_hdl HANDLE
# define CREATE_MUTEX(mut, attr) mut = CreateMutex((LPSECURITY_ATTRIBUTES)MUTEX_ALL_ACCESS, false, 0)
# define LOCK_MUTEX(mut) WaitForSingleObject(mut,INFINITE)
# define UNLOCK_MUTEX(mut) ReleaseMutex(mut)
# define DESTROY_MUTEX(mut) CloseHandle(mut)
# define cond_hdl HANDLE
# define CREATE_SIGNAL(sig, attr) sig = CreateEvent((LPSECURITY_ATTRIBUTES)EVENT_ALL_ACCESS, false, false, 0)
# define SEND_SIGNAL(sig) SetEvent(sig)
# define WAIT_SIGNAL(sig, mut) WaitForSingleObject(sig, INFINITE)
# define DESTROY_SIGNAL(sig) CloseHandle(sig)
#else
# include <pthread.h>
# define SLEEP(A) usleep(A * 1000)
# define thread_hdl pthread_t
# define CREATE_THREAD(hdl, attr, fct, param) pthread_create(&hdl, attr, fct, param)
# define JOIN_THREAD(hdl, ret) pthread_join(hdl, ret);
# define mutex_hdl pthread_mutex_t
# define CREATE_MUTEX(mut, attr) pthread_mutex_init(&mut, attr)
# define LOCK_MUTEX(mut) pthread_mutex_lock(&mut)
# define UNLOCK_MUTEX(mut) pthread_mutex_unlock(&mut)
# define DESTROY_MUTEX(mut) pthread_mutex_destroy(&mut)
# define cond_hdl pthread_cond_t
# define CREATE_SIGNAL(sid, attr) pthread_cond_init(&sig, attr)
# define SEND_SIGNAL(sig) pthread_cond_signal(&sig)
# define WAIT_SIGNAL(sig, mut) pthread_cond_wait(&sig, mut)
# define DESTROY_SIGNAL(sig) pthread_cond_destroy(&sig)
#endif
//!macros compatibilité linux
Stream::Stream (std::string& s)
{
filename_ = s;
}
void Stream::Init(std::string& s)
{
iformat_ = 0;
opened = false;
stop_requested = false;
playing = false;
paused = false;
opened = false;
CREATE_MUTEX(this->mut_packet_queue_, 0);
// CREATE_SIGNAL(this->cond_packet_queue_, 0);
CREATE_MUTEX(this->mut_data_queue_, 0); // le debuggeur pointe la dessus lorsque le programme plante
//CREATE_SIGNAL(this->cond_data_queue_, 0);
} |
Partager