Skip to Content
It is currently November 20th, 2019, 10:33 am

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: October 18th, 2019, 10:02 am 
Offline
Senior User
Senior User

Joined: September 7th, 2018, 9:00 am
Posts: 109
Now I have the 2019.3 Build 66910 and I thought it was solved but I still get this issue.
(W10 1903)

On the song/podcast/ads change, SAM freezes also for 10-20 seconds.
Well, streaming is working and no interruptions, but any other activity of SAM are frozen.
It appears "not responding" ... then it returns alive.

The only one PAL script in action is the one is calling the website, passing a GET instruction to it.
What can causes this issue please?

Here the PAL script

Code:
PAL.loop := true;

{Declaration (Variables)}
var   Player : TPlayer;
var   Song : TSongInfo;
var   statusmessage, returnmessage, picture, SongLabel, ipCheck, ipResult: String;
var   ErrorLog, DebugLog : String;
const RADIO_DOMAIN : string = 'https://www.radioXXXXXXX.com';
const RADIO_SOCIAL : string = RADIO_DOMAIN + '/rd/repeater.php';
const ADDRESS : string = RADIO_DOMAIN + '/OnDemand/pictures/';
const M3U  : string = '#EXTM3U' +#13#10;
const M3U1 : string = '#EXTINF: ';
const PATH_FILES   : string = 'D:\RADIO\SAM-SONG.INFO\';
const AIR_PLAY_SONG : string = PATH_FILES + 'song.txt';
const WEB_RESPONSE : string = PATH_FILES + 'webresponse.txt';
const WEB_ARTWORK  : string = PATH_FILES + 'artwork.m3u';

// Check the IP of SAM
ipCheck := RADIO_SOCIAL + '?myip=ip';
PAL.UnLockExecution;
ipResult := WebToStr(ipCheck);
WriteLn(ipResult);
PAL.LockExecution;
{Declaration (Functions and Procedures)}
// Construct the GET String for the Web Script, call it and return the output
FUNCTION update(status, picture : String) : String; forward;
PAL.WaitForPlayCount(1);
Player := ActivePlayer;
Song := Player.GetSongInfo;

//IF (Song <> NIL) AND (Song['duration'] > 10000) AND (Pos(Song['songtype'],'SAV') > 0) THEN
    //BEGIN
        // Is anything playing right now?
        IF ( Player <> NIL ) THEN
            BEGIN
                //Song := Player.GetSongInfo;
                IF Song['label'] <> '' THEN
                        SongLabel := '&label=' + URLEncode(Song['label'])
                    ELSE
                        SongLabel := '';

                IF (Song <> NIL) AND (Song['duration'] > 10000) AND (Pos(Song['songtype'],'SAV') > 0) THEN
                    BEGIN
                        statusmessage := Song['title'] + ' - ' + Song['artist']; // Message to display in twitter
                        SaveStringToFile(AIR_PLAY_SONG,statusmessage); // Write AirPlay song
                        picture := Song['picture'];

                        IF Pos('jpg', picture) = 0 THEN picture := 'na.png';

                        SaveStringToFile(WEB_ARTWORK,M3U + M3U1 + Song['duration'] + ' ' + statusmessage + #13#10 + ADDRESS + URLEncode(picture)); // Write Artwork song
                        returnmessage := update(statusmessage, picture);

                    END;
            END;
    //END;
Song.Free;
Player.Free;

FUNCTION update(status, picture : String) : String;
    var getStr, returnstr : String;
    httpClient : THttpClient;
    BEGIN
        WriteLn(picture);

        // URLEncode Blanks and Special Chars
        status := URLEncode(status);
        picture := URLEncode(picture);

        getStr := RADIO_SOCIAL
        + '?message=' + status
        + '&picture=' + picture
        + '&title=' + URLEncode(Song['title'])
        + '&artist=' + URLEncode(Song['artist'])
        + '&songtype=' + Song['songtype'];

        httpClient := THttpClient.Create(getStr);

        // Here goes the magic!
        httpClient.Get;

        while not httpClient.ResponseReady DO Pal.WaitForTime('+00:00:01');

        // HTTP Status Codes: 200 = OK, 404 = NOT FOUND, 403 = Forbidden, 500 = Generic Server error
        IF httpClient.ResponseCode = 200 THEN returnstr := httpClient.ResponseData;

        result := returnstr +#13#10;
        WriteLn(result);

        // Write response from PHP script

        IF FileExists(WEB_RESPONSE) THEN
                AppendStringToFile(WEB_RESPONSE, result)
            ELSE
                SaveStringToFile(WEB_RESPONSE, result);


    END;


Top
 Profile  
Reply with quote  
PostPosted: October 19th, 2019, 1:28 pm 
Offline
Senior User
Senior User

Joined: September 7th, 2018, 9:00 am
Posts: 109
With further investigations, I came to the conclusion that the following lines are the responsible of the freezing

Code:
        // Here goes the magic!
        httpClient.Get;

 while not httpClient.ResponseReady DO Pal.WaitForTime('+00:00:01');

        // HTTP Status Codes: 200 = OK, 404 = NOT FOUND, 403 = Forbidden, 500 = Generic Server error
        IF httpClient.ResponseCode = 200 THEN returnstr := httpClient.ResponseData;


When the site is called, till the moment in which an answer is received and processed, freezes the GUI of SAM.

Is there any way to make these operations transparent avoiding the freezing?


Top
 Profile  
Reply with quote  
PostPosted: October 30th, 2019, 5:42 am 
Offline
Senior User
Senior User

Joined: September 7th, 2018, 9:00 am
Posts: 109
PARTIALLY SOLVED

The issue is the response from the website the script calls.
Of course the process is waiting for the answer from the PHP script

But in fact SAM freezes the GUI, when such thing is occurring.
On 4Cores CPU this is not understandable


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: MSN [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group