forked from len0rd/rockbox
Adhere to the 80-char line width limit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28067 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c98f5845f6
commit
51c91c599b
3 changed files with 54 additions and 31 deletions
|
@ -39,8 +39,10 @@ public class RockboxPCM extends AudioTrack
|
|||
private Handler h = null;
|
||||
private static final int samplerate = 44100;
|
||||
/* should be CHANNEL_OUT_STEREO in 2.0 and above */
|
||||
private static final int channels = AudioFormat.CHANNEL_CONFIGURATION_STEREO;
|
||||
private static final int encoding = AudioFormat.ENCODING_PCM_16BIT;
|
||||
private static final int channels =
|
||||
AudioFormat.CHANNEL_CONFIGURATION_STEREO;
|
||||
private static final int encoding =
|
||||
AudioFormat.ENCODING_PCM_16BIT;
|
||||
/* 24k is plenty, but some devices may have a higher minimum */
|
||||
private static final int buf_len =
|
||||
Math.max(24<<10, getMinBufferSize(samplerate, channels, encoding));
|
||||
|
@ -54,7 +56,8 @@ public class RockboxPCM extends AudioTrack
|
|||
{
|
||||
super(AudioManager.STREAM_MUSIC, samplerate, channels, encoding,
|
||||
buf_len, AudioTrack.MODE_STREAM);
|
||||
ht = new HandlerThread("audio thread", Process.THREAD_PRIORITY_URGENT_AUDIO);
|
||||
ht = new HandlerThread("audio thread",
|
||||
Process.THREAD_PRIORITY_URGENT_AUDIO);
|
||||
ht.start();
|
||||
raw_data = new byte[buf_len]; /* in shorts */
|
||||
Arrays.fill(raw_data, (byte) 0);
|
||||
|
@ -88,13 +91,15 @@ public class RockboxPCM extends AudioTrack
|
|||
{
|
||||
if (h == null)
|
||||
h = new Handler(ht.getLooper());
|
||||
if (setNotificationMarkerPosition(bytes2frames(buf_len)/4) != AudioTrack.SUCCESS)
|
||||
if (setNotificationMarkerPosition(bytes2frames(buf_len)/4)
|
||||
!= AudioTrack.SUCCESS)
|
||||
LOG("setNotificationMarkerPosition Error");
|
||||
else
|
||||
setPlaybackPositionUpdateListener(l, h);
|
||||
}
|
||||
/* need to fill with silence before starting playback */
|
||||
write(raw_data, frames2bytes(getPlaybackHeadPosition()), raw_data.length);
|
||||
write(raw_data, frames2bytes(getPlaybackHeadPosition()),
|
||||
raw_data.length);
|
||||
}
|
||||
play();
|
||||
}
|
||||
|
@ -115,9 +120,11 @@ public class RockboxPCM extends AudioTrack
|
|||
private void set_volume(int volume)
|
||||
{
|
||||
/* volume comes from 0..-990 from Rockbox */
|
||||
/* TODO volume is in dB, but this code acts as if it were in %, convert? */
|
||||
/* TODO:
|
||||
* volume is in dB, but this code acts as if it were in %, convert? */
|
||||
float fvolume;
|
||||
/* special case min and max volume to not suffer from floating point accuracy */
|
||||
/* special case min and max volume to not suffer from
|
||||
* floating point accuracy */
|
||||
if (volume == 0)
|
||||
fvolume = 1.0f;
|
||||
else if (volume == -990)
|
||||
|
@ -155,10 +162,15 @@ public class RockboxPCM extends AudioTrack
|
|||
{
|
||||
case AudioTrack.PLAYSTATE_PLAYING:
|
||||
case AudioTrack.PLAYSTATE_PAUSED:
|
||||
/* refill at 25% no matter of how many bytes we've written */
|
||||
if (setNotificationMarkerPosition(bytes2frames(refill_mark))
|
||||
/* refill at 25% no matter of how many
|
||||
* bytes we've written */
|
||||
if (setNotificationMarkerPosition(
|
||||
bytes2frames(refill_mark))
|
||||
!= AudioTrack.SUCCESS)
|
||||
LOG("Error in onMarkerReached: Could not set notification marker");
|
||||
{
|
||||
LOG("Error in onMarkerReached: " +
|
||||
"Could not set notification marker");
|
||||
}
|
||||
else /* recharge */
|
||||
setPlaybackPositionUpdateListener(this, h);
|
||||
break;
|
||||
|
|
|
@ -52,10 +52,10 @@ public class RockboxService extends Service
|
|||
public static RockboxFramebuffer fb = null;
|
||||
private static RockboxService instance;
|
||||
private Notification notification;
|
||||
private static final Class<?>[] mStartForegroundSignature = new Class[] {
|
||||
int.class, Notification.class};
|
||||
private static final Class<?>[] mStopForegroundSignature = new Class[] {
|
||||
boolean.class};
|
||||
private static final Class<?>[] mStartForegroundSignature =
|
||||
new Class[] { int.class, Notification.class };
|
||||
private static final Class<?>[] mStopForegroundSignature =
|
||||
new Class[] { boolean.class };
|
||||
|
||||
private NotificationManager mNM;
|
||||
private Method mStartForeground;
|
||||
|
@ -89,7 +89,8 @@ public class RockboxService extends Service
|
|||
private void do_start(Intent intent)
|
||||
{
|
||||
LOG("Start Service");
|
||||
/* Display a notification about us starting. We put an icon in the status bar. */
|
||||
/* Display a notification about us starting.
|
||||
* We put an icon in the status bar. */
|
||||
create_notification();
|
||||
}
|
||||
|
||||
|
@ -127,9 +128,11 @@ public class RockboxService extends Service
|
|||
BufferedOutputStream dest = null;
|
||||
BufferedInputStream is = null;
|
||||
ZipEntry entry;
|
||||
File file = new File("/data/data/org.rockbox/lib/libmisc.so");
|
||||
File file = new File("/data/data/org.rockbox/" +
|
||||
"lib/libmisc.so");
|
||||
/* use arbitary file to determine whether extracting is needed */
|
||||
File file2 = new File("/data/data/org.rockbox/app_rockbox/rockbox/codecs/mpa.codec");
|
||||
File file2 = new File("/data/data/org.rockbox/" +
|
||||
"app_rockbox/rockbox/codecs/mpa.codec");
|
||||
if (!file2.exists() || (file.lastModified() > file2.lastModified()))
|
||||
{
|
||||
ZipFile zipfile = new ZipFile(file);
|
||||
|
@ -150,7 +153,8 @@ public class RockboxService extends Service
|
|||
}
|
||||
continue;
|
||||
}
|
||||
is = new BufferedInputStream(zipfile.getInputStream(entry), BUFFER);
|
||||
is = new BufferedInputStream(zipfile.getInputStream(entry),
|
||||
BUFFER);
|
||||
int count;
|
||||
byte data[] = new byte[BUFFER];
|
||||
folder = new File(new File(entry.getName()).getParent());
|
||||
|
@ -240,18 +244,22 @@ public class RockboxService extends Service
|
|||
|
||||
private void create_notification()
|
||||
{
|
||||
/* For now we'll use the same text for the ticker and the expanded notification */
|
||||
/* For now we'll use the same text for the ticker and the
|
||||
* expanded notification */
|
||||
CharSequence text = getText(R.string.notification);
|
||||
/* Set the icon, scrolling text and timestamp */
|
||||
notification = new Notification(R.drawable.icon, text,
|
||||
System.currentTimeMillis());
|
||||
|
||||
/* The PendingIntent to launch our activity if the user selects this notification */
|
||||
/* The PendingIntent to launch our activity if the user selects
|
||||
* this notification */
|
||||
Intent intent = new Intent(this, RockboxActivity.class);
|
||||
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, intent, 0);
|
||||
PendingIntent contentIntent =
|
||||
PendingIntent.getActivity(this, 0, intent, 0);
|
||||
|
||||
/* Set the info for the views that show in the notification panel. */
|
||||
notification.setLatestEventInfo(this, getText(R.string.notification), text, contentIntent);
|
||||
notification.setLatestEventInfo(this,
|
||||
getText(R.string.notification), text, contentIntent);
|
||||
}
|
||||
|
||||
public static void startForeground()
|
||||
|
@ -260,7 +268,8 @@ public class RockboxService extends Service
|
|||
{
|
||||
/*
|
||||
* Send the notification.
|
||||
* We use a layout id because it is a unique number. We use it later to cancel.
|
||||
* We use a layout id because it is a unique number.
|
||||
* We use it later to cancel.
|
||||
*/
|
||||
instance.mNM.notify(R.string.notification, instance.notification);
|
||||
/*
|
||||
|
@ -268,7 +277,8 @@ public class RockboxService extends Service
|
|||
* provides enough cpu time to do music decoding in the
|
||||
* background
|
||||
*/
|
||||
instance.startForegroundCompat(R.string.notification, instance.notification);
|
||||
instance.startForegroundCompat(R.string.notification,
|
||||
instance.notification);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,12 +34,13 @@ public class RockboxTimer extends Timer
|
|||
long interval;
|
||||
|
||||
private class RockboxTimerTask extends TimerTask {
|
||||
private RockboxTimer t;
|
||||
private RockboxTimer timer;
|
||||
private TelephonyManager tm;
|
||||
private int last_state;
|
||||
public RockboxTimerTask(RockboxService s, RockboxTimer parent) {
|
||||
public RockboxTimerTask(RockboxService s, RockboxTimer parent)
|
||||
{
|
||||
super();
|
||||
t = parent;
|
||||
timer = parent;
|
||||
tm = (TelephonyManager)s.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
last_state = tm.getCallState();
|
||||
}
|
||||
|
@ -63,8 +64,8 @@ public class RockboxTimer extends Timer
|
|||
}
|
||||
last_state = state;
|
||||
}
|
||||
synchronized(t) {
|
||||
t.notify();
|
||||
synchronized(timer) {
|
||||
timer.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue