This commit is contained in:
plutoo 2014-11-26 01:33:03 +01:00
commit 49ab752427
6 changed files with 61 additions and 44 deletions

View File

@ -3,3 +3,5 @@ mic
Example for using the microphone with ctrulib. Hold down the A button to record, the app will then play the recorded audio once the A button is released. Roughly 32 seconds of audio can be recorded with the default audiobuf size in this app.
Do not use this example(and/or ctrulib MIC?), since MIC is broken currently.

View File

@ -11,13 +11,14 @@ int main()
u8 *audiobuf;
u32 audiobuf_size = 0x100000, audiobuf_pos = 0;
u8 control=0x40;
u32 audio_initialized = 0;
srvInit();
aptInit();
gfxInit();
hidInit(NULL);
CSND_initialize(NULL);
if(CSND_initialize(NULL)==0)audio_initialized = 1;
sharedmem = (u32*)memalign(0x1000, sharedmem_size);
audiobuf = linearAlloc(audiobuf_size);
@ -26,10 +27,18 @@ int main()
while(aptMainLoop())
{
framebuf = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
hidScanInput();
gspWaitForVBlank();
if(hidKeysDown() & KEY_A)
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu
if(audio_initialized)
{
framebuf = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
if(kDown & KEY_A)
{
audiobuf_pos = 0;
@ -63,15 +72,18 @@ int main()
framebuf = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
memset(framebuf, 0xe0, 0x46500);
}
}
gfxFlushBuffers();
gfxSwapBuffers();
gspWaitForVBlank();
}
MIC_Shutdown();
CSND_shutdown();
if(audio_initialized)CSND_shutdown();
free(sharedmem);
linearFree(audiobuf);
hidExit();
gfxExit();

View File

@ -7,12 +7,12 @@ Result httpcInit()
Result ret=0;
if(__httpc_servhandle)return 0;
if((ret=srvGetServiceHandle(&__httpc_servhandle, "http:C")))*((u32*)0x500) = ret;//return ret;
if((ret=srvGetServiceHandle(&__httpc_servhandle, "http:C")))return ret;
//*((u32*)0x600) = __httpc_servhandle;
ret = HTTPC_Initialize(__httpc_servhandle);
if(ret!=0)*((u32*)0x400) = ret;//return ret;
if(ret!=0)return ret;
return 0;
}
@ -29,18 +29,18 @@ Result httpcOpenContext(httpcContext *context, char* url, u32 use_defaultproxy)
Result ret=0;
ret = HTTPC_CreateContext(__httpc_servhandle, url, &context->httphandle);
if(ret!=0)*((u32*)0x100) = ret;//return ret;
if(ret!=0)return ret;
ret = srvGetServiceHandle(&context->servhandle, "http:C");
if(ret!=0)*((u32*)0x104) = ret;//return ret;
if(ret!=0)return ret;
ret = HTTPC_InitializeConnectionSession(context->servhandle, context->httphandle);
if(ret!=0)*((u32*)0x108) = ret;//return ret;
if(ret!=0)return ret;
if(use_defaultproxy==0)return 0;
ret = HTTPC_SetProxyDefault(context->servhandle, context->httphandle);
if(ret!=0)*((u32*)0x10c) = ret;//return ret;
if(ret!=0)return ret;
return 0;
}

View File

@ -207,7 +207,7 @@ Result MIC_GetEventHandle(Handle *handle)
if((ret = svcSendSyncRequest(MIC_handle))!=0)return ret;
if(handle)*handle = cmdbuf[2];
if(handle)*handle = cmdbuf[3];
return (Result)cmdbuf[1];
}

View File

@ -24,6 +24,7 @@ int ioctl(int fd, int request, ...)
flags = fcntl(fd, F_GETFL, 0);
if(flags == -1) {
errno = SOC_GetErrno();
va_end(ap);
return -1;
}

View File

@ -187,11 +187,13 @@ svcWaitSynchronization:
.type svcWaitSynchronizationN, %function
svcWaitSynchronizationN:
str r5, [sp, #-4]!
str r4, [sp, #-4]!
mov r5, r0
ldr r0, [sp, #0x4]
ldr r4, [sp, #0x4+0x4]
ldr r0, [sp, #0x8]
ldr r4, [sp, #0x8+0x4]
svc 0x25
str r1, [r5]
ldr r4, [sp], #4
ldr r5, [sp], #4
bx lr