<commit_before>package com.genymobile.scrcpy;

import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.atomic.AtomicBoolean;

public class ScreenStreamerSession {

    private final DesktopConnection connection;
    private Process screenRecordProcess; // protected by 'this'
    private final AtomicBoolean stopped = new AtomicBoolean();
    private final byte[] buffer = new byte[0x10000];

    public ScreenStreamerSession(DesktopConnection connection) {
        this.connection = connection;
    }

    public void streamScreen() throws IOException {
        // screenrecord may not record more than 3 minutes, so restart it on EOF
        while (!stopped.get() && streamScreenOnce()) ;
    }

    /**
     * Starts screenrecord once and relay its output to the desktop connection.
     *
     * @return {@code true} if EOF is reached, {@code false} otherwise (i.e. requested to stop).
     * @throws IOException if an I/O error occurred
     */
    private boolean streamScreenOnce() throws IOException {
        Process process = startScreenRecord();
        setCurrentProcess(process);
        InputStream inputStream = process.getInputStream();
        int r;
        while ((r = inputStream.read(buffer)) != -1 && !stopped.get()) {
            connection.sendVideoStream(buffer, r);
        }
        return r != -1;
    }<commit_msg>Add debug log on new screenrecord execution<commit_after>package com.genymobile.scrcpy;

import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.atomic.AtomicBoolean;

public class ScreenStreamerSession {

    private final DesktopConnection connection;
    private Process screenRecordProcess; // protected by 'this'
    private final AtomicBoolean stopped = new AtomicBoolean();
    private final byte[] buffer = new byte[0x10000];

    public ScreenStreamerSession(DesktopConnection connection) {
        this.connection = connection;
    }

    public void streamScreen() throws IOException {
        // screenrecord may not record more than 3 minutes, so restart it on EOF
        while (!stopped.get() && streamScreenOnce()) ;
    }

    /**
     * Starts screenrecord once and relay its output to the desktop connection.
     *
     * @return {@code true} if EOF is reached, {@code false} otherwise (i.e. requested to stop).
     * @throws IOException if an I/O error occurred
     */
    private boolean streamScreenOnce() throws IOException {
        Ln.d("Recording...");
        Process process = startScreenRecord();
        setCurrentProcess(process);
        InputStream inputStream = process.getInputStream();
        int r;
        while ((r = inputStream.read(buffer)) != -1 && !stopped.get()) {
            connection.sendVideoStream(buffer, r);
        }
        return r != -1;
    }
{'fraction_non_alphanumeric': 0.09528907922912205, 'fraction_numerical': 0.006423982869379015, 'mean_word_length': 3.0272988505747125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3225396', 'n_tokens_mistral': 729, 'n_tokens_neox': 699, 'n_words': 237}