1 /* 2 * Copyright 2010, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include "IOScheduler.h" 8 9 #include <stdlib.h> 10 #include <string.h> 11 12 #include "IOSchedulerRoster.h" 13 14 15 IOScheduler::IOScheduler(DMAResource* resource) 16 : 17 fDMAResource(resource), 18 fName(NULL), 19 fID(IOSchedulerRoster::Default()->NextID()), 20 fIOCallback(NULL), 21 fIOCallbackData(NULL), 22 fSchedulerRegistered(false) 23 { 24 } 25 26 27 IOScheduler::~IOScheduler() 28 { 29 if (fSchedulerRegistered) 30 IOSchedulerRoster::Default()->RemoveScheduler(this); 31 32 free(fName); 33 } 34 35 36 status_t 37 IOScheduler::Init(const char* name) 38 { 39 fName = strdup(name); 40 if (fName == NULL) 41 return B_NO_MEMORY; 42 43 IOSchedulerRoster::Default()->AddScheduler(this); 44 fSchedulerRegistered = true; 45 46 return B_OK; 47 } 48 49 50 void 51 IOScheduler::SetCallback(IOCallback& callback) 52 { 53 SetCallback(&IOCallback::WrapperFunction, &callback); 54 } 55 56 57 void 58 IOScheduler::SetCallback(io_callback callback, void* data) 59 { 60 fIOCallback = callback; 61 fIOCallbackData = data; 62 } 63 64 65 void 66 IOScheduler::SetDeviceCapacity(off_t deviceCapacity) 67 { 68 } 69 70 71 void 72 IOScheduler::MediaChanged() 73 { 74 } 75