This file is indexed.

/usr/share/perl5/Audio/Nama/EngineCleanup.pm is in nama 1.208-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# ----------- Engine cleanup (post-recording) -----------
package Audio::Nama;
use Modern::Perl;
use Cwd;
use Audio::Nama::Globals qw(:all);

sub rec_cleanup {  
	logsub("&rec_cleanup");
	logpkg(__FILE__,__LINE__,'debug',"transport still running, can't cleanup"),return if transport_running();
	if( my (@files) = new_files_were_recorded() )
	{
		if( my @rec_tracks = Audio::Nama::ChainSetup::engine_wav_out_tracks() )
		{
			$project->{playback_position} = 0;
			$setup->{_last_rec_tracks} = \@rec_tracks;
			pager(join " ", "Files recorded for these tracks:",
				map{ $_->name } @rec_tracks);
		}

		if( grep /Mixdown/, @files) { mixdown_postprocessing() }
		else { post_rec_configure() }
	}
}
sub mixdown_postprocessing {
	logsub("&mixdown_postprocessing");
	process_command('mixplay');
	my ($oldfile) = $tn{Mixdown}->full_path =~ m{([^/]+)$};
	$oldfile = join_path('.wav',$oldfile);
	my $tag_name = join '-', $project->{name}, current_branch();
	my $version = $tn{Mixdown}->monitor_version;

	# simplify the tagname basename 
	# 
	# 	untitled-master        -> untitled
	#   untitled-premix-branch -> untitled-premix
	
	$tag_name =~ s/-branch$//;
	$tag_name =~ s/-master$//;
	$tag_name .= "_$version";

	delete_existing_mixdown_tag_and_convenience_encodings($tag_name);

	# create symlink in project_dir()
	
	my $was_in = getcwd;
	chdir project_dir() or die "couldn't chdir: $!";
	my $newfile = "$tag_name.wav";
	logpkg(__FILE__,__LINE__,'debug',"symlinking oldfile: $oldfile, newfile: $newfile");
	symlink $oldfile, $newfile or throw("symlink didn't work: $!");
	tag_mixdown_commit($tag_name, $newfile, $oldfile) if $config->{use_git};

	my $sha = git_sha(); # possibly undef
	my $encoding = $config->{mixdown_encodings};
	my $comment;
	if ($sha or $encoding){
		$comment .= "tagged " if $sha;
		$comment .= "and " if $sha and $encoding;
		$comment .= "encoded " if $encoding;
		$comment .= "as $tag_name ";
		$comment .= "(commit $sha)" if $sha;
	}
	$tn{Mixdown}->add_system_version_comment($version, $comment);
	pager_newline($comment);	
	encode_mixdown_file($oldfile,$tag_name);
	chdir $was_in;
}
sub tag_mixdown_commit {
	logsub('&tag_mixdown_commit');
	my ($name, $newfile, $mixdownfile) = @_;
	logpkg(__FILE__,__LINE__,'debug',"tag_mixdown_commit: @_");

	my ($sym) = $newfile =~ m([^/]+$);
	my ($mix) = $mixdownfile =~ m([^/]+$);

	# we want to tag the normal playback state
	
	local $quiet = 1;
	mixoff();

	my $msg = "State for $sym ($mix)";
	git_snapshot($msg);
	git('tag', $name, '-m', $mix);

	# rec_cleanup wants to audition the mixdown
	mixplay();
}
sub delete_existing_mixdown_tag_and_convenience_encodings {
	logsub('&delete_existing_mixdown_tag_and_convenience_encodings');
	my $name = shift;
	logpkg(__FILE__,__LINE__,'debug',"name: $name");
		git('tag', '-d', $name);
		foreach( qw(mp3 ogg wav) ){
			my $file = join_path(project_dir(),"$name.$_");
			unlink $file if -e $file;
		}
	}
sub encode_mixdown_file {
	state $shell_encode_command = {
		mp3 => q(lame -h --ta "$artist" --ty $year --tt "$title" $input_file $output_file),
		ogg => q(oggenc -o $output_file -a "$artist" -t "$title" -d "$date" $input_file)
	};	
	my($mixdownfile, $tag_name, @formats) = @_;
	@formats or @formats = split " ", $config->{mixdown_encodings};
	logpkg(__FILE__,__LINE__,'debug',"formats: @formats");
	my $artist = $project->{artist} || qx(whoami);
	my $title = $project->{name};
	my $date = qx(date);
	chomp($date, $artist);
	my ($year) = $date =~ /(\d{4})$/;
	my $input_file = $mixdownfile;
	for my $format( @formats ){
		my $output_file = join_path(project_dir(),"$tag_name.$format");
		logpkg(__FILE__,__LINE__,'debug',"artist $artist, title $title, date $date, year $year, input file $input_file, output file $output_file");
		my $cmd = eval qq(qq($shell_encode_command->{$format}));
		logpkg(__FILE__,__LINE__,'debug',"Mixdown encoding command:\n$cmd");
		system $cmd; 
	}

}
		
sub adjust_offset_recordings {
	for( Audio::Nama::ChainSetup::engine_wav_out_tracks()){
		no warnings 'uninitialized';
		if (my $mark = $setup->{offset_run}->{mark}){
			$_->set(playat => $mark);
			logpkg(__FILE__,__LINE__,'debug',$_->name, ": offsetting to $mark");
		}
	}
}
sub post_rec_configure {

		$ui->global_version_buttons(); # recreate
		adjust_offset_recordings();

		# toggle recorded tracks to PLAY for auditioning
		
		map{ $_->set(rw => PLAY) } @{$setup->{_last_rec_tracks}};
		
		undef $mode->{offset_run} if ! defined $this_edit;
		no warnings 'uninitialized';
		$mode->{midish_transport_sync} = 'play' 
			if $mode->{midish_transport_sync} eq 'record';

		$ui->refresh();
		request_setup();
		reconfigure_engine();
}
sub new_files_were_recorded {
 	return unless my @files = Audio::Nama::ChainSetup::really_recording();
	logpkg(__FILE__,__LINE__,'debug',join $/, "intended recordings:", @files);
	my @recorded =
		grep { 	my ($name, $version) = /([^\/]+)_(\d+).wav$/;
				if (-e ) {
					if (-s  > 44100) { # 0.5s x 16 bits x 44100/s
						logpkg(__FILE__,__LINE__,'debug',"File size >44100 bytes: $_");
						$tn{$name}->set(version => $version) if $tn{$name};
						$ui->update_version_button($tn{$name}->n, $version);
					1;
					}
					else { unlink $_; 0 }
				}
		} @files;
	if(@recorded){
		restart_wav_memoize();
		pager(join $/, "recorded:",@recorded);
	}
	map{ _get_wav_info($_) } @recorded;
	@recorded 
} 
1;
__END__