indent
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403502
This commit is contained in:
parent
072760ebb7
commit
628262d3af
13 changed files with 117 additions and 122 deletions
|
@ -228,9 +228,9 @@ extern DECLSPEC const SDL_VideoInfo *SDLCALL SDL_GetVideoInfo(void);
|
||||||
extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width,
|
extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width,
|
||||||
int height,
|
int height,
|
||||||
int bpp, Uint32 flags);
|
int bpp, Uint32 flags);
|
||||||
extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(const SDL_PixelFormat * format, Uint32 flags);
|
extern DECLSPEC SDL_Rect **SDLCALL SDL_ListModes(const SDL_PixelFormat *
|
||||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode(int width,
|
format, Uint32 flags);
|
||||||
int height,
|
extern DECLSPEC SDL_Surface *SDLCALL SDL_SetVideoMode(int width, int height,
|
||||||
int bpp, Uint32 flags);
|
int bpp, Uint32 flags);
|
||||||
extern DECLSPEC SDL_Surface *SDLCALL SDL_GetVideoSurface(void);
|
extern DECLSPEC SDL_Surface *SDLCALL SDL_GetVideoSurface(void);
|
||||||
extern DECLSPEC void SDLCALL SDL_UpdateRects(SDL_Surface * screen,
|
extern DECLSPEC void SDLCALL SDL_UpdateRects(SDL_Surface * screen,
|
||||||
|
|
|
@ -915,7 +915,8 @@ SDL_BuildAudioResampleCVT(SDL_AudioCVT * cvt, int dst_channels,
|
||||||
if (filter == NULL) {
|
if (filter == NULL) {
|
||||||
int i;
|
int i;
|
||||||
const int upsample = (src_rate < dst_rate) ? 1 : 0;
|
const int upsample = (src_rate < dst_rate) ? 1 : 0;
|
||||||
const int multiple = SDL_FindFrequencyMultiple(src_rate, dst_rate);
|
const int multiple =
|
||||||
|
SDL_FindFrequencyMultiple(src_rate, dst_rate);
|
||||||
|
|
||||||
for (i = 0; sdl_audio_rate_filters[i].filter != NULL; i++) {
|
for (i = 0; sdl_audio_rate_filters[i].filter != NULL; i++) {
|
||||||
const SDL_AudioRateFilters *filt = &sdl_audio_rate_filters[i];
|
const SDL_AudioRateFilters *filt = &sdl_audio_rate_filters[i];
|
||||||
|
@ -980,7 +981,6 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
|
||||||
if ((src_rate == 0) || (dst_rate == 0)) {
|
if ((src_rate == 0) || (dst_rate == 0)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_CONVERT
|
#ifdef DEBUG_CONVERT
|
||||||
printf("Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
|
printf("Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
|
||||||
src_fmt, dst_fmt, src_channels, dst_channels, src_rate, dst_rate);
|
src_fmt, dst_fmt, src_channels, dst_channels, src_rate, dst_rate);
|
||||||
|
@ -1054,7 +1054,8 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Do rate conversion, if necessary. Updates (cvt). */
|
/* Do rate conversion, if necessary. Updates (cvt). */
|
||||||
if (SDL_BuildAudioResampleCVT(cvt, dst_channels, src_rate, dst_rate) == -1) {
|
if (SDL_BuildAudioResampleCVT(cvt, dst_channels, src_rate, dst_rate) ==
|
||||||
|
-1) {
|
||||||
return -1; /* shouldn't happen, but just in case... */
|
return -1; /* shouldn't happen, but just in case... */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,8 @@ CalculateGammaRamp(float gamma, Uint16 * ramp)
|
||||||
int value;
|
int value;
|
||||||
gamma = 1.0f / gamma;
|
gamma = 1.0f / gamma;
|
||||||
for (i = 0; i < 256; ++i) {
|
for (i = 0; i < 256; ++i) {
|
||||||
value = (int) (SDL_pow((double) i / 256.0, gamma) * 65535.0 + 0.5);
|
value =
|
||||||
|
(int) (SDL_pow((double) i / 256.0, gamma) * 65535.0 + 0.5);
|
||||||
if (value > 65535) {
|
if (value > 65535) {
|
||||||
value = 65535;
|
value = 65535;
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,8 +199,7 @@ DirectFB_WM_MaximizeWindow(_THIS, SDL_Window * window)
|
||||||
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
|
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
|
||||||
|
|
||||||
windata->window->GetPosition(windata->window,
|
windata->window->GetPosition(windata->window,
|
||||||
&windata->restore.x,
|
&windata->restore.x, &windata->restore.y);
|
||||||
&windata->restore.y);
|
|
||||||
windata->window->GetSize(windata->window, &windata->restore.w,
|
windata->window->GetSize(windata->window, &windata->restore.w,
|
||||||
&windata->restore.h);
|
&windata->restore.h);
|
||||||
|
|
||||||
|
@ -210,8 +209,7 @@ DirectFB_WM_MaximizeWindow(_THIS, SDL_Window * window)
|
||||||
|
|
||||||
windata->window->MoveTo(windata->window, 0, 0);
|
windata->window->MoveTo(windata->window, 0, 0);
|
||||||
windata->window->Resize(windata->window,
|
windata->window->Resize(windata->window,
|
||||||
display->current_mode.w,
|
display->current_mode.w, display->current_mode.h);
|
||||||
display->current_mode.h);
|
|
||||||
SDL_SendWindowEvent(windata->sdl_id, SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
|
SDL_SendWindowEvent(windata->sdl_id, SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +289,7 @@ static int wm_lastx;
|
||||||
static int wm_lasty;
|
static int wm_lasty;
|
||||||
|
|
||||||
int
|
int
|
||||||
DirectFB_WM_ProcessEvent(_THIS, SDL_Window *window, DFBWindowEvent * evt)
|
DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt)
|
||||||
{
|
{
|
||||||
SDL_DFB_WINDOWDATA(window);
|
SDL_DFB_WINDOWDATA(window);
|
||||||
|
|
||||||
|
@ -306,7 +304,8 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window *window, DFBWindowEvent * evt)
|
||||||
case WM_POS_NONE:
|
case WM_POS_NONE:
|
||||||
return 0;
|
return 0;
|
||||||
case WM_POS_CLOSE:
|
case WM_POS_CLOSE:
|
||||||
SDL_SendWindowEvent(windata->sdl_id, SDL_WINDOWEVENT_CLOSE, 0, 0);
|
SDL_SendWindowEvent(windata->sdl_id, SDL_WINDOWEVENT_CLOSE, 0,
|
||||||
|
0);
|
||||||
return 1;
|
return 1;
|
||||||
case WM_POS_MAX:
|
case WM_POS_MAX:
|
||||||
if (window->flags & SDL_WINDOW_MAXIMIZED) {
|
if (window->flags & SDL_WINDOW_MAXIMIZED) {
|
||||||
|
|
|
@ -46,9 +46,11 @@ extern void DirectFB_WM_MaximizeWindow(_THIS, SDL_Window * window);
|
||||||
extern void DirectFB_WM_RestoreWindow(_THIS, SDL_Window * window);
|
extern void DirectFB_WM_RestoreWindow(_THIS, SDL_Window * window);
|
||||||
extern void DirectFB_WM_RedrawLayout(SDL_Window * window);
|
extern void DirectFB_WM_RedrawLayout(SDL_Window * window);
|
||||||
|
|
||||||
extern int DirectFB_WM_ProcessEvent(_THIS, SDL_Window *window, DFBWindowEvent * evt);
|
extern int DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window,
|
||||||
|
DFBWindowEvent * evt);
|
||||||
|
|
||||||
extern DFBResult DirectFB_WM_GetClientSize(_THIS, SDL_Window * window, int *cw, int *ch);
|
extern DFBResult DirectFB_WM_GetClientSize(_THIS, SDL_Window * window,
|
||||||
|
int *cw, int *ch);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _SDL_directfb_wm_h */
|
#endif /* _SDL_directfb_wm_h */
|
||||||
|
|
|
@ -193,7 +193,8 @@ ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS))
|
if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS))
|
||||||
SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_ENTER, 0, 0);
|
SDL_SendWindowEvent(p->sdl_id, SDL_WINDOWEVENT_ENTER, 0,
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DWET_KEYDOWN:
|
case DWET_KEYDOWN:
|
||||||
|
|
|
@ -198,15 +198,13 @@ SetBlendMode(DirectFB_RenderData * data, int blendMode,
|
||||||
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
|
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
|
||||||
data->drawFlags = DSDRAW_BLEND;
|
data->drawFlags = DSDRAW_BLEND;
|
||||||
destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA);
|
destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA);
|
||||||
destsurf->SetDstBlendFunction(destsurf,
|
destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA);
|
||||||
DSBF_INVSRCALPHA);
|
|
||||||
break;
|
break;
|
||||||
case SDL_BLENDMODE_BLEND:
|
case SDL_BLENDMODE_BLEND:
|
||||||
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
|
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
|
||||||
data->drawFlags = DSDRAW_BLEND;
|
data->drawFlags = DSDRAW_BLEND;
|
||||||
destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA);
|
destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA);
|
||||||
destsurf->SetDstBlendFunction(destsurf,
|
destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA);
|
||||||
DSBF_INVSRCALPHA);
|
|
||||||
break;
|
break;
|
||||||
case SDL_BLENDMODE_ADD:
|
case SDL_BLENDMODE_ADD:
|
||||||
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
|
data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL;
|
||||||
|
@ -215,8 +213,7 @@ SetBlendMode(DirectFB_RenderData * data, int blendMode,
|
||||||
// It will be cheaper to copy the surface to
|
// It will be cheaper to copy the surface to
|
||||||
// a temporay surface and premultiply
|
// a temporay surface and premultiply
|
||||||
if (source && TextureHasAlpha(source))
|
if (source && TextureHasAlpha(source))
|
||||||
destsurf->SetSrcBlendFunction(destsurf,
|
destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA);
|
||||||
DSBF_SRCALPHA);
|
|
||||||
else
|
else
|
||||||
destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE);
|
destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE);
|
||||||
destsurf->SetDstBlendFunction(destsurf, DSBF_ONE);
|
destsurf->SetDstBlendFunction(destsurf, DSBF_ONE);
|
||||||
|
@ -324,7 +321,8 @@ DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||||
} else
|
} else
|
||||||
data->flipflags |= DSFLIP_ONSYNC;
|
data->flipflags |= DSFLIP_ONSYNC;
|
||||||
|
|
||||||
SDL_DFB_CHECKERR(windata->surface->GetCapabilities(windata->surface, &scaps));
|
SDL_DFB_CHECKERR(windata->surface->
|
||||||
|
GetCapabilities(windata->surface, &scaps));
|
||||||
if (scaps & DSCAPS_DOUBLE)
|
if (scaps & DSCAPS_DOUBLE)
|
||||||
renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
|
renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2;
|
||||||
else if (scaps & DSCAPS_TRIPLE)
|
else if (scaps & DSCAPS_TRIPLE)
|
||||||
|
@ -809,8 +807,7 @@ PrepareDraw(SDL_Renderer * renderer)
|
||||||
a = renderer->a;
|
a = renderer->a;
|
||||||
|
|
||||||
SetBlendMode(data, renderer->blendMode, NULL);
|
SetBlendMode(data, renderer->blendMode, NULL);
|
||||||
SDL_DFB_CHECKERR(destsurf->SetDrawingFlags(destsurf,
|
SDL_DFB_CHECKERR(destsurf->SetDrawingFlags(destsurf, data->drawFlags));
|
||||||
data->drawFlags));
|
|
||||||
|
|
||||||
switch (renderer->blendMode) {
|
switch (renderer->blendMode) {
|
||||||
case SDL_BLENDMODE_NONE:
|
case SDL_BLENDMODE_NONE:
|
||||||
|
@ -856,8 +853,7 @@ DirectFB_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
|
||||||
PrepareDraw(renderer);
|
PrepareDraw(renderer);
|
||||||
/* Use antialiasing when available */
|
/* Use antialiasing when available */
|
||||||
#if (DFB_VERSION_ATLEAST(1,2,0))
|
#if (DFB_VERSION_ATLEAST(1,2,0))
|
||||||
SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf,
|
SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf, DSRO_ANTIALIAS));
|
||||||
DSRO_ANTIALIAS));
|
|
||||||
#endif
|
#endif
|
||||||
SDL_DFB_CHECKERR(destsurf->DrawLine(destsurf, x1, y1, x2, y2));
|
SDL_DFB_CHECKERR(destsurf->DrawLine(destsurf, x1, y1, x2, y2));
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -938,9 +934,11 @@ DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
SDLtoDFBRect(srcrect, &sr);
|
SDLtoDFBRect(srcrect, &sr);
|
||||||
SDLtoDFBRect(dstrect, &dr);
|
SDLtoDFBRect(dstrect, &dr);
|
||||||
|
|
||||||
SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF, 0xFF, 0xFF));
|
SDL_DFB_CHECKERR(destsurf->
|
||||||
if (texture->modMode &
|
SetColor(destsurf, 0xFF, 0xFF, 0xFF, 0xFF));
|
||||||
(SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA)) {
|
if (texture->
|
||||||
|
modMode & (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA))
|
||||||
|
{
|
||||||
if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
|
if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
|
||||||
alpha = texture->a;
|
alpha = texture->a;
|
||||||
SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF,
|
SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF,
|
||||||
|
@ -963,8 +961,7 @@ DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
SetBlendMode(data, texture->blendMode, texturedata);
|
SetBlendMode(data, texture->blendMode, texturedata);
|
||||||
|
|
||||||
SDL_DFB_CHECKERR(destsurf->SetBlittingFlags(destsurf,
|
SDL_DFB_CHECKERR(destsurf->SetBlittingFlags(destsurf,
|
||||||
data->blitFlags
|
data->blitFlags | flags));
|
||||||
| flags));
|
|
||||||
|
|
||||||
#if (DFB_VERSION_ATLEAST(1,2,0))
|
#if (DFB_VERSION_ATLEAST(1,2,0))
|
||||||
SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf,
|
SDL_DFB_CHECKERR(destsurf->SetRenderOptions(destsurf,
|
||||||
|
|
|
@ -44,10 +44,10 @@
|
||||||
(DFB_COMPILEDVERSION >= DFB_VERSIONNUM(X, Y, Z))
|
(DFB_COMPILEDVERSION >= DFB_VERSIONNUM(X, Y, Z))
|
||||||
|
|
||||||
#if (DFB_VERSION_ATLEAST(1,0,0))
|
#if (DFB_VERSION_ATLEAST(1,0,0))
|
||||||
#define SDL_DIRECTFB_OPENGL 1
|
#define SDL_DIRECTFB_OPENGL 1
|
||||||
#include <directfbgl.h>
|
#include <directfbgl.h>
|
||||||
#else
|
#else
|
||||||
#error "SDL_DIRECTFB: Please compile against libdirectfb version >= 1.0.0"
|
#error "SDL_DIRECTFB: Please compile against libdirectfb version >= 1.0.0"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SDL_DIRECTFB_OPENGL
|
#if SDL_DIRECTFB_OPENGL
|
||||||
|
|
|
@ -101,7 +101,8 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
|
||||||
windata->window->SetOptions(windata->window, wopts);
|
windata->window->SetOptions(windata->window, wopts);
|
||||||
|
|
||||||
/* See what we got */
|
/* See what we got */
|
||||||
SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize(_this, window, &window->w, &window->h));
|
SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize
|
||||||
|
(_this, window, &window->w, &window->h));
|
||||||
|
|
||||||
/* Get the window's surface. */
|
/* Get the window's surface. */
|
||||||
SDL_DFB_CHECKERR(windata->window->GetSurface(windata->window,
|
SDL_DFB_CHECKERR(windata->window->GetSurface(windata->window,
|
||||||
|
@ -115,9 +116,10 @@ DirectFB_CreateWindow(_THIS, SDL_Window * window)
|
||||||
|
|
||||||
/* Create Eventbuffer */
|
/* Create Eventbuffer */
|
||||||
SDL_DFB_CHECKERR(windata->window->CreateEventBuffer(windata->window,
|
SDL_DFB_CHECKERR(windata->window->CreateEventBuffer(windata->window,
|
||||||
&windata->eventbuffer));
|
&windata->
|
||||||
SDL_DFB_CHECKERR(windata->
|
eventbuffer));
|
||||||
window->EnableEvents(windata->window, DWET_ALL));
|
SDL_DFB_CHECKERR(windata->window->
|
||||||
|
EnableEvents(windata->window, DWET_ALL));
|
||||||
|
|
||||||
/* Create a font */
|
/* Create a font */
|
||||||
/* FIXME: once during Video_Init */
|
/* FIXME: once during Video_Init */
|
||||||
|
@ -279,7 +281,8 @@ DirectFB_SetWindowSize(_THIS, SDL_Window * window)
|
||||||
SDL_DFB_CHECKERR(windata->window->EnableEvents(windata->window,
|
SDL_DFB_CHECKERR(windata->window->EnableEvents(windata->window,
|
||||||
DWET_ALL));
|
DWET_ALL));
|
||||||
|
|
||||||
SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize(_this, window, &window->w, &window->h));
|
SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize
|
||||||
|
(_this, window, &window->w, &window->h));
|
||||||
|
|
||||||
SDL_OnWindowResized(window);
|
SDL_OnWindowResized(window);
|
||||||
}
|
}
|
||||||
|
@ -440,12 +443,11 @@ DirectFB_AdjustWindowSurface(SDL_Window * window)
|
||||||
windata->size.w,
|
windata->size.w,
|
||||||
windata->size.h));
|
windata->size.h));
|
||||||
SDL_DFB_CHECKERR(windata->window_surface->
|
SDL_DFB_CHECKERR(windata->window_surface->
|
||||||
GetSubSurface(windata->window_surface, &windata->client,
|
GetSubSurface(windata->window_surface,
|
||||||
&windata->surface));
|
&windata->client, &windata->surface));
|
||||||
#endif
|
#endif
|
||||||
DirectFB_WM_RedrawLayout(window);
|
DirectFB_WM_RedrawLayout(window);
|
||||||
}
|
}
|
||||||
error:
|
error:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,6 @@ X11_DispatchEvent(_THIS)
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SDL_VIDEO_DRIVER_X11_XINPUT
|
#if SDL_VIDEO_DRIVER_X11_XINPUT
|
||||||
data = (X11_MouseData *) mouse->driverdata;
|
data = (X11_MouseData *) mouse->driverdata;
|
||||||
if (xevent.type == data->motion) {
|
if (xevent.type == data->motion) {
|
||||||
|
@ -398,7 +397,7 @@ X11_PumpEvents(_THIS)
|
||||||
if (_this->suspend_screensaver) {
|
if (_this->suspend_screensaver) {
|
||||||
Uint32 now = SDL_GetTicks();
|
Uint32 now = SDL_GetTicks();
|
||||||
if (!data->screensaver_activity ||
|
if (!data->screensaver_activity ||
|
||||||
(int)(now-data->screensaver_activity) >= 30000) {
|
(int) (now - data->screensaver_activity) >= 30000) {
|
||||||
XResetScreenSaver(data->display);
|
XResetScreenSaver(data->display);
|
||||||
data->screensaver_activity = now;
|
data->screensaver_activity = now;
|
||||||
}
|
}
|
||||||
|
@ -415,7 +414,8 @@ X11_PumpEvents(_THIS)
|
||||||
#ifdef GNOME_SCREENSAVER_HACK
|
#ifdef GNOME_SCREENSAVER_HACK
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
static pid_t screensaver_inhibit_pid;
|
static pid_t screensaver_inhibit_pid;
|
||||||
static void gnome_screensaver_disable()
|
static void
|
||||||
|
gnome_screensaver_disable()
|
||||||
{
|
{
|
||||||
screensaver_inhibit_pid = fork();
|
screensaver_inhibit_pid = fork();
|
||||||
if (screensaver_inhibit_pid == 0) {
|
if (screensaver_inhibit_pid == 0) {
|
||||||
|
@ -426,12 +426,12 @@ static void gnome_screensaver_disable()
|
||||||
"gnome-screensaver-command",
|
"gnome-screensaver-command",
|
||||||
"--inhibit",
|
"--inhibit",
|
||||||
"--reason",
|
"--reason",
|
||||||
"GNOME screensaver doesn't respect MIT-SCREEN-SAVER",
|
"GNOME screensaver doesn't respect MIT-SCREEN-SAVER", NULL);
|
||||||
NULL);
|
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static void gnome_screensaver_enable()
|
static void
|
||||||
|
gnome_screensaver_enable()
|
||||||
{
|
{
|
||||||
kill(screensaver_inhibit_pid, 15);
|
kill(screensaver_inhibit_pid, 15);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
SDL_AudioSpec spec;
|
SDL_AudioSpec spec;
|
||||||
SDL_AudioCVT cvt;
|
SDL_AudioCVT cvt;
|
||||||
|
@ -13,30 +14,26 @@ int main(int argc, char **argv)
|
||||||
int avgbytes = 0;
|
int avgbytes = 0;
|
||||||
SDL_RWops *io = NULL;
|
SDL_RWops *io = NULL;
|
||||||
|
|
||||||
if (argc != 4)
|
if (argc != 4) {
|
||||||
{
|
|
||||||
fprintf(stderr, "USAGE: %s in.wav out.wav newfreq\n", argv[0]);
|
fprintf(stderr, "USAGE: %s in.wav out.wav newfreq\n", argv[0]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cvtfreq = atoi(argv[3]);
|
cvtfreq = atoi(argv[3]);
|
||||||
|
|
||||||
if (SDL_Init(SDL_INIT_AUDIO) == -1)
|
if (SDL_Init(SDL_INIT_AUDIO) == -1) {
|
||||||
{
|
|
||||||
fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
|
fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_LoadWAV(argv[1], &spec, &data, &len) == NULL)
|
if (SDL_LoadWAV(argv[1], &spec, &data, &len) == NULL) {
|
||||||
{
|
|
||||||
fprintf(stderr, "failed to load %s: %s\n", argv[1], SDL_GetError());
|
fprintf(stderr, "failed to load %s: %s\n", argv[1], SDL_GetError());
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_BuildAudioCVT(&cvt, spec.format, spec.channels, spec.freq,
|
if (SDL_BuildAudioCVT(&cvt, spec.format, spec.channels, spec.freq,
|
||||||
spec.format, spec.channels, cvtfreq) == -1)
|
spec.format, spec.channels, cvtfreq) == -1) {
|
||||||
{
|
|
||||||
fprintf(stderr, "failed to build CVT: %s\n", SDL_GetError());
|
fprintf(stderr, "failed to build CVT: %s\n", SDL_GetError());
|
||||||
SDL_FreeWAV(data);
|
SDL_FreeWAV(data);
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
@ -45,8 +42,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
cvt.len = len;
|
cvt.len = len;
|
||||||
cvt.buf = (Uint8 *) malloc(len * cvt.len_mult);
|
cvt.buf = (Uint8 *) malloc(len * cvt.len_mult);
|
||||||
if (cvt.buf == NULL)
|
if (cvt.buf == NULL) {
|
||||||
{
|
|
||||||
fprintf(stderr, "Out of memory.\n");
|
fprintf(stderr, "Out of memory.\n");
|
||||||
SDL_FreeWAV(data);
|
SDL_FreeWAV(data);
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
@ -54,8 +50,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
memcpy(cvt.buf, data, len);
|
memcpy(cvt.buf, data, len);
|
||||||
|
|
||||||
if (SDL_ConvertAudio(&cvt) == -1)
|
if (SDL_ConvertAudio(&cvt) == -1) {
|
||||||
{
|
|
||||||
fprintf(stderr, "Conversion failed: %s\n", SDL_GetError());
|
fprintf(stderr, "Conversion failed: %s\n", SDL_GetError());
|
||||||
free(cvt.buf);
|
free(cvt.buf);
|
||||||
SDL_FreeWAV(data);
|
SDL_FreeWAV(data);
|
||||||
|
@ -65,8 +60,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
/* write out a WAV header... */
|
/* write out a WAV header... */
|
||||||
io = SDL_RWFromFile(argv[2], "wb");
|
io = SDL_RWFromFile(argv[2], "wb");
|
||||||
if (io == NULL)
|
if (io == NULL) {
|
||||||
{
|
|
||||||
fprintf(stderr, "fopen('%s') failed: %s\n", argv[2], SDL_GetError());
|
fprintf(stderr, "fopen('%s') failed: %s\n", argv[2], SDL_GetError());
|
||||||
free(cvt.buf);
|
free(cvt.buf);
|
||||||
SDL_FreeWAV(data);
|
SDL_FreeWAV(data);
|
||||||
|
@ -93,8 +87,7 @@ int main(int argc, char **argv)
|
||||||
SDL_WriteLE32(io, cvt.len_cvt); /* size */
|
SDL_WriteLE32(io, cvt.len_cvt); /* size */
|
||||||
SDL_RWwrite(io, cvt.buf, cvt.len_cvt, 1);
|
SDL_RWwrite(io, cvt.buf, cvt.len_cvt, 1);
|
||||||
|
|
||||||
if (SDL_RWclose(io) == -1)
|
if (SDL_RWclose(io) == -1) {
|
||||||
{
|
|
||||||
fprintf(stderr, "fclose('%s') failed: %s\n", argv[2], SDL_GetError());
|
fprintf(stderr, "fclose('%s') failed: %s\n", argv[2], SDL_GetError());
|
||||||
free(cvt.buf);
|
free(cvt.buf);
|
||||||
SDL_FreeWAV(data);
|
SDL_FreeWAV(data);
|
||||||
|
@ -109,4 +102,3 @@ int main(int argc, char **argv)
|
||||||
} // main
|
} // main
|
||||||
|
|
||||||
// end of resample_test.c ...
|
// end of resample_test.c ...
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue