Skip to content
Snippets Groups Projects

misc/m3u: Split m3u metadata write so that newline is infallible

Open sdasda7777 requested to merge sdasda7777/vlc:sdasda7777_infallible_m3u_newline into master
1 unresolved thread

This basically fixes #28641, at least the part where user data is irreversibly lost.

Writing metadata to file may still fail, and it appears there is nothing VLC can do about that, but with this fix, all tracks will still be present in the resulting file, and will not be lost on m3u file read+write.

Merge request reports

Members who can merge are allowed to add commits.

Merge request pipeline #469738 passed with warnings

Merge request pipeline passed with warnings for 0c2812ee

Test coverage 18.32% from 1 job
Approval is optional
Merge blocked: 2 checks failed
Unresolved discussions must be resolved.
Merge request must be rebased, because a fast-forward merge is not possible.

Merge details

  • The source branch is 4336 commits behind the target branch.
  • 2 commits will be added to master.
  • Source branch will be deleted.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Thanks

    Thanks for your contribution!

    When all of the following conditions are fulfilled, your MergeRequest will be reviewed by the Team:

    • the check pipeline passes
    • the MR is considered as 'mergeable' by gitlab

    You can find more details about the acceptance process here.

    This message was automatically generated by homer-bot.

  • Nit: you could use fputs() for that and move it out of the if() block.

  • Steve Lhomme changed milestone to %4.0

    changed milestone to %4.0

  • sdasda7777 added 1 commit

    added 1 commit

    Compare with previous version

  • Also nitpicking: use descriptive description of your commit titles. For example "minor improvement" gives zero information about what is happening to the code.

    You can also prefix the titles with the file(s) and or module(s) you're changing. See how we usually do it: https://code.videolan.org/videolan/vlc/-/commits/master/?ref_type=undefined

    And finally, please put the description of why you're making this change in your first commit description.

  • sdasda7777 changed title from Split m3u metadata write so that newline is infallible to misc/m3u: Split m3u metadata write so that newline is infallible

    changed title from Split m3u metadata write so that newline is infallible to misc/m3u: Split m3u metadata write so that newline is infallible

  • Also nitpicking: use descriptive description of your commit titles. For example "minor improvement" gives zero information about what is happening to the code.

    I assume the commits will be squashed in the end, no?

    And finally, please put the description of why you're making this change in your first commit description.

    Is there any way to do that from the web IDE?

  • I assume the commits will be squashed in the end, no?

    No, you're responsible for your commits.

    Is there any way to do that from the web IDE?

    AFAIK it's based on VSCode, by default I think it doesn't have "interactive rebase" to handle that. Maybe it can do git from the command line. So you can do something like git -i rebase origin/master.

84 pf_fprintf( p_export->file, "#EXTINF:%"PRIu64",%s - %s\n",
85 SEC_FROM_VLC_TICK(i_duration), psz_artist, psz_name);
86 }
87 else
88 {
89 /* write EXTINF without artist */
90 pf_fprintf( p_export->file, "#EXTINF:%"PRIu64",%s\n",
91 SEC_FROM_VLC_TICK(i_duration), psz_name);
87 /* write EXTINF artist */
88 pf_fprintf( p_export->file, "%s", psz_artist);
89 fputs(" - ", p_export->file);
92 90 }
91 /* write EXTINF song name */
92 pf_fprintf( p_export->file, "%s", psz_name);
93
94 // End metadata - the newline is separated because it must be written regardless of whether writing other metadata succeeded
  • This both misleading and wrong. If there is an I/O error, it will be detected upon the new line anyway, due to line buffering (C11 §7.23.1). So all this does is make the code more complicated and slower.

    There are two ways to handle errors: abort the output and pass the error upward, or seek to a known good point and resume (which will clear the error flag on the FILE). This is doing neither.

  • It may be too early in the morning for me, but could you please explain why this is not doing the latter?

  • Because when you have I/O errors, here fputws seems to return EOF, on a FILE stream flags are set and your internal buffer is in a undefined state. It might be flushed, might be garbage, you just cannot know and it will depend on your CRT.

    As Rémi said, if you want to handle the error internally you should probably call ftell() before trying to call, pf_fprintf then check its return. If it's EOF you should probably fseek back to the position (which will clear the flags and the internal buffer) that ftell gave you then only write the file MRL.

    Edit: scratch the last part since the function is also used for m3u8 you need at least the #EXTINF:<duration>,\n

    Edited by Denis Charmet
  • Please register or sign in to reply
  • **** added MRStatus::Stale label and removed MRStatus::InReview label

    added MRStatus::Stale label and removed MRStatus::InReview label

  • Please register or sign in to reply
    Loading