forked from len0rd/rockbox
sansapatcher: move sectorbuf pointer into sansa_t structure.
Similar as the ipod_t structure for ipodpatcher the sansa_t structure holds all relevant information for sansapatcher. Put the global sansa_sectorbuf pointer into it as well. Change-Id: Iad08ef6aafc49609c3d0d556914246f230ee0179
This commit is contained in:
parent
24e37ddf57
commit
9c1ed84d28
9 changed files with 77 additions and 97 deletions
|
|
@ -167,9 +167,8 @@ bool Autodetection::detect()
|
|||
|
||||
// try sansapatcher
|
||||
// initialize sector buffer. Needed.
|
||||
sansa_sectorbuf = NULL;
|
||||
sansa_alloc_buffer(&sansa_sectorbuf, BUFFER_SIZE);
|
||||
struct sansa_t sansa;
|
||||
sansa_alloc_buffer(&sansa, BUFFER_SIZE);
|
||||
n = sansa_scan(&sansa);
|
||||
if(n == 1) {
|
||||
qDebug() << "[Autodetect] Sansa found:" << sansa.targetname << "at" << sansa.diskname;
|
||||
|
|
@ -187,8 +186,8 @@ bool Autodetection::detect()
|
|||
else {
|
||||
qDebug() << "[Autodetect] sansapatcher: no Sansa found." << n;
|
||||
}
|
||||
free(sansa_sectorbuf);
|
||||
sansa_sectorbuf = NULL;
|
||||
free(sansa.sectorbuf);
|
||||
sansa.sectorbuf = NULL;
|
||||
|
||||
if(m_mountpoint.isEmpty() && m_device.isEmpty()
|
||||
&& m_errdev.isEmpty() && m_incompat.isEmpty())
|
||||
|
|
|
|||
|
|
@ -27,22 +27,17 @@ BootloaderInstallSansa::BootloaderInstallSansa(QObject *parent)
|
|||
: BootloaderInstallBase(parent)
|
||||
{
|
||||
(void)parent;
|
||||
// initialize sector buffer. sansa_sectorbuf is instantiated by
|
||||
// sansapatcher.
|
||||
// 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(sansa_sectorbuf == NULL)
|
||||
sansa_alloc_buffer(&sansa_sectorbuf, BUFFER_SIZE);
|
||||
// initialize sector buffer. The sector buffer is part of the sansa_t
|
||||
// structure, so a second instance of this class will have its own buffer.
|
||||
sansa_alloc_buffer(&sansa, BUFFER_SIZE);
|
||||
}
|
||||
|
||||
|
||||
BootloaderInstallSansa::~BootloaderInstallSansa()
|
||||
{
|
||||
if(sansa_sectorbuf) {
|
||||
free(sansa_sectorbuf);
|
||||
sansa_sectorbuf = NULL;
|
||||
if(sansa.sectorbuf) {
|
||||
free(sansa.sectorbuf);
|
||||
sansa.sectorbuf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -51,7 +46,7 @@ BootloaderInstallSansa::~BootloaderInstallSansa()
|
|||
*/
|
||||
bool BootloaderInstallSansa::install(void)
|
||||
{
|
||||
if(sansa_sectorbuf == NULL) {
|
||||
if(sansa.sectorbuf == NULL) {
|
||||
emit logItem(tr("Error: can't allocate buffer memory!"), LOGERROR);
|
||||
return false;
|
||||
emit done(true);
|
||||
|
|
@ -59,8 +54,6 @@ bool BootloaderInstallSansa::install(void)
|
|||
|
||||
emit logItem(tr("Searching for Sansa"), LOGINFO);
|
||||
|
||||
struct sansa_t sansa;
|
||||
|
||||
int n = sansa_scan(&sansa);
|
||||
if(n == -1) {
|
||||
emit logItem(tr("Permission for disc access denied!\n"
|
||||
|
|
@ -95,7 +88,6 @@ bool BootloaderInstallSansa::install(void)
|
|||
*/
|
||||
void BootloaderInstallSansa::installStage2(void)
|
||||
{
|
||||
struct sansa_t sansa;
|
||||
unsigned char* buf = NULL;
|
||||
unsigned int len;
|
||||
|
||||
|
|
@ -174,8 +166,6 @@ void BootloaderInstallSansa::installStage3(bool mounted)
|
|||
*/
|
||||
bool BootloaderInstallSansa::uninstall(void)
|
||||
{
|
||||
struct sansa_t sansa;
|
||||
|
||||
emit logItem(tr("Uninstalling bootloader"), LOGINFO);
|
||||
QCoreApplication::processEvents();
|
||||
|
||||
|
|
@ -222,7 +212,6 @@ bool BootloaderInstallSansa::uninstall(void)
|
|||
*/
|
||||
BootloaderInstallBase::BootloaderType BootloaderInstallSansa::installed(void)
|
||||
{
|
||||
struct sansa_t sansa;
|
||||
int num;
|
||||
|
||||
if(!sansaInitialize(&sansa)) {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <QtCore>
|
||||
#include "bootloaderinstallbase.h"
|
||||
#include "sansapatcher.h"
|
||||
|
||||
|
||||
// bootloader installation class for devices handled by sansapatcher.
|
||||
|
|
@ -38,6 +39,7 @@ class BootloaderInstallSansa : public BootloaderInstallBase
|
|||
|
||||
private:
|
||||
bool sansaInitialize(struct sansa_t *);
|
||||
struct sansa_t sansa;
|
||||
|
||||
private slots:
|
||||
void installStage2(void);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue