Use proper flags for clang compiler too

parent c94f19ad
......@@ -63,6 +63,9 @@ STRICT_OPTIONS="-Wall -Wdeclaration-after-statement -Wuninitialized"
case $CC in
*clang*)
STRICT_OPTIONS="$STRICT_OPTIONS -Qunused-arguments "
#disabled due to wrong optimization false positive with small string
#(cf. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35903)
STRICT_OPTIONS="$STRICT_OPTIONS -Wno-array-bounds "
;;
esac
......@@ -70,6 +73,8 @@ if test "$strictness" = "yes" ; then
STRICT_OPTIONS="$STRICT_OPTIONS -Werror"
CFLAGS="$CFLAGS -fno-strict-aliasing"
fi
AC_SUBST(STRICT_OPTIONS)
dnl enable timestamp support
AC_ARG_ENABLE(ntp-timestamp,
......
......@@ -43,7 +43,7 @@ static int configure_fd(int fd, int bits,int stereo, int rate, int *minsz)
int i=0;
int min_size=0,blocksize=512;
int err;
//g_message("opening sound device");
/* unset nonblocking mode */
/* We wanted non blocking open but now put it back to normal ; thanks Xine !*/
......@@ -51,15 +51,15 @@ static int configure_fd(int fd, int bits,int stereo, int rate, int *minsz)
/* reset is maybe not needed but takes time*/
/*ioctl(fd, SNDCTL_DSP_RESET, 0); */
p=AFMT_S16_NE;
err=ioctl(fd,SNDCTL_DSP_SETFMT,&p);
if (err<0){
ms_warning("oss_open: can't set sample format:%s.",strerror(errno));
}
p = bits; /* 16 bits */
err=ioctl(fd, SNDCTL_DSP_SAMPLESIZE, &p);
if (err<0){
......@@ -71,13 +71,13 @@ static int configure_fd(int fd, int bits,int stereo, int rate, int *minsz)
if (err<0){
ms_warning("oss_open: can't set sample rate to %i:%s.",rate,strerror(errno));
}
p = stereo; /* stereo or not */
err=ioctl(fd, SNDCTL_DSP_STEREO, &p);
if (err<0){
ms_warning("oss_open: can't set mono/stereo mode:%s.",strerror(errno));
}
if (rate==16000) blocksize=4096; /* oss emulation is not very good at 16khz */
else blocksize=blocksize*(rate/8000);
......@@ -88,8 +88,9 @@ static int configure_fd(int fd, int bits,int stereo, int rate, int *minsz)
*/
if (min_size>blocksize) {
int size_selector=0;
int frag;
while ((blocksize >> size_selector) != 1)size_selector++; /*compute selector blocksize = 1<< size_selector*/
int frag = (2 << 16) | (size_selector);
frag = (2 << 16) | (size_selector);
if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &frag) == -1) {
ms_warning("This OSS driver does not support trying SNDCTL_DSP_SETFRAGMENT");
ioctl(fd, SNDCTL_DSP_GETBLKSIZE, &min_size);
......@@ -125,15 +126,15 @@ static int configure_fd(int fd, int bits,int stereo, int rate, int *minsz)
ms_message("/dev/dsp opened: rate=%i,bits=%i,stereo=%i blocksize=%i.",
rate,bits,stereo,min_size);
/* start recording !!! Alex */
{
int fl,res;
fl=PCM_ENABLE_OUTPUT|PCM_ENABLE_INPUT;
res=ioctl(fd, SNDCTL_DSP_SETTRIGGER, &fl);
if (res<0) ms_warning("OSS_TRIGGER: %s",strerror(errno));
}
}
*minsz=min_size;
return fd;
}
......@@ -245,7 +246,7 @@ static void oss_set_source(MSSndCard *card, MSSndCardCapture source)
p = 1 << SOUND_MIXER_LINE;
break;
}
mix_fd = open(d->mixdev, O_WRONLY);
ioctl(mix_fd, SOUND_MIXER_WRITE_RECSRC, &p);
close(mix_fd);
......@@ -331,7 +332,7 @@ static void * oss_thread(void *p){
int err;
mblk_t *rm=NULL;
bool_t did_read=FALSE;
oss_open(d,&bsize);
if (d->pcmfd_read>=0){
rtmpbuff=(uint8_t*)alloca(bsize);
......
......@@ -29,11 +29,11 @@ static MSFilter *pulse_card_create_writer(MSSndCard *card);
static void pulse_card_init(MSSndCard *obj){
}
static void pulse_card_uninit(MSSndCard *obj){
}
......@@ -69,8 +69,8 @@ static void uninit_pulse_context(){
}
static void context_state_notify_cb(pa_context *ctx, void *userdata){
contextState=pa_context_get_state(ctx);
const char *sname="";
contextState=pa_context_get_state(ctx);
switch (contextState){
case PA_CONTEXT_UNCONNECTED:
sname="PA_CONTEXT_UNCONNECTED";
......
......@@ -130,6 +130,7 @@ MSFactory *ms_factory_get_fallback(void){
void ms_factory_init(MSFactory *obj){
int i;
long num_cpu=1;
char *debug_log_enabled;
#ifdef WIN32
SYSTEM_INFO sysinfo;
#endif
......@@ -137,8 +138,8 @@ void ms_factory_init(MSFactory *obj){
#if defined(ENABLE_NLS)
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
#endif
if (getenv("MEDIASTREAMER_DEBUG")!=NULL && strcmp(getenv("MEDIASTREAMER_DEBUG"),"1")==0){
debug_log_enabled=getenv("MEDIASTREAMER_DEBUG");
if (debug_log_enabled!=NULL && (strcmp("1",debug_log_enabled)==0) ){
ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
}
......
......@@ -30,11 +30,11 @@ static const double smooth_coef=0.9;
#define TICKER_MEASUREMENTS 1
#if defined(__ARM_ARCH__)
#if defined(__ARM_ARCH__)
# if __ARM_ARCH__ < 7
/* as MSTicker load computation requires floating point, we prefer to disable it on ARM processors without FPU*/
# undef TICKER_MEASUREMENTS
# define TICKER_MEASUREMENTS 0
# define TICKER_MEASUREMENTS 0
# endif
#endif
......@@ -154,7 +154,7 @@ int ms_ticker_attach_multiple(MSTicker *ticker,MSFilter *f,...)
for(it=filters;it!=NULL;it=it->next)
ms_filter_preprocess((MSFilter*)it->data,ticker);
ms_list_free(filters);
total_sources=ms_list_concat(total_sources,sources);
total_sources=ms_list_concat(total_sources,sources);
}else ms_message("Filter %s is already being scheduled; nothing to do.",f->desc->name);
}while ((f=va_arg(l,MSFilter*))!=NULL);
va_end(l);
......@@ -239,8 +239,8 @@ static void run_graph(MSFilter *f, MSTicker *s, MSList **unschedulable, bool_t f
if (filter_can_process(f,s->ticks) || force_schedule) {
/* this is a candidate */
f->last_tick=s->ticks;
call_process(f);
/* now recurse to next filters */
call_process(f);
/* now recurse to next filters */
for(i=0;i<f->desc->noutputs;i++){
l=f->outputs[i];
if (l!=NULL){
......@@ -261,7 +261,7 @@ static void run_graphs(MSTicker *s, MSList *execution_list, bool_t force_schedul
run_graph((MSFilter*)it->data,s,&unschedulable,force_schedule);
}
/* filters that are part of a loop haven't been called in process() because one of their input refers to a filter that could not be scheduled (because they could not be scheduled themselves)... Do you understand ?*/
/* we resolve this by simply assuming that they must be called anyway
/* we resolve this by simply assuming that they must be called anyway
for the loop to run correctly*/
/* we just recall run_graphs on them, as if they were source filters */
if (unschedulable!=NULL) {
......@@ -319,7 +319,7 @@ static void sleepMs(int ms){
static int set_high_prio(MSTicker *obj){
int precision=2;
int prio=obj->prio;
if (prio>MS_TICKER_PRIO_NORMAL){
#ifdef WIN32
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
......@@ -347,14 +347,14 @@ static int set_high_prio(MSTicker *obj){
#else
struct sched_param param;
int policy=SCHED_RR;
memset(&param,0,sizeof(param));
int result=0;
char* env_prio_c=NULL;
int min_prio, max_prio, env_prio;
memset(&param,0,sizeof(param));
if (prio==MS_TICKER_PRIO_REALTIME)
policy=SCHED_FIFO;
min_prio = sched_get_priority_min(policy);
max_prio = sched_get_priority_max(policy);
env_prio_c = getenv("MS_TICKER_SCHEDPRIO");
......@@ -368,7 +368,7 @@ static int set_high_prio(MSTicker *obj){
if((result=pthread_setschedparam(pthread_self(),policy, &param))) {
if (result==EPERM){
/*
The linux kernel has
The linux kernel has
sched_get_priority_max(SCHED_OTHER)=sched_get_priority_max(SCHED_OTHER)=0.
As long as we can't use SCHED_RR or SCHED_FIFO, the only way to increase priority of a calling thread
is to use setpriority().
......@@ -404,7 +404,7 @@ static int wait_next_tick(void *data, uint64_t virt_ticker_time){
uint64_t realtime;
int64_t diff;
int late;
while(1){
realtime=s->get_cur_time_ptr(s->get_cur_time_data)-s->orig;
diff=s->time-realtime;
......@@ -426,14 +426,14 @@ void * ms_ticker_run(void *arg)
int lastlate=0;
int precision=2;
int late;
precision = set_high_prio(s);
s->ticks=1;
s->orig=s->get_cur_time_ptr(s->get_cur_time_data);
ms_mutex_lock(&s->lock);
while(s->run){
s->ticks++;
/*Step 1: run the graphs*/
......@@ -472,13 +472,13 @@ void * ms_ticker_run(void *arg)
void ms_ticker_set_time_func(MSTicker *ticker, MSTickerTimeFunc func, void *user_data){
if (func==NULL) func=get_cur_time_ms;
ticker->get_cur_time_ptr=func;
ticker->get_cur_time_data=user_data;
/*re-set the origin to take in account that previous function ptr and the
new one may return different times*/
ticker->orig=func(user_data)-ticker->time;
ms_message("ms_ticker_set_time_func: ticker's time method updated.");
}
......@@ -503,7 +503,7 @@ static void print_graph(MSFilter *f, MSTicker *s, MSList **unschedulable, bool_t
/* this is a candidate */
f->last_tick=s->ticks;
ms_message("print_graphs: %s", f->desc->name);
/* now recurse to next filters */
/* now recurse to next filters */
for(i=0;i<f->desc->noutputs;i++){
l=f->outputs[i];
if (l!=NULL){
......@@ -524,7 +524,7 @@ static void print_graphs(MSTicker *s, MSList *execution_list, bool_t force_sched
print_graph((MSFilter*)it->data,s,&unschedulable,force_schedule);
}
/* filters that are part of a loop haven't been called in process() because one of their input refers to a filter that could not be scheduled (because they could not be scheduled themselves)... Do you understand ?*/
/* we resolve this by simply assuming that they must be called anyway
/* we resolve this by simply assuming that they must be called anyway
for the loop to run correctly*/
/* we just recall run_graphs on them, as if they were source filters */
if (unschedulable!=NULL) {
......
......@@ -70,7 +70,7 @@ enum {
#define TEXTURE_BUFFER_SIZE 3
struct opengles_display {
struct opengles_display {
/* input: yuv image to display */
ms_mutex_t yuv_mutex;
mblk_t *yuv[MAX_IMAGE];
......@@ -83,7 +83,7 @@ struct opengles_display {
MSVideoSize allocatedTexturesSize[MAX_IMAGE];
int texture_index;
/* GL view size */
GLint backingWidth;
GLint backingHeight;
......@@ -117,12 +117,12 @@ struct opengles_display* ogl_display_new() {
void ogl_display_free(struct opengles_display* gldisp) {
int i;
if (!gldisp) {
ms_error("%s called with null struct opengles_display", __FUNCTION__);
return;
}
for(i=0; i<MAX_IMAGE; i++) {
if (gldisp->yuv[i]) {
ms_free(gldisp->yuv[i]);
......@@ -138,9 +138,9 @@ void ogl_display_set_size(struct opengles_display* gldisp, int width, int height
gldisp->backingWidth = width;
gldisp->backingHeight = height;
ms_message("resize opengles_display (%d x %d, gl initialized:%d)", width, height, gldisp->glResourcesInitialized);
GL_OPERATION(glViewport(0, 0, gldisp->backingWidth, gldisp->backingHeight));
check_GL_errors("ogl_display_set_size");
}
......@@ -158,7 +158,7 @@ void ogl_display_init(struct opengles_display* gldisp, int width, int height) {
GL_OPERATION(glClearColor(0, 0, 0, 1))
ogl_display_set_size(gldisp, width, height);
if (gldisp->glResourcesInitialized)
return;
......@@ -180,17 +180,17 @@ void ogl_display_init(struct opengles_display* gldisp, int width, int height) {
ms_message("OpenGL GLSL version: %s", glGetString(GL_SHADING_LANGUAGE_VERSION));
}
load_shaders(&gldisp->program, gldisp->uniforms);
GL_OPERATION(glUseProgram(gldisp->program))
gldisp->glResourcesInitialized = TRUE;
check_GL_errors("ogl_display_init");
}
void ogl_display_uninit(struct opengles_display* gldisp, bool_t freeGLresources) {
int i,j;
if (!gldisp) {
ms_error("%s called with null struct opengles_display", __FUNCTION__);
return;
......@@ -215,11 +215,12 @@ void ogl_display_uninit(struct opengles_display* gldisp, bool_t freeGLresources)
}
gldisp->glResourcesInitialized = FALSE;
check_GL_errors("ogl_display_uninit");
}
static void ogl_display_set_yuv(struct opengles_display* gldisp, mblk_t *yuv, enum ImageType type) {
int j;
if (!gldisp) {
ms_error("%s called with null struct opengles_display", __FUNCTION__);
return;
......@@ -228,12 +229,11 @@ static void ogl_display_set_yuv(struct opengles_display* gldisp, mblk_t *yuv, en
if (gldisp->yuv[type])
freemsg(gldisp->yuv[type]);
gldisp->yuv[type] = dupmsg(yuv);
int j;
for(j = 0; j < TEXTURE_BUFFER_SIZE; ++j) {
gldisp->new_yuv_image[j][type] = TRUE;
}
ms_mutex_unlock(&gldisp->yuv_mutex);
ms_mutex_unlock(&gldisp->yuv_mutex);
}
void ogl_display_set_yuv_to_display(struct opengles_display* gldisp, mblk_t *yuv) {
......@@ -245,49 +245,57 @@ void ogl_display_set_preview_yuv_to_display(struct opengles_display* gldisp, mbl
}
static void ogl_display_render_type(struct opengles_display* gldisp, enum ImageType type, bool_t clear, float vpx, float vpy, float vpw, float vph, int orientation) {
if (!gldisp) {
float uLeft, uRight, vTop, vBottom;
GLfloat squareUvs[8];
GLfloat squareVertices[8];
int screenW, screenH;
int x,y,w,h;
GLfloat mat[16];
float rad;
if (!gldisp) {
ms_error("%s called with null struct opengles_display", __FUNCTION__);
return;
}
if (!gldisp->yuv[type] || !gldisp->glResourcesInitialized) {
return;
}
ms_mutex_lock(&gldisp->yuv_mutex);
if (gldisp->new_yuv_image[gldisp->texture_index][type]) {
update_textures_with_yuv(gldisp, type);
gldisp->new_yuv_image[gldisp->texture_index][type] = FALSE;
}
ms_mutex_unlock(&gldisp->yuv_mutex);
float uLeft, uRight, vTop, vBottom;
uLeft = vBottom = 0.0f;
uRight = gldisp->uvx[type];
vTop = gldisp->uvy[type];
GLfloat squareUvs[] = {
uLeft, vTop,
uRight, vTop,
uLeft, vBottom,
uRight, vBottom
};
vTop = gldisp->uvy[type];
squareUvs[0] = uLeft;
squareUvs[1] = vTop;
squareUvs[2] = uRight;
squareUvs[3] = vTop;
squareUvs[4] = uLeft;
squareUvs[5] = vBottom;
squareUvs[6] = uRight;
squareUvs[7] = vBottom;
if (clear) {
GL_OPERATION(glClear(GL_COLOR_BUFFER_BIT))
}
GLfloat squareVertices[8];
// drawing surface dimensions
int screenW = gldisp->backingWidth;
int screenH = gldisp->backingHeight;
screenW = gldisp->backingWidth;
screenH = gldisp->backingHeight;
if (orientation == 90 || orientation == 270) {
screenW = screenH;
screenH = gldisp->backingWidth;
screenH = gldisp->backingWidth;
}
int x,y,w,h;
// Fill the smallest dimension, then compute the other one using the image ratio
if (screenW <= screenH) {
float ratio = (gldisp->yuv_size[type].height) / (float)(gldisp->yuv_size[type].width);
......@@ -310,7 +318,7 @@ static void ogl_display_render_type(struct opengles_display* gldisp, enum ImageT
x = vpx * screenW;
y = vpy * screenH;
}
squareVertices[0] = (x - w * 0.5) / screenW - 0.;
squareVertices[1] = (y - h * 0.5) / screenH - 0.;
squareVertices[2] = (x + w * 0.5) / screenW - 0.;
......@@ -319,8 +327,7 @@ static void ogl_display_render_type(struct opengles_display* gldisp, enum ImageT
squareVertices[5] = (y + h * 0.5) / screenH - 0.;
squareVertices[6] = (x + w * 0.5) / screenW - 0.;
squareVertices[7] = (y + h * 0.5) / screenH - 0.;
GLfloat mat[16];
#define VP_SIZE 1.0f
if (type == REMOTE_IMAGE) {
float scale_factor = 1.0 / gldisp->zoom_factor;
......@@ -335,26 +342,26 @@ static void ogl_display_render_type(struct opengles_display* gldisp, enum ImageT
else diff = bMax - (a + aSize); \
a += diff; \
}
ENSURE_RANGE_A_INSIDE_RANGE_B(gldisp->zoom_cx, vpDim, squareVertices[0], squareVertices[2])
ENSURE_RANGE_A_INSIDE_RANGE_B(gldisp->zoom_cy, vpDim, squareVertices[1], squareVertices[7])
load_orthographic_matrix(
gldisp->zoom_cx - vpDim,
gldisp->zoom_cx + vpDim,
gldisp->zoom_cy - vpDim,
gldisp->zoom_cy + vpDim,
gldisp->zoom_cx - vpDim,
gldisp->zoom_cx + vpDim,
gldisp->zoom_cy - vpDim,
gldisp->zoom_cy + vpDim,
0, 0.5, mat);
} else {
load_orthographic_matrix(- VP_SIZE * 0.5, VP_SIZE * 0.5, - VP_SIZE * 0.5, VP_SIZE * 0.5, 0, 0.5, mat);
}
GL_OPERATION(glUniformMatrix4fv(gldisp->uniforms[UNIFORM_PROJ_MATRIX], 1, GL_FALSE, mat))
float rad = (2.0 * 3.14157 * orientation / 360.0); // Convert orientation to radian
rad = (2.0 * 3.14157 * orientation / 360.0); // Convert orientation to radian
GL_OPERATION(glUniform1f(gldisp->uniforms[UNIFORM_ROTATION], rad))
GL_OPERATION(glActiveTexture(GL_TEXTURE0))
GL_OPERATION(glBindTexture(GL_TEXTURE_2D, gldisp->textures[gldisp->texture_index][type][Y]))
GL_OPERATION(glUniform1i(gldisp->uniforms[UNIFORM_TEXTURE_Y], 0))
......@@ -364,23 +371,23 @@ static void ogl_display_render_type(struct opengles_display* gldisp, enum ImageT
GL_OPERATION(glActiveTexture(GL_TEXTURE2))
GL_OPERATION(glBindTexture(GL_TEXTURE_2D, gldisp->textures[gldisp->texture_index][type][V]))
GL_OPERATION(glUniform1i(gldisp->uniforms[UNIFORM_TEXTURE_V], 2))
GL_OPERATION(glVertexAttribPointer(ATTRIB_VERTEX, 2, GL_FLOAT, 0, 0, squareVertices))
GL_OPERATION(glEnableVertexAttribArray(ATTRIB_VERTEX))
GL_OPERATION(glVertexAttribPointer(ATTRIB_UV, 2, GL_FLOAT, 1, 0, squareUvs))
GL_OPERATION(glEnableVertexAttribArray(ATTRIB_UV))
GL_OPERATION(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4))
GL_OPERATION(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4))
check_GL_errors("ogl_display_render_type");
}
void ogl_display_render(struct opengles_display* gldisp, int orientation) {
ogl_display_render_type(gldisp, REMOTE_IMAGE, TRUE, 0, 0, 1, 1, orientation);
// preview image already have the correct orientation
ogl_display_render_type(gldisp, PREVIEW_IMAGE, FALSE, 0.4f, -0.4f, 0.2f, 0.2f, 0);
gldisp->texture_index = (gldisp->texture_index + 1) % TEXTURE_BUFFER_SIZE;
}
......@@ -404,12 +411,12 @@ static void check_GL_errors(const char* context) {
}
static bool_t load_shaders(GLuint* program, GLint* uniforms) {
GLuint vertShader, fragShader;
#include "yuv2rgb.vs.h"
#include "yuv2rgb.fs.h"
(void)yuv2rgb_vs_len;
(void)yuv2rgb_fs_len;
GLuint vertShader, fragShader;
*program = glCreateProgram();
if (!compileShader(&vertShader, GL_VERTEX_SHADER, (const char*)yuv2rgb_vs))
......@@ -436,7 +443,7 @@ static bool_t load_shaders(GLuint* program, GLint* uniforms) {
glDeleteShader(fragShader);
return TRUE;
check_GL_errors("load_shaders");
}
......@@ -498,7 +505,7 @@ static void allocate_gl_textures(struct opengles_display* gldisp, int w, int h,
gldisp->allocatedTexturesSize[type].height = h;
ms_message("%s: allocated new textures[%d] (%d x %d)\n", __FUNCTION__, type, w, h);
check_GL_errors("allocate_gl_textures");
}
......@@ -562,7 +569,7 @@ static bool_t update_textures_with_yuv(struct opengles_display* gldisp, enum Ima
gldisp->yuv_size[type].height = yuvbuf.h;
check_GL_errors("update_textures_with_yuv");
return TRUE;
}
......
/*
File: shaders.c
Abstract: Shader utilities for compiling, linking and validating shaders.
Abstract: Shader utilities for compiling, linking and validating shaders.
It is important to check the result status.
Copyright (C) 2009 Apple Inc. All Rights Reserved.
Code based on Apple's OpenGLES sample
Code based on Apple's OpenGLES sample
*/
#include "shaders.h"
......@@ -16,17 +16,17 @@
GLint compileShader(GLuint *shader, GLenum type, const char *sources)
{
GLint status;
GLint logLength;
if (!sources)
{
ms_error("Failed to load vertex shader");
return 0;
}
*shader = glCreateShader(type); // create shader
glShaderSource(*shader, 1, &sources, 0); // set source code in the shader
glCompileShader(*shader); // compile shader
GLint logLength;
glGetShaderiv(*shader, GL_INFO_LOG_LENGTH, &logLength);
if (logLength > 1)
{
......@@ -35,13 +35,13 @@ GLint compileShader(GLuint *shader, GLenum type, const char *sources)
ms_message("Shader compile log:\n%s", log);
free(log);
}
glGetShaderiv(*shader, GL_COMPILE_STATUS, &status);
if (status == GL_FALSE)
{
ms_error("Failed to compile shader\n");
}
return status;
}
......@@ -50,10 +50,10 @@ GLint compileShader(GLuint *shader, GLenum type, const char *sources)
GLint linkProgram(GLuint prog)
{
GLint status;
glLinkProgram(prog);
GLint logLength;
glLinkProgram(prog);
glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &logLength);
if (logLength > 1)
{
......@@ -62,11 +62,11 @@ GLint linkProgram(GLuint prog)
ms_message("Program link log:\n%s", log);
free(log);
}
glGetProgramiv(prog, GL_LINK_STATUS, &status);
if (status == GL_FALSE)
ms_error("Failed to link program %d", prog);
return status;
}
......@@ -75,7 +75,7 @@ GLint linkProgram(GLuint prog)
GLint validateProgram(GLuint prog)
{
GLint logLength, status;
glValidateProgram(prog);
glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &logLength);
if (logLength > 0)
......@@ -85,17 +85,17 @@ GLint validateProgram(GLuint prog)
ms_debug("Program validate log:\n%s", log);
free(log);
}
glGetProgramiv(prog, GL_VALIDATE_STATUS, &status);
if (status == GL_FALSE)
ms_error("Failed to validate program %d", prog);
return status;
}
/* delete shader resources */
void destroyShaders(GLuint vertShader, GLuint fragShader, GLuint prog)
{
{
if (vertShader) {
glDeleteShader(vertShader);
vertShader = 0;
......
......@@ -163,7 +163,7 @@ static void glxvideo_process(MSFilter *f){
mblk_t *inm;
MSPicture src={0};
bool_t precious=FALSE;
XWindowAttributes wa;
XGetWindowAttributes(obj->display,obj->window_id,&wa);
if (wa.width!=obj->wsize.width || wa.height!=obj->wsize.height){
......@@ -172,7 +172,7 @@ static void glxvideo_process(MSFilter *f){
obj->wsize.height=wa.height;
ogl_display_init(obj->glhelper, wa.width, wa.height);
}
ms_filter_lock(f);
if (!obj->show) {
goto end;
......@@ -194,7 +194,7 @@ static void glxvideo_process(MSFilter *f){
obj->vsize=newsize;
if (obj->autofit){
MSVideoSize new_window_size;
static const MSVideoSize min_size=MS_VIDEO_SIZE_QVGA;
static const MSVideoSize min_size=MS_VIDEO_SIZE_QVGA;
/*don't resize less than QVGA, it is too small*/
if (min_size.width*min_size.height>newsize.width*newsize.height){
new_window_size.width=newsize.width*2;
......@@ -256,7 +256,7 @@ static int glxvideo_zoom(MSFilter *f, void *arg){
ms_filter_lock(f);
ogl_display_zoom(s->glhelper, arg);
ms_filter_unlock(f);
return 0;
}
......@@ -289,7 +289,15 @@ static bool_t createX11GLWindow(Display* display, MSVideoSize size, GLXContext*
None
};
int glx_major, glx_minor;
int fbcount;
GLXFBConfig *fbc;
int best_fbc = -1, worst_fbc = -1, best_num_samp = -1, worst_num_samp = 999;
int i;
GLXFBConfig bestFbc;
XVisualInfo *vi;
XSetWindowAttributes swa;
Colormap cmap;
// FBConfigs were added in GLX version 1.3.
if ( !glXQueryVersion( display, &glx_major, &glx_minor ) || ( ( glx_major == 1 ) && ( glx_minor < 3 ) ) || ( glx_major < 1 ) ) {
ms_error( "Invalid GLX version" );
......@@ -297,8 +305,7 @@ static bool_t createX11GLWindow(Display* display, MSVideoSize size, GLXContext*
}