forked from len0rd/rockbox
ipodpatcher: move sectorbuf pointer into ipod_t structure.
The ipod_t structure holds all relevant information for ipodpatcher. Put the global ipod_sectorbuf pointer into it as well. Allows the Rockbox Utility Ipod class to be instanciated multiple times since each instance can now have its own buffer. Change-Id: Ie319cbadbc20c367ceadba9a46b4dc34b57a79a7
This commit is contained in:
parent
6803d7b10c
commit
24e37ddf57
9 changed files with 210 additions and 161 deletions
|
|
@ -137,9 +137,9 @@ bool Autodetection::detect()
|
|||
int n;
|
||||
// try ipodpatcher
|
||||
// initialize sector buffer. Needed.
|
||||
ipod_sectorbuf = NULL;
|
||||
ipod_alloc_buffer(&ipod_sectorbuf, BUFFER_SIZE);
|
||||
struct ipod_t ipod;
|
||||
ipod.sectorbuf = NULL;
|
||||
ipod_alloc_buffer(&ipod, BUFFER_SIZE);
|
||||
n = ipod_scan(&ipod);
|
||||
if(n == 1) {
|
||||
qDebug() << "[Autodetect] Ipod found:" << ipod.modelstr << "at" << ipod.diskname;
|
||||
|
|
@ -162,8 +162,8 @@ bool Autodetection::detect()
|
|||
else {
|
||||
qDebug() << "[Autodetect] ipodpatcher: no Ipod found." << n;
|
||||
}
|
||||
free(ipod_sectorbuf);
|
||||
ipod_sectorbuf = NULL;
|
||||
free(ipod.sectorbuf);
|
||||
ipod.sectorbuf = NULL;
|
||||
|
||||
// try sansapatcher
|
||||
// initialize sector buffer. Needed.
|
||||
|
|
|
|||
|
|
@ -28,33 +28,32 @@ BootloaderInstallIpod::BootloaderInstallIpod(QObject *parent)
|
|||
: BootloaderInstallBase(parent)
|
||||
{
|
||||
(void)parent;
|
||||
// initialize sector buffer. ipod_sectorbuf is defined in ipodpatcher.
|
||||
// The buffer itself is only present once, so make sure to not allocate
|
||||
// it if it was already allocated. The application needs to take care
|
||||
// no concurrent (i.e. multiple objects of this class running) requests
|
||||
// are done.
|
||||
if(ipod_sectorbuf == NULL)
|
||||
ipod_alloc_buffer(&ipod_sectorbuf, BUFFER_SIZE);
|
||||
// initialize sector buffer. The sector buffer is part of the ipod_t
|
||||
// structure, so a second instance of this class will have its own buffer.
|
||||
ipod_alloc_buffer(&ipod, BUFFER_SIZE);
|
||||
}
|
||||
|
||||
|
||||
BootloaderInstallIpod::~BootloaderInstallIpod()
|
||||
{
|
||||
if(ipod_sectorbuf) {
|
||||
free(ipod_sectorbuf);
|
||||
ipod_sectorbuf = NULL;
|
||||
if(ipod.sectorbuf) {
|
||||
free(ipod.sectorbuf);
|
||||
ipod.sectorbuf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool BootloaderInstallIpod::install(void)
|
||||
{
|
||||
if(ipod_sectorbuf == NULL) {
|
||||
if(ipod.sectorbuf == NULL) {
|
||||
emit logItem(tr("Error: can't allocate buffer memory!"), LOGERROR);
|
||||
emit done(true);
|
||||
return false;
|
||||
}
|
||||
// save buffer pointer before cleaning up ipod_t structure
|
||||
unsigned char* sb = ipod.sectorbuf;
|
||||
memset(&ipod, 0, sizeof(struct ipod_t));
|
||||
ipod.sectorbuf = sb;
|
||||
|
||||
if(!ipodInitialize(&ipod)) {
|
||||
emit done(true);
|
||||
|
|
@ -139,7 +138,6 @@ void BootloaderInstallIpod::installStage3(bool mounted)
|
|||
|
||||
bool BootloaderInstallIpod::uninstall(void)
|
||||
{
|
||||
struct ipod_t ipod;
|
||||
emit logItem(tr("Uninstalling bootloader"), LOGINFO);
|
||||
QCoreApplication::processEvents();
|
||||
|
||||
|
|
@ -190,7 +188,6 @@ bool BootloaderInstallIpod::uninstall(void)
|
|||
|
||||
BootloaderInstallBase::BootloaderType BootloaderInstallIpod::installed(void)
|
||||
{
|
||||
struct ipod_t ipod;
|
||||
BootloaderInstallBase::BootloaderType result = BootloaderRockbox;
|
||||
|
||||
if(!ipodInitialize(&ipod)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue