From 392f3853b15c94dc0f7fd149777312b033feeea3 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Sat, 29 Jun 2002 23:01:10 +0000 Subject: Added USB insertion handling git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1259 a1c6a512-1295-4272-9138-f99709370657 --- firmware/mpeg.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'firmware/mpeg.c') diff --git a/firmware/mpeg.c b/firmware/mpeg.c index fb53585aef..815de997d5 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c @@ -25,6 +25,7 @@ #include "debug.h" #include "kernel.h" #include "thread.h" +#include "usb.h" #include "panic.h" #include "file.h" #include "mpeg.h" @@ -471,6 +472,17 @@ struct mp3entry* mpeg_current_track(void) return &(id3tags[0].id3); } +static void stop_playing(void) +{ + /* Stop the current stream */ + playing = false; + filling = false; + if(mpeg_file >= 0) + close(mpeg_file); + mpeg_file = -1; + stop_dma(); +} + static void mpeg_thread(void) { struct event ev; @@ -526,13 +538,7 @@ static void mpeg_thread(void) case MPEG_STOP: DEBUGF("MPEG_STOP\n"); - /* Stop the current stream */ - playing = false; - filling = false; - if(mpeg_file >= 0) - close(mpeg_file); - mpeg_file = -1; - stop_dma(); + stop_playing(); break; case MPEG_PAUSE: @@ -683,6 +689,18 @@ static void mpeg_thread(void) yield(); /* To be safe */ } break; + + case SYS_USB_CONNECTED: + stop_playing(); + + /* Tell the USB thread that we are safe */ + DEBUGF("mpeg_thread got SYS_USB_CONNECTED\n"); + usb_acknowledge(SYS_USB_CONNECTED_ACK); + + /* Wait until the system reboots */ + while(1) + yield(); + break; } } } -- cgit v1.2.3