Skip to content

Commit 8831927

Browse files
authored
Merge pull request #952 from glampert/audsrv-thpri
feat(audsrv): add a 'thpri=N' argument for the RPC thread priority.
2 parents f1ca58a + b452878 commit 8831927

4 files changed

Lines changed: 34 additions & 6 deletions

File tree

‎iop/sound/audsrv/src/audsrv.c‎

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -549,16 +549,42 @@ int audsrv_quit()
549549
}
550550

551551
/** IRX _start function
552+
* @param argc number of module arguments
553+
* @param argv module arguments
552554
* @returns zero on success
553555
*
554556
* Initializes interrupts and the RPC thread. Oh, and greets the user.
557+
*
558+
* Arguments:
559+
* thpri=N priority of the RPC server thread, 9 to 123 (default 40).
560+
* At the default it shares fileXio's priority, so an RPC that
561+
* arrives while a file read is in progress waits for the whole
562+
* read to finish. A value below 40 lets audsrv_available and
563+
* audsrv_play_audio preempt the read.
555564
*/
556565
int _start(int argc, char *argv[])
557566
{
558567
int err;
568+
int i;
569+
int rpc_thpri = 40;
559570

560-
(void)argc;
561-
(void)argv;
571+
for (i = 1; i < argc; i++)
572+
{
573+
if (strncmp(argv[i], "thpri=", 6) == 0)
574+
{
575+
char *end;
576+
long prio = strtol(argv[i] + 6, &end, 10);
577+
578+
if (end != argv[i] + 6 && *end == '\0' && prio >= 9 && prio <= 123)
579+
{
580+
rpc_thpri = prio;
581+
}
582+
else
583+
{
584+
printf("audsrv: ignoring invalid argument '%s'\n", argv[i]);
585+
}
586+
}
587+
}
562588

563589
FlushDcache();
564590
CpuEnableIntr();
@@ -575,7 +601,7 @@ int _start(int argc, char *argv[])
575601
audsrv_adpcm_init();
576602

577603
/* create RPC listener thread */
578-
initialize_rpc_thread();
604+
initialize_rpc_thread(rpc_thpri);
579605

580606
return MODULE_RESIDENT_END;
581607
}

‎iop/sound/audsrv/src/imports.lst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ I_memset
2929
I_memcpy
3030
I_strcpy
3131
I_strlen
32+
I_strncmp
33+
I_strtol
3234
sysclib_IMPORTS_end
3335

3436
sifcmd_IMPORTS_start

‎iop/sound/audsrv/src/rpc_server.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ static void rpc_server_thread(void *arg)
192192
sceSifRpcLoop(&qd);
193193
}
194194

195-
int initialize_rpc_thread()
195+
int initialize_rpc_thread(int priority)
196196
{
197-
int rpc_tid = create_thread(rpc_server_thread, 40, 0);
197+
int rpc_tid = create_thread(rpc_server_thread, priority, 0);
198198
DPRINTF("rpc server thread 0x%x started\n", rpc_tid);
199199
return (rpc_tid > 0);
200200
}

‎iop/sound/audsrv/src/rpc_server.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
#ifndef __RPC_SERVER_H__
1616
#define __RPC_SERVER_H__
1717

18-
extern int initialize_rpc_thread();
18+
extern int initialize_rpc_thread(int priority);
1919

2020
#endif

0 commit comments

Comments
 (0)