📄 sdl-friptv.diff
字号:
diff -urN SDL-1.2/include/SDL_audio.h SDL-1.2-iptv/include/SDL_audio.h--- SDL-1.2/include/SDL_audio.h 2008-01-20 21:42:04.000000000 +0100+++ SDL-1.2-iptv/include/SDL_audio.h 2007-12-03 14:57:04.000000000 +0100@@ -243,6 +243,16 @@ */ extern DECLSPEC void SDLCALL SDL_CloseAudio(void); +/*+ * Determine if we have the ability to detect the audio buffer delay+ */+extern DECLSPEC int SDL_HasAudioDelay(void);++/*+ * Determine the audio buffer delay in samples+ */+extern DECLSPEC int SDL_AudioDelay(void);+ /* Ends C function definitions when using C++ */ #ifdef __cplusplusdiff -urN SDL-1.2/include/SDL_timer.h SDL-1.2-iptv/include/SDL_timer.h--- SDL-1.2/include/SDL_timer.h 2008-01-20 21:42:05.000000000 +0100+++ SDL-1.2-iptv/include/SDL_timer.h 2007-12-03 14:57:04.000000000 +0100@@ -38,7 +38,7 @@ #define SDL_TIMESLICE 10 /* This is the maximum resolution of the SDL timer on all platforms */-#define TIMER_RESOLUTION 10 /* Experimentally determined */+#define TIMER_RESOLUTION 1 /* Experimentally determined */ /* Get the number of milliseconds since the SDL library initialization. * Note that this value wraps if the program runs for more than ~49 days.diff -urN SDL-1.2/include/SDL_video.h SDL-1.2-iptv/include/SDL_video.h--- SDL-1.2/include/SDL_video.h 2008-01-20 21:42:05.000000000 +0100+++ SDL-1.2-iptv/include/SDL_video.h 2008-01-20 22:18:55.000000000 +0100@@ -287,6 +287,31 @@ extern DECLSPEC SDL_Rect ** SDLCALL SDL_ListModes(SDL_PixelFormat *format, Uint32 flags); /*+ * If possible, retrieves the current resolution of the user's display. If this+ * operation is supported and succeeds, the width and height are written to the+ * values pointed to by the parameters and 1 is returned. If unsupported or+ * unsuccessful, the pointed to values are not touched and 0 is returned.+ */+extern DECLSPEC int SDLCALL SDL_GetDesktopMode(int *width, int *height);++/*+ * If possible, retrieves the current window position. If this+ * operation is supported and succeeds, the position is written to the+ * value pointed to by the parameter and 1 is returned. If unsupported or+ * unsuccessful, the pointed to value is not touched and 0 is returned.+ */+extern DECLSPEC int SDLCALL SDL_GetWindowPosition(SDL_Rect *pos);++/*+ * If possible, retrieves the current scanline. If this+ * operation is supported and succeeds, the scanline is written to the+ * value pointed to by the parameter and 1 is returned. If unsupported or+ * unsuccessful, the pointed to value is not touched and 0 is returned.+ * If vblank is in progress, 2 is returned.+ */+extern DECLSPEC int SDLCALL SDL_GetScanline(int *scanline);++/* * Set up a video mode with the specified width, height and bits-per-pixel. * * If 'bpp' is 0, it is treated as the current display bits per pixel.@@ -807,6 +832,11 @@ extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int* value); /*+ * Make OpenGL context current in calling thread.+ */+extern DECLSPEC void SDLCALL SDL_GL_MakeCurrent(int release);++/* * Swap the OpenGL buffers, if double-buffering is supported. */ extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void);diff -urN SDL-1.2/src/audio/SDL_audio.c SDL-1.2-iptv/src/audio/SDL_audio.c--- SDL-1.2/src/audio/SDL_audio.c 2008-01-20 21:42:05.000000000 +0100+++ SDL-1.2-iptv/src/audio/SDL_audio.c 2007-12-03 14:57:04.000000000 +0100@@ -122,7 +122,7 @@ void SDL_AudioQuit(void); /* The general mixing thread function */-int SDLCALL SDL_RunAudio(void *audiop)+static int SDLCALL SDL_RunAudio(void *audiop) { SDL_AudioDevice *audio = (SDL_AudioDevice *)audiop; Uint8 *stream;@@ -619,6 +619,25 @@ SDL_QuitSubSystem(SDL_INIT_AUDIO); } +int SDL_HasAudioDelay (void)+{+ SDL_AudioDevice *audio = current_audio;++ if (audio && audio->AudioDelay != NULL) {+ return 1;+ }+ return 0;+}++int SDL_AudioDelay (void)+{+ SDL_AudioDevice *audio = current_audio;+ if (audio && audio->AudioDelay != NULL) {+ return (audio->AudioDelay(audio));+ }+ return (-1);+} + void SDL_AudioQuit(void) { SDL_AudioDevice *audio = current_audio;@@ -643,7 +662,7 @@ audio->opened = 0; } /* Free the driver data */- audio->free(audio);+ if (audio->free) audio->free(audio); current_audio = NULL; } }diff -urN SDL-1.2/src/audio/SDL_audio_c.h SDL-1.2-iptv/src/audio/SDL_audio_c.h--- SDL-1.2/src/audio/SDL_audio_c.h 2008-01-20 21:42:05.000000000 +0100+++ SDL-1.2-iptv/src/audio/SDL_audio_c.h 2007-12-03 14:57:04.000000000 +0100@@ -29,6 +29,3 @@ /* Function to calculate the size and silence for a SDL_AudioSpec */ extern void SDL_CalculateAudioSpec(SDL_AudioSpec *spec);--/* The actual mixing thread function */-extern int SDLCALL SDL_RunAudio(void *audiop);diff -urN SDL-1.2/src/audio/SDL_sysaudio.h SDL-1.2-iptv/src/audio/SDL_sysaudio.h--- SDL-1.2/src/audio/SDL_sysaudio.h 2008-01-20 21:42:05.000000000 +0100+++ SDL-1.2-iptv/src/audio/SDL_sysaudio.h 2007-12-03 14:57:04.000000000 +0100@@ -53,6 +53,7 @@ Uint8 *(*GetAudioBuf)(_THIS); void (*WaitDone)(_THIS); void (*CloseAudio)(_THIS);+ int (*AudioDelay)(_THIS); /* * * */ /* Lock / Unlock functions added for the Mac port */diff -urN SDL-1.2/src/audio/alsa/SDL_alsa_audio.c SDL-1.2-iptv/src/audio/alsa/SDL_alsa_audio.c--- SDL-1.2/src/audio/alsa/SDL_alsa_audio.c 2008-01-20 21:42:05.000000000 +0100+++ SDL-1.2-iptv/src/audio/alsa/SDL_alsa_audio.c 2007-12-03 14:57:04.000000000 +0100@@ -88,6 +88,7 @@ static int (*SDL_NAME(snd_pcm_sw_params_set_avail_min))(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val); static int (*SDL_NAME(snd_pcm_sw_params))(snd_pcm_t *pcm, snd_pcm_sw_params_t *params); static int (*SDL_NAME(snd_pcm_nonblock))(snd_pcm_t *pcm, int nonblock);+static int (*SDL_NAME(snd_pcm_delay))(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp); #define snd_pcm_hw_params_sizeof SDL_NAME(snd_pcm_hw_params_sizeof) #define snd_pcm_sw_params_sizeof SDL_NAME(snd_pcm_sw_params_sizeof) @@ -121,6 +122,7 @@ { "snd_pcm_sw_params_set_avail_min", (void**)(char*)&SDL_NAME(snd_pcm_sw_params_set_avail_min) }, { "snd_pcm_sw_params", (void**)(char*)&SDL_NAME(snd_pcm_sw_params) }, { "snd_pcm_nonblock", (void**)(char*)&SDL_NAME(snd_pcm_nonblock) },+ { "snd_pcm_delay", (void**)(char*)&SDL_NAME(snd_pcm_delay) }, }; static void UnloadALSALibrary(void) {@@ -169,6 +171,25 @@ #endif /* SDL_AUDIO_DRIVER_ALSA_DYNAMIC */ +static int ALSA_AudioDelay(_THIS)+{+ snd_pcm_sframes_t delayp;++ delayp = 0;+ if (SDL_NAME(snd_pcm_delay)(pcm_handle, &delayp) > 0) {+ delayp /= this->spec.channels; // to get samples.+#if 0+ // below turns into msec+ if (delayp > 0) {+ delayp *= 1000;+ delayp /= this->spec.channels;+ delayp /= this->spec.freq;+ }+#endif+ }+ return delayp;+}+ static const char *get_audio_device(int channels) { const char *device;@@ -237,6 +258,7 @@ this->PlayAudio = ALSA_PlayAudio; this->GetAudioBuf = ALSA_GetAudioBuf; this->CloseAudio = ALSA_CloseAudio;+ this->AudioDelay = ALSA_AudioDelay; this->free = Audio_DeleteDevice; diff -urN SDL-1.2/src/audio/dsp/SDL_dspaudio.c SDL-1.2-iptv/src/audio/dsp/SDL_dspaudio.c--- SDL-1.2/src/audio/dsp/SDL_dspaudio.c 2008-01-20 21:42:05.000000000 +0100+++ SDL-1.2-iptv/src/audio/dsp/SDL_dspaudio.c 2007-12-03 14:57:04.000000000 +0100@@ -66,6 +66,30 @@ /* Audio driver bootstrap functions */ +static int DSP_AudioDelay (_THIS)+{+ int odelay;+#ifdef SNDCTL_DSP_GETODELAY+ ioctl(audio_fd, SNDCTL_DSP_GETODELAY, &odelay);+ if (odelay > 0) {+ /*+ * delay in msec is bytes * 1000 / (bytes per sample * channels * freq)+ * delay in samples is bytes / bytes_per_sample * channels;+ */+ //odelay *= 1000;+ odelay /= this->spec.channels;+ if (!(this->spec.format == AUDIO_U8 ||+ this->spec.format == AUDIO_S8)) {+ odelay /= 2; // 2 bytes per sample+ }+ //odelay /= this->spec.freq;+ }+#else+ odelay = -1;+#endif+ return (odelay);+}+ static int Audio_Available(void) { int fd;@@ -113,6 +137,9 @@ this->PlayAudio = DSP_PlayAudio; this->GetAudioBuf = DSP_GetAudioBuf; this->CloseAudio = DSP_CloseAudio;+#ifdef SNDCTL_DSP_GETODELAY+ this->AudioDelay = DSP_AudioDelay;+#endif this->free = Audio_DeleteDevice; diff -urN SDL-1.2/src/audio/windx5/SDL_dx5audio.c SDL-1.2-iptv/src/audio/windx5/SDL_dx5audio.c--- SDL-1.2/src/audio/windx5/SDL_dx5audio.c 2008-01-20 21:42:05.000000000 +0100+++ SDL-1.2-iptv/src/audio/windx5/SDL_dx5audio.c 2008-02-24 23:43:06.000000000 +0100@@ -48,6 +48,40 @@ /* Audio driver bootstrap functions */ +static int DX5_AudioDelay (_THIS)+{+ DWORD cursor, write, calc;+ HRESULT result;+ int odelay;+ char buffer[512];+ result = IDirectSoundBuffer_GetCurrentPosition(mixbuf, &cursor, &write);+#if 0+ calc = cursor / mixlen;+ calc = (calc+1)%NUM_BUFFERS;+ calc *= mixlen;+ sprintf(buffer, "cursor %ld write %ld calc %ld mixlen %d num %d\n", cursor, write, + calc, mixlen, NUM_BUFFERS);+ OutputDebugString(buffer);+#else+ calc = write;+#endif+ if (result == DS_OK) {+ /*+ * delay in msec is bytes * 1000 / (bytes per sample * channels * freq)++ */+ odelay = (calc - cursor);+ // odelay *= 1000;+ odelay /= this->spec.channels;+ if (!(this->spec.format == AUDIO_U8 ||+ this->spec.format == AUDIO_S8)) {+ odelay /= 2; // 2 bytes per sample+ }+ //odelay /= this->spec.freq;+ return odelay;+ }+ return -1;+}+ static int Audio_Available(void) { HINSTANCE DSoundDLL;@@ -167,6 +201,7 @@ this->GetAudioBuf = DX5_GetAudioBuf; this->WaitDone = DX5_WaitDone; this->CloseAudio = DX5_CloseAudio;+ this->AudioDelay = DX5_AudioDelay; this->free = Audio_DeleteDevice; @@ -529,11 +564,7 @@ #ifdef USE_POSITION_NOTIFY format.dwFlags |= DSBCAPS_CTRLPOSITIONNOTIFY; #endif- if ( ! focus ) {- format.dwFlags |= DSBCAPS_GLOBALFOCUS;- } else {- format.dwFlags |= DSBCAPS_STICKYFOCUS;- }+ format.dwFlags |= DSBCAPS_GLOBALFOCUS; format.dwBufferBytes = numchunks*chunksize; if ( (format.dwBufferBytes < DSBSIZE_MIN) || (format.dwBufferBytes > DSBSIZE_MAX) ) {diff -urN SDL-1.2/src/events/SDL_events.c SDL-1.2-iptv/src/events/SDL_events.c--- SDL-1.2/src/events/SDL_events.c 2008-01-20 21:42:05.000000000 +0100+++ SDL-1.2-iptv/src/events/SDL_events.c 2007-12-03 14:57:04.000000000 +0100@@ -194,6 +194,7 @@ } #ifndef IPOD SDL_DestroyMutex(SDL_EventQ.lock);+ SDL_EventQ.lock = NULL; #endif } diff -urN SDL-1.2/src/video/SDL_sysvideo.h SDL-1.2-iptv/src/video/SDL_sysvideo.h--- SDL-1.2/src/video/SDL_sysvideo.h 2008-01-20 21:42:05.000000000 +0100+++ SDL-1.2-iptv/src/video/SDL_sysvideo.h 2008-01-20 22:21:26.000000000 +0100@@ -63,6 +63,12 @@ */ SDL_Rect **(*ListModes)(_THIS, SDL_PixelFormat *format, Uint32 flags); + /* Get the current resolution of the user's display. */+ int (*GetDesktopMode)(_THIS, int *width, int *height);++ /* Get the current drawing scanline of the user's display. */+ int (*GetScanline)(_THIS, int *scanline);+ /* Set the requested video mode, returning a surface which will be set to the SDL_VideoSurface. The width and height will already be verified by ListModes(), and the video subsystem is free to@@ -177,7 +183,7 @@ int (*GL_GetAttribute)(_THIS, SDL_GLattr attrib, int* value); /* Make the context associated with this driver current */- int (*GL_MakeCurrent)(_THIS);+ int (*GL_MakeCurrent)(_THIS, int release); /* Swap the current buffers in double buffer mode. */ void (*GL_SwapBuffers)(_THIS);diff -urN SDL-1.2/src/video/SDL_video.c SDL-1.2-iptv/src/video/SDL_video.c--- SDL-1.2/src/video/SDL_video.c 2008-01-20 21:42:05.000000000 +0100+++ SDL-1.2-iptv/src/video/SDL_video.c 2008-01-20 22:30:02.000000000 +0100@@ -75,12 +75,12 @@ #if SDL_VIDEO_DRIVER_GAPI &GAPI_bootstrap, #endif-#if SDL_VIDEO_DRIVER_WINDIB- &WINDIB_bootstrap,-#endif #if SDL_VIDEO_DRIVER_DDRAW &DIRECTX_bootstrap, #endif+#if SDL_VIDEO_DRIVER_WINDIB+ &WINDIB_bootstrap,+#endif #if SDL_VIDEO_DRIVER_BWINDOW &BWINDOW_bootstrap, #endif@@ -339,6 +339,69 @@ } /*+ * If possible, retrieves the current resolution of the user's display. If this+ * operation is supported and succeeds, the width and height are written to the+ * values pointed to by the parameters and 1 is returned. If unsupported or+ * unsuccessful, the pointed to values are not touched and 0 is returned.+ */+int SDL_GetDesktopMode(int *width, int *height)+{+ SDL_VideoDevice *video = current_video;+ SDL_VideoDevice *this = current_video;++ if (video && video->GetDesktopMode) {+ return video->GetDesktopMode(this, width, height);+ } else {+ return 0;+ }+}++/*+ * If possible, retrieves the current window position. If this+ * operation is supported and succeeds, the position is written to the+ * value pointed to by the parameter and 1 is returned. If unsupported or+ * unsuccessful, the pointed to value is not touched and 0 is returned.+ */+#if defined(__WIN32__)+extern HWND SDL_Window;+#endif++int SDL_GetWindowPosition(SDL_Rect *pos)+{+#if defined(__WIN32__)+ RECT rect;+ if (pos) {+ GetWindowRect(SDL_Window, &rect);+ pos->x = rect.left;+ pos->y = rect.top;+ pos->w = rect.right-rect.left;+ pos->h = rect.bottom-rect.top;+ return 1;+ }+#endif+ return 0;+}++/*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -