mirror of
https://github.com/mpv-player/mpv
synced 2024-12-16 11:55:42 +00:00
2e91d44e20
This mechanism originates from MPlayer's way of dealing with blocking network, but it's still useful. On opening and closing, mpv waits for network synchronously, and also some obscure commands and use-cases can lead to such blocking. In these situations, the stream is asynchronously forced to stop by "interrupting" it. The old design interrupting I/O was a bit broken: polling with a callback, instead of actively interrupting it. Change the direction of this. There is no callback anymore, and the player calls mp_cancel_trigger() to force the stream to return. libavformat (via stream_lavf.c) has the old broken design, and fixing it would require fixing libavformat, which won't happen so quickly. So we have to keep that part. But everything above the stream layer is prepared for a better design, and more sophisticated methods than mp_cancel_test() could be easily introduced. There's still one problem: commands are still run in the central playback loop, which we assume can block on I/O in the worst case. That's not a problem yet, because we simply mark some commands as being able to stop playback of the current file ("quit" etc.), so input.c could abort playback as soon as such a command is queued. But there are also commands abort playback only conditionally, and the logic for that is in the playback core and thus "unreachable". For example, "playlist_next" aborts playback only if there's a next file. We don't want it to always abort playback. As a quite ugly hack, abort playback only if at least 2 abort commands are queued - this pretty much happens only if the core is frozen and doesn't react to input.
62 lines
2.0 KiB
C
62 lines
2.0 KiB
C
/*****************************************************************************
|
|
* rar.h: uncompressed RAR parser
|
|
*****************************************************************************
|
|
* Copyright (C) 2008-2010 Laurent Aimar
|
|
* $Id: 4dea45925c2d8f319d692475bc0307fdd9f6cfe7 $
|
|
*
|
|
* Author: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation; either version 2.1 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
|
*****************************************************************************/
|
|
|
|
#ifndef MP_RAR_H
|
|
#define MP_RAR_H
|
|
|
|
#include <inttypes.h>
|
|
#include <sys/types.h>
|
|
|
|
typedef struct {
|
|
char *mrl;
|
|
uint64_t offset;
|
|
uint64_t size;
|
|
uint64_t cummulated_size;
|
|
} rar_file_chunk_t;
|
|
|
|
typedef struct {
|
|
char *name;
|
|
uint64_t size;
|
|
bool is_complete;
|
|
|
|
int chunk_count;
|
|
rar_file_chunk_t **chunk;
|
|
uint64_t real_size; /* Gathered size */
|
|
|
|
// When actually reading the data
|
|
struct mpv_global *global;
|
|
struct mp_cancel *cancel;
|
|
uint64_t i_pos;
|
|
stream_t *s;
|
|
rar_file_chunk_t *current_chunk;
|
|
} rar_file_t;
|
|
|
|
int RarProbe(struct stream *);
|
|
void RarFileDelete(rar_file_t *);
|
|
int RarParse(struct stream *, int *, rar_file_t ***);
|
|
|
|
int RarSeek(rar_file_t *file, uint64_t position);
|
|
ssize_t RarRead(rar_file_t *file, void *data, size_t size);
|
|
|
|
#endif
|