]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
cl_capturevideo_raw* modes now use O_NONBLOCKING file access for more performance
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 9 Mar 2005 17:36:50 +0000 (17:36 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 9 Mar 2005 17:36:50 +0000 (17:36 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5074 d7cf8633-e32d-0410-b094-e92efae38249

13 files changed:
cl_demo.c
cl_screen.c
console.c
dpvsimpledecode.c
fs.c
fs.h
host.c
host_cmd.c
jpeg.c
menu.c
pr_cmds.c
prvm_cmds.c
wad.c

index af7015902170e583dca0688cc877d18f345d35fc..e9236ce823bc63a974319013059b2f2b4cf9bc9d 100644 (file)
--- a/cl_demo.c
+++ b/cl_demo.c
@@ -286,7 +286,7 @@ void CL_Record_f (void)
 
        // open the demo file
        Con_Printf("recording to %s.\n", name);
-       cls.demofile = FS_Open (name, "wb", false);
+       cls.demofile = FS_Open (name, "wb", false, false);
        if (!cls.demofile)
        {
                Con_Print("ERROR: couldn't open.\n");
@@ -334,7 +334,7 @@ void CL_PlayDemo_f (void)
        FS_DefaultExtension (name, ".dem", sizeof (name));
 
        Con_Printf("Playing demo from %s.\n", name);
-       cls.demofile = FS_Open (name, "rb", false);
+       cls.demofile = FS_Open (name, "rb", false, false);
        if (!cls.demofile)
        {
                Con_Print("ERROR: couldn't open.\n");
@@ -414,6 +414,6 @@ void CL_TimeDemo_f (void)
 
        cls.timedemo = true;
        // get first message this frame
-       cls.td_lastframe = -1;  
+       cls.td_lastframe = -1;
 }
 
index 00a2630a9133bffac28fb0fc392c80ff5db0b22a..dc0418a19968096b6fdf22f8af521f61bf972817 100644 (file)
@@ -784,12 +784,12 @@ Cr = R *  .500 + G * -.419 + B * -.0813 + 128.;
        if (cl_capturevideo_rawrgb.integer)
        {
                cl_capturevideo_format = CAPTUREVIDEOFORMAT_RAWRGB;
-               cl_capturevideo_videofile = FS_Open ("video/dpvideo.rgb", "wb", false);
+               cl_capturevideo_videofile = FS_Open ("video/dpvideo.rgb", "wb", false, true);
        }
        else if (cl_capturevideo_rawyv12.integer)
        {
                cl_capturevideo_format = CAPTUREVIDEOFORMAT_RAWYV12;
-               cl_capturevideo_videofile = FS_Open ("video/dpvideo.yv12", "wb", false);
+               cl_capturevideo_videofile = FS_Open ("video/dpvideo.yv12", "wb", false, true);
        }
        else if (scr_screenshot_jpeg.integer)
        {
@@ -802,7 +802,7 @@ Cr = R *  .500 + G * -.419 + B * -.0813 + 128.;
                cl_capturevideo_videofile = NULL;
        }
 
-       cl_capturevideo_soundfile = FS_Open ("video/dpvideo.wav", "wb", false);
+       cl_capturevideo_soundfile = FS_Open ("video/dpvideo.wav", "wb", false, true);
 
        // wave header will be filled out when video ends
        memset(out, 0, 44);
index 72dfd9e0a64aca901375ba0f155a3da55a6cb307..f36ca203efcbf0022f690ba4bf4e682531863639 100644 (file)
--- a/console.c
+++ b/console.c
@@ -138,7 +138,7 @@ void Log_Open (void)
        if (logfile != NULL || log_file.string[0] == '\0')
                return;
 
-       logfile = FS_Open (log_file.string, "ab", false);
+       logfile = FS_Open (log_file.string, "ab", false, false);
        if (logfile != NULL)
        {
                strlcpy (crt_log_file, log_file.string, sizeof (crt_log_file));
@@ -252,7 +252,7 @@ void Log_Printf (const char *logfilename, const char *fmt, ...)
 {
        qfile_t *file;
 
-       file = FS_Open (logfilename, "ab", true);
+       file = FS_Open (logfilename, "ab", true, false);
        if (file != NULL)
        {
                va_list argptr;
@@ -752,7 +752,7 @@ static void _Con_DrawString( float x, float y, const char *text, int maxlen, flo
                        color = _con_colors[index];
                        // we dont want to display the color tag and the color index
                        first = last;
-               } 
+               }
        }
 }
 
@@ -907,7 +907,7 @@ void Con_DrawConsole (int lines)
 
        rows = (lines-16)>>3;           // rows of text to draw
        y = lines - 16 - (rows<<3);     // may start slightly negative
-    
+
        for (i = con_current - rows + 1;i <= con_current;i++, y += 8)
        {
                j = max(i - con_backscroll, 0);
index 9927a7606e06eab2a1c75c2a709d7f309bc5d613..90b86dc57f843cc24d0f920b8f3a0dca5d114d08 100644 (file)
@@ -37,7 +37,7 @@ hz_bitstream_read_t *hz_bitstream_read_open(char *filename)
 {
        qfile_t *file;
        hz_bitstream_read_t *stream;
-       if ((file = FS_Open (filename, "rb", false)))
+       if ((file = FS_Open (filename, "rb", false, false)))
        {
                stream = malloc(sizeof(hz_bitstream_read_t));
                memset(stream, 0, sizeof(*stream));
diff --git a/fs.c b/fs.c
index b47d611700e848c96f472b7941f87015205143dc..8e0708d1cd855c390c0932cb048d150964007005 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -1012,7 +1012,7 @@ FS_SysOpen
 Internal function used to create a qfile_t and open the relevant non-packed file on disk
 ====================
 */
-static qfile_t* FS_SysOpen (const char* filepath, const char* mode)
+static qfile_t* FS_SysOpen (const char* filepath, const char* mode, qboolean nonblocking)
 {
        qfile_t* file;
        int mod, opt;
@@ -1053,6 +1053,9 @@ static qfile_t* FS_SysOpen (const char* filepath, const char* mode)
                }
        }
 
+       if (nonblocking)
+               opt |= O_NONBLOCK;
+
        file = Mem_Alloc (fs_mempool, sizeof (*file));
        memset (file, 0, sizeof (*file));
        file->ungetc = EOF;
@@ -1291,7 +1294,7 @@ Look for a file in the search paths and open it in read-only mode
 Sets fs_filesize
 ===========
 */
-qfile_t *FS_OpenReadFile (const char *filename, qboolean quiet)
+qfile_t *FS_OpenReadFile (const char *filename, qboolean quiet, qboolean nonblocking)
 {
        searchpath_t *search;
        int pack_ind;
@@ -1310,7 +1313,7 @@ qfile_t *FS_OpenReadFile (const char *filename, qboolean quiet)
        {
                char path [MAX_OSPATH];
                dpsnprintf (path, sizeof (path), "%s/%s", search->filename, filename);
-               return FS_SysOpen (path, "rb");
+               return FS_SysOpen (path, "rb", nonblocking);
        }
 
        // So, we found it in a package...
@@ -1333,7 +1336,7 @@ FS_Open
 Open a file. The syntax is the same as fopen
 ====================
 */
-qfile_t* FS_Open (const char* filepath, const char* mode, qboolean quiet)
+qfile_t* FS_Open (const char* filepath, const char* mode, qboolean quiet, qboolean nonblocking)
 {
        qfile_t* file;
 
@@ -1354,11 +1357,11 @@ qfile_t* FS_Open (const char* filepath, const char* mode, qboolean quiet)
                // Create directories up to the file
                FS_CreatePath (real_path);
 
-               return FS_SysOpen (real_path, mode);
+               return FS_SysOpen (real_path, mode, nonblocking);
        }
 
        // Else, we look at the various search paths and open the file in read-only mode
-       file = FS_OpenReadFile (filepath, quiet);
+       file = FS_OpenReadFile (filepath, quiet, nonblocking);
        if (file != NULL)
                fs_filesize = file->real_length;
 
@@ -1794,7 +1797,7 @@ qbyte *FS_LoadFile (const char *path, mempool_t *pool, qboolean quiet)
        qfile_t *file;
        qbyte *buf;
 
-       file = FS_Open (path, "rb", quiet);
+       file = FS_Open (path, "rb", quiet, false);
        if (!file)
                return NULL;
 
@@ -1819,7 +1822,7 @@ qboolean FS_WriteFile (const char *filename, void *data, int len)
 {
        qfile_t *file;
 
-       file = FS_Open (filename, "wb", false);
+       file = FS_Open (filename, "wb", false, false);
        if (!file)
        {
                Con_Printf("FS_WriteFile: failed on %s\n", filename);
diff --git a/fs.h b/fs.h
index 665de9dcad89718da1e1183fb33b323fa24f4c6a..219adee0dec20166e39c6ffee56844a47b8cacb6 100644 (file)
--- a/fs.h
+++ b/fs.h
@@ -44,7 +44,7 @@ extern int fs_filesize;  // set by FS_Open (in "read" mode) and FS_LoadFile
 // IMPORTANT: the file path is automatically prefixed by the current game directory for
 // each file created by FS_WriteFile, or opened in "write" or "append" mode by FS_Open
 
-qfile_t *FS_Open (const char* filepath, const char* mode, qboolean quiet);
+qfile_t *FS_Open (const char* filepath, const char* mode, qboolean quiet, qboolean nonblocking);
 int FS_Close (qfile_t* file);
 size_t FS_Write (qfile_t* file, const void* data, size_t datasize);
 size_t FS_Read (qfile_t* file, void* buffer, size_t buffersize);
diff --git a/host.c b/host.c
index 7a49529f9c8c964db68f0af7cf3d48a4b05c3b0a..3c698965f6d153e251996ceffd43ccbef8c53e9e 100644 (file)
--- a/host.c
+++ b/host.c
@@ -280,7 +280,7 @@ void Host_SaveConfig_f(void)
 // config.cfg cvars
        if (host_initialized && cls.state != ca_dedicated)
        {
-               f = FS_Open ("config.cfg", "wb", false);
+               f = FS_Open ("config.cfg", "wb", false, false);
                if (!f)
                {
                        Con_Print("Couldn't write config.cfg.\n");
index 2efcdd05626f41c1fd4f5a84b6673c6bcb3438d0..86668a20a267a3c2dae6c6fb67621d8bbed28102 100644 (file)
@@ -500,7 +500,7 @@ void Host_Savegame_f (void)
        FS_DefaultExtension (name, ".sav", sizeof (name));
 
        Con_Printf("Saving game to %s...\n", name);
-       f = FS_Open (name, "wb", false);
+       f = FS_Open (name, "wb", false, false);
        if (!f)
        {
                Con_Print("ERROR: couldn't open.\n");
diff --git a/jpeg.c b/jpeg.c
index 70bd13dab1f5b00c537995429696bab95cd41424..45a2c32b56040932b2e501eca6bf62d383cf6c83 100644 (file)
--- a/jpeg.c
+++ b/jpeg.c
@@ -671,7 +671,7 @@ qboolean JPEG_SaveImage_preflipped (const char *filename, int width, int height,
        }
 
        // Open the file
-       file = FS_Open (filename, "wb", true);
+       file = FS_Open (filename, "wb", true, false);
        if (!file)
                return false;
 
diff --git a/menu.c b/menu.c
index 452565ce806e05893406f5d78e392e6afcb76839..3fcc7dbd10ac9b657ad9e366d9d36682aa6fde2e 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -607,11 +607,11 @@ void M_Main_Key (int key, char ascii)
                                case 0:
                                        M_Menu_Transfusion_Episode_f ();
                                        break;
-                                       
+
                                case 1:
                                        M_Menu_MultiPlayer_f ();
                                        break;
-                                       
+
                                case 2:
                                        M_Menu_Options_f ();
                                        break;
@@ -623,7 +623,7 @@ void M_Main_Key (int key, char ascii)
                                case 4:
                                        M_Menu_Help_f ();
                                        break;
-                                       
+
                                case 5:
                                        M_Menu_Credits_f ();
                                        break;
@@ -640,11 +640,11 @@ void M_Main_Key (int key, char ascii)
                                case 0:
                                        M_Menu_Transfusion_Episode_f ();
                                        break;
-                                       
+
                                case 1:
                                        M_Menu_MultiPlayer_f ();
                                        break;
-                                       
+
                                case 2:
                                        M_Menu_Options_f ();
                                        break;
@@ -656,7 +656,7 @@ void M_Main_Key (int key, char ascii)
                                case 4:
                                        M_Menu_Load_f ();
                                        break;
-                                       
+
                                case 5:
                                        M_Menu_Help_f ();
                                        break;
@@ -833,7 +833,7 @@ void M_ScanSaves (void)
                strcpy (m_filenames[i], "--- UNUSED SLOT ---");
                loadable[i] = false;
                sprintf (name, "s%i.sav", i);
-               f = FS_Open (name, "rb", false);
+               f = FS_Open (name, "rb", false, false);
                if (!f)
                        continue;
                // read enough to get the comment
@@ -1010,13 +1010,13 @@ void M_Transfusion_Episode_Draw (void)
        int y;
        cachepic_t *p;
        M_Background(640, 480);
-       
+
        p = Draw_CachePic ("gfx/tb-episodes");
        M_DrawPic (640/2 - p->width/2, 40, "gfx/tb-episodes");
        for (y = 0; y < EPISODE_ITEMS; y++){
                M_DrawPic (0, 160 + y * 40, va("gfx/episode%i", y+1));
        }
-       
+
        M_DrawPic (0, 120 + (m_episode_cursor + 1) * 40, va("gfx/episode%iselected", m_episode_cursor + 1));
 }
 
index 500f57f63e1601b144de8767b71415819d397f99..e57ebe3927067778d57f07e4dba5f90d4947e054 100644 (file)
--- a/pr_cmds.c
+++ b/pr_cmds.c
@@ -2840,10 +2840,10 @@ void PF_fopen(void)
        }
        filename = G_STRING(OFS_PARM0);
        // -4 failure (dangerous/non-portable filename) removed, FS_Open checks
-       pr_files[filenum] = FS_Open(va("data/%s", filename), modestring, false);
+       pr_files[filenum] = FS_Open(va("data/%s", filename), modestring, false, false);
 
        if (pr_files[filenum] == NULL && modestring == "rb")
-               pr_files[filenum] = FS_Open(filename, modestring, false);
+               pr_files[filenum] = FS_Open(filename, modestring, false, false);
 
        if (pr_files[filenum] == NULL)
                G_FLOAT(OFS_RETURN) = -1;
index 1d0a3d4cafe61905f0ff42cc1a9abb46b2dcfdee..126d3a45d0663d23ae6769d85cc91d13e31e9aef 100644 (file)
@@ -1775,9 +1775,9 @@ void VM_fopen(void)
                PRVM_G_FLOAT(OFS_RETURN) = -4;
                return;
        }
-       VM_FILES[filenum] = FS_Open(va("data/%s", filename), modestring, false);
+       VM_FILES[filenum] = FS_Open(va("data/%s", filename), modestring, false, false);
        if (VM_FILES[filenum] == NULL && mode == 0)
-               VM_FILES[filenum] = FS_Open(va("%s", filename), modestring, false);
+               VM_FILES[filenum] = FS_Open(va("%s", filename), modestring, false, false);
 
        if (VM_FILES[filenum] == NULL)
                PRVM_G_FLOAT(OFS_RETURN) = -1;
diff --git a/wad.c b/wad.c
index 0f4459c89862d23066a1593ca141ec81947b0adc..2183b8e3f9962577be9a5ec40b6c13e261dc9277 100644 (file)
--- a/wad.c
+++ b/wad.c
@@ -157,7 +157,7 @@ void W_LoadTextureWadFile (char *filename, int complain)
        qfile_t                 *file;
        int                             numlumps;
 
-       file = FS_Open (filename, "rb", false);
+       file = FS_Open (filename, "rb", false, false);
        if (!file)
        {
                if (complain)