Skip to content

Commit

Permalink
Source: Remove temporary playlists
Browse files Browse the repository at this point in the history
  • Loading branch information
univrsal committed Nov 8, 2023
1 parent 203ab41 commit d4dc328
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/mpv-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ static inline void generate_and_load_playlist(struct mpv_source* context)
obs_data_array_t* array = obs_data_get_array(settings, "playlist");
size_t count = obs_data_array_count(array);

// remove temporary playlist file
if (context->tmp_playlist_path) {
remove(context->tmp_playlist_path);
bfree(context->tmp_playlist_path);
context->tmp_playlist_path = NULL;
}

DARRAY(char*)
tmp;
da_init(tmp);
Expand Down Expand Up @@ -89,6 +96,8 @@ static inline void generate_and_load_playlist(struct mpv_source* context)
}

end:
bfree(context->tmp_playlist_path);
context->tmp_playlist_path = bstrdup(tmp_file.array);
da_free(tmp);
obs_data_array_release(array);
dstr_free(&tmp_file);
Expand Down Expand Up @@ -238,9 +247,16 @@ static void mpvs_source_destroy(void* data)
bfree(context->files.array[i]);
da_free(context->files);

bfree(context->queued_temp_playlist_file_path);
// remove temporary playlist file
if (context->tmp_playlist_path) {
remove(context->tmp_playlist_path);
bfree(context->tmp_playlist_path);
context->tmp_playlist_path = NULL;
}

destroy_jack_source(context);
dstr_free(&context->last_path);
bfree(context->queued_temp_playlist_file_path);
bfree(data);
}

Expand Down
1 change: 1 addition & 0 deletions src/mpv-source.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ struct mpv_source {
bool osc; // mpv on screen controller
DARRAY(char*) files;
struct dstr last_path;
char* tmp_playlist_path;
bool shuffle;
bool loop;

Expand Down

0 comments on commit d4dc328

Please sign in to comment.