mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
better pause when displaying audio samples
Originally committed as revision 1941 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
7408ad05cc
commit
5e0257e305
8
ffplay.c
8
ffplay.c
@ -94,6 +94,7 @@ typedef struct VideoState {
|
|||||||
int show_audio; /* if true, display audio samples */
|
int show_audio; /* if true, display audio samples */
|
||||||
int16_t sample_array[SAMPLE_ARRAY_SIZE];
|
int16_t sample_array[SAMPLE_ARRAY_SIZE];
|
||||||
int sample_array_index;
|
int sample_array_index;
|
||||||
|
int last_i_start;
|
||||||
|
|
||||||
double video_clock; /* current video clock value */
|
double video_clock; /* current video clock value */
|
||||||
int video_stream;
|
int video_stream;
|
||||||
@ -128,7 +129,7 @@ static int show_status;
|
|||||||
/* current context */
|
/* current context */
|
||||||
static int is_full_screen;
|
static int is_full_screen;
|
||||||
static VideoState *cur_stream;
|
static VideoState *cur_stream;
|
||||||
static int16_t audio_callback_time;
|
static int64_t audio_callback_time;
|
||||||
|
|
||||||
#define FF_ALLOC_EVENT (SDL_USEREVENT)
|
#define FF_ALLOC_EVENT (SDL_USEREVENT)
|
||||||
#define FF_REFRESH_EVENT (SDL_USEREVENT + 1)
|
#define FF_REFRESH_EVENT (SDL_USEREVENT + 1)
|
||||||
@ -374,6 +375,7 @@ static void video_audio_display(VideoState *s)
|
|||||||
/* compute display index : center on currently output samples */
|
/* compute display index : center on currently output samples */
|
||||||
channels = s->audio_st->codec.channels;
|
channels = s->audio_st->codec.channels;
|
||||||
nb_display_channels = channels;
|
nb_display_channels = channels;
|
||||||
|
if (!s->paused) {
|
||||||
n = 2 * channels;
|
n = 2 * channels;
|
||||||
delay = audio_write_get_buf_size(s);
|
delay = audio_write_get_buf_size(s);
|
||||||
delay /= n;
|
delay /= n;
|
||||||
@ -389,6 +391,10 @@ static void video_audio_display(VideoState *s)
|
|||||||
if (delay < s->width)
|
if (delay < s->width)
|
||||||
delay = s->width;
|
delay = s->width;
|
||||||
i_start = compute_mod(s->sample_array_index - delay * channels, SAMPLE_ARRAY_SIZE);
|
i_start = compute_mod(s->sample_array_index - delay * channels, SAMPLE_ARRAY_SIZE);
|
||||||
|
s->last_i_start = i_start;
|
||||||
|
} else {
|
||||||
|
i_start = s->last_i_start;
|
||||||
|
}
|
||||||
|
|
||||||
bgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);
|
bgcolor = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);
|
||||||
fill_rectangle(screen,
|
fill_rectangle(screen,
|
||||||
|
Loading…
Reference in New Issue
Block a user