Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

output.file can create multiple files on reopen #2842

Closed
vitoyucepi opened this issue Jan 10, 2023 · 0 comments · Fixed by #2922
Closed

output.file can create multiple files on reopen #2842

vitoyucepi opened this issue Jan 10, 2023 · 0 comments · Fixed by #2922

Comments

@vitoyucepi
Copy link
Collaborator

Describe the bug
I've found out that sometimes output.file can create two different files if the file name has seconds in it. This happens because the file name function is called several times, and the current time is near the round second.

To Reproduce

def file_name()
    a = time.string('/tmp/%H_%M_%S.mp3')
    print('file name is #{a}')
    a
end

output.file(
    reopen_delay=1.0,
    reopen_when={true},
    %ffmpeg(format="mp3", %audio(codec="libmp3lame", samplerate=48000, b="320k")),
    file_name,
    sine(480.)
)
2023/01/10 19:53:22 [/tmp/19_53_18.mp3:3] Re-opening output pipe.
file name is /tmp/19_53_22.mp3
file name is /tmp/19_53_22.mp3
file name is /tmp/19_53_22.mp3
2023/01/10 19:53:23 [/tmp/19_53_18.mp3:3] Re-opening output pipe.
file name is /tmp/19_53_23.mp3
file name is /tmp/19_53_23.mp3
file name is /tmp/19_53_24.mp3
2023/01/10 19:53:25 [/tmp/19_53_18.mp3:3] Re-opening output pipe.
file name is /tmp/19_53_25.mp3
file name is /tmp/19_53_25.mp3
file name is /tmp/19_53_25.mp3
#stat 19_53_23.mp3 
  File: 19_53_23.mp3
  Size: 43245     	Blocks: 88         IO Block: 4096   regular file
Device: 0,30	Inode: 69095       Links: 1
Access: (0644/-rw-r--r--)  Uid: (10000/ UNKNOWN)   Gid: (10001/ UNKNOWN)
Access: 2023-01-10 19:53:23.976039781 +0000
Modify: 2023-01-10 19:53:25.016028702 +0000
Change: 2023-01-10 19:53:25.016028702 +0000
 Birth: 2023-01-10 19:53:23.976039781 +0000
#stat 19_53_24.mp3 
  File: 19_53_24.mp3
  Size: 0         	Blocks: 0          IO Block: 4096   regular empty file
Device: 0,30	Inode: 69096       Links: 1
Access: (0644/-rw-r--r--)  Uid: (10000/ UNKNOWN)   Gid: (10001/ UNKNOWN)
Access: 2023-01-10 19:53:24.012706057 +0000
Modify: 2023-01-10 19:53:24.012706057 +0000
Change: 2023-01-10 19:53:24.012706057 +0000
 Birth: 2023-01-10 19:53:24.012706057 +0000

Expected behavior
I think that between reopen tries should be exactly the reopen_delay time, but it drifts slightly forward.
The file name function should not be called several times.

Version details

  • OS: ubuntu:22.04 in docker
  • Version: 2.1.3

Install method
Deb package from liquidsoap releases at github

Common issues
N/A

toots added a commit that referenced this issue Feb 24, 2023
* Use `Atomic` for values potentially acessed concurrently.
* Make filename computation idempotent
* Prevent filename function from being called to set the source's name

Fix: #2842
toots added a commit that referenced this issue Feb 24, 2023
* Use `Atomic` for values potentially acessed concurrently.
* Make filename computation idempotent
* Prevent filename function from being called to set the source's name

Fix: #2842
toots added a commit that referenced this issue Feb 24, 2023
* Use `Atomic` for values potentially acessed concurrently.
* Make filename computation idempotent
* Prevent filename function from being called to set the source's name

Fix: #2842
toots added a commit that referenced this issue Feb 24, 2023
toots added a commit that referenced this issue Feb 24, 2023
toots added a commit that referenced this issue Feb 25, 2023
toots added a commit that referenced this issue Feb 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant