Browse code

Merge branch 'hotfix_1_7_9' into master

Lorenz Glaser authored onSun/Aug/2020 06:0:th
Showing5 changed files
... ...
@@ -1,4 +1,4 @@
1
-#!/boot/home/config/bin/yab
1
+#!/boot/home/config/non-packaged/bin/yab
2 2
 
3 3
 screenWidth = peek("desktopwidth")
4 4
 screenHeight = peek("desktopheight")
... ...
@@ -19,6 +19,7 @@ TABVIEW ADD "Tab","Sound"
19 19
 
20 20
 // on the 1 Tab
21 21
 draw text 10,15 ,upper$("Demonstration Columnbox sorting"), "Tab1"
22
+draw text 10,30 ,"!!! The sorting algorythm isn't perfect. This is an issue for next version", "Tab1"
22 23
 x=0
23 24
 i=0
24 25
 d=0
... ...
@@ -135,6 +136,20 @@ Button 20,70 to 200,90, "pause","Playsound Pause / Continue","Tab5"
135 136
 
136 137
 Button 20,100 to 200,120, "start_Media","MediaSound Start","Tab5"
137 138
 Button 20,130 to 200,150, "stop_Media","MediaSound Stop","Tab5"
139
+
140
+draw text 250,30, "To avoid accidental crashes when exiting the program with sound, here is a solution to deal with this","Tab5"
141
+draw text 250,50, "this can you put in the quit cases","Tab5"
142
+draw text 250,90, "case \"Quit|\"","Tab5"
143
+draw text 250,110,"   IF (ID=1) THEN","Tab5"
144
+draw text 250,130,"      SOUND STOP ID","Tab5"
145
+draw text 250,150,"   ENDIF","Tab5"
146
+draw text 250,170,"   IF (NEW_ID=1) THEN","Tab5"
147
+draw text 250,190,"      MEDIASOUND STOP NEW_ID","Tab5"
148
+draw text 250,210,"   endif","Tab5"
149
+draw text 250,230,"   window close \"Main\"","Tab5"
150
+draw text 250,250,"   exit","Tab5"
151
+draw text 250,270,"break", "Tab5"
152
+
138 153
 //tooltip "start_Media", "testetxt"
139 154
 //tooltipnew "start_Media" , "testetxt" ,"lowcolor", 255,255,255
140 155
 textedit 10,300 to (View GET "Tab", "width")-20,(View GET "Tab", "Height")-40, "ausgabe9", 1, "Tab5"
... ...
@@ -174,16 +189,33 @@ textedit add "ausgabe9","//If you click MEDIASOUND STOP  twice, the program brea
174 189
 			switch (msg$)
175 190
 
176 191
 				case "Main:_QuitRequested|":
192
+					IF (ID=1) THEN
193
+						SOUND STOP ID
194
+					ENDIF
195
+					IF (NEW_ID=1) THEN
196
+						MEDIASOUND STOP NEW_ID
197
+						wait 0.1
198
+					endif
199
+					
177 200
 					window close "Main"
201
+					exit
178 202
 					//window close "View"
179 203
 				break
180 204
 
181 205
 				case "Quit|"
206
+				IF (ID=1) THEN
207
+						SOUND STOP ID
208
+					ENDIF
209
+					IF (NEW_ID=1) THEN
210
+						MEDIASOUND STOP NEW_ID
211
+					endif
182 212
 					window close "Main"
213
+					exit
183 214
 				break
184 215
 
185 216
 				case "View:Spiel:Beenden|"
186 217
 				        window close "Main"
218
+						exit
187 219
 				break
188 220
 				case ":_Select:"+PartThree$+"|"
189 221
 					eintragnummer=val(PartThree$)
... ...
@@ -199,11 +231,18 @@ textedit add "ausgabe9","//If you click MEDIASOUND STOP  twice, the program brea
199 231
 					//draw text 10,15 ,"TEXTCONTROL WITH / WITHOUT LABEL", "Tab2"
200 232
 				break
201 233
 				case "start|"
202
-					ID=SOUND PLAY "yab_testsong.mp3", 1
234
+					IF (ID=1) THEN
235
+						SOUND STOP ID
236
+						
237
+						ID=SOUND PLAY "Examples/yab_testsong.mp3", 1
238
+					ELSE
239
+						ID=SOUND PLAY "Examples/yab_testsong.mp3", 1
240
+					ENDIF				
203 241
 					
204
-					print "------"	
205
-					print ID
206
-					print "------"					
242
+					
243
+					//print "------"	
244
+					//print ID
245
+					//print "------"					
207 246
 				break
208 247
 				case "stop|"
209 248
 					IF (ID=1) THEN
... ...
@@ -216,12 +255,25 @@ textedit add "ausgabe9","//If you click MEDIASOUND STOP  twice, the program brea
216 255
 								
217 256
 				break 
218 257
 				case "pause|"
219
-					SOUND WAIT ID // 2
258
+					IF (ID=1) THEN
259
+						SOUND WAIT ID // 2
260
+					ELSE
261
+						print "Nothing to do"
262
+					ENDIF				
263
+								
264
+					
220 265
 				break 
221 266
 
222 267
 				case "start_Media|"
223
-					//ID = MEDIASOUND play "02 - Let Her Go.mp3"
224
-					NEW_ID = MEDIASOUND play "https://swr-edge-10b8-fra-dtag-cdn.cast.addradio.de/swr/swr3/live/mp3/128/stream.mp3"
268
+					
269
+					IF (NEW_ID=1) THEN
270
+						MEDIASOUND STOP NEW_ID
271
+						NEW_ID = MEDIASOUND play "Examples/yab_testsong.mp3"
272
+						//print "NEW_ID:"+str$(NEW_ID)
273
+					ELSE
274
+						NEW_ID = MEDIASOUND play "Examples/yab_testsong.mp3"
275
+					ENDIF				
276
+					//NEW_ID = MEDIASOUND play "https://swr-edge-10b8-fra-dtag-cdn.cast.addradio.de/swr/swr3/live/mp3/128/stream.mp3"
225 277
 				break
226 278
 				case "stop_Media|"
227 279
 					IF (NEW_ID=1) THEN
... ...
@@ -63,7 +63,7 @@ URLView::URLView( BRect frame, const char *name, const char *label,
63 63
 	SetURL( url );
64 64
 	
65 65
 	// Create the cursor to use when over the link.
66
-	this->linkCursor = new BCursor( url_cursor );
66
+	this->linkCursor = new BCursor(  B_CURSOR_ID_FOLLOW_LINK); //new BCursor( url_cursor );
67 67
 	
68 68
 	// The link is not currently selected.
69 69
 	selected = false;
... ...
@@ -75,6 +75,7 @@
75 75
 
76 76
 #include <stdio.h>
77 77
 #include <stdlib.h>
78
+#include <unistd.h>
78 79
 
79 80
 #include "YabInterface.h"
80 81
 #include "YabWindow.h"
... ...
@@ -89,7 +90,8 @@
89 90
 #include "column/ColorTools.h"
90 91
 #include "column/ColumnListView.h"
91 92
 
92
-
93
+thread_id reader = -1;
94
+sem_id finished = -1;
93 95
 BMediaTrack* playTrack;
94 96
 media_format playFormat;
95 97
 BSoundPlayer* player = 0;
... ...
@@ -220,7 +222,7 @@ YabInterface::~YabInterface()
220 222
 	// delete fopen;
221 223
 	// delete fsave;
222 224
 	delete viewList;
223
-	// delete Roster;
225
+	//delete Roster;
224 226
 	delete myProps;
225 227
 	delete fPlayer;
226 228
 	if(yabCatalog)
... ...
@@ -303,10 +305,29 @@ void YabInterface::MessageReceived(BMessage *message)
303 305
  */
304 306
 bool YabInterface::QuitRequested()
305 307
 {
308
+	/*printf("%d\n",player);
309
+	if (player == NULL) {
310
+		
311
+	}
312
+	else{
313
+		
314
+		player->Stop();
315
+		player->SetHasData(false);
316
+		delete player;
317
+		delete Roster;
318
+	}*/
319
+	
320
+	if (fPlayer->IsPlaying()) {
321
+		fPlayer->StopPlaying();
322
+	}
323
+		kill_thread(reader);
324
+		delete fPlayer;
325
+		fPlayer = NULL;
306 326
 	//exiting = true;
307 327
 	//return false;
308 328
 	exiting = true;
309 329
 	ExitRequested();
330
+	
310 331
 	snooze(20000);
311 332
 	return true;
312 333
 }
... ...
@@ -9000,18 +9021,23 @@ void YabInterface::Canvas(BRect frame, const char* id, const char* view)
9000 9021
 }
9001 9022
 int YabInterface::Sound(const char* filename, int status) //Reactivate Sound Lorglas 2020.01.02
9002 9023
 {
9003
-	
9004
-	//printf("%s - %d",filename, status);
9024
+	BMediaFile* fplayer;
9025
+		BEntry entry(filename,true);
9005 9026
 	entry_ref ref; 
9006
-	BEntry entry(filename, true); 
9027
+	//entry.GetRef(&ref) ;
9028
+  //  printf("> %s\n", filename);
9007 9029
 	//Check, if filename is ok
9008 9030
 	if (entry.InitCheck() == B_OK) 
9009
-		if (entry.GetRef(&ref) == B_OK) 
9031
+		if (entry.GetRef(&ref) == B_OK) 		
9010 9032
 		//delete playing fplayer, because we get no ID back from fplayer. So if we didn't deleting fplayer, a second sound will be played and the first one can't be stopped
9011 9033
 			delete fPlayer;
9012
-	
9013
-	  		fPlayer = new BFileGameSound(&ref, status);			
9034
+		
9035
+			 finished = create_sem(255255255, "yab");
9036
+	  		fPlayer = new BFileGameSound(filename, status);	
9037
+	  			
9014 9038
 			fPlayer->StartPlaying();	
9039
+			printf("%s is playing\n", filename);
9040
+			acquire_sem(finished);
9015 9041
 			return 1;
9016 9042
 }
9017 9043
 
... ...
@@ -9023,6 +9049,8 @@ void YabInterface::SoundStop(int32) //Reactivate Sound Lorglas 2020.01.02
9023 9049
 	//Check, if fplayer is Playing, then stop playing and delete fplayer
9024 9050
 	if (fPlayer->IsPlaying()) {
9025 9051
 		fPlayer->StopPlaying();
9052
+		//	interrupt = true;
9053
+		kill_thread(reader);
9026 9054
 		delete fPlayer;
9027 9055
 		fPlayer = NULL;
9028 9056
 	}		
... ...
@@ -9048,7 +9076,7 @@ void play_buffer(void *cookie, void * buffer, size_t size, const media_raw_audio
9048 9076
 
9049 9077
 	if (frames <=0) {
9050 9078
 		player->SetHasData(false);
9051
-		
9079
+			release_sem(finished);
9052 9080
 	}
9053 9081
 }
9054 9082
 int YabInterface::MediaSound(const char* filename) //Implementation MediaSound Lorglas 2020.01.02 code used and modified from media_client
... ...
@@ -9057,28 +9085,21 @@ int YabInterface::MediaSound(const char* filename) //Implementation MediaSound L
9057 9085
 	entry_ref ref;
9058 9086
 	BMediaFile* playFile;
9059 9087
 	int finished;
9060
-	if (get_ref_for_path(filename, &ref) != B_OK)
9061
-	{
9088
+	BString tempstr;
9089
+	if (get_ref_for_path(filename, &ref) != B_OK) {
9062 9090
 		url.SetUrlString(filename);
9063
-		if (url.IsValid())
9064
-		{
9091
+		if (url.IsValid()) {
9065 9092
 			playFile = new BMediaFile(url);
9066
-		} 
9067
-		else
9068
-		{
9093
+		} else
9069 9094
 			return 2;
9070
-		}
9071
-	} 
9072
-	else
9073
-	{
9074
-		playFile = new BMediaFile(&ref);
9075
-	}
9076
-	if (playFile->InitCheck() != B_OK) 
9077
-	{
9095
+	} else
9096
+		playFile = new BMediaFile(&ref);	
9097
+		
9098
+	if (playFile->InitCheck() != B_OK) {
9078 9099
 		delete playFile;
9079 9100
 		return 2;
9080 9101
 	}
9081
-
9102
+	//printf(" %s is playing %sd \n",filename,playFile);
9082 9103
 	for (int i = 0; i < playFile->CountTracks(); i++) 
9083 9104
 	{
9084 9105
 		BMediaTrack* track = playFile->TrackAt(i);
... ...
@@ -9092,31 +9113,25 @@ int YabInterface::MediaSound(const char* filename) //Implementation MediaSound L
9092 9113
 			}
9093 9114
 			playFile->ReleaseTrack(track);
9094 9115
 		}
9095
-	}
9096
-	
9097
-	player = new BSoundPlayer(&playFormat.u.raw_audio, "playFile", play_buffer);
9098
-	player->SetVolume(1.0f);
9099
-	player->SetHasData(true);
9100
-	player->Start();	
9101
-	finished=1;
9102
-	printf(" %s is playing \n",filename);
9103
-	return finished;
9116
+	}			
9117
+		player = new BSoundPlayer(&playFormat.u.raw_audio, "Yab-Mediaoutput", play_buffer);
9118
+		//player->SetVolume(1.0f);
9119
+		player->SetHasData(true);
9120
+		player->Start();	
9121
+		finished=1;
9122
+		printf(" %s is playing \n",filename);
9123
+		return finished;
9104 9124
 	
9105 9125
 }
9106 9126
 void YabInterface::MediaSoundStop(int32 finished) //New Version Sound Lorglas 2020.01.02
9107 9127
 {
9108
-	//Check, if fplayer is NULL, then do nothing
9109
-	//if (player == NULL) {
9110
-	//}
9111
-	//Check, if fplayer is Playing, then stop playing and delete fplayer
9112
-	
9128
+	//Check, if player is NULL, then do nothing
9129
+	if (player == NULL) {
9130
+	}
9131
+	//Check, if player is Playing, then stop playing and delete player
9113 9132
 		player->Stop();
9114 9133
 		delete player;
9115
-		//delete_sem(finished);
9116
-		//delete playFile;
9117
-		//player = NULL;
9118
-		
9119
-		
9134
+		//finished=0;
9120 9135
 }
9121 9136
 void YabInterface::SetOption(const char* id, const char* option, double x, double y)
9122 9137
 {
9123 9138
old mode 100755
9124 9139
new mode 100644
... ...
@@ -4,9 +4,17 @@ Bug fixes
4 4
 - Bug fixes in YabInterfaces (some return Statement added (bbjimmy/lorglas)
5 5
 Reactivating Feature
6 6
 - Columnbox sorting activated
7
+<<<<<<< HEAD
7 8
 enhancement
8 9
 - Sound command loop activted
10
+=======
11
+Enhancement 
12
+- Sound command loop activted, Example: sound play "file.mp3", loop
13
+>>>>>>> hotfix_1_7_9
9 14
 - texturl allow to use https
15
+- Change Cursor to Haiku Style
16
+
17
+See in Examples directory Changes_to_1_7_9.yab
10 18
 
11 19
 yab 1.7.8
12 20