예제 #1
0
파일: musicmgr.c 프로젝트: azuwis/xreader
int music_resume(void)
{
	struct music_file *fl = music_get(g_list.curr_pos);
	int ret;

	dbg_printf(d, "%s", __func__);

	if (fl == NULL) {
		dbg_printf(d, "%s: Resume failed!", __func__);
		music_unlock();

		return -1;
	}

	ret = musicdrv_resume(fl->shortpath->ptr, fl->longpath->ptr);

	if (ret < 0) {
		dbg_printf(d, "%s %d: Resume failed!", __func__, __LINE__);
		music_unlock();

		return ret;
	}

	g_list.is_list_playing = prev_is_playing;
	music_unlock();

	return 0;
}
예제 #2
0
int music_resume(void)
{
	MusicListEntry *fl = musiclist_get(&g_music_list, g_list.curr_pos);
	int ret;

	dbg_printf(d, "%s", __func__);

	if (fl == NULL) {
		dbg_printf(d, "%s: Resume failed!", __func__);
		music_unlock();

		return -1;
	}

	ret = musicdrv_resume(fl->spath, fl->lpath);

	if (ret < 0) {
		dbg_printf(d, "%s %d: Resume failed!", __func__, __LINE__);
		music_unlock();

		return ret;
	}

	g_list.is_list_playing = prev_is_playing;
	music_unlock();

	return 0;
}
예제 #3
0
파일: musicmgr.c 프로젝트: azuwis/xreader
int music_directplay(const char *spath, const char *lpath)
{
	int pos;
	int ret;

	music_lock();
	music_add(spath, lpath);
	pos = music_find(spath, lpath);

	if (pos < 0) {
		music_unlock();
		return -1;
	}

	g_list.curr_pos = pos;
	ret = music_play(pos);

	if (ret == 0) {
		g_list.is_list_playing = true;
		g_list.first_time = false;
	}

	music_unlock();
	return 0;
}
예제 #4
0
int music_prev(void)
{
	int ret = 0;

	music_lock();

	switch (g_list.cycle_mode) {
		case conf_cycle_single:
			{
				if (g_list.curr_pos == 0)
					g_list.curr_pos = music_maxindex() - 1;
				else
					g_list.curr_pos--;
				break;
			}
		case conf_cycle_repeat:
			{
				if (g_list.curr_pos == 0)
					g_list.curr_pos = music_maxindex() - 1;
				else
					g_list.curr_pos--;
				break;
			}
			break;
		case conf_cycle_repeat_one:
			{
				if (g_list.curr_pos == 0)
					g_list.curr_pos = music_maxindex() - 1;
				else
					g_list.curr_pos--;
				break;
			}
			break;
		case conf_cycle_random:
			{
				if (shuffle_prev() != 0) {
					ret = music_stop();
					g_list.is_list_playing = false;
					music_unlock();
					return ret;
				}

				break;
			}
			break;
	}

	if (!g_list.is_list_playing)
		g_list.is_list_playing = true;

	if (g_list.is_list_playing)
		ret = music_play(g_list.curr_pos);

	music_unlock();

	return ret;
}
예제 #5
0
파일: musicmgr.c 프로젝트: azuwis/xreader
int music_add(const char *spath, const char *lpath)
{
	struct music_file *n;
	struct music_file **tmp;
	int count;

	if (spath == NULL || lpath == NULL)
		return -EINVAL;

	if (!fs_is_music(spath, lpath))
		return -EINVAL;

	tmp = &g_music_files;
	count = 0;

	while (*tmp) {
		if (!strcmp((*tmp)->shortpath->ptr, spath) &&
			!strcmp((*tmp)->longpath->ptr, lpath)) {
			return -EBUSY;
		}
		tmp = &(*tmp)->next;
		count++;
	}

	n = new_music_file(spath, lpath);
	if (n != NULL)
		*tmp = n;
	else
		return -ENOMEM;
	music_lock();
	rebuild_shuffle_data();
	music_unlock();
	return count;
}
예제 #6
0
파일: musicmgr.c 프로젝트: azuwis/xreader
int music_free(void)
{
	int ret;
	unsigned to = 500000;

	cache_on(false);

	music_lock();

	ret = -1;

	while (ret != 0) {
		ret = music_stop();
		if (ret != 0)
			xrKernelDelayThread(100000);
	}

	g_list.is_list_playing = 0;
	g_thread_actived = 0;
	music_unlock();
	free_shuffle_data();

	if (xrKernelWaitThreadEnd(g_music_thread, &to) != 0) {
		xrKernelTerminateDeleteThread(g_music_thread);
	} else {
		xrKernelDeleteThread(g_music_thread);
	}

	xr_lock_destroy(&music_l);

	return 0;
}
예제 #7
0
파일: musicmgr.c 프로젝트: azuwis/xreader
int music_movedown(int i)
{
	struct music_file **tmp;
	struct music_file *a, *b, *c;
	int n;

	if (i < 0 || i >= music_maxindex() - 1)
		return -EINVAL;

	tmp = &g_music_files;
	n = i;

	while (*tmp && n > 0) {
		n--;
		tmp = &(*tmp)->next;
	}

	b = (*tmp);
	a = b->next;
	c = a->next;
	a->next = b;
	b->next = c;
	*tmp = a;
	music_lock();
	rebuild_shuffle_data();
	music_unlock();
	return i + 1;
}
예제 #8
0
파일: musicmgr.c 프로젝트: azuwis/xreader
int music_del(int i)
{
	int n;
	struct music_file **tmp;
	struct music_file *p;

	tmp = &g_music_files;
	n = i;
	while (*tmp && n > 0) {
		n--;
		tmp = &(*tmp)->next;
	}

	p = (*tmp);
	*tmp = p->next;
	free_music_file(p);
	music_lock();
	rebuild_shuffle_data();
	n = music_maxindex();

	if (n == 0) {
		music_list_refresh();
	}

	music_unlock();
	return n;
}
예제 #9
0
파일: musicmgr.c 프로젝트: azuwis/xreader
int music_moveup(int i)
{
	struct music_file **tmp;
	struct music_file *a, *b, *c;
	int n;

	if (i < 1 || i >= music_maxindex())
		return -EINVAL;

	tmp = &g_music_files;
	n = i - 1;

	while (*tmp && n > 0) {
		n--;
		tmp = &(*tmp)->next;
	}

	a = *tmp;
	b = a->next;
	c = b->next;
	b->next = a;
	a->next = c;
	*tmp = b;
	music_lock();
	rebuild_shuffle_data();
	music_unlock();
	return i - 1;
}
예제 #10
0
파일: musicmgr.c 프로젝트: azuwis/xreader
static int music_list_refresh(void)
{
	music_lock();
	g_list.curr_pos = 0;

	if (music_maxindex() > 0) {
		if (g_list.is_list_playing) {
			if (music_play(g_list.curr_pos) < 0) {
				g_list.is_list_playing = false;
			}
		} else {
			// only load information
			if (music_load(g_list.curr_pos) >= 0) {
				musicdrv_end();
			}
		}
	} else {
		musicdrv_end();
		set_musicdrv(NULL);
	}

	g_list.first_time = true;
	g_shuffle.first_time = true;
	music_unlock();

	return 0;
}
예제 #11
0
int music_movedown(int i)
{
	music_lock();
	musiclist_movedown(&g_music_list, i);
	music_unlock();

	return 0;
}
예제 #12
0
int music_list_clear(void)
{
	music_lock();
	musiclist_clear(&g_music_list);
	music_unlock();

	return 0;
}
예제 #13
0
int music_del(int i)
{
	music_lock();
	musiclist_remove(&g_music_list, musiclist_get(&g_music_list, i));
	music_unlock();

	return 0;
}
예제 #14
0
int music_list_stop(void)
{
	int ret;

	music_lock();
	ret = music_stop();

	if (ret < 0) {
		music_unlock();
		return ret;
	}

	g_list.is_list_playing = false;
	g_list.first_time = true;
	music_unlock();
	return ret;
}
예제 #15
0
파일: musicmgr.c 프로젝트: azuwis/xreader
int music_set_cycle_mode(int mode)
{
	music_lock();
	if (mode >= 0 && mode <= conf_cycle_random)
		g_list.cycle_mode = mode;

	music_unlock();
	return g_list.cycle_mode;
}
예제 #16
0
파일: musicmgr.c 프로젝트: azuwis/xreader
int music_list_play(void)
{
	music_lock();

	if (!g_list.is_list_playing)
		g_list.is_list_playing = true;

	music_unlock();
	return 0;
}
예제 #17
0
파일: musicmgr.c 프로젝트: azuwis/xreader
int music_list_playorpause(void)
{
	music_lock();
	if (!g_list.is_list_playing)
		g_list.is_list_playing = true;
	else {
		int ret = musicdrv_get_status();

		if (ret < 0) {
			music_unlock();
			return ret;
		}
		if (ret == ST_PLAYING)
			musicdrv_pause();
		else if (ret == ST_PAUSED)
			musicdrv_play();
	}
	music_unlock();

	return 0;
}
예제 #18
0
파일: musicmgr.c 프로젝트: azuwis/xreader
int music_next(void)
{
	int ret;

	music_lock();

	switch (g_list.cycle_mode) {
		case conf_cycle_single:
			{
				if (g_list.curr_pos == music_maxindex() - 1)
					g_list.curr_pos = 0;
				else
					g_list.curr_pos++;
				break;
			}
		case conf_cycle_repeat:
			{
				if (g_list.curr_pos == music_maxindex() - 1)
					g_list.curr_pos = 0;
				else
					g_list.curr_pos++;
				break;
			}
		case conf_cycle_repeat_one:
			{
				if (g_list.curr_pos == music_maxindex() - 1)
					g_list.curr_pos = 0;
				else
					g_list.curr_pos++;
				break;
			}
		case conf_cycle_random:
			{
				shuffle_next();
				break;
			}
	}

	if (!g_list.is_list_playing)
		g_list.is_list_playing = true;

	ret = music_play(g_list.curr_pos);

	music_unlock();
	return ret;
}
예제 #19
0
int music_set_cycle_mode(int mode)
{
	int prev;

	music_lock();
	prev = g_list.cycle_mode;

	if (mode >= 0 && mode <= conf_cycle_random)
		g_list.cycle_mode = mode;

	if (prev != g_list.cycle_mode && (g_list.cycle_mode == conf_cycle_random || prev == conf_cycle_random)) {
		stack_clear(&g_played);
	}

	music_unlock();
	return g_list.cycle_mode;
}
예제 #20
0
파일: musicmgr.c 프로젝트: azuwis/xreader
int music_list_clear(void)
{
	struct music_file *l, *t;

	music_lock();

	for (l = g_music_files; l != NULL; l = t) {
		buffer_free(l->shortpath);
		buffer_free(l->longpath);
		t = l->next;
		free(l);
	}

	g_music_files = NULL;

	music_unlock();

	return 0;
}
예제 #21
0
파일: musicmgr.c 프로젝트: azuwis/xreader
int music_suspend(void)
{
	int ret;

	dbg_printf(d, "%s", __func__);

	music_lock();
	ret = musicdrv_suspend();

	if (ret < 0) {
		dbg_printf(d, "%s: Suspend failed!", __func__);
		musicdrv_end();
		music_unlock();
		return ret;
	}

	prev_is_playing = g_list.is_list_playing;
	g_list.is_list_playing = 0;

	// now music module is locked
	return 0;
}
예제 #22
0
파일: musicmgr.c 프로젝트: azuwis/xreader
static int music_thread(SceSize arg, void *argp)
{
	dword key = 0;
	dword oldkey = 0;
	u64 start, end;
	double interval = 0;

	g_thread_actived = 1;
	g_thread_exited = 0;

	xrRtcGetCurrentTick(&start);
	xrRtcGetCurrentTick(&end);

	while (g_thread_actived) {
		music_lock();
		if (g_list.is_list_playing) {
			if (musicdrv_has_stop()) {
				if (g_list.first_time) {
					int ret;

					ret = music_play(g_list.curr_pos);
					if (ret == 0)
						g_list.first_time = false;
				} else {
					get_next_music();

					if (!g_list.is_list_playing) {
						music_unlock();
						music_load(g_list.curr_pos);
						music_stop();
						continue;
					}

					music_play(g_list.curr_pos);
				}
			}

			music_unlock();
			xrKernelDelayThread(100000);
		} else {
			music_unlock();
			xrKernelDelayThread(500000);
		}

		if (g_music_hprm_enable) {
			key = ctrl_hprm_raw();
			xrRtcGetCurrentTick(&end);
			interval = pspDiffTime(&end, &start);

			if (key == PSP_HPRM_FORWARD || key == PSP_HPRM_BACK
				|| key == PSP_HPRM_PLAYPAUSE) {
				if (key != oldkey) {
					xrRtcGetCurrentTick(&start);
					xrRtcGetCurrentTick(&end);
					interval = pspDiffTime(&end, &start);
				}

				if (interval >= 0.5) {
					if (key == PSP_HPRM_FORWARD) {
						musicdrv_fforward(5);
						xrKernelDelayThread(200000);
					} else if (key == PSP_HPRM_BACK) {
						musicdrv_fbackward(5);
						xrKernelDelayThread(200000);
					}
				}

				oldkey = key;

				if (key == PSP_HPRM_PLAYPAUSE && interval >= 4.0) {
					power_down();
					xrPowerRequestSuspend();
				}
			} else {
				if ((oldkey == PSP_HPRM_FORWARD || oldkey == PSP_HPRM_BACK
					 || oldkey == PSP_HPRM_PLAYPAUSE)) {
					if (interval < 0.5) {
						if (oldkey == PSP_HPRM_FORWARD)
							music_next();
						else if (oldkey == PSP_HPRM_BACK)
							music_prev();
					}

					if (interval < 4.0) {
						if (oldkey == PSP_HPRM_PLAYPAUSE)
							music_list_playorpause();
					}
				}
				oldkey = key;
				xrRtcGetCurrentTick(&start);
			}
		}

		{
			int thid = xrKernelGetThreadId();
			int oldpri = xrKernelGetThreadCurrentPriority();

			xrKernelChangeThreadPriority(thid, 90);
			cache_routine();
			xrKernelChangeThreadPriority(thid, oldpri);
		}
	}

	g_thread_actived = 0;
	g_thread_exited = 1;

	return 0;
}