Skip to content

Commit

Permalink
Make al_is_video_playing return false before al_start_video.
Browse files Browse the repository at this point in the history
  • Loading branch information
SiegeLordEx authored and SiegeLord committed Nov 20, 2024
1 parent 082d06d commit b2f5887
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions addons/video/video.c
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
/* This is just a quick hack. But good enough for our use of displaying
* a short intro video when our game starts up - so might as well share
* it.
*
*
* Known bugs:
*
*
* - Only very crude synching. Audio is slightly delayed and some
* videos seem to constantly drift off and then the audio gets all
* distorted...
*
* - Seeking/Pausing doesn't really work.
*
*
* - Memory leaks. Easy to fix but don't have time right now.
*
* Missing features:
*
*
* - Stream information. For example allow selection of one of several
* audio streams or subtitle overlay streams.
*
*
* - Non audio/video streams. For example something like:
* ALLEGRO_USTR *al_get_video_subtitle(float *x, float *y);
*
*
* - Buffering. Right now buffering is hardcoded to a fixed size which
* seemed enough for streaming 720p from disk in my tests. Obviously
* when streaming higher bandwidth or from a source with high
* fluctuation like an internet stream this won't work at all.
*
*
* - Provide an audio stream for the audio. Then could use this to
* stream audio files. Right now opening an .mp3 with the video
* addon will play it but only with the video API instead of Allegro's
* normal audio streaming API...
*
*
* - Audio/Video sync. For a game user-controlled sync is probably not
* too important as it can just ship with a properly synchronizeded
* video. However right now the audio delay is completely ignored.
*
*
* - Additional drivers. Also redo the API a bit so not everything
* has to be done by the driver.
*/

#include "allegro5/allegro5.h"
#include "allegro5/allegro_video.h"
#include "allegro5/internal/aintern.h"
Expand Down Expand Up @@ -119,18 +119,17 @@ ALLEGRO_VIDEO *al_open_video(char const *filename)
}

video->filename = al_create_path(filename);
video->playing = true;

if (!video->vtable->open_video(video)) {
ALLEGRO_ERROR("Could not open %s.\n", filename);
al_destroy_path(video->filename);
al_free(video);
return NULL;
}

al_init_user_event_source(&video->es);
video->es_inited = true;

return video;
}

Expand Down Expand Up @@ -164,6 +163,7 @@ void al_start_video(ALLEGRO_VIDEO *video, ALLEGRO_MIXER *mixer)

/* XXX why is this not just a parameter? */
video->mixer = mixer;
video->playing = true;
video->vtable->start_video(video);
}

Expand Down
4 changes: 2 additions & 2 deletions docs/src/refman/video.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Since: 5.1.12

## API: al_open_video

Reads a video file. This does not start streaming yet but reads the
Reads a video file. This does not start playing yet but reads the
meta info so you can query e.g. the size or audio rate.

Since: 5.1.0
Expand Down Expand Up @@ -127,7 +127,7 @@ Since: 5.1.0

## API: al_start_video

Starts streaming the video from the beginning.
Starts playing the video from the beginning.

Since: 5.1.0

Expand Down

0 comments on commit b2f5887

Please sign in to comment.