Esempio n. 1
0
static void start_tracking_thread(void)
{
	if (s_tracking_enabled)
		return;
	
	s_tracking_enabled = true;
	sys_start_thread(&s_tracking_thread, device_tracking_thread);
}
Esempio n. 2
0
/**
 * start_channel:  Allocate a new channel and starts playback.
 *
 * [Parameters]
 *     buffer_desc: Playback buffer descriptor
 * [Return value]
 *     Nonzero on success, zero on error
 */
static int start_channel(PSPSoundBufferDesc *buffer_desc)
{
    if (!buffer_desc) {
        DMSG("buffer_desc == NULL");
        return 0;
    }
    if (buffer_desc->started) {
        DMSG("Buffer is already started!");
        return 0;
    }

    /* Allocate a hardware channel */
    buffer_desc->channel = sceAudioChReserve(
        PSP_AUDIO_NEXT_CHANNEL, BUFFER_SIZE, PSP_AUDIO_FORMAT_STEREO
    );
    if (buffer_desc->channel < 0) {
        DMSG("Failed to allocate channel: %s",
             psp_strerror(buffer_desc->channel));
        return 0;
    }

    /* Initialize the ring buffer */
    buffer_desc->cur_play = NUM_BUFFERS - 1;
    buffer_desc->next_play = 0;
    buffer_desc->next_write = 0;
    int i;
    for (i = 0; i < NUM_BUFFERS; i++) {
        buffer_desc->write_ready[i] = 1;
    }
    buffer_desc->stop = 0;
    /* Also write everything out of the cache so it's ready for the ME */
    sceKernelDcacheWritebackAll();

    /* Start the playback thread */
    char thname[100];
    snprintf(thname, sizeof(thname), "YabauseSoundCh%d", buffer_desc->channel);
    SceUID handle = sys_start_thread(thname, playback_thread,
                                     THREADPRI_SOUND, 0x1000,
                                     sizeof(buffer_desc), &buffer_desc);
    if (handle < 0) {
        DMSG("Failed to create thread: %s", psp_strerror(handle));
        sceAudioChRelease(buffer_desc->channel);
        return 0;
    }
    buffer_desc->thread = handle;

    /* Success */
    buffer_desc->started = 1;
    return 1;
}
Esempio n. 3
0
/**
 * display_end_frame:  End processing for the current frame, then swap the
 * displayed buffer and work buffer.  The current frame will not actually
 * be shown until the next vertical blank.
 *
 * [Parameters]
 *     None
 * [Return value]
 *     None
 */
void display_end_frame(void)
{
    guFinish();
    swap_pending = 1;
    /* Give the new thread a slightly higher priority than us, or else it
     * won't actually get a chance to run. */
    if (sys_start_thread("YabauseBufferSwapThread", buffer_swap_thread,
                         sceKernelGetThreadCurrentPriority() - 1,
                         0x1000, 0, NULL) < 0) {
        DMSG("Failed to start buffer swap thread");
        swap_pending = 0;
        do_buffer_swap();  // Do it ourselves
    }
}