diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2012-12-23 23:36:00 +0100 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2013-01-01 15:06:34 +0100 |
commit | 9c1ed84d28edfa4a2b5b0a327dccd83d1a1beef8 (patch) | |
tree | 1c884e4db52c2d365095c281e63956f909691226 /rbutil/rbutilqt/base | |
parent | 24e37ddf57bac6a1c9786d50abbe3a1982930382 (diff) | |
download | rockbox-9c1ed84d28edfa4a2b5b0a327dccd83d1a1beef8.tar.gz rockbox-9c1ed84d28edfa4a2b5b0a327dccd83d1a1beef8.zip |
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
Diffstat (limited to 'rbutil/rbutilqt/base')
-rw-r--r-- | rbutil/rbutilqt/base/autodetection.cpp | 7 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/bootloaderinstallsansa.cpp | 25 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/bootloaderinstallsansa.h | 2 |
3 files changed, 12 insertions, 22 deletions
diff --git a/rbutil/rbutilqt/base/autodetection.cpp b/rbutil/rbutilqt/base/autodetection.cpp index 8fba1d8cea..a453fa8d60 100644 --- a/rbutil/rbutilqt/base/autodetection.cpp +++ b/rbutil/rbutilqt/base/autodetection.cpp | |||
@@ -167,9 +167,8 @@ bool Autodetection::detect() | |||
167 | 167 | ||
168 | // try sansapatcher | 168 | // try sansapatcher |
169 | // initialize sector buffer. Needed. | 169 | // initialize sector buffer. Needed. |
170 | sansa_sectorbuf = NULL; | ||
171 | sansa_alloc_buffer(&sansa_sectorbuf, BUFFER_SIZE); | ||
172 | struct sansa_t sansa; | 170 | struct sansa_t sansa; |
171 | sansa_alloc_buffer(&sansa, BUFFER_SIZE); | ||
173 | n = sansa_scan(&sansa); | 172 | n = sansa_scan(&sansa); |
174 | if(n == 1) { | 173 | if(n == 1) { |
175 | qDebug() << "[Autodetect] Sansa found:" << sansa.targetname << "at" << sansa.diskname; | 174 | qDebug() << "[Autodetect] Sansa found:" << sansa.targetname << "at" << sansa.diskname; |
@@ -187,8 +186,8 @@ bool Autodetection::detect() | |||
187 | else { | 186 | else { |
188 | qDebug() << "[Autodetect] sansapatcher: no Sansa found." << n; | 187 | qDebug() << "[Autodetect] sansapatcher: no Sansa found." << n; |
189 | } | 188 | } |
190 | free(sansa_sectorbuf); | 189 | free(sansa.sectorbuf); |
191 | sansa_sectorbuf = NULL; | 190 | sansa.sectorbuf = NULL; |
192 | 191 | ||
193 | if(m_mountpoint.isEmpty() && m_device.isEmpty() | 192 | if(m_mountpoint.isEmpty() && m_device.isEmpty() |
194 | && m_errdev.isEmpty() && m_incompat.isEmpty()) | 193 | && m_errdev.isEmpty() && m_incompat.isEmpty()) |
diff --git a/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp b/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp index b05839e297..061ec2578f 100644 --- a/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp +++ b/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp | |||
@@ -27,22 +27,17 @@ BootloaderInstallSansa::BootloaderInstallSansa(QObject *parent) | |||
27 | : BootloaderInstallBase(parent) | 27 | : BootloaderInstallBase(parent) |
28 | { | 28 | { |
29 | (void)parent; | 29 | (void)parent; |
30 | // initialize sector buffer. sansa_sectorbuf is instantiated by | 30 | // initialize sector buffer. The sector buffer is part of the sansa_t |
31 | // sansapatcher. | 31 | // structure, so a second instance of this class will have its own buffer. |
32 | // The buffer itself is only present once, so make sure to not allocate | 32 | sansa_alloc_buffer(&sansa, BUFFER_SIZE); |
33 | // it if it was already allocated. The application needs to take care | ||
34 | // no concurrent (i.e. multiple objects of this class running) requests | ||
35 | // are done. | ||
36 | if(sansa_sectorbuf == NULL) | ||
37 | sansa_alloc_buffer(&sansa_sectorbuf, BUFFER_SIZE); | ||
38 | } | 33 | } |
39 | 34 | ||
40 | 35 | ||
41 | BootloaderInstallSansa::~BootloaderInstallSansa() | 36 | BootloaderInstallSansa::~BootloaderInstallSansa() |
42 | { | 37 | { |
43 | if(sansa_sectorbuf) { | 38 | if(sansa.sectorbuf) { |
44 | free(sansa_sectorbuf); | 39 | free(sansa.sectorbuf); |
45 | sansa_sectorbuf = NULL; | 40 | sansa.sectorbuf = NULL; |
46 | } | 41 | } |
47 | } | 42 | } |
48 | 43 | ||
@@ -51,7 +46,7 @@ BootloaderInstallSansa::~BootloaderInstallSansa() | |||
51 | */ | 46 | */ |
52 | bool BootloaderInstallSansa::install(void) | 47 | bool BootloaderInstallSansa::install(void) |
53 | { | 48 | { |
54 | if(sansa_sectorbuf == NULL) { | 49 | if(sansa.sectorbuf == NULL) { |
55 | emit logItem(tr("Error: can't allocate buffer memory!"), LOGERROR); | 50 | emit logItem(tr("Error: can't allocate buffer memory!"), LOGERROR); |
56 | return false; | 51 | return false; |
57 | emit done(true); | 52 | emit done(true); |
@@ -59,8 +54,6 @@ bool BootloaderInstallSansa::install(void) | |||
59 | 54 | ||
60 | emit logItem(tr("Searching for Sansa"), LOGINFO); | 55 | emit logItem(tr("Searching for Sansa"), LOGINFO); |
61 | 56 | ||
62 | struct sansa_t sansa; | ||
63 | |||
64 | int n = sansa_scan(&sansa); | 57 | int n = sansa_scan(&sansa); |
65 | if(n == -1) { | 58 | if(n == -1) { |
66 | emit logItem(tr("Permission for disc access denied!\n" | 59 | emit logItem(tr("Permission for disc access denied!\n" |
@@ -95,7 +88,6 @@ bool BootloaderInstallSansa::install(void) | |||
95 | */ | 88 | */ |
96 | void BootloaderInstallSansa::installStage2(void) | 89 | void BootloaderInstallSansa::installStage2(void) |
97 | { | 90 | { |
98 | struct sansa_t sansa; | ||
99 | unsigned char* buf = NULL; | 91 | unsigned char* buf = NULL; |
100 | unsigned int len; | 92 | unsigned int len; |
101 | 93 | ||
@@ -174,8 +166,6 @@ void BootloaderInstallSansa::installStage3(bool mounted) | |||
174 | */ | 166 | */ |
175 | bool BootloaderInstallSansa::uninstall(void) | 167 | bool BootloaderInstallSansa::uninstall(void) |
176 | { | 168 | { |
177 | struct sansa_t sansa; | ||
178 | |||
179 | emit logItem(tr("Uninstalling bootloader"), LOGINFO); | 169 | emit logItem(tr("Uninstalling bootloader"), LOGINFO); |
180 | QCoreApplication::processEvents(); | 170 | QCoreApplication::processEvents(); |
181 | 171 | ||
@@ -222,7 +212,6 @@ bool BootloaderInstallSansa::uninstall(void) | |||
222 | */ | 212 | */ |
223 | BootloaderInstallBase::BootloaderType BootloaderInstallSansa::installed(void) | 213 | BootloaderInstallBase::BootloaderType BootloaderInstallSansa::installed(void) |
224 | { | 214 | { |
225 | struct sansa_t sansa; | ||
226 | int num; | 215 | int num; |
227 | 216 | ||
228 | if(!sansaInitialize(&sansa)) { | 217 | if(!sansaInitialize(&sansa)) { |
diff --git a/rbutil/rbutilqt/base/bootloaderinstallsansa.h b/rbutil/rbutilqt/base/bootloaderinstallsansa.h index 55a6341534..40dc89ff25 100644 --- a/rbutil/rbutilqt/base/bootloaderinstallsansa.h +++ b/rbutil/rbutilqt/base/bootloaderinstallsansa.h | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include <QtCore> | 22 | #include <QtCore> |
23 | #include "bootloaderinstallbase.h" | 23 | #include "bootloaderinstallbase.h" |
24 | #include "sansapatcher.h" | ||
24 | 25 | ||
25 | 26 | ||
26 | // bootloader installation class for devices handled by sansapatcher. | 27 | // bootloader installation class for devices handled by sansapatcher. |
@@ -38,6 +39,7 @@ class BootloaderInstallSansa : public BootloaderInstallBase | |||
38 | 39 | ||
39 | private: | 40 | private: |
40 | bool sansaInitialize(struct sansa_t *); | 41 | bool sansaInitialize(struct sansa_t *); |
42 | struct sansa_t sansa; | ||
41 | 43 | ||
42 | private slots: | 44 | private slots: |
43 | void installStage2(void); | 45 | void installStage2(void); |